local function FileSave(t) editor.Editor(t[1][1],_,_,_,_,_,bit64.bor(F.EF_NONMODAL,F.EF_IMMEDIATERETURN,F.EF_OPENMODE_USEEXISTING)) for j=2,#t do editor.SetString(-1,t[j][1],t[j][2]) end if not editor.SaveFile(-1) then msgbox("Warning! File is not saved - blocked?",t[1][1]) else editor.Quit(-1) end end Macro { area="Editor"; key="AltG"; flags=""; description="RESearch: 3. Grep Save All"; filemask="/\\w+\\.tmp$/i"; action=function() local t={} for i=1,editor.GetInfo(-1).TotalLines do local l=editor.GetString(-1,i).StringText local y,s = l:match('^(%d-)[-:](.+)$') if y and s and #t>=1 then table.insert(t,{y,s}) else local f=GetFileName(l) if f then if #t>1 then FileSave(t) t={} end t[1]={f,nil} end end end if #t>1 then FileSave(t) end end; } |