Permalink
Browse files

Add an option for saving the MRU list on every update

Closes #317
  • Loading branch information...
1 parent 92b0774 commit 4f7d0a30f4122fb4ed92cafb799ab93d58f376c7 @kien committed Nov 20, 2012
Showing with 19 additions and 4 deletions.
  1. +10 −3 autoload/ctrlp/mrufiles.vim
  2. +9 −1 doc/ctrlp.txt
@@ -14,6 +14,7 @@ fu! ctrlp#mrufiles#opts()
\ 'exclude': ['s:ex', ''],
\ 'case_sensitive': ['s:cseno', 1],
\ 'relative': ['s:re', 0],
+ \ 'save_on_update': ['s:soup', 1],
\ }]
for [ke, va] in items(opts)
let [{va[0]}, {pref.ke}] = [pref.ke, exists(pref.ke) ? {pref.ke} : va[1]]
@@ -62,8 +63,14 @@ fu! s:addtomrufs(fname)
if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
en
- cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
- cal insert(s:mrufs, fn)
+ if ( {s:cseno} && get(s:mrufs, 0, '') !=# fn )
+ \ || ( !{s:cseno} && get(s:mrufs, 0, '') !=? fn )
+ cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
+ cal insert(s:mrufs, fn)
+ if {s:soup}
+ cal s:savetofile(s:mergelists())
+ en
+ en
endf
fu! s:savetofile(mrufs)
@@ -118,7 +125,7 @@ fu! ctrlp#mrufiles#init()
let s:locked = 0
aug CtrlPMRUF
au!
- au BufAdd,BufEnter,BufLeave,BufUnload * cal s:record(expand('<abuf>', 1))
+ au BufAdd,BufEnter,BufLeave,BufWritePost * cal s:record(expand('<abuf>', 1))
au QuickFixCmdPre *vimgrep* let s:locked = 1
au QuickFixCmdPost *vimgrep* let s:locked = 0
au VimLeavePre * cal s:savetofile(s:mergelists())
View
@@ -75,6 +75,7 @@ Overview:~
|ctrlp_mruf_relative|.........Show only MRU files in the working directory.
|ctrlp_mruf_default_order|....Disable sorting.
|ctrlp_mruf_case_sensitive|...MRU files are case sensitive or not.
+ |ctrlp_mruf_save_on_update|...Save the list to disk whenever it's updated.
Advanced options:
|ctrlp_open_func|.............Use custom file opening functions.
@@ -574,6 +575,12 @@ MRU entries: >
let g:ctrlp_mruf_case_sensitive = 1
<
+ *'g:ctrlp_mruf_save_on_update'*
+Set this to 0 to disable saving of the MRU list to disk whenever the list is
+updated, saving will then only occur when exiting Vim: >
+ let g:ctrlp_mruf_save_on_update = 1
+<
+
----------------------------------------
Advanced options:~
@@ -1249,7 +1256,8 @@ CHANGELOG *ctrlp-changelog*
+ New options: |g:ctrlp_abbrev|,
|g:ctrlp_key_loop|,
|g:ctrlp_open_func|,
- |g:ctrlp_tabpage_position|
+ |g:ctrlp_tabpage_position|,
+ |g:ctrlp_mruf_save_on_update|
+ Rename:
*g:ctrlp_dotfiles* -> |g:ctrlp_show_hidden|.
+ Change |g:ctrlp_switch_buffer|'s and |g:ctrlp_working_path_mode|'s type

0 comments on commit 4f7d0a3

Please sign in to comment.