@@ -472,7 +472,16 @@ fu! s:MatchedItems(items, pat, limit)
472
472
let exc = exists (' s:crfilerel' ) ? s: crfilerel : ' '
473
473
let items = s: narrowable () ? s: matched + s: mdata [3 ] : a: items
474
474
if s: matcher != {}
475
- let argms = [items , a: pat , a: limit , s: mmode (), s: ispath , exc, s: regexp ]
475
+ let argms =
476
+ \ has_key (s: matcher , ' arg_type' ) && s: matcher [' arg_type' ] == ' dict' ? [{
477
+ \ ' items' : items ,
478
+ \ ' str' : a: pat ,
479
+ \ ' limit' : a: limit ,
480
+ \ ' mmode' : s: mmode (),
481
+ \ ' ispath' : s: ispath ,
482
+ \ ' crfile' : exc,
483
+ \ ' regex' : s: regexp ,
484
+ \ }] : [items , a: pat , a: limit , s: mmode (), s: ispath , exc, s: regexp ]
476
485
let lines = call (s: matcher [' match' ], argms, s: matcher )
477
486
el
478
487
let lines = s: MatchIt (items , a: pat , a: limit , exc)
@@ -961,22 +970,29 @@ fu! s:SetWD(args)
961
970
en
962
971
endf
963
972
" * AcceptSelection() {{{1
964
- fu ! ctrlp#acceptfile (mode , line , ... )
965
- let [md, useb] = [a: mode , 0 ]
966
- if ! type (a: line )
967
- let [filpath, bufnr , useb] = [a: line , a: line , 1 ]
973
+ fu ! ctrlp#acceptfile (... )
974
+ let useb = 0
975
+ if a: 0 == 1 && type (a: 1 ) == 4
976
+ let [md, line ] = [a: 1 [' action' ], a: 1 [' line' ]]
977
+ let atl = has_key (a: 1 , ' tail' ) ? a: 1 [' tail' ] : ' '
968
978
el
969
- let filpath = fnamemodify (a: line , ' :p' )
970
- if s: nonamecond (a: line , filpath)
971
- let bufnr = str2nr (matchstr (a: line , ' [\/]\?\[\zs\d\+\ze\*No Name\]$' ))
979
+ let [md, line ] = [a: 1 , a: 2 ]
980
+ let atl = a: 0 > 2 ? a: 3 : ' '
981
+ en
982
+ if ! type (line )
983
+ let [filpath, bufnr , useb] = [line , line , 1 ]
984
+ el
985
+ let filpath = fnamemodify (line , ' :p' )
986
+ if s: nonamecond (line , filpath)
987
+ let bufnr = str2nr (matchstr (line , ' [\/]\?\[\zs\d\+\ze\*No Name\]$' ))
972
988
let [filpath, useb] = [bufnr , 1 ]
973
989
el
974
990
let bufnr = bufnr (' ^' .filpath.' $' )
975
991
en
976
992
en
977
993
cal s: PrtExit ()
978
994
let tail = s: tail ()
979
- let j2l = a: 0 ? a: 1 : matchstr (tail, ' ^ +\zs\d\+$' )
995
+ let j2l = atl != ' ' ? atl : matchstr (tail, ' ^ +\zs\d\+$' )
980
996
if ( s: jmptobuf = ~ md || ( s: jmptobuf && md = ~ ' [et]' ) ) && bufnr > 0
981
997
\ && ! ( md == ' e' && bufnr == bufnr (' %' ) )
982
998
let [jmpb, bufwinnr ] = [1 , bufwinnr (bufnr )]
@@ -1004,7 +1020,7 @@ fu! ctrlp#acceptfile(mode, line, ...)
1004
1020
" Reset &switchbuf option
1005
1021
let [swb , &swb ] = [&swb , ' ' ]
1006
1022
" Open new window/buffer
1007
- let [fid, tail] = [( useb ? bufnr : filpath ), ( a: 0 ? ' +' .a: 1 : tail )]
1023
+ let [fid, tail] = [( useb ? bufnr : filpath ), ( atl != ' ' ? ' +' .atl : tail )]
1008
1024
let args = [cmd, fid, tail, 1 , [useb, j2l]]
1009
1025
cal call (' s:openfile' , args )
1010
1026
let &swb = swb
@@ -1035,24 +1051,34 @@ fu! s:SpecInputs(str)
1035
1051
retu 0
1036
1052
endf
1037
1053
1038
- fu ! s: AcceptSelection (mode )
1039
- if a: mode != ' e' && s: OpenMulti (a: mode ) != -1 | retu | en
1054
+ fu ! s: AcceptSelection (action)
1055
+ let [md, icr] = [a: action [0 ], match (a: action , ' r' ) >= 0 ]
1056
+ let subm = icr || ( ! icr && md == ' e' )
1057
+ if ! subm && s: OpenMulti (md) != -1 | retu | en
1040
1058
let str = s: getinput ()
1041
- if a: mode == ' e ' | if s: SpecInputs (str) | retu | en | en
1059
+ if subm | if s: SpecInputs (str) | retu | en | en
1042
1060
" Get the selected line
1043
1061
let line = ctrlp#getcline ()
1044
- if a: mode != ' e ' && ! s: itemtype && line == ' '
1062
+ if ! subm && ! s: itemtype && line == ' ' && line ( ' . ' ) > s: offset
1045
1063
\ && str !~ ' \v^(\.\.([\/]\.\.)*[\/]?[.\/]*|/|\\|\?|\@.+)$'
1046
- cal s: CreateNewFile (a: mode ) | retu
1064
+ cal s: CreateNewFile (md ) | retu
1047
1065
en
1048
1066
if empty (line ) | retu | en
1049
1067
" Do something with it
1050
1068
if s: openfunc != {} && has_key (s: openfunc , s: ctype )
1051
1069
let actfunc = s: openfunc [s: ctype ]
1070
+ let type = has_key (s: openfunc , ' arg_type' ) ? s: openfunc [' arg_type' ] : ' list'
1052
1071
el
1053
- let actfunc = s: itemtype < 3 ? ' ctrlp#acceptfile' : s: getextvar (' accept' )
1072
+ if s: itemtype < 3
1073
+ let [actfunc, type ] = [' ctrlp#acceptfile' , ' dict' ]
1074
+ el
1075
+ let [actfunc, exttype] = [s: getextvar (' accept' ), s: getextvar (' act_farg' )]
1076
+ let type = exttype == ' dict' ? exttype : ' list'
1077
+ en
1054
1078
en
1055
- cal call (actfunc, [a: mode , line ])
1079
+ let actargs = type == ' dict' ? [{ ' action' : md, ' line' : line , ' icr' : icr }]
1080
+ \ : [md, line ]
1081
+ cal call (actfunc, actargs)
1056
1082
endf
1057
1083
" - CreateNewFile() {{{1
1058
1084
fu ! s: CreateNewFile (... )
@@ -1211,7 +1237,10 @@ fu! s:OpenNoMarks(md, line)
1211
1237
cal s: remarksigns ()
1212
1238
cal s: BuildPrompt (0 )
1213
1239
elsei a: md == ' x'
1214
- cal call (s: openfunc [s: ctype ], [a: md , a: line ], s: openfunc )
1240
+ let type = has_key (s: openfunc , ' arg_type' ) ? s: openfunc [' arg_type' ] : ' dict'
1241
+ let argms = type == ' dict' ? [{ ' action' : a: md , ' line' : a: line }]
1242
+ \ : [a: md , a: line ]
1243
+ cal call (s: openfunc [s: ctype ], argms, s: openfunc )
1215
1244
elsei a: md == ' d'
1216
1245
let dir = fnamemodify (a: line , ' :h' )
1217
1246
if isdirectory (dir )
@@ -1352,8 +1381,17 @@ fu! ctrlp#statusline()
1352
1381
let marked = s: opmul != ' 0' ?
1353
1382
\ exists (' s:marked' ) ? ' <' .s: dismrk ().' >' : ' <->' : ' '
1354
1383
if s: status != {}
1355
- let args = [focus, byfname, s: regexp , prv, s: ctype , nxt, marked]
1356
- let &l: stl = call (s: status [' main' ], args , s: status )
1384
+ let argms =
1385
+ \ has_key (s: status , ' arg_type' ) && s: status [' arg_type' ] == ' dict' ? [{
1386
+ \ ' focus' : focus,
1387
+ \ ' byfname' : byfname,
1388
+ \ ' regex' : s: regexp ,
1389
+ \ ' prev' : prv,
1390
+ \ ' item' : s: ctype ,
1391
+ \ ' next' : nxt,
1392
+ \ ' marked' : marked,
1393
+ \ }] : [focus, byfname, s: regexp , prv, s: ctype , nxt, marked]
1394
+ let &l: stl = call (s: status [' main' ], argms, s: status )
1357
1395
el
1358
1396
let item = ' %#CtrlPMode1# ' .s: ctype .' %*'
1359
1397
let focus = ' %#CtrlPMode2# ' .focus.' %*'
@@ -1373,8 +1411,13 @@ endf
1373
1411
fu ! ctrlp#progress (enum , ... )
1374
1412
if has (' macunix' ) || has (' mac' ) | sl 1 m | en
1375
1413
let txt = a: 0 ? ' (press ctrl-c to abort)' : ' '
1376
- let &l: stl = s: status != {} ? call (s: status [' prog' ], [a: enum ], s: status )
1377
- \ : ' %#CtrlPStats# ' .a: enum .' %* ' .txt.' %=%<%#CtrlPMode2# %{getcwd()} %*'
1414
+ if s: status != {}
1415
+ let argms = has_key (s: status , ' arg_type' ) && s: status [' arg_type' ] == ' dict'
1416
+ \ ? [{ ' str' : a: enum }] : [a: enum ]
1417
+ let &l: stl = call (s: status [' prog' ], argms, s: status )
1418
+ el
1419
+ let &l: stl = ' %#CtrlPStats# ' .a: enum .' %* ' .txt.' %=%<%#CtrlPMode2# %{getcwd()} %*'
1420
+ en
1378
1421
redraws
1379
1422
endf
1380
1423
" *** Paths {{{2
@@ -2178,6 +2221,10 @@ endf
2178
2221
fu ! ctrlp#call (func , ... )
2179
2222
retu call (a: func , a: 000 )
2180
2223
endf
2224
+
2225
+ fu ! ctrlp#getvar (var )
2226
+ retu {a: var }
2227
+ endf
2181
2228
" }}}1
2182
2229
" * Initialization {{{1
2183
2230
fu ! ctrlp#setlines (... )
0 commit comments