@@ -414,13 +414,13 @@ fu! ctrlp#files()
414414endf
415415
416416fu ! s: InitCustomFuncs ()
417- if s: igntype == 4 && has_key (s: usrign , ' func-init' ) && s: usrign [ ' func-init ' ] != ' '
417+ if s: igntype == 4 && get (s: usrign , ' func-init' , ' ' ) != ' '
418418 exe call (s: usrign [' func-init' ], [])
419419 en
420420endf
421421
422422fu ! s: CloseCustomFuncs ()
423- if s: igntype == 4 && has_key (s: usrign , ' func-close' ) && s: usrign [ ' func-close ' ] != ' '
423+ if s: igntype == 4 && get (s: usrign , ' func-close' , ' ' ) != ' '
424424 exe call (s: usrign [' func-close' ], [])
425425 en
426426endf
521521fu ! s: UserCmd (lscmd)
522522 let [path , lscmd] = [s: dyncwd , a: lscmd ]
523523 let do_ign =
524- \ type (s: usrcmd ) == 4 && has_key (s: usrcmd , ' ignore' ) && s: usrcmd [ ' ignore ' ]
524+ \ type (s: usrcmd ) == 4 && get (s: usrcmd , ' ignore' , 0 )
525525 if do_ign && ctrlp#igncwd (s: cwd ) | retu | en
526526 if exists (' +ssl' ) && &ssl && &shell !~ ' sh'
527527 let [ssl , &ssl , path ] = [&ssl , 0 , tr (path , ' /' , ' \' )]
@@ -587,15 +587,15 @@ fu! s:lsCmd()
587587 retu cmd[1 ]
588588 elsei type (cmd) == 4 && ( has_key (cmd, ' types' ) || has_key (cmd, ' fallback' ) )
589589 let fndroot = []
590- if has_key (cmd, ' types' ) && cmd[ ' types ' ] != {}
590+ if get (cmd, ' types' , {}) != {}
591591 let [markrs, cmdtypes] = [[], values (cmd[' types' ])]
592592 for pair in cmdtypes
593593 cal add (markrs, pair[0 ])
594594 endfo
595595 let fndroot = s: findroot (s: dyncwd , markrs, 0 , 1 )
596596 en
597597 if fndroot == []
598- retu has_key (cmd, ' fallback' ) ? cmd[ ' fallback ' ] : ' '
598+ retu get (cmd, ' fallback' , ' ' )
599599 en
600600 for pair in cmdtypes
601601 if pair[0 ] == fndroot[0 ] | brea | en
@@ -669,7 +669,7 @@ fu! s:MatchedItems(items, pat, limit)
669669 en
670670 if matcher != {}
671671 let argms =
672- \ has_key (matcher, ' arg_type' ) && matcher[ ' arg_type ' ] == ' dict' ? [{
672+ \ get (matcher, ' arg_type' , ' ' ) == ' dict' ? [{
673673 \ ' items' : items ,
674674 \ ' str' : a: pat ,
675675 \ ' limit' : a: limit ,
@@ -1187,10 +1187,10 @@ fu! s:SetWD(args)
11871187 \ && exists (' s:dyncwd' )
11881188 cal ctrlp#setdir (s: dyncwd ) | retu
11891189 en
1190- if has_key (a: args , ' dir' ) && a: args [ ' dir ' ] != ' '
1190+ if get (a: args , ' dir' , ' ' ) != ' '
11911191 cal ctrlp#setdir (a: args [' dir' ]) | retu
11921192 en
1193- let pmodes = has_key (a: args , ' mode' ) ? a: args [ ' mode ' ] : s: pathmode
1193+ let pmodes = get (a: args , ' mode' , s: pathmode)
11941194 let [s: crfilerel , s: dyncwd ] = [fnamemodify (s: crfile , ' :.' ), getcwd ()]
11951195 if (! type (pmodes))
11961196 let pmodes =
@@ -1209,7 +1209,7 @@ fu! ctrlp#acceptfile(...)
12091209 let useb = 0
12101210 if a: 0 == 1 && type (a: 1 ) == 4
12111211 let [md, line ] = [a: 1 [' action' ], a: 1 [' line' ]]
1212- let atl = has_key (a: 1 , ' tail' ) ? a: 1 [ ' tail ' ] : ' '
1212+ let atl = get (a: 1 , ' tail' , ' ' )
12131213 el
12141214 let [md, line ] = [a: 1 , a: 2 ]
12151215 let atl = a: 0 > 2 ? a: 3 : ' '
@@ -1301,7 +1301,7 @@ fu! s:AcceptSelection(action)
13011301 " Do something with it
13021302 if s: openfunc != {} && has_key (s: openfunc , s: ctype )
13031303 let actfunc = s: openfunc [s: ctype ]
1304- let type = has_key (s: openfunc , ' arg_type' ) ? s: openfunc [ ' arg_type ' ] : ' list'
1304+ let type = get (s: openfunc , ' arg_type' , ' list' )
13051305 el
13061306 if s: itemtype < len (s: coretypes )
13071307 let [actfunc, type ] = [' ctrlp#acceptfile' , ' dict' ]
@@ -1491,7 +1491,7 @@ fu! s:OpenNoMarks(md, line)
14911491 cal s: remarksigns ()
14921492 cal s: BuildPrompt (0 )
14931493 elsei a: md == ' x'
1494- let type = has_key (s: openfunc , ' arg_type' ) ? s: openfunc [ ' arg_type ' ] : ' dict'
1494+ let type = get (s: openfunc , ' arg_type' , ' dict' )
14951495 let argms = type == ' dict' ? [{ ' action' : a: md , ' line' : a: line }]
14961496 \ : [a: md , a: line ]
14971497 cal call (s: openfunc [s: ctype ], argms, s: openfunc )
@@ -1668,7 +1668,7 @@ fu! ctrlp#statusline()
16681668 \ exists (' s:marked' ) ? ' <' .s: dismrk ().' >' : ' <->' : ' '
16691669 if s: status != {}
16701670 let argms =
1671- \ has_key (s: status , ' arg_type' ) && s: status [ ' arg_type ' ] == ' dict' ? [{
1671+ \ get (s: status , ' arg_type' , ' ' ) == ' dict' ? [{
16721672 \ ' focus' : focus,
16731673 \ ' byfname' : byfname,
16741674 \ ' regex' : s: regexp ,
@@ -1701,7 +1701,7 @@ fu! ctrlp#progress(enum, ...)
17011701 if has (' macunix' ) || has (' mac' ) | sl 1 m | en
17021702 let txt = a: 0 ? ' (press ctrl-c to abort)' : ' '
17031703 if s: status != {}
1704- let argms = has_key (s: status , ' arg_type' ) && s: status [ ' arg_type ' ] == ' dict'
1704+ let argms = get (s: status , ' arg_type' , ' ' ) == ' dict'
17051705 \ ? [{ ' str' : a: enum }] : [a: enum ]
17061706 let &l: stl = call (s: status [' prog' ], argms, s: status )
17071707 el
@@ -1851,17 +1851,12 @@ endf
18511851
18521852fu ! s: usrign (item, type )
18531853 if s: igntype == 1 | retu a: item = ~ s: usrign | en
1854- if s: igntype == 2
1855- if call (s: usrign , [a: item , a: type ])
1856- retu 1
1857- en
1858- elsei s: igntype == 4
1859- if has_key (s: usrign , a: type ) && s: usrign [a: type ] != ' '
1860- \ && a: item = ~ s: usrign [a: type ]
1861- retu 1
1862- elsei has_key (s: usrign , ' func' ) && s: usrign [' func' ] != ' '
1863- \ && call (s: usrign [' func' ], [a: item , a: type ])
1864- retu 1
1854+ if s: igntype == 2 | retu call (s: usrign , [a: item , a: type ]) | en
1855+ if s: igntype == 4
1856+ if get (s: usrign , a: type , ' ' ) != ' '
1857+ retu a: item = ~ s: usrign [a: type ]
1858+ elsei get (s: usrign , ' func' , ' ' ) != ' '
1859+ retu call (s: usrign [' func' ], [a: item , a: type ])
18651860 en
18661861 en
18671862 retu 0
@@ -2370,14 +2365,14 @@ endf
23702365fu ! s: getinput (... )
23712366 let [prt, spi] = [s: prompt , ( a: 0 ? a: 1 : ' ' )]
23722367 if s: abbrev != {}
2373- let gmd = has_key (s: abbrev , ' gmode' ) ? s: abbrev [ ' gmode ' ] : ' '
2368+ let gmd = get (s: abbrev , ' gmode' , ' ' )
23742369 let str = ( gmd = ~ ' t' && ! a: 0 ) || spi == ' c' ? prt[0 ] : join (prt, ' ' )
23752370 if gmd = ~ ' t' && gmd = ~ ' k' && ! a: 0 && matchstr (str, ' .$' ) = ~ ' \k'
23762371 retu join (prt, ' ' )
23772372 en
23782373 let [pf, rz] = [( s: byfname () ? ' f' : ' p' ), ( s: regexp ? ' r' : ' z' )]
23792374 for dict in s: abbrev [' abbrevs' ]
2380- let dmd = has_key (dict , ' mode' ) ? dict [ ' mode ' ] : ' '
2375+ let dmd = get (dict , ' mode' , ' ' )
23812376 let pat = escape (dict [' pattern' ], ' ~' )
23822377 if ( dmd == ' ' || ( dmd = ~ pf && dmd = ~ rz && ! a: 0 )
23832378 \ || dmd = ~ ' [' .spi.' ]' ) && str = ~ pat
0 commit comments