@@ -178,11 +178,6 @@ function! s:IsLocationListOpen()
178
178
return s: IsListOpen (" Location" )
179
179
endfunction
180
180
" }}}
181
- " EscapeDirIfSpace {{{
182
- function ! s: EscapeDirIfSpace (dir )
183
- return match (a: dir , ' ' ) == -1 ? a: dir : s: ShellEscape (a: dir )
184
- endfunction
185
- " }}}
186
181
" GetCwdEscaped {{{
187
182
function ! s: GetCwdEscaped ()
188
183
return s: FileEscape (getcwd ())
@@ -210,87 +205,8 @@ function! s:ShellEscapeList(lst, seperator)
210
205
return s: DoEscapeList (a: lst , a: seperator , function (" s:ShellEscape" ))
211
206
endfunction
212
207
" }}}
213
- " DoEscapeSpecialCharacters {{{
214
- function ! s: DoEscapeSpecialCharacters (str, escapeonce, escapetwice)
215
- let str = a: str
216
-
217
- let i = 0
218
- let len = strlen (a: escapeonce )
219
- while i < len
220
- let str = escape (str, a: escapeonce [i ])
221
- let i += 1
222
- endwhile
223
-
224
- let i = 0
225
- let len = strlen (a: escapetwice )
226
- while i < len
227
- let str = escape (str, a: escapetwice [i ])
228
- let str = escape (str, a: escapetwice [i ])
229
- let i += 1
230
- endwhile
231
-
232
- return str
233
- endfunction
234
- " }}}
235
- " EscapeSpecialCharacters {{{
236
- function ! s: EscapeSpecialCharacters (str)
237
- if s: IsCommandVimgrep ()
238
- return s: EscapeSpecialCharactersForVim (a: str )
239
- endif
240
-
241
- let commandParams = s: GetGrepCommandParameters ()
242
- let escapeonce = s: CommandParameter (commandParams, " req_str_escapespecialcharacters" )
243
- let escapetwice = s: CommandParameterOr (commandParams, " opt_str_escapespecialcharacterstwice" , " " )
244
- return s: DoEscapeSpecialCharacters (a: str , escapeonce, escapetwice)
245
- endfunction
246
- " }}}
247
- " EscapeSpecialCharactersForVim {{{
248
- function ! s: EscapeSpecialCharactersForVim (str)
249
- let escapeonce = " \\ /^$#"
250
- if &magic
251
- let escapeonce .= " *.~[]"
252
- endif
253
- return s: DoEscapeSpecialCharacters (a: str , escapeonce, " " )
254
- endfunction
255
- " }}}
256
- " IsRecursivePattern {{{
257
- function ! s: IsRecursivePattern (pattern)
258
- return stridx (a: pattern , " \*\*\/ " ) == 0 ? 1 : 0
259
- endfunction
260
- " }}}
261
- " IsBufferDirSearchAllowed {{{
262
- function ! s: IsBufferDirSearchAllowed ()
263
- if s: IsModeBuffers ()
264
- return 0
265
- endif
266
-
267
- let commandParams = s: GetGrepCommandParameters ()
268
- if ! has_key (commandParams, " opt_bool_bufferdirsearchallowed" )
269
- return 1
270
- endif
271
-
272
- let bufferdirsearchallowed = commandParams[" opt_bool_bufferdirsearchallowed" ]
273
- if bufferdirsearchallowed == # " 1"
274
- return 1
275
- elseif bufferdirsearchallowed == # " 0"
276
- return 0
277
- elseif bufferdirsearchallowed == # " !recursive"
278
- return ! s: IsRecursiveSearch ()
279
- else
280
- return 1
281
- endif
282
- endfunction
283
- " }}}
284
- " IsRecursiveSearch {{{
285
- function ! s: IsRecursiveSearch ()
286
- if g: EasyGrepRecursive
287
- return ! s: IsModeBuffers ()
288
- endif
289
- return s: CommandHas (" opt_bool_isinherentlyrecursive" )
290
- endfunction
291
- " }}}
292
- " GetSavedName {{{
293
- function ! s: GetSavedName (var )
208
+ " GetSavedVariableName {{{
209
+ function ! s: GetSavedVariableName (var )
294
210
let var = a: var
295
211
if match (var , " g:" ) == 0
296
212
let var = substitute (var , " g:" , " g_" , " " )
@@ -303,7 +219,7 @@ function! s:SaveVariable(var)
303
219
if empty (a: var )
304
220
return
305
221
endif
306
- let savedName = s: GetSavedName (a: var )
222
+ let savedName = s: GetSavedVariableName (a: var )
307
223
if match (a: var , " g:" ) == 0
308
224
execute " let " .savedName." = " .a: var
309
225
else
@@ -315,7 +231,7 @@ endfunction
315
231
" if a second variable is present, indicate no unlet
316
232
function ! s: RestoreVariable (var , ... )
317
233
let doUnlet = a: 0 == 1
318
- let savedName = s: GetSavedName (a: var )
234
+ let savedName = s: GetSavedVariableName (a: var )
319
235
if exists (savedName)
320
236
if match (a: var , " g:" ) == 0
321
237
execute " let " .a: var ." = " .savedName
@@ -463,6 +379,54 @@ function! <sid>EchoNewline()
463
379
echo " "
464
380
endfunction
465
381
" }}}
382
+ " EscapeDirIfSpace {{{
383
+ function ! s: EscapeDirIfSpace (dir )
384
+ return match (a: dir , ' ' ) == -1 ? a: dir : s: ShellEscape (a: dir )
385
+ endfunction
386
+ " }}}
387
+ " DoEscapeSpecialCharacters {{{
388
+ function ! s: DoEscapeSpecialCharacters (str, escapeonce, escapetwice)
389
+ let str = a: str
390
+
391
+ let i = 0
392
+ let len = strlen (a: escapeonce )
393
+ while i < len
394
+ let str = escape (str, a: escapeonce [i ])
395
+ let i += 1
396
+ endwhile
397
+
398
+ let i = 0
399
+ let len = strlen (a: escapetwice )
400
+ while i < len
401
+ let str = escape (str, a: escapetwice [i ])
402
+ let str = escape (str, a: escapetwice [i ])
403
+ let i += 1
404
+ endwhile
405
+
406
+ return str
407
+ endfunction
408
+ " }}}
409
+ " EscapeSpecialCharacters {{{
410
+ function ! s: EscapeSpecialCharacters (str)
411
+ if s: IsCommandVimgrep ()
412
+ return s: EscapeSpecialCharactersForVim (a: str )
413
+ endif
414
+
415
+ let commandParams = s: GetGrepCommandParameters ()
416
+ let escapeonce = s: CommandParameter (commandParams, " req_str_escapespecialcharacters" )
417
+ let escapetwice = s: CommandParameterOr (commandParams, " opt_str_escapespecialcharacterstwice" , " " )
418
+ return s: DoEscapeSpecialCharacters (a: str , escapeonce, escapetwice)
419
+ endfunction
420
+ " }}}
421
+ " EscapeSpecialCharactersForVim {{{
422
+ function ! s: EscapeSpecialCharactersForVim (str)
423
+ let escapeonce = " \\ /^$#"
424
+ if &magic
425
+ let escapeonce .= " *.~[]"
426
+ endif
427
+ return s: DoEscapeSpecialCharacters (a: str , escapeonce, " " )
428
+ endfunction
429
+ " }}}
466
430
" SetGrepRoot {{{
467
431
function ! s: SetGrepRoot (... )
468
432
if a: 0 > 0
@@ -635,6 +599,42 @@ function! s:GetCurrentSelection()
635
599
return s: ClearNewline (@" )
636
600
endfunction
637
601
" }}}
602
+ " IsBufferDirSearchAllowed {{{
603
+ function ! s: IsBufferDirSearchAllowed ()
604
+ if s: IsModeBuffers ()
605
+ return 0
606
+ endif
607
+
608
+ let commandParams = s: GetGrepCommandParameters ()
609
+ if ! has_key (commandParams, " opt_bool_bufferdirsearchallowed" )
610
+ return 1
611
+ endif
612
+
613
+ let bufferdirsearchallowed = commandParams[" opt_bool_bufferdirsearchallowed" ]
614
+ if bufferdirsearchallowed == # " 1"
615
+ return 1
616
+ elseif bufferdirsearchallowed == # " 0"
617
+ return 0
618
+ elseif bufferdirsearchallowed == # " !recursive"
619
+ return ! s: IsRecursiveSearch ()
620
+ else
621
+ return 1
622
+ endif
623
+ endfunction
624
+ " }}}
625
+ " IsRecursivePattern {{{
626
+ function ! s: IsRecursivePattern (pattern)
627
+ return stridx (a: pattern , " \*\*\/ " ) == 0 ? 1 : 0
628
+ endfunction
629
+ " }}}
630
+ " IsRecursiveSearch {{{
631
+ function ! s: IsRecursiveSearch ()
632
+ if g: EasyGrepRecursive
633
+ return ! s: IsModeBuffers ()
634
+ endif
635
+ return s: CommandHas (" opt_bool_isinherentlyrecursive" )
636
+ endfunction
637
+ " }}}
638
638
" ChangeDirectoryToGrepRoot {{{
639
639
function ! s: ChangeDirectoryToGrepRoot ()
640
640
if g: EasyGrepRoot != " cwd" && ! s: IsCommandVimgrep ()
@@ -2369,7 +2369,7 @@ function! s:ReplaceUndo()
2369
2369
2370
2370
" If either of these variables exists, that means the last command was
2371
2371
" interrupted; give it another shot
2372
- if ! exists (s: GetSavedName (" switchbuf" )) && ! exists (s: GetSavedName (" autowriteall" ))
2372
+ if ! exists (s: GetSavedVariableName (" switchbuf" )) && ! exists (s: GetSavedVariableName (" autowriteall" ))
2373
2373
2374
2374
call s: SaveVariable (" switchbuf" )
2375
2375
set switchbuf = useopen
0 commit comments