6 , functionName = "s:delete"
8 ArgumentList [ Argument "first" , Argument "last" ]
9 , functionAttributes = []
11 [ LetStatement { letLexpr = "l:list" , letValue = "getqflist()" }
12 , LetStatement { letLexpr = "l:line" , letValue = "a:first" }
13 , GenericStatement "while l:line >= a:first && l:line <= a:last"
14 , LetStatement { letLexpr = "l:list[l:line - 1]" , letValue = "0" }
15 , LetStatement { letLexpr = "l:line" , letValue = "l:line + 1" }
16 , GenericStatement "endwhile"
17 , GenericStatement "call setqflist(l:list, 'r')"
18 , GenericStatement "execute 'cc ' . a:first"
19 , GenericStatement "execute \"normal \\<C-W>\\<C-P>\""
24 , functionName = "s:dispatch"
25 , functionArguments = ArgumentList []
26 , functionAttributes = []
29 [ OptionAnnotation "g:FerretDispatch" "boolean" (Just "1")
31 [ Plaintext "Controls"
39 , Plaintext "vim-dispatch"
43 , Plaintext "specifically,"
54 , Plaintext "searches"
56 , Plaintext "asynchronously,"
60 , Plaintext "available."
66 , Plaintext "vim-dispatch"
80 , Fenced [ "let g:FerretDispatch=0" ]
83 { letLexpr = "l:dispatch"
84 , letValue = "get(g:, 'FerretDispatch', 1)"
86 , GenericStatement "return l:dispatch && exists(':Make') == 2"
91 , functionName = "s:error"
92 , functionArguments = ArgumentList [ Argument "message" ]
93 , functionAttributes = [ "abort" ]
95 [ GenericStatement "call inputsave()"
96 , GenericStatement "echohl ErrorMsg"
98 "call input(a:message . ': press ENTER to continue')"
99 , GenericStatement "echohl NONE"
100 , GenericStatement "call inputrestore()"
101 , GenericStatement "echo"
104 , FunctionDeclaration
105 { functionBang = True
106 , functionName = "s:parse"
107 , functionArguments = ArgumentList [ Argument "arg" ]
108 , functionAttributes = [ "abort" ]
110 [ GenericStatement "if exists('g:ferret_lastsearch')"
112 { unletBang = False , unletBody = "g:ferret_lastsearch" }
113 , GenericStatement "endif"
115 { letLexpr = "l:escaped_spaces_replaced_with_markers"
116 , letValue = "substitute(a:arg, '\\\\ ', '<!!S!!>', 'g')"
119 { letLexpr = "l:split_on_spaces"
120 , letValue = "split(l:escaped_spaces_replaced_with_markers)"
122 , LetStatement { letLexpr = "l:expanded_args" , letValue = "[]" }
123 , GenericStatement "for l:arg in l:split_on_spaces"
124 , GenericStatement "if l:arg =~# '^-'"
125 , GenericStatement "call add(l:expanded_args, l:arg)"
126 , GenericStatement "elseif exists('g:ferret_lastsearch')"
128 { letLexpr = "l:file_args"
130 "glob(l:arg, 1, 1) \" Ignore 'wildignore', return a list."
132 , GenericStatement "if len(l:file_args)"
133 , GenericStatement "call extend(l:expanded_args, l:file_args)"
134 , GenericStatement "else"
135 , GenericStatement "call add(l:expanded_args, l:arg)"
136 , GenericStatement "endif"
137 , GenericStatement "else"
139 { letLexpr = "g:ferret_lastsearch"
140 , letValue = "substitute(l:arg, '<!!S!!>', ' ', 'g')"
142 , GenericStatement "call add(l:expanded_args, l:arg)"
143 , GenericStatement "endif"
144 , GenericStatement "endfor"
146 { letLexpr = "l:each_word_shell_escaped"
147 , letValue = "map(l:expanded_args, 'shellescape(v:val)')"
150 { letLexpr = "l:joined"
151 , letValue = "join(l:each_word_shell_escaped)"
154 "return substitute(l:joined, '<!!S!!>', ' ', 'g')"
157 , FunctionDeclaration
158 { functionBang = True
159 , functionName = "ferret#private#post"
160 , functionArguments = ArgumentList [ Argument "type" ]
161 , functionAttributes = [ "abort" ]
163 [ GenericStatement "if has('autocmd')"
164 , GenericStatement "augroup FerretPostQF"
165 , GenericStatement "autocmd!"
166 , GenericStatement "augroup END"
167 , GenericStatement "endif"
169 { letLexpr = "l:lastsearch "
170 , letValue = "get(g:, 'ferret_lastsearch', '')"
173 { letLexpr = "l:qflist "
174 , letValue = "a:type == 'qf' ? getqflist() : getloclist(0)"
177 { letLexpr = "l:tip "
178 , letValue = "' [see `:help ferret-quotes`]'"
180 , GenericStatement "if len(l:qflist) == 0"
182 { letLexpr = "l:base "
184 "'No results for search pattern `' . l:lastsearch . '`'"
187 "if l:lastsearch =~ '\\v^([' . \"'\" . '\"])[^ \\1]+\\1$'"
188 , GenericStatement "call s:error(l:base . l:tip)"
189 , GenericStatement "else"
190 , GenericStatement "call s:error(l:base)"
191 , GenericStatement "endif"
192 , GenericStatement "else"
194 { letLexpr = "l:invalid "
195 , letValue = "filter(copy(l:qflist), 'v:val.valid == 0')"
197 , GenericStatement "if len(l:invalid) == len(l:qflist)"
198 , GenericStatement "redraw!"
199 , GenericStatement "echohl ErrorMsg"
200 , GenericStatement "for l:item in l:invalid"
201 , GenericStatement "echomsg l:item.text"
202 , GenericStatement "endfor"
203 , GenericStatement "echohl NONE"
205 { letLexpr = "l:base "
206 , letValue = "'Search for `' . l:lastsearch . '` failed'"
209 { letLexpr = "l:suffix "
210 , letValue = "a:type == 'qf' && s:dispatch() ?"
212 , GenericStatement "\\ ' (run `:messages` to see details)' : ''"
214 "if l:lastsearch =~ '\\v^[' . \"'\" . '\"].+[^' . \"'\" . '\"]$'"
215 , GenericStatement "call s:error(l:base . l:tip . l:suffix)"
216 , GenericStatement "else"
217 , GenericStatement "call s:error(l:base . l:suffix)"
218 , GenericStatement "endif"
219 , GenericStatement "endif"
220 , GenericStatement "endif"
223 , FunctionDeclaration
224 { functionBang = True
225 , functionName = "ferret#private#ack"
226 , functionArguments = ArgumentList [ Argument "command" ]
227 , functionAttributes = [ "abort" ]
230 { letLexpr = "l:command" , letValue = "s:parse(a:command)" }
231 , GenericStatement "call ferret#private#hlsearch()"
232 , GenericStatement "if empty(&grepprg)"
233 , GenericStatement "return"
234 , GenericStatement "endif"
235 , GenericStatement "if s:dispatch()"
236 , GenericStatement "if has('autocmd')"
237 , GenericStatement "augroup FerretPostQF"
238 , GenericStatement "autocmd!"
240 "autocmd QuickfixCmdPost cgetfile call ferret#private#post('qf')"
241 , GenericStatement "augroup END"
242 , GenericStatement "endif"
244 { letLexpr = "l:original_makeprg" , letValue = "&l:makeprg" }
246 { letLexpr = "l:original_errorformat"
247 , letValue = "&l:errorformat"
249 , GenericStatement "try"
251 { letLexpr = "&l:makeprg"
252 , letValue = "&grepprg . ' ' . l:command"
255 { letLexpr = "&l:errorformat" , letValue = "&grepformat" }
256 , GenericStatement "Make"
257 , GenericStatement "catch"
258 , GenericStatement "if has('autocmd')"
259 , GenericStatement "augroup! FerretPostQF"
260 , GenericStatement "endif"
261 , GenericStatement "finally"
263 { letLexpr = "&l:makeprg" , letValue = "l:original_makeprg" }
265 { letLexpr = "&l:errorformat"
266 , letValue = "l:original_errorformat"
268 , GenericStatement "endtry"
269 , GenericStatement "else"
270 , GenericStatement "cexpr system(&grepprg . ' ' . l:command)"
271 , GenericStatement "cwindow"
272 , GenericStatement "call ferret#private#post('qf')"
273 , GenericStatement "endif"
276 , FunctionDeclaration
277 { functionBang = True
278 , functionName = "ferret#private#lack"
279 , functionArguments = ArgumentList [ Argument "command" ]
280 , functionAttributes = [ "abort" ]
283 { letLexpr = "l:command" , letValue = "s:parse(a:command)" }
284 , GenericStatement "call ferret#private#hlsearch()"
285 , GenericStatement "if empty(&grepprg)"
286 , GenericStatement "return"
287 , GenericStatement "endif"
290 , lexprExpr = "system(&grepprg . ' ' . l:command)"
292 , LwindowStatement { lwindowHeight = Nothing }
293 , GenericStatement "call ferret#private#post('location')"
296 , FunctionDeclaration
297 { functionBang = True
298 , functionName = "ferret#private#hlsearch"
299 , functionArguments = ArgumentList []
300 , functionAttributes = [ "abort" ]
302 [ GenericStatement "if has('extra_search')"
303 , GenericStatement "\"\""
305 { letLexpr = "l:hlsearch"
306 , letValue = "get(g:, 'FerretHlsearch', &hlsearch)"
308 , GenericStatement "if l:hlsearch"
310 { letLexpr = "@/" , letValue = "g:ferret_lastsearch" }
312 "call feedkeys(\":let &hlsearch=1 | echo \\<CR>\", 'n')"
313 , GenericStatement "endif"
314 , GenericStatement "endif"
317 , FunctionDeclaration
318 { functionBang = True
319 , functionName = "ferret#private#acks"
320 , functionArguments = ArgumentList [ Argument "command" ]
321 , functionAttributes = [ "abort" ]
324 "if match(a:command, '\\v^/.+/.*/$') == -1 \" crude sanity check"
326 "echoerr 'Ferret: Expected a substitution expression (/foo/bar/); got: ' . a:command"
327 , GenericStatement "return"
328 , GenericStatement "endif"
330 { letLexpr = "l:filenames" , letValue = "ferret#private#qargs()" }
331 , GenericStatement "if l:filenames ==# ''"
333 "echoerr 'Ferret: Quickfix filenames must be present, but there are none'"
334 , GenericStatement "return"
335 , GenericStatement "endif"
336 , GenericStatement "execute 'args' l:filenames"
338 "if v:version > 703 || v:version == 703 && has('patch438')"
340 "silent doautocmd <nomodeline> User FerretWillWrite"
341 , GenericStatement "else"
342 , GenericStatement "silent doautocmd User FerretWillWrite"
343 , GenericStatement "endif"
345 "execute 'argdo' '%s' . a:command . 'ge | update'"
347 "if v:version > 703 || v:version == 703 && has('patch438')"
349 "silent doautocmd <nomodeline> User FerretDidWrite"
350 , GenericStatement "else"
351 , GenericStatement "silent doautocmd User FerretDidWrite"
352 , GenericStatement "endif"
355 , FunctionDeclaration
356 { functionBang = True
357 , functionName = "ferret#private#qargs"
358 , functionArguments = ArgumentList []
359 , functionAttributes = [ "abort" ]
361 [ LetStatement { letLexpr = "l:buffer_numbers" , letValue = "{}" }
362 , GenericStatement "for l:item in getqflist()"
364 { letLexpr = "l:buffer_numbers[l:item['bufnr']]"
365 , letValue = "bufname(l:item['bufnr'])"
367 , GenericStatement "endfor"
369 "return join(map(values(l:buffer_numbers), 'fnameescape(v:val)'))"
372 , FunctionDeclaration
373 { functionBang = True
374 , functionName = "ferret#private#qf_delete"
375 , functionArguments = ArgumentList []
376 , functionAttributes = [ "range" ]
378 [ GenericStatement "call s:delete(a:firstline, a:lastline)" ]
380 , FunctionDeclaration
381 { functionBang = True
382 , functionName = "ferret#private#qf_delete_motion"
383 , functionArguments =
384 ArgumentList [ Argument "type" , Argument "..." ]
385 , functionAttributes = []
388 { letLexpr = "l:selection" , letValue = "&selection" }
390 { letLexpr = "&selection" , letValue = "'inclusive'" }
392 { letLexpr = "l:firstline" , letValue = "line(\"'[\")" }
394 { letLexpr = "l:lastline" , letValue = "line(\"']\")" }
395 , GenericStatement "call s:delete(l:firstline, l:lastline)"
397 { letLexpr = "&selection" , letValue = "l:selection" }
402 , OptionAnnotation "g:FerretDispatch" "boolean" (Just "1")
404 [ Plaintext "Controls"
406 , Plaintext "whether"
412 , Plaintext "vim-dispatch"
416 , Plaintext "specifically,"
427 , Plaintext "searches"
429 , Plaintext "asynchronously,"
433 , Plaintext "available."
437 , Plaintext "prevent"
439 , Plaintext "vim-dispatch"
453 , Fenced [ "let g:FerretDispatch=0" ]