Sample applications
MC comes with sample scripts (or “applications”, if you
will) for you to use, some of which:
- Editor
—linter, visual replace, speller, modeline, …
- Fields
—git, mplayer, bidi, …
- Filesystems
—MHT, MySQL, SQLite
- Filemanager
—visual rename, …
- Accessories
—calculator, find-as-you-type, screensavers, …
- Games
By “samples” we don’t at all mean to say that these are incomplete
applications. We use the word “samples” merely to distinguish such code
from the code we consider core.
To enable most of these applications all you have to do is to add the
following line to a Lua file in your user Lua folder:
require('samples.official-suggestions')
Take a peek at that file (official-suggestions.lua) to see what
key bindings activate the various applications.
A better approach is to copy that file (official-suggestions.lua)
to your user Lua folder: you'll then be able to edit it to your liking.
Lua code is organized in modules. You use Lua’s
require() to load a module.
Using modules
What to do when you see a module you like? How do you “activate” it?
The sample modules follow these rules:
- It’s generally enough to just require() a module. This activates the
feature the module provides.
Example:
require('samples.editbox.modeline')
Alternatively, you may symlink to such modules in your user Lua
folder. This technique works for any kind of files: e.g., you can
symlink to code snippets in snippets/ to “activate”
them.
- Modules that provide some intrusive feature, where automatic activation
is not always desired, provide an install() function which you need to
call.
Example:
require('samples.screensavers.clocks.analog').install()
- If the module has some entry point, e.g. a dialog box that starts some
process, it provides a run() function to trigger it.
Example:
keymap.bind('C-x c', function()
require('samples.apps.calc').run()
end)
All modules have a comment at their top explaining their purpose and how
to enable them.