@@ -957,23 +957,19 @@ fu! s:SetWD(args)
957957 if has_key (a: args , ' dir' ) && a: args [' dir' ] != ' '
958958 cal ctrlp#setdir (a: args [' dir' ]) | retu
959959 en
960- let pmode = has_key (a: args , ' mode' ) ? a: args [' mode' ] : s: pathmode
960+ let pmodes = has_key (a: args , ' mode' ) ? a: args [' mode' ] : s: pathmode
961961 let [s: crfilerel , s: dyncwd ] = [fnamemodify (s: crfile , ' :.' ), getcwd ()]
962- if s: crfile = ~ ' ^.\+://' | retu | en
963- if pmode = ~ ' c' || ( pmode = ~ ' a' && stridx (s: crfpath , s: cwd ) < 0 )
964- \ || ( ! type (pmode) && pmode )
965- if exists (' +acd' ) | let [s: glb_acd , &acd ] = [&acd , 0 ] | en
966- cal ctrlp#setdir (s: crfpath )
967- en
968- if pmode = ~ ' r' || pmode == 2
969- let markers = [' .git' , ' .hg' , ' .svn' , ' .bzr' , ' _darcs' ] + s: custom_markers
970- let spath = pmode = ~ ' d' ? s: dyncwd : pmode = ~ ' w' ? s: cwd : s: crfpath
971- if type (s: rmarkers ) == 3 && ! empty (s: rmarkers )
972- if s: findroot (spath, s: rmarkers , 0 , 0 ) != [] | retu | en
973- cal filter (markers, ' index(s:rmarkers, v:val) < 0' )
974- en
975- cal s: findroot (spath, markers, 0 , 0 )
976- en
962+ if (! type (pmodes))
963+ let pmodes =
964+ \ pmodes == 0 ? ' ' :
965+ \ pmodes == 1 ? ' a' :
966+ \ pmodes == 2 ? ' r' :
967+ \ ' c'
968+ en
969+ let spath = pmodes = ~ ' d' ? s: dyncwd : pmodes = ~ ' w' ? s: cwd : s: crfpath
970+ for pmode in split (pmodes, ' \zs' )
971+ if ctrlp#setpathmode (pmode, spath) | retu | en
972+ endfo
977973endf
978974" * AcceptSelection() {{{1
979975fu ! ctrlp#acceptfile (... )
@@ -1584,6 +1580,23 @@ fu! s:findroot(curr, mark, depth, type)
15841580 retu []
15851581endf
15861582
1583+ fu ! ctrlp#setpathmode (pmode, ... )
1584+ if a: pmode == ' c' || ( a: pmode == ' a' && stridx (s: crfpath , s: cwd ) < 0 )
1585+ if exists (' +acd' ) | let [s: glb_acd , &acd ] = [&acd , 0 ] | en
1586+ cal ctrlp#setdir (s: crfpath )
1587+ retu 1
1588+ elsei a: pmode == ' r'
1589+ let spath = a: 0 ? a: 1 : s: crfpath
1590+ let markers = [' .git' , ' .hg' , ' .svn' , ' .bzr' , ' _darcs' ]
1591+ if type (s: rmarkers ) == 3 && ! empty (s: rmarkers )
1592+ if s: findroot (spath, s: rmarkers , 0 , 0 ) != [] | retu 1 | en
1593+ cal filter (markers, ' index(s:rmarkers, v:val) < 0' )
1594+ en
1595+ if s: findroot (spath, markers, 0 , 0 ) != [] | retu 1 | en
1596+ en
1597+ retu 0
1598+ endf
1599+
15871600fu ! ctrlp#setdir (path , ... )
15881601 let cmd = a: 0 ? a: 1 : ' lc!'
15891602 sil ! exe cmd s: fnesc (a: path , ' c' )
0 commit comments