Neomacs use modes to provide functionalities to buffers. Neomacs modes are mixins, i.e. CLOS classes that can be dynamically added to buffers. A Neomacs buffer always inherit from zero or more modes and the buffer
class.
mode
inherits (defaultable-class)
commands
keymap
lighter
hooks
Mixins mostly supersede buffer-local variables and hooks used in previous editors like Emacs and Hemlock. Modes can have slots, which are introduced to the buffers that enable them. Methods that specialize on a mode customize behavior of generic functions on buffers. Many generic functions (e.g. on-*
) in Neomacs has a buffer as the first argument, which is suitable for specializing on modes. Many ordinary functions in Neomacs has a backing generic function which has a buffer as first argument, usually with name *-aux
.
enable
(mode-name)
disable
(mode-name)
toggle
(mode-name)
Mode toggling hooks:
enable-aux
(mode-name)
current-buffer
bound to the buffer
for which MODE-NAME is being enabled.disable-aux
(mode-name previous-instance)
current-buffer
bound to the buffer
for which MODE-NAME is being disabled.hooks
(object)
Mode hooks and super-modes both allow enabling some other modes when a mode is enabled, which may be somewhat confusing. Suppose mode A has mode B in its hooks
and mode C as its super-mode, note the differences:
Thefore, super-modes are best used for expressing dependencies between modes (e.g. minibuffer-completion-mode
has minibuffer-mode
as a super-mode), and mode hooks are best used for suggesting using some other modes together with a mode (e.g. prog-mode
has undo-mode
in its mode hooks by default).
define-mode
(name super-modes slots &rest options)
define-class
besides supporting extra OPTIONS: