Move getenv stuff to each extension

This commit is contained in:
Kien N 2012-03-29 08:53:00 +07:00
parent c4fe304565
commit 535b13a82d
3 changed files with 33 additions and 33 deletions

View File

@ -173,6 +173,7 @@ let s:hlgrps = {
fu! s:Open()
cal s:log(1)
cal s:getenv()
cal s:extvar('enter')
sil! exe 'noa keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
let [s:bufnr, s:prompt, s:winw] = [bufnr('%'), ['', '', ''], winwidth(0)]
abc <buffer>
@ -1412,14 +1413,6 @@ fu! s:getenv()
let s:currwin = s:mwbottom ? winnr() : winnr() + has('autocmd')
let s:wpmode = exists('b:ctrlp_working_path_mode')
\ ? b:ctrlp_working_path_mode : s:pathmode
if exists('g:ctrlp_extensions')
if index(g:ctrlp_extensions, 'undo') >= 0
let s:undos = s:getundo()
en
if index(g:ctrlp_extensions, 'tag') >= 0
let s:tagfiles = s:tagfiles()
en
en
endf
fu! s:lastvisual()
@ -1529,10 +1522,6 @@ fu! s:type(...)
\ ? g:ctrlp_ext_vars[s:itemtype - 3][a:0 ? 'type' : 'sname'] : s:itemtype
endf
fu! s:tagfiles()
retu filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'), 'filereadable(v:val)')
endf
fu! s:extvar(key)
if exists('g:ctrlp_ext_vars')
cal map(filter(copy(g:ctrlp_ext_vars),
@ -1540,18 +1529,6 @@ fu! s:extvar(key)
en
endf
fu! s:getundo()
if exists('*undotree')
\ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
retu [1, undotree()]
el
redi => result
sil! undol
redi END
retu [0, split(result, "\n")[1:]]
en
endf
fu! ctrlp#exit()
cal s:PrtExit()
endf

View File

@ -11,10 +11,11 @@ en
let g:loaded_ctrlp_tag = 1
let s:tag_var = {
\ 'init': 'ctrlp#tag#init(s:tagfiles)',
\ 'init': 'ctrlp#tag#init()',
\ 'accept': 'ctrlp#tag#accept',
\ 'lname': 'tags',
\ 'sname': 'tag',
\ 'enter': 'ctrlp#tag#enter()',
\ 'type': 'tabs',
\ }
@ -57,10 +58,10 @@ fu! s:filter(tags)
retu alltags
endf
" Public {{{1
fu! ctrlp#tag#init(tagfiles)
if empty(a:tagfiles) | retu [] | en
fu! ctrlp#tag#init()
if empty(s:tagfiles) | retu [] | en
let g:ctrlp_alltags = []
let tagfiles = sort(filter(a:tagfiles, 'count(a:tagfiles, v:val) == 1'))
let tagfiles = sort(filter(s:tagfiles, 'count(s:tagfiles, v:val) == 1'))
for each in tagfiles
let alltags = s:filter(ctrlp#utils#readfile(each))
cal extend(g:ctrlp_alltags, alltags)
@ -101,6 +102,11 @@ endf
fu! ctrlp#tag#id()
retu s:id
endf
fu! ctrlp#tag#enter()
let s:tagfiles = filter(map(tagfiles(), 'fnamemodify(v:val, ":p")'),
\ 'filereadable(v:val)')
endf
"}}}
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2

View File

@ -11,10 +11,11 @@ en
let g:loaded_ctrlp_undo = 1
let s:undo_var = {
\ 'init': 'ctrlp#undo#init(s:undos)',
\ 'init': 'ctrlp#undo#init()',
\ 'accept': 'ctrlp#undo#accept',
\ 'lname': 'undo',
\ 'sname': 'udo',
\ 'enter': 'ctrlp#undo#enter()',
\ 'exit': 'ctrlp#undo#exit()',
\ 'type': 'line',
\ }
@ -27,6 +28,18 @@ let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
let s:text = map(['second', 'seconds', 'minutes', 'hours', 'days', 'weeks',
\ 'months', 'years'], '" ".v:val." ago"')
" Utilities {{{1
fu! s:getundo()
if exists('*undotree')
\ && ( v:version > 703 || ( v:version == 703 && has('patch005') ) )
retu [1, undotree()]
el
redi => result
sil! undol
redi END
retu [0, split(result, "\n")[1:]]
en
endf
fu! s:flatten(tree, cur)
let flatdict = {}
for each in a:tree
@ -104,16 +117,16 @@ fu! s:formatul(...)
retu parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
endf
" Public {{{1
fu! ctrlp#undo#init(undo)
let entries = a:undo[0] ? a:undo[1]['entries'] : a:undo[1]
fu! ctrlp#undo#init()
let entries = s:undos[0] ? s:undos[1]['entries'] : s:undos[1]
if empty(entries) | retu [] | en
if has('syntax') && exists('g:syntax_on')
cal s:syntax()
en
let g:ctrlp_nolimit = 1
if !exists('s:lines')
if a:undo[0]
let entries = s:dict2list(s:flatten(entries, a:undo[1]['seq_cur']))
if s:undos[0]
let entries = s:dict2list(s:flatten(entries, s:undos[1]['seq_cur']))
let s:lines = map(sort(entries, 's:compval'), 's:format(v:val)')
el
let s:lines = map(reverse(entries), 's:formatul(v:val)')
@ -133,6 +146,10 @@ fu! ctrlp#undo#id()
retu s:id
endf
fu! ctrlp#undo#enter()
let s:undos = s:getundo()
endf
fu! ctrlp#undo#exit()
unl! s:lines
endf