diff vim/vimfiles/autoload/ctrlp.vim @ 3:92af3257a261

Update to latest ctrlp.vim.
author Brian Neal <bgneal@gmail.com>
date Wed, 04 Jan 2012 19:37:22 -0600
parents 48859d9c82c5
children
line wrap: on
line diff
--- a/vim/vimfiles/autoload/ctrlp.vim	Wed Jan 04 19:34:22 2012 -0600
+++ b/vim/vimfiles/autoload/ctrlp.vim	Wed Jan 04 19:37:22 2012 -0600
@@ -2,7 +2,7 @@
 " File:          autoload/ctrlp.vim
 " Description:   Fuzzy file, buffer, mru and tag finder.
 " Author:        Kien Nguyen <github.com/kien>
-" Version:       1.6.4
+" Version:       1.6.5
 " =============================================================================
 
 " Static variables {{{1
@@ -11,13 +11,14 @@
 	let opts = {
 		\ 'g:ctrlp_by_filename':           ['s:byfname', 0],
 		\ 'g:ctrlp_clear_cache_on_exit':   ['s:clrex', 1],
+		\ 'g:ctrlp_custom_ignore':         ['s:usrign', ''],
 		\ 'g:ctrlp_dont_split':            ['s:nosplit', ''],
 		\ 'g:ctrlp_dotfiles':              ['s:dotfiles', 1],
 		\ 'g:ctrlp_extensions':            ['s:extensions', []],
 		\ 'g:ctrlp_follow_symlinks':       ['s:folsym', 0],
 		\ 'g:ctrlp_highlight_match':       ['s:mathi', [1, 'Identifier']],
 		\ 'g:ctrlp_lazy_update':           ['s:lazy', 0],
-		\ 'g:ctrlp_jump_to_buffer':        ['s:jmptobuf', 1],
+		\ 'g:ctrlp_jump_to_buffer':        ['s:jmptobuf', 2],
 		\ 'g:ctrlp_match_window_bottom':   ['s:mwbottom', 1],
 		\ 'g:ctrlp_match_window_reversed': ['s:mwreverse', 1],
 		\ 'g:ctrlp_max_depth':             ['s:maxdepth', 40],
@@ -53,7 +54,7 @@
 " Global options
 let s:glbs = { 'magic': 1, 'to': 1, 'tm': 0, 'sb': 1, 'hls': 0, 'im': 0,
 	\ 'report': 9999, 'sc': 0, 'ss': 0, 'siso': 0, 'mfd': 200, 'mouse': 'n',
-	\ 'gcr': 'a:block-PmenuSel-blinkon0' }
+	\ 'gcr': 'a:blinkon0' }
 
 if s:lazy
 	cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
@@ -63,6 +64,9 @@
 let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000]
 " * Open & Close {{{1
 fu! s:Open()
+	if exists('g:ctrlp_log') && g:ctrlp_log
+		sil! exe 'redi >>' ctrlp#utils#cachedir().s:lash.'ctrlp.log'
+	en
 	let [s:cwd, s:winres] = [getcwd(), winrestcmd()]
 	let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)]
 	let [s:crword, s:crline] = [expand('<cword>'), getline('.')]
@@ -95,9 +99,11 @@
 	let [g:ctrlp_lines, g:ctrlp_allfiles] = [[], []]
 	exe s:winres
 	unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
-		\ s:crfile s:crfpath s:crword s:crvisual s:tagfiles s:crline s:crcursor
-		\ g:ctrlp_nolimit s:crbufnr
+		\ g:ctrlp_nolimit
 	cal ctrlp#recordhist()
+	if exists('g:ctrlp_log') && g:ctrlp_log
+		sil! redi END
+	en
 	ec
 endf
 " * Clear caches {{{1
@@ -126,23 +132,45 @@
 	unl! s:cline
 endf
 " * Files() {{{1
-fu! s:GlobPath(dirs, allfiles, depth)
+fu! s:Files()
+	let [cwd, cafile, g:ctrlp_allfiles] = [getcwd(), ctrlp#utils#cachefile(), []]
+	if g:ctrlp_newcache || !filereadable(cafile) || !s:caching
+		let lscmd = s:lsCmd()
+		" Get the list of files
+		if empty(lscmd)
+			cal s:GlobPath(cwd, 0)
+		el
+			sil! cal ctrlp#progress('Indexing...')
+			try | cal s:UserCmd(cwd, lscmd) | cat | retu [] | endt
+		en
+		" Remove base directory
+		cal ctrlp#rmbasedir(g:ctrlp_allfiles)
+		let read_cache = 0
+	el
+		let g:ctrlp_allfiles = ctrlp#utils#readfile(cafile)
+		let read_cache = 1
+	en
+	if len(g:ctrlp_allfiles) <= s:compare_lim
+		cal sort(g:ctrlp_allfiles, 'ctrlp#complen')
+	en
+	cal s:writecache(read_cache, cafile)
+	retu g:ctrlp_allfiles
+endf
+
+fu! s:GlobPath(dirs, depth)
 	let entries = split(globpath(a:dirs, s:glob), "\n")
-	if !s:folsym
-		let entries = filter(entries, 'getftype(v:val) != "link"')
+	if s:usrign != ''
+		cal filter(entries, 'v:val !~ s:usrign')
 	en
-	let g:ctrlp_allfiles = filter(copy(entries), '!isdirectory(v:val)')
-	let ftrfunc = s:dotfiles ? 'ctrlp#dirfilter(v:val)' : 'isdirectory(v:val)'
-	let alldirs = filter(entries, ftrfunc)
-	cal extend(g:ctrlp_allfiles, a:allfiles, 0)
-	let depth = a:depth + 1
-	if !empty(alldirs) && !s:maxfiles(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
+	let [dnf, depth] = [ctrlp#dirnfile(entries), a:depth + 1]
+	cal extend(g:ctrlp_allfiles, dnf[1])
+	if !empty(dnf[0]) && !s:maxf(len(g:ctrlp_allfiles)) && depth <= s:maxdepth
 		sil! cal ctrlp#progress(len(g:ctrlp_allfiles))
-		cal s:GlobPath(join(alldirs, ','), g:ctrlp_allfiles, depth)
+		cal s:GlobPath(join(dnf[0], ','), depth)
 	en
 endf
 
-fu! s:UserCommand(path, lscmd)
+fu! s:UserCmd(path, lscmd)
 	let path = a:path
 	if exists('+ssl') && &ssl
 		let [ssl, &ssl, path] = [&ssl, 0, tr(path, '/', '\')]
@@ -158,34 +186,26 @@
 	en
 endf
 
-fu! s:Files()
-	let [cwd, cache_file] = [getcwd(), ctrlp#utils#cachefile()]
-	if g:ctrlp_newcache || !filereadable(cache_file) || !s:caching
-		let lscmd = s:lscommand()
-		" Get the list of files
-		if empty(lscmd)
-			cal s:GlobPath(cwd, [], 0)
-		el
-			sil! cal ctrlp#progress('Waiting...')
-			try | cal s:UserCommand(cwd, lscmd) | cat | retu [] | endt
+fu! s:lsCmd()
+	let cmd = s:usrcmd
+	if type(cmd) == 1
+		retu cmd
+	elsei type(cmd) == 3 && len(cmd) >= 2 && !empty(cmd[0]) && !empty(cmd[1])
+		let rmarker = cmd[0]
+		" Find a repo root
+		cal s:findroot(getcwd(), rmarker, 0, 1)
+		if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) )
+			" Try the secondary_command
+			retu len(cmd) == 3 ? cmd[2] : ''
 		en
-		" Remove base directory
-		cal ctrlp#rmbasedir(g:ctrlp_allfiles)
-		let read_cache = 0
-	el
-		let g:ctrlp_allfiles = ctrlp#utils#readfile(cache_file)
-		let read_cache = 1
+		let s:vcscmd = s:lash == '\' ? 1 : 0
+		retu cmd[1]
 	en
-	if len(g:ctrlp_allfiles) <= s:compare_lim
-		cal sort(g:ctrlp_allfiles, 'ctrlp#complen')
-	en
-	cal s:writecache(read_cache, cache_file)
-	retu g:ctrlp_allfiles
 endf
 fu! s:Buffers() "{{{1
 	let allbufs = []
 	for each in range(1, bufnr('$'))
-		if getbufvar(each, '&bl') && each != bufnr('#')
+		if getbufvar(each, '&bl') && each != s:crbufnr
 			let bufname = bufname(each)
 			if strlen(bufname) && getbufvar(each, '&ma') && bufname != 'ControlP'
 				cal add(allbufs, fnamemodify(bufname, ':p'))
@@ -195,14 +215,11 @@
 	retu allbufs
 endf
 " * MatchedItems() {{{1
-fu! s:MatchIt(items, pat, limit, ispathitem)
-	let [items, pat, limit, newitems] = [a:items, a:pat, a:limit, []]
-	let mfunc = s:byfname && a:ispathitem ? 's:matchfname'
-		\ : s:itemtype > 2 && len(items) < 30000 && !a:ispathitem ? 's:matchtab'
-		\ : 'match'
-	for item in items
-		if call(mfunc, [item, pat]) >= 0 | cal add(newitems, item) | en
-		if limit > 0 && len(newitems) >= limit | brea | en
+fu! s:MatchIt(items, pat, limit, ispathitem, mfunc)
+	let newitems = []
+	for item in a:items
+		if call(a:mfunc, [item, a:pat]) >= 0 | cal add(newitems, item) | en
+		if a:limit > 0 && len(newitems) >= a:limit | brea | en
 	endfo
 	retu newitems
 endf
@@ -213,8 +230,11 @@
 	if len(items) >= s:mltipats_lim | let pats = [pats[-1]] | en
 	cal map(pats, 'substitute(v:val, "\\\~", "\\\\\\~", "g")')
 	if !s:regexp | cal map(pats, 'escape(v:val, ".")') | en
+	let mfunc = s:byfname && ipt ? 's:matchfname'
+		\ : s:itemtype > 2 && len(items) < 30000 && !ipt ? 's:matchtab'
+		\ : 'match'
 	" Loop through the patterns
-	for each in pats
+	for pat in pats
 		" If newitems is small, set it as items to search in
 		if exists('newitems') && len(newitems) < limit
 			let items = copy(newitems)
@@ -223,7 +243,7 @@
 			retu exists('newitems') ? newitems : []
 		el " Start here, go back up if have 2 or more in pats
 			" Loop through the items
-			let newitems = s:MatchIt(items, each, limit, ipt)
+			let newitems = s:MatchIt(items, pat, limit, ipt, mfunc)
 		en
 	endfo
 	let s:matches = len(newitems)
@@ -263,7 +283,7 @@
 	if len(array) > 1
 		for item in range(1, len(array) - 1)
 			" Separator
-			let sep = exists('a:1') ? a:1 : '[^'.array[item-1].']\{-}'
+			let sep = a:0 ? a:1 : '[^'.array[item-1].']\{-}'
 			let nitem .= sep.array[item]
 			cal add(newpats, nitem)
 		endfo
@@ -294,7 +314,7 @@
 	en
 	if s:mwreverse | cal reverse(lines) | en
 	let s:matched = copy(lines)
-	cal map(lines, 'substitute(v:val, "^", "> ", "")')
+	cal map(lines, '"> ".v:val')
 	cal setline(1, lines)
 	exe 'keepj norm!' s:mwreverse ? 'G' : 'gg'
 	keepj norm! 1|
@@ -312,13 +332,15 @@
 	let oldstr = exists('s:savestr') ? s:savestr : ''
 	let pats = s:SplitPattern(a:str)
 	" Get the new string sans tail
-	let notail = substitute(a:str, ':\([^:]\|\\:\)*$', '', 'g')
+	let notail = substitute(a:str, '\\\\', '\', 'g')
+	let notail = substitute(notail, '\\\@<!:\([^:]\|\\:\)*$', '', '')
+	let notail = substitute(notail, '\\\ze:', '', 'g')
 	" Stop if the string's unchanged
 	if notail == oldstr && !empty(notail) && !exists('s:force')
 		retu
 	en
 	let lines = exists('g:ctrlp_nolimit') && empty(notail) ? copy(g:ctrlp_lines)
-		\ : s:MatchedItems(g:ctrlp_lines, pats, s:mxheight)
+		\ : s:MatchedItems(g:ctrlp_lines, copy(pats), s:mxheight)
 	cal s:Render(lines, pats[-1])
 endf
 
@@ -334,7 +356,8 @@
 	cal map(prt, 'escape(v:val, estr)')
 	let str = join(prt, '')
 	let lazy = empty(str) || exists('s:force') || !has('autocmd') ? 0 : s:lazy
-	if a:upd && ( s:matches || s:regexp || match(str, '[*|]') >= 0 ) && !lazy
+	if a:upd && !lazy && ( s:matches || s:regexp
+		\ || match(str, '[*|]') >= 0 || match(str, '\\\:\([^:]\|\\:\)*$') >= 0 )
 		sil! cal s:Update(str)
 	en
 	sil! cal ctrlp#statusline()
@@ -541,7 +564,7 @@
 		\ 'ToggleFocus()':        ['<tab>'],
 		\ 'ToggleRegex()':        ['<c-r>'],
 		\ 'ToggleByFname()':      ['<c-d>'],
-		\ 'ToggleType(1)':        ['<c-f>', '<c-up'],
+		\ 'ToggleType(1)':        ['<c-f>', '<c-up>'],
 		\ 'ToggleType(-1)':       ['<c-b>', '<c-down>'],
 		\ 'PrtInsert("w")':       ['<F2>'],
 		\ 'PrtInsert("s")':       ['<F3>'],
@@ -563,7 +586,7 @@
 	en
 	" Correct arrow keys in terminal
 	if ( has('termresponse') && !empty(v:termresponse) )
-		\ || &term =~? 'xterm\|\<k\?vt\|gnome\|screen'
+		\ || &term =~? 'xterm\|\<k\?vt\|gnome\|screen\|linux'
 		for each in ['\A <up>','\B <down>','\C <right>','\D <left>']
 			exe lcmap.' <esc>['.each
 		endfo
@@ -669,19 +692,19 @@
 	let filpath = s:itemtype ? matchstr : getcwd().s:lash.matchstr
 	cal s:PrtExit()
 	let bufnum = bufnr(filpath)
-	if s:jmptobuf && bufnum > 0 && md == 'e'
+	if s:jmptobuf && bufnum > 0 && md =~ 'e\|t'
 		let [jmpb, bufwinnr] = [1, bufwinnr(bufnum)]
-		let buftab = s:jmptobuf > 1 ? s:buftab(bufnum) : [0, 0]
+		let buftab = s:jmptobuf > 1 ? s:buftab(bufnum, md) : [0, 0]
 		let j2l = a:0 ? a:1 : str2nr(matchstr(s:tail(), '^ +\zs\d\+$'))
 	en
 	" Switch to existing buffer or open new one
-	if exists('jmpb') && buftab[0]
-		exe 'tabn' buftab[1]
-		exe buftab[0].'winc w'
-		if j2l | cal s:j2l(j2l) | en
-	elsei exists('jmpb') && bufwinnr > 0
+	if exists('jmpb') && bufwinnr > 0 && md != 't'
 		exe bufwinnr.'winc w'
-		if j2l | cal s:j2l(j2l) | en
+		if j2l | cal ctrlp#j2l(j2l) | en
+	elsei exists('jmpb') && buftab[0]
+		exe 'tabn' buftab[0]
+		exe buftab[1].'winc w'
+		if j2l | cal ctrlp#j2l(j2l) | en
 	el
 		" Determine the command to use
 		let cmd = md == 't' || s:splitwin == 1 ? 'tabe'
@@ -692,8 +715,31 @@
 	en
 endf
 
+fu! s:SpecInputs()
+	let str = join(s:prompt, '')
+	let type = s:itemtype > 2 ?
+		\ g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][3] : s:itemtype
+	if str == '..' && type =~ '0\|dir'
+		cal s:parentdir(getcwd())
+		cal s:SetLines(s:itemtype)
+		cal s:PrtClear()
+		retu 1
+	elsei ( str == '/' || str == '\' ) && type =~ '0\|dir'
+		cal s:SetWD(2, 0)
+		cal s:SetLines(s:itemtype)
+		cal s:PrtClear()
+		retu 1
+	elsei str == '?'
+		cal s:PrtExit()
+		let hlpwin = &columns > 159 ? '| vert res 80' : ''
+		sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0'
+		retu 1
+	en
+	retu 0
+endf
+
 fu! s:AcceptSelection(mode)
-	if a:mode == 'e' | if s:specinputs() | retu | en | en
+	if a:mode == 'e' | if s:SpecInputs() | retu | en | en
 	" Get the selected line
 	let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
 	if empty(matchstr) | retu | en
@@ -778,7 +824,7 @@
 	let spt = len(s:opmul) > 1 ? cmds[matchstr(s:opmul, '\w$')] : 'vne'
 	let nr = matchstr(s:opmul, '^\d\+')
 	exe wnr.'winc w'
-	for [ke, va] in items(mkd)
+	for va in values(mkd)
 		let cmd = ic == 1 ? 'e' : spt
 		cal s:openfile(cmd, va)
 		if nr > 1 && nr < ic | clo! | el | let ic += 1 | en
@@ -885,22 +931,44 @@
 	redr
 endf
 " Paths {{{2
-fu! ctrlp#dirfilter(val)
-	retu isdirectory(a:val) && match(a:val, '[\/]\.\{,2}$') < 0 ? 1 : 0
+fu! s:ispathitem()
+	let ext = s:itemtype - ( g:ctrlp_builtins + 1 )
+	retu s:itemtype < 3 || ( s:itemtype > 2 && g:ctrlp_ext_vars[ext][3] == 'dir' )
 endf
 
-fu! s:ispathitem()
-	let ext = s:itemtype - ( g:ctrlp_builtins + 1 )
-	if s:itemtype < 3 || ( s:itemtype > 2 && g:ctrlp_ext_vars[ext][3] == 'dir' )
-		retu 1
-	en
-	retu 0
+fu! ctrlp#dirnfile(entries)
+	let [items, cwd] = [[[], []], getcwd().s:lash]
+	for each in a:entries
+		let etype = getftype(each)
+		if etype == 'dir'
+			if s:dotfiles | if match(each, '[\/]\.\{,2}$') < 0
+				cal add(items[0], each)
+			en | el
+				cal add(items[0], each)
+			en
+		elsei etype == 'link'
+			if s:folsym
+				let isfile = !isdirectory(each)
+				if !s:samerootsyml(each, isfile, cwd)
+					cal add(items[isfile], each)
+				en
+			en
+		elsei etype == 'file'
+			cal add(items[1], each)
+		en
+	endfo
+	retu items
+endf
+
+fu! s:samerootsyml(each, isfile, cwd)
+	let resolve = resolve(a:each)
+	let resolve = ( a:isfile ? fnamemodify(resolve, ':p:h') : resolve ).s:lash
+	retu !( stridx(resolve, a:cwd) && ( stridx(a:cwd, resolve) || a:isfile ) )
 endf
 
 fu! ctrlp#rmbasedir(items)
-	let path = &ssl || !exists('+ssl') ? getcwd().'/' :
-		\ substitute(getcwd(), '\\', '\\\\', 'g').'\\'
-	retu map(a:items, 'substitute(v:val, path, "", "g")')
+	let idx = strlen(getcwd()) + 1
+	retu map(a:items, 'strpart(v:val, idx)')
 endf
 
 fu! s:parentdir(curr)
@@ -981,7 +1049,7 @@
 
 fu! s:highlight(pat, grp)
 	cal clearmatches()
-	if !empty(a:pat) && a:pat != '..' && s:itemtype < 3
+	if !empty(a:pat) && s:itemtype < 3
 		let pat = substitute(a:pat, '\~', '\\~', 'g')
 		if !s:regexp | let pat = escape(pat, '.') | en
 		" Match only filename
@@ -995,7 +1063,7 @@
 endf
 
 fu! s:dohighlight()
-	retu type(s:mathi) == 3 && len(s:mathi) == 2 && s:mathi[0]
+	retu type(s:mathi) == 3 && len(s:mathi) > 1 && s:mathi[0]
 		\ && exists('*clearmatches')
 endf
 " Prompt history {{{2
@@ -1026,9 +1094,9 @@
 
 fu! s:remarksigns()
 	if !s:dosigns() | retu | en
-	let nls = s:matched
+	let [nls, head] = [s:matched, s:itemtype ? '' : getcwd().s:lash]
 	for ic in range(1, len(nls))
-		let filpath = s:itemtype ? nls[ic - 1] : getcwd().s:lash.nls[ic - 1]
+		let filpath = head.nls[ic - 1]
 		let key = s:dictindex(s:marked, filpath)
 		if key > 0
 			exe 'sign place' key 'line='.ic.' name=ctrlpmark buffer='.s:bufnr
@@ -1051,14 +1119,14 @@
 	retu filter(range(1, max(keys(a:dict))), '!has_key(a:dict, v:val)')
 endf
 " Buffers {{{2
-fu! s:buftab(bufnum)
-	for nr in range(1, tabpagenr('$'))
-		let buflist = tabpagebuflist(nr)
-		if match(buflist, a:bufnum) >= 0
-			let [buftabnr, tabwinnrs] = [nr, tabpagewinnr(nr, '$')]
-			for ewin in range(1, tabwinnrs)
-				if buflist[ewin - 1] == a:bufnum
-					retu [ewin, buftabnr]
+fu! s:buftab(bufnum, md)
+	for tabnr in range(1, tabpagenr('$'))
+		if tabpagenr() == tabnr && a:md == 't' | con | en
+		let buflist = tabpagebuflist(tabnr)
+		if index(buflist, a:bufnum) >= 0
+			for winnr in range(1, tabpagewinnr(tabnr, '$'))
+				if buflist[winnr - 1] == a:bufnum
+					retu [tabnr, winnr]
 				en
 			endfo
 		en
@@ -1097,7 +1165,7 @@
 fu! s:setupblank()
 	setl noswf nobl nonu nowrap nolist nospell nocuc wfh
 	setl fdc=0 fdl=99 tw=0 bt=nofile bh=unload
-	if v:version >= 703
+	if v:version > 702
 		setl nornu noudf cc=0
 	en
 endf
@@ -1126,39 +1194,15 @@
 endf
 
 fu! s:sanstail(str)
-	" Restore the number of backslashes
-	let str = substitute(a:str, '\\\\', '\', 'g')
+	let [str, pat] = [substitute(a:str, '\\\\', '\', 'g'), '\([^:]\|\\:\)*$']
 	unl! s:optail
-	if match(str, ':\([^:]\|\\:\)*$') >= 0
-		let s:optail = matchstr(str, ':\zs\([^:]\|\\:\)*$')
-		retu substitute(str, ':\([^:]\|\\:\)*$', '', 'g')
+	if match(str, '\\\@<!:'.pat) >= 0
+		let s:optail = matchstr(str, '\\\@<!:\zs'.pat)
+		let str = substitute(str, '\\\@<!:'.pat, '', '')
 	en
-	retu str
+	retu substitute(str, '\\\ze:', '', 'g')
 endf
 " Misc {{{2
-fu! s:specinputs()
-	let str = join(s:prompt, '')
-	let type = s:itemtype > 2 ?
-		\ g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][3] : s:itemtype
-	if str == '..' && type =~ '0\|dir'
-		cal s:parentdir(getcwd())
-		cal s:SetLines(s:itemtype)
-		cal s:PrtClear()
-		retu 1
-	elsei ( str == '/' || str == '\' ) && type =~ '0\|dir'
-		cal s:SetWD(2, 0)
-		cal s:SetLines(s:itemtype)
-		cal s:PrtClear()
-		retu 1
-	elsei str == '?'
-		cal s:PrtExit()
-		let hlpwin = &columns > 159 ? '| vert res 80' : ''
-		sil! exe 'bo vert h ctrlp-mappings' hlpwin '| norm! 0'
-		retu 1
-	en
-	retu 0
-endf
-
 fu! s:lastvisual()
 	let cview = winsaveview()
 	let [ovreg, ovtype] = [getreg('v'), getregtype('v')]
@@ -1172,7 +1216,7 @@
 endf
 
 fu! ctrlp#msg(msg)
-	echoh Identifier | echon "CtrlP: ".a:msg | echoh None
+	redr | echoh Identifier | echon "CtrlP: ".a:msg | echoh None
 endf
 
 fu! s:openfile(cmd, filpath, ...)
@@ -1181,10 +1225,9 @@
 	try
 		exe cmd.tail.' '.ctrlp#fnesc(a:filpath)
 	cat
-		cal ctrlp#msg("Operation can't be completed. Make sure filename is valid.")
 	fina
 		if !empty(tail)
-			sil! norm! zOzz
+			sil! norm! zvzz
 		en
 	endt
 endf
@@ -1197,9 +1240,9 @@
 	en
 endf
 
-fu! s:j2l(nr)
+fu! ctrlp#j2l(nr)
 	exe a:nr
-	sil! norm! zOzz
+	sil! norm! zvzz
 endf
 
 fu! s:regexfilter(str)
@@ -1228,7 +1271,7 @@
 	retu match(split(a:item, '\t\+[^\t]\+$')[0], a:pat)
 endf
 
-fu! s:maxfiles(len)
+fu! s:maxf(len)
 	retu s:maxfiles && a:len > s:maxfiles ? 1 : 0
 endf
 
@@ -1248,23 +1291,6 @@
 	cal insert(data, str, pos)
 	cal s:writecache(0, ctrlp#utils#cachefile())
 endf
-
-fu! s:lscommand()
-	let cmd = s:usrcmd
-	if type(cmd) == 1
-		retu cmd
-	elsei type(cmd) == 3 && len(cmd) >= 2 && !empty(cmd[0]) && !empty(cmd[1])
-		let rmarker = cmd[0]
-		" Find a repo root
-		cal s:findroot(getcwd(), rmarker, 0, 1)
-		if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) )
-			" Try the secondary_command
-			retu len(cmd) == 3 ? cmd[2] : ''
-		en
-		let s:vcscmd = s:lash == '\' ? 1 : 0
-		retu cmd[1]
-	en
-endf
 " Extensions {{{2
 fu! s:tagfiles()
 	retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)')
@@ -1300,13 +1326,11 @@
 	if exists('s:init') | retu | en
 	let [s:matches, s:init] = [1, 1]
 	cal s:Open()
-	cal s:SetWD(exists('a:1') ? a:1 : '')
+	cal s:SetWD(a:0 ? a:1 : '')
 	cal s:MapKeys()
 	cal s:SetLines(a:type)
 	cal s:BuildPrompt(1)
-	if has('syntax') && exists('g:syntax_on')
-		cal s:syntax()
-	en
+	if has('syntax') && exists('g:syntax_on') | cal s:syntax() | en
 endf
 if has('autocmd') "{{{1
 	aug CtrlPAug