Further extending ctrlp_open_multi

This commit is contained in:
Kien N 2012-01-13 10:42:15 +07:00
parent 34aa84e6db
commit 418a22859c
2 changed files with 23 additions and 18 deletions

View File

@ -113,13 +113,6 @@ fu! s:opts()
if s:lazy if s:lazy
cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) }) cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
en en
" Regexp
let s:fpats = {
\ '^\(\\|\)\|\(\\|\)$': '\\|',
\ '^\\\(zs\|ze\|<\|>\)': '^\\\(zs\|ze\|<\|>\)',
\ '^\S\*$': '\*',
\ '^\S\\?$': '\\?',
\ }
endf endf
cal s:opts() cal s:opts()
@ -127,6 +120,14 @@ let s:lash = ctrlp#utils#lash()
" Limiters " Limiters
let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000] let [s:compare_lim, s:nocache_lim, s:mltipats_lim] = [3000, 4000, 2000]
" Regexp
let s:fpats = {
\ '^\(\\|\)\|\(\\|\)$': '\\|',
\ '^\\\(zs\|ze\|<\|>\)': '^\\\(zs\|ze\|<\|>\)',
\ '^\S\*$': '\*',
\ '^\S\\?$': '\\?',
\ }
" * Open & Close {{{1 " * Open & Close {{{1
fu! s:Open() fu! s:Open()
if exists('g:ctrlp_log') && g:ctrlp_log if exists('g:ctrlp_log') && g:ctrlp_log
@ -143,7 +144,7 @@ fu! s:Open()
for [ke, va] in items(s:glbs) for [ke, va] in items(s:glbs)
sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va) sil! exe 'let s:glb_'.ke.' = &'.ke.' | let &'.ke.' = '.string(va)
endfo endfo
if s:opmul && has('signs') if s:opmul != '0' && has('signs')
sign define ctrlpmark text=+> texthl=Search sign define ctrlpmark text=+> texthl=Search
en en
cal s:setupblank() cal s:setupblank()
@ -783,7 +784,7 @@ fu! s:CreateNewFile(...) "{{{1
endf endf
" * OpenMulti() {{{1 " * OpenMulti() {{{1
fu! s:MarkToOpen() fu! s:MarkToOpen()
if s:bufnr <= 0 || !s:opmul if s:bufnr <= 0 || s:opmul == '0'
\ || ( s:itemtype > g:ctrlp_builtins && s:type() !~ 'rts' ) \ || ( s:itemtype > g:ctrlp_builtins && s:type() !~ 'rts' )
retu retu
en en
@ -815,9 +816,9 @@ fu! s:MarkToOpen()
endf endf
fu! s:OpenMulti() fu! s:OpenMulti()
if !exists('s:marked') || !s:opmul | retu | en if !exists('s:marked') || s:opmul == '0' | retu | en
" Get the options " Get the options
let [nr, md, ucr] = matchlist(s:opmul, '\v^(\d+)(\w)=(\w)=$')[1:3] let [nr, md, ucr] = matchlist(s:opmul, '\v^(\d+)=(\w)=(\w)=$')[1:3]
if s:argmap if s:argmap
let md = s:argmaps(md) let md = s:argmaps(md)
if md == 'cancel' | retu | en if md == 'cancel' | retu | en
@ -831,11 +832,13 @@ fu! s:OpenMulti()
let repabl = ( empty(bufname('%')) && empty(&l:ft) ) || s:nosplit() let repabl = ( empty(bufname('%')) && empty(&l:ft) ) || s:nosplit()
" Pick a command for the rest of the files " Pick a command for the rest of the files
let [ic, cmds] = [1, { 'v': 'vne', 'h': 'new', 't': 'tabe' }] let [ic, cmds] = [1, { 'v': 'vne', 'h': 'new', 't': 'tabe' }]
let snd = len(s:opmul) > 1 && has_key(cmds, md) ? cmds[md] : 'vne' let snd = md != '' && has_key(cmds, md) ? cmds[md] : 'vne'
" Open the files " Open the files
for va in values(mkd) for va in values(mkd)
cal s:openfile(ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd, va) cal s:openfile(ic == 1 && ( ucr == 'r' || repabl ) ? fst : snd, va)
if nr > 1 && nr < ic | sil! hid clo! | el | let ic += 1 | en if ( nr != '' && nr > 1 && nr < ic ) || ( nr == '' && ic > 1 )
sil! hid clo! | el | let ic += 1
en
endfo endfo
endf endf
" ** Helper functions {{{1 " ** Helper functions {{{1
@ -925,7 +928,7 @@ fu! ctrlp#statusline()
let item = '%#Character# '.item.' %*' let item = '%#Character# '.item.' %*'
let slider = ' <'.prv.'>={'.item.'}=<'.nxt.'>' let slider = ' <'.prv.'>={'.item.'}=<'.nxt.'>'
let dir = ' %=%<%#LineNr# '.getcwd().' %*' let dir = ' %=%<%#LineNr# '.getcwd().' %*'
let marked = s:opmul ? exists('s:marked') ? ' <'.s:dismrk().'>' : ' <+>' : '' let marked = s:opmul != '0' ? exists('s:marked') ? ' <'.s:dismrk().'>' : ' <+>' : ''
let &l:stl = focus.byfname.regex.slider.marked.dir let &l:stl = focus.byfname.regex.slider.marked.dir
endf endf
@ -1111,7 +1114,7 @@ fu! s:remarksigns()
endf endf
fu! s:dosigns() fu! s:dosigns()
retu exists('s:marked') && s:bufnr > 0 && s:opmul && has('signs') retu exists('s:marked') && s:bufnr > 0 && s:opmul != '0' && has('signs')
endf endf
" Dictionaries {{{2 " Dictionaries {{{2
fu! s:dictindex(dict, expr) fu! s:dictindex(dict, expr)

View File

@ -296,9 +296,11 @@ If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
let g:ctrlp_open_multi = '1v' let g:ctrlp_open_multi = '1v'
< <
For the number: For the number:
If bigger than 1, itll be used as the maximum number of windows or tabs to - If bigger than 1, itll be used as the maximum number of windows or tabs to
create when opening the files (the rest will be hidden buffers). If is 1, create when opening the files, the rest will be hidden buffers.
<c-o> will open all files, each in a new window or new tab. - If is 1, <c-o> will open all files, each in a new window or new tab.
- If no number is given, only the first file will be opened in a window,
either new window or reused, and the rest will be hidden buffers.
For the letter: For the letter:
t - each in a tab t - each in a tab
h - each in a horizontal split h - each in a horizontal split