Don't save and restore &tags option

Fix #86

Also:
* Make <F5> in MRU mode also remove excluded files.
* Make switching MRU and MRE an option. Close #87.
* Improve handling of some option vars.
This commit is contained in:
Kien N 2012-01-17 23:13:39 +07:00
parent b3b8f7beae
commit 4110144ae4
4 changed files with 34 additions and 28 deletions

View File

@ -45,6 +45,7 @@ fu! s:opts()
endfo
if !exists('g:ctrlp_newcache') | let g:ctrlp_newcache = 0 | en
let s:maxdepth = min([s:maxdepth, 100])
let s:mxheight = max([s:mxheight, 1])
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
" Extensions
let g:ctrlp_builtins = 2
@ -1087,11 +1088,10 @@ fu! s:findroot(curr, mark, depth, type)
let [depth, notfound] = [a:depth + 1, empty(s:glbpath(a:curr, a:mark, 1))]
if !notfound || depth > s:maxdepth
if notfound | cal ctrlp#setdir(s:cwd) | en
if a:type | if depth <= s:maxdepth
if a:type && depth <= s:maxdepth
let s:vcsroot = a:curr
en | el
cal ctrlp#setdir(a:curr)
let s:foundroot = 1
elsei !a:type && !notfound
cal ctrlp#setdir(a:curr) | let s:foundroot = 1
en
el
let parent = s:getparent(a:curr)

View File

@ -12,6 +12,7 @@ fu! ctrlp#mrufiles#opts()
\ 'g:ctrlp_mruf_exclude': ['s:exclude', ''],
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
\ 'g:ctrlp_mruf_relative': ['s:relate', 0],
\ 'g:ctrlp_mruf_last_entered': ['s:mre', 0],
\ }
for [ke, va] in items(opts)
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
@ -43,7 +44,7 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
let mrufs = ctrlp#utils#readfile(s:cafile)
" Remove non-existent files
if a:0 && a:1 == 1
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1))')
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
en
" Return the list with the active buffer removed
@ -65,12 +66,19 @@ fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
if len(mrufs) > s:max | cal remove(mrufs, s:max, -1) | en
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
endf "}}}
fu! s:excl(fname) "{{{
retu !empty(s:exclude) && a:fname =~# s:exclude
endf "}}}
fu! ctrlp#mrufiles#init() "{{{1
let s:locked = 0
aug CtrlPMRUF
au!
au BufReadPost,BufNewFile,BufWritePost *
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
if s:mre
au BufEnter,BufUnload *
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
en
au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0
aug END

View File

@ -33,8 +33,7 @@ endf
fu! s:findcount(str)
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
let [&l:tags, fname] = [s:ltags, expand(fname, 1)]
let tgs = taglist('^'.tg.'$')
let [fname, tgs] = [expand(fname, 1), taglist('^'.tg.'$')]
if empty(tgs) | retu [1, 1] | en
let [fnd, ct, pos] = [0, 0, 0]
for each in tgs
@ -68,9 +67,7 @@ endf
" Public {{{1
fu! ctrlp#tag#init(tagfiles)
if empty(a:tagfiles) | retu [] | en
let tagfiles = sort(s:nodup(a:tagfiles))
let s:ltags = join(tagfiles, ',')
let g:ctrlp_alltags = []
let [tagfiles, g:ctrlp_alltags] = [sort(s:nodup(a:tagfiles)), []]
for each in tagfiles
let alltags = s:filter(ctrlp#utils#readfile(each))
cal extend(g:ctrlp_alltags, alltags)
@ -86,17 +83,18 @@ fu! ctrlp#tag#accept(mode, str)
let [md, tg] = [a:mode, split(str, '^[^\t]\+\zs\t')[0]]
let fnd = s:findcount(str)
let cmds = {
\ 't': ['tabe', 'tab stj'],
\ 'h': ['new', 'stj'],
\ 'v': ['vne', 'vert stj'],
\ 'e': ['ene', 'tj'],
\ 't': ['tab sp', 'tab stj'],
\ 'h': ['sp', 'stj'],
\ 'v': ['vs', 'vert stj'],
\ 'e': ['', 'tj'],
\ }
let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1]
let cmd = cmd =~ 'tj\|ene' && &modified ? 'hid '.cmd : cmd
let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd
try
if fnd[0] == 1
exe cmd
let &l:tags = s:ltags
if cmd != ''
exe cmd
en
exe fnd[1].'ta' tg
el
exe cmd.' '.tg

View File

@ -66,8 +66,8 @@ Set this to 0 to show the match window at the top of the screen: >
<
*'g:ctrlp_match_window_reversed'*
Reverse the sort order of the matched files in the match window. The default
setting is from bottom to top: >
Change the listing order of the matched files in the match window. The default
setting (1) is from bottom to top: >
let g:ctrlp_match_window_reversed = 1
<
@ -179,7 +179,7 @@ Specify the number of recently opened files you want |CtrlP| to remember: >
<
*'g:ctrlp_mruf_exclude'*
Files you dont want |CtrlP| to remember; use |regexp| to specify the patterns:
Files you dont want |CtrlP| to remember. Use |regexp| to specify the patterns:
>
let g:ctrlp_mruf_exclude = ''
<
@ -207,6 +207,11 @@ MRU entries: >
let g:ctrlp_mruf_case_sensitive = 1
<
*'g:ctrlp_mruf_last_entered'*
Set to 1 to sort the MRU file list to most-recently-entered-buffer order: >
let g:ctrlp_mruf_last_entered = 0
<
*'g:ctrlp_dotfiles'*
Set this to 0 if you dont want |CtrlP| to search for dotfiles and dotdirs: >
let g:ctrlp_dotfiles = 1
@ -235,7 +240,7 @@ Examples: >
\ 'file': '\.exe$\|\.so$\|\.dll$',
\ 'link': 'some$\|bad$\|symbolic$\|links$',
\ }
>
<
*'g:ctrlp_highlight_match'*
Use this to enable/disable highlighting of the matched patterns and to specify
@ -688,13 +693,6 @@ USER-CONFIGURATION *ctrlp-user-config*
Some miscellaneous configurations:~
+) MRU ==> MRE (most-recently-entered): >
autocmd BufEnter,BufUnload * 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
@ -741,6 +739,8 @@ Special thanks:~
===============================================================================
CHANGELOG *ctrlp-changelog*
+ New option: |g:ctrlp_mruf_last_entered| change MRU to recently-entered
Before 2012/01/15~
+ New mapping: Switch <tab> and <s-tab>. <tab> is now used for completion