Add buffer_func option

This commit is contained in:
Kien N 2012-04-07 18:42:31 +07:00
parent a14bbe0737
commit 9f0cd39ea9
2 changed files with 29 additions and 2 deletions

View File

@ -12,6 +12,7 @@ fu! s:opts()
let [pref, opts] = ['g:ctrlp_', { let [pref, opts] = ['g:ctrlp_', {
\ 'arg_map': ['s:argmap', 0], \ 'arg_map': ['s:argmap', 0],
\ 'by_filename': ['s:byfname', 0], \ 'by_filename': ['s:byfname', 0],
\ 'buffer_func': ['s:buffunc', {}],
\ 'clear_cache_on_exit': ['s:clrex', 1], \ 'clear_cache_on_exit': ['s:clrex', 1],
\ 'custom_ignore': ['s:usrign', ''], \ 'custom_ignore': ['s:usrign', ''],
\ 'default_input': ['s:deftxt', 0], \ 'default_input': ['s:deftxt', 0],
@ -175,6 +176,7 @@ fu! s:Open()
cal s:getenv() cal s:getenv()
cal s:execextvar('enter') cal s:execextvar('enter')
sil! exe 'noa keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP' sil! exe 'noa keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
cal s:buffunc(1)
let [s:bufnr, s:prompt, s:winw] = [bufnr('%'), ['', '', ''], winwidth(0)] let [s:bufnr, s:prompt, s:winw] = [bufnr('%'), ['', '', ''], winwidth(0)]
abc <buffer> abc <buffer>
if !exists('s:hstry') if !exists('s:hstry')
@ -191,6 +193,7 @@ fu! s:Open()
endf endf
fu! s:Close() fu! s:Close()
cal s:buffunc(0)
try | noa bun! try | noa bun!
cat | noa clo! | endt cat | noa clo! | endt
cal s:unmarksigns() cal s:unmarksigns()
@ -1492,6 +1495,14 @@ fu! s:log(m)
en | en en | en
endf endf
fu! s:buffunc(e)
if a:e && has_key(s:buffunc, 'enter')
cal call(s:buffunc['enter'], [])
elsei !a:e && has_key(s:buffunc, 'exit')
cal call(s:buffunc['exit'], [])
en
endf
fu! s:openfile(cmd, fid, tail, ...) fu! s:openfile(cmd, fid, tail, ...)
let cmd = a:cmd =~ '^[eb]$' && &modified ? 'hid '.a:cmd : a:cmd let cmd = a:cmd =~ '^[eb]$' && &modified ? 'hid '.a:cmd : a:cmd
let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd

View File

@ -374,6 +374,9 @@ works in regexp mode. To split the pattern, separate words with space: >
let g:ctrlp_use_migemo = 0 let g:ctrlp_use_migemo = 0
< <
-------------------------------------------------------------------------------
ADVANCED OPTIONS *ctrlp-advanced-options*
*'g:ctrlp_status_func'* *'g:ctrlp_status_func'*
Use this to customize the statuslines for the CtrlP window: > Use this to customize the statuslines for the CtrlP window: >
let g:ctrlp_status_func = {} let g:ctrlp_status_func = {}
@ -417,6 +420,18 @@ Structure of the functions: >
< <
See https://gist.github.com/1610859 for a working example. See https://gist.github.com/1610859 for a working example.
*'g:ctrlp_buffer_func'*
Specify the functions that will be called after entering and before exiting the
CtrlP buffer: >
let g:ctrlp_buffer_func = {}
<
Example: >
let g:ctrlp_buffer_func = {
\ 'enter': 'Function_Name_1',
\ 'exit': 'Function_Name_2',
\ }
<
*'g:ctrlp_match_func'* *'g:ctrlp_match_func'*
Set an external fuzzy matching function for CtrlP to use: > Set an external fuzzy matching function for CtrlP to use: >
let g:ctrlp_match_func = {} let g:ctrlp_match_func = {}
@ -904,13 +919,14 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
+ New option: |g:ctrlp_buffer_func|, callback functions for CtrlP buffer.
+ Remove: g:ctrlp_mruf_last_entered, make it a default for MRU mode. + Remove: g:ctrlp_mruf_last_entered, make it a default for MRU mode.
+ New commands: |:CtrlPLastMode|, open CtrlP in the last mode used. + New commands: |:CtrlPLastMode|, open CtrlP in the last mode used.
|:CtrlPMixed|, search in files, buffers and MRU files. |:CtrlPMixed|, search in files, buffers and MRU files.
Before 2012/03/31~ Before 2012/03/31~
+ New option: |g:ctrlp_default_input|, default input when entering CtrlP. + New options: |g:ctrlp_default_input|, default input when entering CtrlP.
|g:ctrlp_match_func|, allow using a custom fuzzy matcher. |g:ctrlp_match_func|, allow using a custom fuzzy matcher.
+ Rename: + Rename:
*ClearCtrlPCache* -> |CtrlPClearCache| *ClearCtrlPCache* -> |CtrlPClearCache|