From ece04926b0d5d9e3a918c15e5883556737bed7b5 Mon Sep 17 00:00:00 2001 From: Kien N Date: Thu, 2 Feb 2012 03:18:04 +0700 Subject: [PATCH] More silent executions * Silently continue execution of commands regardless of errors which are prone to happen with Vim's customizability. * Remove ctrlp#msg() as it's no longer needed. Fix #95 and prevent similar issues. --- autoload/ctrlp.vim | 28 ++++++++-------------------- autoload/ctrlp/buffertag.vim | 3 --- autoload/ctrlp/quickfix.vim | 9 ++------- autoload/ctrlp/tag.vim | 20 ++++++++------------ 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 9a194a7..128a818 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1110,11 +1110,7 @@ endf fu! ctrlp#setdir(path, ...) let cmd = exists('a:1') ? a:1 : 'lc!' - try - exe cmd.' '.ctrlp#fnesc(a:path) - cat - cal ctrlp#msg("Can't change working directory.") - endt + sil! exe cmd.' '.ctrlp#fnesc(a:path) endf " Highlighting {{{2 fu! s:syntax() @@ -1345,25 +1341,17 @@ fu! s:migemo(str) retu str endf -fu! ctrlp#msg(msg) - redr | echoh Identifier | echon "CtrlP: ".a:msg | echoh None -endf - fu! s:openfile(cmd, filpath, ...) let cmd = a:cmd =~ '^[eb]$' && &modified ? 'hid '.a:cmd : a:cmd let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd let tail = a:0 ? a:1 : s:tail() - try - exe cmd.tail.' '.ctrlp#fnesc(a:filpath) - cat - fina - if !empty(tail) - sil! norm! zvzz - en - if exists('*haslocaldir') - cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!') - en - endt + sil! exe cmd.tail.' '.ctrlp#fnesc(a:filpath) + if !empty(tail) + sil! norm! zvzz + en + if exists('*haslocaldir') + cal ctrlp#setdir(getcwd(), haslocaldir() ? 'lc!' : 'cd!') + en endf fu! s:writecache(read_cache, cache_file) diff --git a/autoload/ctrlp/buffertag.vim b/autoload/ctrlp/buffertag.vim index 843ab6f..5c8045b 100644 --- a/autoload/ctrlp/buffertag.vim +++ b/autoload/ctrlp/buffertag.vim @@ -165,9 +165,6 @@ fu! s:esctagscmd(bin, args, ...) let last = s:enc != &enc ? s:enc : !empty($LANG) ? $LANG : &enc let cmd = iconv(cmd, &enc, last) en - if empty(cmd) - cal ctrlp#msg("Encoding conversion failed!") - en retu cmd endf diff --git a/autoload/ctrlp/quickfix.vim b/autoload/ctrlp/quickfix.vim index 606eb53..cc64d2f 100644 --- a/autoload/ctrlp/quickfix.vim +++ b/autoload/ctrlp/quickfix.vim @@ -43,13 +43,8 @@ fu! ctrlp#quickfix#accept(mode, str) let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne' \ : ctrlp#normcmd('e') let cmd = cmd == 'e' && &modified ? 'hid e' : cmd - try - exe cmd.' '.ctrlp#fnesc(filpath) - cat - cal ctrlp#msg("Invalid command or argument.") - fina - cal cursor(items[2], items[3]) | sil! norm! zvzz - endt + sil! exe cmd.' '.ctrlp#fnesc(filpath) + cal cursor(items[2], items[3]) | sil! norm! zvzz endf fu! ctrlp#quickfix#id() diff --git a/autoload/ctrlp/tag.vim b/autoload/ctrlp/tag.vim index c4728f2..d74a38f 100644 --- a/autoload/ctrlp/tag.vim +++ b/autoload/ctrlp/tag.vim @@ -90,19 +90,15 @@ fu! ctrlp#tag#accept(mode, str) \ } let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1] let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd - try - let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd - if fnd[0] == 1 - if cmd != '' - exe cmd - en - exe fnd[1].'ta' tg - el - exe cmd.' '.tg + let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd + if fnd[0] == 1 + if cmd != '' + sil! exe cmd en - cat - cal ctrlp#msg("Tag not found.") - endt + sil! exe fnd[1].'ta' tg + el + sil! exe cmd.' '.tg + en endf fu! ctrlp#tag#id()