MakeResident
MakeResident (file)
Function MakeResident is available to the _usermenu.lua script.
It allows to add a file, containing one or more handlers that will be further called on some FAR events.
The following handlers are supported:
ProcessEditorInputProcessEditorEventProcessViewerEventExitScript
Parameters
file
A specification for a Lua script that is run by this function. The exact file name is determined according to the same rules as withrequirefunction, that is,package.pathis used to search for the file. But contrary torequire, the value returned by the script is not cached inpackage.loaded.
Notes about the handlers
- Handlers must be defined as global functions.
- There can be multiple handlers for the same event type. They will
be called in the order their files are specified in
_usermenu.lua. - The handlers' input parameters correspond to the exported
functions with the same names, e.g.
ProcessViewerEventcorresponds toexport.ProcessViewerEvent, etc. (see LuaFAR manual for details).ExitScripthas no parameters, no return value. - If the return value of a handler’s
ProcessEditorInputis true, the rest ofProcessEditorInputhandlers are not called, and true is returned to Far. - The return values of
ProcessEditorEventandProcessViewerEventare ignored. ProcessEditorInputhandlers are not called when a user-defined hot key is pressed.ExitScriptis called when the plugin is about to be unloaded. It is also called before the “Reload User file” operation.