Extremely Useful Emacs'isms

Created on 2022-03-07T20:12:50-06:00

Return to the Index

This card can also be read via Gemini.

lexical scoping

lexical scoping allows changing variables about the system for the purpose of a single call; for example changing the fill column of a text field to infinite characters, but only to call a paragraph filling function, where it then returns to its original value.

Emacs Lisp does this for everything though people get confused by lexical scoping. Janet Lisp has “with-dyn” but you have to specifically mark variables as lexically scoped.

Commands

not sure how strictly useful this one is. Some functions are marked “interactive” which means they are commands, can be called through M-x or from things which run commands.

Key maps

A table which maps particular device inputs to commands. Can be stacked on top of one another (via minor modes) or temporary (via transient key maps.) Swapping key maps around allows emulating modal interfaces (vi, evil-mode) or Raskin interfaces (holding modifiers to do things.)

Major Modes

Takes main control over the interface.

Minor Modes

Overlays a keymap, toolbar and menu on top of the existing interface. Multiple minor modes exist at once.

Hooks

A hook is a list of functions which is executed when something happens. When the event is triggered, iterate the list and call all of the hooks. In some cases the hooks can be temporarily toggled on and off. In some implementations adding a hook also returns a receipt which can be used to revoke the hook later on.

Autoload

Shim functions which, when run, trigger loading a package. It is assumed the loaded package will replace the autoloads with an actual implementation.