Expose extension commands

This commit is contained in:
Kien N 2012-03-31 12:51:33 +07:00
parent 7c67b3bde6
commit 49e7018a61
2 changed files with 20 additions and 43 deletions

View File

@ -59,7 +59,6 @@ fu! s:opts()
let s:glob = s:dotfiles ? '.*\|*' : '*'
let s:igntype = empty(s:usrign) ? -1 : type(s:usrign)
" Extensions
let g:ctrlp_builtins = 2
for each in s:extensions
exe 'ru autoload/ctrlp/'.each.'.vim'
endfo
@ -174,7 +173,7 @@ let s:hlgrps = {
fu! s:Open()
cal s:log(1)
cal s:getenv()
cal s:extvar('enter')
cal s:execextvar('enter')
sil! exe 'noa keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
let [s:bufnr, s:prompt, s:winw] = [bufnr('%'), ['', '', ''], winwidth(0)]
abc <buffer>
@ -206,7 +205,7 @@ fu! s:Close()
unl! s:focus s:hisidx s:hstgot s:marked s:statypes s:cline s:init s:savestr
\ g:ctrlp_nolimit
cal ctrlp#recordhist()
cal s:extvar('exit')
cal s:execextvar('exit')
cal s:log(0)
ec
endf
@ -230,7 +229,7 @@ fu! ctrlp#reset()
cal s:autocmds()
cal ctrlp#utils#opts()
cal ctrlp#mrufiles#opts()
cal s:extvar('opts')
cal s:execextvar('opts')
endf
" * Files {{{1
fu! ctrlp#files()
@ -1548,7 +1547,7 @@ fu! s:type(...)
\ ? g:ctrlp_ext_vars[s:itemtype - 3][a:0 ? 'type' : 'sname'] : s:itemtype
endf
fu! s:extvar(key)
fu! s:execextvar(key)
if exists('g:ctrlp_ext_vars')
cal map(filter(copy(g:ctrlp_ext_vars),
\ 'has_key(v:val, a:key)'), 'eval(v:val[a:key])')

View File

@ -8,7 +8,10 @@
if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
fini
en
let [g:loaded_ctrlp, g:ctrlp_lines, g:ctrlp_allfiles] = [1, [], []]
let g:loaded_ctrlp = 1
let [g:ctrlp_lines, g:ctrlp_allfiles, g:ctrlp_alltags, g:ctrlp_alldirs,
\ g:ctrlp_buftags, g:ctrlp_builtins] = [[], [], [], [], {}, 2]
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
@ -36,47 +39,22 @@ en
cal ctrlp#mrufiles#init()
if !exists('g:ctrlp_extensions') | fini | en
com! CtrlPTag cal ctrlp#init(ctrlp#tag#id())
let s:ext = g:ctrlp_extensions
com! CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
if index(s:ext, 'tag') >= 0
let g:ctrlp_alltags = []
com! CtrlPTag cal ctrlp#init(ctrlp#tag#id())
en
com! -n=? -com=dir CtrlPDir cal ctrlp#init(ctrlp#dir#id(), <q-args>)
if index(s:ext, 'quickfix') >= 0
com! CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
en
if index(s:ext, 'dir') >= 0
let g:ctrlp_alldirs = []
com! -n=? -com=dir CtrlPDir cal ctrlp#init(ctrlp#dir#id(), <q-args>)
en
if index(s:ext, 'buffertag') >= 0
let g:ctrlp_buftags = {}
com! -n=? -com=buffer CtrlPBufTag
com! -n=? -com=buffer CtrlPBufTag
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
en
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
if index(s:ext, 'rtscript') >= 0
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
en
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
if index(s:ext, 'undo') >= 0
com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
en
com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
if index(s:ext, 'line') >= 0
com! CtrlPLine cal ctrlp#init(ctrlp#line#id())
en
com! CtrlPLine cal ctrlp#init(ctrlp#line#id())
if index(s:ext, 'changes') >= 0
com! -n=? -com=buffer CtrlPChange
com! -n=? -com=buffer CtrlPChange
\ cal ctrlp#init(ctrlp#changes#cmd(0, <q-args>))
com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))
en
unl s:ext
com! CtrlPChangeAll cal ctrlp#init(ctrlp#changes#cmd(1))