Loading macrofiles
Regular macros and event handlers are loaded from Lua-files (extension
*.lua
) and/or MoonScript files (extension*.moon
). Further we will call these files macrofiles. The macros are loaded when macrofiles are executed by LuaMacro plugin.Macrofiles are loaded from sequence of directories (recursively with their subdirectories), determined by one of the following ways (in order of priorities):
- A sequence of directories, specified explicitly (in a command or a function argument)
- The value of
MacroPath
variable in the fileluamacro.ini
- The directory
%FARPROFILE%\Macros\scripts
Far Manager itself never makes any changes to the above mentioned directories. The files are added, removed, renamed and edited solely by the user.
One macrofile can contain arbitrary number of macros and event handlers.
When a macrofile is executed it receives 2 arguments: (1) the full pathname of this macrofile and (2) the value of execution counter in the current session of plugin LuaMacro. If we define 2 variables at top of the macrofile, e.g.
local MacroFileName, ExeCounter = ...
then these variables will be available to all the macros and event handlers defined in that file.If macrofiles are loaded from a sequence of trees
root1;root2;...
, that means that:- The tree
root2
loads only after loadingroot1
- For each tree
rootN
the first macrofile run isrootN\_macroinit.lua
if such a file exists. For the rest of macrofiles in the given tree order of execution is not defined.
- The tree