Running script from within the editor
-- This macro saves the editor contents (if it was modified)
-- then runs the edited file as Lua-script.
Macro {
description="Save and run script from editor";
area="Editor"; key="CtrlF10";
action=function()
for k=1,2 do
local info=editor.GetInfo()
if bit64.band(info.CurState, far.Flags.ECSTATE_SAVED)~=0 then
local Flags = info.FileName:sub(-5):lower()==".moon"
and "KMFLAGS_MOONSCRIPT" or "KMFLAGS_LUA"
far.MacroPost('@"' .. info.FileName .. '"', Flags)
break
end
if k==1 then editor.SaveFile(); end
end
end;
}