Resolve some issues

* Remove active buffer from MRU listing. Close #66.
* Re-evaluate ctrlp_user_command when changing dir. Fix #69.
* Link to custom ctrlp_user_command config in the docs. Close #70.
This commit is contained in:
Kien N 2012-01-10 05:58:59 +07:00
parent 34a2cae6c6
commit f04196941a
4 changed files with 58 additions and 31 deletions

View File

@ -190,13 +190,13 @@ fu! s:lsCmd()
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)
cal s:findroot(getcwd(), cmd[0], 0, 1)
if !exists('s:vcsroot') || ( exists('s:vcsroot') && empty(s:vcsroot) )
" Try the secondary_command
retu len(cmd) == 3 ? cmd[2] : ''
en
unl! s:vcsroot
let s:vcscmd = s:lash == '\' ? 1 : 0
retu cmd[1]
en
@ -742,19 +742,17 @@ fu! s:AcceptSelection(mode)
if a:mode == 'e' | if s:SpecInputs() | retu | en | en
" Get the selected line
let line = getline('.')
if line == ' == NO ENTRIES =='
cal <SID>CreateNewFile()
retu
if a:mode != 'e' && s:itemtype < 3 && line == ' == NO ENTRIES =='
cal s:CreateNewFile(a:mode) | retu
en
let matchstr = matchstr(line, '^> \zs.\+\ze\t*$')
let matchstr = matchstr(getline('.'), '^> \zs.\+\ze\t*$')
if empty(matchstr) | retu | en
" Do something with it
let actfunc = s:itemtype =~ '0\|1\|2' ? 'ctrlp#acceptfile'
let actfunc = s:itemtype < 3 ? 'ctrlp#acceptfile'
\ : g:ctrlp_ext_vars[s:itemtype - ( g:ctrlp_builtins + 1 )][1]
cal call(actfunc, [a:mode, matchstr])
endf
fu! s:CreateNewFile() "{{{1
fu! s:CreateNewFile(...) "{{{1
let str = join(s:prompt, '')
if empty(str) | retu | en
let str = s:sanstail(str)
@ -769,9 +767,9 @@ fu! s:CreateNewFile() "{{{1
let filpath = getcwd().s:lash.optyp
cal s:insertcache(str)
cal s:PrtExit()
let cmd = s:newfop == 1 ? 'tabe'
\ : s:newfop == 2 ? 'new'
\ : s:newfop == 3 ? 'vne' : ctrlp#normcmd('e')
let cmd = s:newfop == 1 || ( a:0 && a:1 == 't' ) ? 'tabe'
\ : s:newfop == 2 || ( a:0 && a:1 == 'h' ) ? 'new'
\ : s:newfop == 3 || ( a:0 && a:1 == 'v' ) ? 'vne' : ctrlp#normcmd('e')
cal s:openfile(cmd, filpath)
en
endf
@ -1089,6 +1087,7 @@ fu! ctrlp#recordhist()
if len(hst) > 1 && hst[1] == str | retu | en
cal extend(hst, [str], 1)
if len(hst) > s:maxhst | cal remove(hst, s:maxhst, -1) | en
cal ctrlp#utils#writecache(hst, s:gethistloc()[0], s:gethistloc()[1])
endf
" Signs {{{2
fu! s:unmarksigns()
@ -1181,7 +1180,6 @@ fu! s:leavepre()
\ ( has('clientserver') && len(split(serverlist(), "\n")) == 1 ) )
cal ctrlp#clra(1)
en
cal ctrlp#utils#writecache(s:hstry, s:gethistloc()[0], s:gethistloc()[1])
endf
fu! s:checkbuf()

View File

@ -15,42 +15,46 @@ fu! ctrlp#mrufiles#opts()
for [ke, va] in items(opts)
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
endfo
let s:csen = s:csen ? '#' : '?'
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
endf
cal ctrlp#mrufiles#opts()
fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
if s:locked | retu | en
" Get the list
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
let cafile = cadir.ctrlp#utils#lash().'cache.txt'
let mrufs = ctrlp#utils#readfile(cafile)
let mrufs = ctrlp#utils#readfile(s:cafile)
" Remove non-existent files
if exists('a:1') && a:1 == 1
let mrufs = s:rmdeleted(mrufs, cadir, cafile)
elsei exists('a:1') && a:1 == 2
cal ctrlp#utils#writecache([], cadir, cafile)
if a:0 && a:1 == 1
let mrufs = s:rmdeleted(mrufs)
elsei a:0 && a:1 == 2
cal ctrlp#utils#writecache([], s:cadir, s:cafile)
retu []
en
" Return the list
if a:bufnr == -1 | retu mrufs | en
" Return the list, filter the active buffer
if a:bufnr == -1
let crfile = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
retu empty(crfile) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crfile')
en
" Filter it
let filename = fnamemodify(bufname(a:bufnr + 0), ':p')
if empty(filename) || !empty(&bt)
\ || ( !empty(s:include) && filename !~# s:include )
\ || ( !empty(s:exclude) && filename =~# s:exclude )
\ || ( index(mrufs, filename) == -1 && !filereadable(filename) )
\ || ( index(mrufs, filename) < 0 && !filereadable(filename) )
retu
en
" Remove old matched entry
cal filter(mrufs, 'v:val !='.( s:csen ? "#" : "?" ).' filename')
cal filter(mrufs, 'v:val !='.s:csen.' filename')
" Insert new one
cal insert(mrufs, filename)
" Remove oldest entry
if len(mrufs) > s:max | cal remove(mrufs, s:max, -1) | en
cal ctrlp#utils#writecache(mrufs, cadir, cafile)
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
endf "}}}
fu! s:rmdeleted(mrufs, cadir, cafile) "{{{
fu! s:rmdeleted(mrufs) "{{{
cal filter(a:mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
cal ctrlp#utils#writecache(a:mrufs, a:cadir, a:cafile)
cal ctrlp#utils#writecache(a:mrufs, s:cadir, s:cafile)
retu a:mrufs
endf
fu! ctrlp#mrufiles#init() "{{{1

View File

@ -115,7 +115,8 @@ be enabled for directories that have more than 4000 files: >
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
*'g:ctrlp_clear_cache_on_exit'*
Set this to 0 to enable cross-sessions caching: >
Set this to 0 to enable cross-sessions caching by not clearing the cache files
upon exiting Vim: >
let g:ctrlp_clear_cache_on_exit = 1
<
@ -287,7 +288,7 @@ The maximum number of input strings you want |CtrlP| to remember. The default
value mirrors Vims global |'history'| option: >
let g:ctrlp_max_history = &history
<
Set to 0 to disable prompts history.
Set to 0 to disable prompts history. Browse the history with <c-n> and <c-p>.
*'g:ctrlp_open_multi'*
If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
@ -515,8 +516,8 @@ c) End the string with a colon ':' followed by a Vim command to execute that
instance of 'my:function'.
'abc:+setf\ myfiletype|50' will open the selected file and set its
filetype to 'myfiletype', then jump to line 50.
'abc:difft' will open the selected file and run |:diffthis| on the first
four files.
'abc:diffthis' will open the selected file and run |:diffthis| on the
first 4 files.
See also Vims |++opt| and |+cmd|.
@ -657,6 +658,30 @@ Special thanks:~
* Yasuhiro Matsumoto <github.com/mattn>
Added option to use Migemo for Japanese language.
* Kyo Nagashima <github.com/hail2u>
Made some enhancements to file opening mappings.
* Simon Ruderich
* Ken Earley <github.com/kenearley>
* Zak Johnson <github.com/zakj>
* Diego Viola <github.com/diegoviola>
Bugfixes/Corrections.
===============================================================================
USERS-CONFIGURATION *ctrlp-users-config*
Some configurations for your .vimrc:~
+) MRU ==> MRE (most-recently-entered): >
autocmd BufEnter * call ctrlp#mrufiles#list(expand('<abuf>', 1))
<
The default implementation of MRU is similar to that of desktop applications.
Use the above |autocmd| to change it to recording most-recently-entered buffers
(that have a file) instead.
+) |g:ctrlp_user_command| config that makes use of your |wildignore| setting:
https://github.com/kien/ctrlp.vim/issues/70 by Rich Alesi
===============================================================================
CHANGELOG *ctrlp-changelog*

View File

@ -75,6 +75,6 @@ Examples:
_Check [the docs][2] for more mappings, commands and options._
[1]: http://i.imgur.com/3rtLt.png
[1]: http://i.imgur.com/yIynr.png
[2]: https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt
[3]: https://github.com/kien/ctrlp.vim/tree/extensions