Option to change the new tabpage's position

Close #225
This commit is contained in:
Kien N 2012-07-06 12:28:29 +07:00
parent f837c34774
commit 5e4bfa660b
3 changed files with 21 additions and 4 deletions

View File

@ -78,6 +78,7 @@ let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', {
\ 'root_markers': ['s:rmarkers', []], \ 'root_markers': ['s:rmarkers', []],
\ 'split_window': ['s:splitwin', 0], \ 'split_window': ['s:splitwin', 0],
\ 'status_func': ['s:status', {}], \ 'status_func': ['s:status', {}],
\ 'tabpage_position': ['s:tabpage', 'ac'],
\ 'use_caching': ['s:caching', 1], \ 'use_caching': ['s:caching', 1],
\ 'use_migemo': ['s:migemo', 0], \ 'use_migemo': ['s:migemo', 0],
\ 'user_command': ['s:usrcmd', ''], \ 'user_command': ['s:usrcmd', ''],
@ -1017,7 +1018,7 @@ fu! s:OpenMulti(...)
\ + ( ur ? [] : ['ignruw'] ) \ + ( ur ? [] : ['ignruw'] )
let fst = call('ctrlp#normcmd', ncmd) let fst = call('ctrlp#normcmd', ncmd)
" Check if the current window has a replaceable buffer " Check if the current window has a replaceable buffer
let repabl = empty(bufname('%')) && empty(&l:ft) let repabl = !( md == 't' && !ur ) && empty(bufname('%')) && empty(&l:ft)
" Commands for the rest of the files " Commands for the rest of the files
let [ic, cmds] = [1, { 'v': ['vert sb', 'vne'], 'h': ['sb', 'new'], let [ic, cmds] = [1, { 'v': ['vert sb', 'vne'], 'h': ['sb', 'new'],
\ 't': ['tab sb', 'tabe'] }] \ 't': ['tab sb', 'tabe'] }]
@ -1712,7 +1713,7 @@ 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' ? ctrlp#tabcount().cmd : cmd
let j2l = a:0 && a:1 ? a:2 : 0 let j2l = a:0 && a:1 ? a:2 : 0
exe cmd.( a:0 && a:1 ? '' : a:tail ) ctrlp#fnesc(a:fid) exe cmd.( a:0 && a:1 ? '' : a:tail ) ctrlp#fnesc(a:fid)
if j2l if j2l
@ -1726,6 +1727,12 @@ fu! s:openfile(cmd, fid, tail, ...)
en en
endf endf
fu! ctrlp#tabcount()
retu
\ s:tabpage == 'al' ? tabpagenr('$') :
\ s:tabpage == 'ac' ? '' : ''
endf
fu! s:settype(type) fu! s:settype(type)
retu a:type < 0 ? exists('s:itemtype') ? s:itemtype : 0 : a:type retu a:type < 0 ? exists('s:itemtype') ? s:itemtype : 0 : a:type
endf endf

View File

@ -87,7 +87,7 @@ fu! ctrlp#tag#accept(mode, str)
\ } \ }
let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1] let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd
let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd
if fnd[0] == 1 if fnd[0] == 1
if cmd != '' if cmd != ''
exe cmd exe cmd

View File

@ -45,6 +45,7 @@ Overview:~
|ctrlp_max_height| Max height of the match window. |ctrlp_max_height| Max height of the match window.
|ctrlp_switch_buffer| Jump to an open buffer if already opened. |ctrlp_switch_buffer| Jump to an open buffer if already opened.
|ctrlp_reuse_window| Reuse special windows (help, quickfix, etc). |ctrlp_reuse_window| Reuse special windows (help, quickfix, etc).
|ctrlp_tabpage_position| Where to put the new tab page.
|ctrlp_working_path_mode| How to set CtrlP's local working directory. |ctrlp_working_path_mode| How to set CtrlP's local working directory.
|ctrlp_root_markers| Additional, high priority root markers. |ctrlp_root_markers| Additional, high priority root markers.
|ctrlp_use_caching| Use per-session caching or not. |ctrlp_use_caching| Use per-session caching or not.
@ -145,6 +146,13 @@ Example: >
let g:ctrlp_reuse_window = 'netrw\|help\|quickfix' let g:ctrlp_reuse_window = 'netrw\|help\|quickfix'
< <
*'g:ctrlp_tabpage_position'*
Where to put the new tab page when opening one: >
let g:ctrlp_tabpage_position = 'ac'
<
al - after the last tab page.
ac - after the current tab page.
*'g:ctrlp_working_path_mode'* *'g:ctrlp_working_path_mode'*
When starting up, CtrlP sets its local working directory according to this When starting up, CtrlP sets its local working directory according to this
variable: > variable: >
@ -669,7 +677,7 @@ Opening/Creating a file:~
Open the selected file in the 'current' window if possible. Open the selected file in the 'current' window if possible.
<c-t> <c-t>
Open the selected file in a new 'tab' after the last tabpage. Open the selected file in a new 'tab'.
<c-v> <c-v>
Open the selected file in a 'vertical' split. Open the selected file in a 'vertical' split.
@ -1035,6 +1043,8 @@ Special thanks:~
=============================================================================== ===============================================================================
CHANGELOG *ctrlp-changelog* CHANGELOG *ctrlp-changelog*
+ New option: |g:ctrlp_tabpage_position|.
Before 2012/06/15~ Before 2012/06/15~
+ New value for |g:ctrlp_follow_symlinks|: 2. + New value for |g:ctrlp_follow_symlinks|: 2.