Add b:var support for some options

Refs #273
This commit is contained in:
Kien N 2012-09-10 22:24:48 +07:00
parent f66f4e8503
commit 4a66d00bc9
2 changed files with 20 additions and 8 deletions

View File

@ -50,7 +50,8 @@ fu! s:ignore() "{{{2
\ }
endf "}}}2
" Options
let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', {
let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ ['g:ctrlp_', 'b:ctrlp_', {
\ 'arg_map': ['s:argmap', 0],
\ 'buffer_func': ['s:buffunc', {}],
\ 'by_filename': ['s:byfname', 0],
@ -90,6 +91,10 @@ let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', {
\ 'reuse_window': 's:nosplit',
\ 'show_hidden': 's:showhidden',
\ 'switch_buffer': 's:jmptobuf',
\ }, {
\ 'root_markers': 's:rmarkers',
\ 'user_command': 's:usrcmd',
\ 'working_path_mode': 's:pathmode',
\ }]
" Global options
@ -189,6 +194,13 @@ fu! s:opts() "{{{2
for [ke, va] in items(s:new_opts)
let {va} = {exists(s:pref.ke) ? s:pref.ke : va}
endfo
unl va
for [ke, va] in items(s:lc_opts)
if exists(s:bpref.ke)
unl {va}
let {va} = {s:bpref.ke}
en
endfo
for each in ['byfname', 'regexp'] | if exists(each)
let s:{each} = {each}
en | endfo
@ -829,7 +841,7 @@ fu! s:SetWD(args)
if has_key(a:args, 'dir') && a:args['dir'] != ''
cal ctrlp#setdir(a:args['dir']) | retu
en
let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:wpmode
let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:pathmode
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
if s:crfile =~ '^.\+://' | retu | en
if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
@ -1753,8 +1765,6 @@ fu! s:getenv()
let [s:crword, s:crline] = [expand('<cword>', 1), getline('.')]
let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')]
let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()]
let s:wpmode = exists('b:ctrlp_working_path_mode')
\ ? b:ctrlp_working_path_mode : s:pathmode
let [s:mrbs, s:crgfile] = [ctrlp#mrufiles#bufs(), expand('<cfile>', 1)]
endf

View File

@ -175,17 +175,17 @@ variable: >
when "r" is also present.
0 or <empty-string> - disable this feature.
Note #1: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option
on a per buffer basis.
Note #1: if "a" or "c" is included with "r", use the behavior of "a" or "c" (as
a fallback) when a root can't be found.
Note #2: with "ra" or "rc", use the behavior of "a" or "c" if a root can't be
found.
Note #2: you can use a |b:var| to set this option on a per buffer basis.
*'g:ctrlp_root_markers'*
Use this to set your own root markers in addition to the default ones (.git,
.hg, .svn, .bzr, and _darcs). Your markers will take precedence: >
let g:ctrlp_root_markers = ['']
<
Note: you can use a |b:var| to set this option on a per buffer basis.
*'g:ctrlp_use_caching'*
Enable/Disable per-session caching: >
@ -331,6 +331,8 @@ default to retain the performance advantage of using external commands.
Note #3: when changing the option's variable type, remember to |:unlet| it
first or restart Vim to avoid the "E706: Variable type mismatch" error.
Note #4: you can use a |b:var| to set this option on a per buffer basis.
*'g:ctrlp_max_history'*
The maximum number of input strings you want CtrlP to remember. The default
value mirrors Vim's global |'history'| option: >