Commits

kien committed 65994aa Draft

Add an option for saving the MRU list on every update

Comments (0)

Files changed (3)

autoload/ctrlp.vim

 endf
 
 fu! ctrlp#call(func, ...)
-	cal call(a:func, a:000)
+	retu call(a:func, a:000)
 endf
 "}}}1
 " * Initialization {{{1

autoload/ctrlp/mrufiles.vim

 		\ '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]]
 	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)
 	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())
   |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.
   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:~
 
     * Lowe Thiderman <github.com/thiderman>
     * Christopher Fredén <github.com/icetan>
     * Zahary Karadjov <github.com/zah>
+    * Jo De Boeck <github.com/grimpy>
 
 ===============================================================================
 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