@@ -334,7 +334,7 @@ let s:EasyGrepModeAll=0
334334let s: EasyGrepModeBuffers= 1
335335let s: EasyGrepModeTracked= 2
336336let s: EasyGrepModeUser= 3
337- let s: EasyGrepNumModes = 4
337+ let s: EasyGrepNumModes= 4
338338
339339" This is a special mode
340340let s: EasyGrepModeMultipleChoice= 4
@@ -3075,6 +3075,39 @@ function! s:ResultListDo(command)
30753075
30763076endfunction
30773077" }}}
3078+ " ResultListSave {{{
3079+ function ! s: ResultListSave (f )
3080+ if filereadable (a: f )
3081+ let confirmed = confirm (" File '" .a: f ." ' exists; overwrite it?" , " &Yes\n &No" )-1
3082+ if confirmed
3083+ return
3084+ endif
3085+ call s: Echo (" Proceeding to overwrite '" .a: f ." '" )
3086+ endif
3087+
3088+ let lst = s: GetErrorList ()
3089+
3090+ if empty (lst)
3091+ call s: Error (" No result list to save" )
3092+ return
3093+ endif
3094+
3095+ try
3096+ let contents = []
3097+ for e in lst
3098+ let line = bufname (e .bufnr )." |" .e .lnum." col " .e .col ." | " .e .text
3099+ call insert (contents, line , len (contents))
3100+ endfor
3101+
3102+ call writefile (contents, a: f )
3103+ catch
3104+ call s: Error (" Error saving result list to '" .a: f ." '" )
3105+ return
3106+ endtry
3107+
3108+ call s: Echo (" Result list was saved to '" .a: f ." ' successfully" )
3109+ endfunction
3110+ " }}}
30783111" }}}
30793112" }}}
30803113
@@ -3090,6 +3123,7 @@ command! -bang ReplaceUndo :call s:ReplaceUndo("<bang>")
30903123command ! -nargs =0 ResultListOpen :call s: ResultListOpen ()
30913124command ! -nargs =+ ResultListFilter :call s: ResultListFilter (<f-args> )
30923125command ! -nargs =+ ResultListDo :call s: ResultListDo (<q-args> )
3126+ command ! -nargs =1 ResultListSave :call s: ResultListSave (<q-args> )
30933127" }}}
30943128" Keymaps {{{
30953129if ! hasmapto (" <plug>EgMapGrepOptions" )
0 commit comments