Mike Zamansky has published the latest video in his Learning Elisp series. This is (probably) the last video in his emoji replacement project. In the last video, Zamansky showed how to turn his emoji replacement code into a minor mode. This video cleans things up a bit and explores two other aspects of programming in Elisp.
First off, he shows how configure the minor mode to use either the replace or overlay method for substituting an emoji for a keyword. That’s done with a boolean variable, of course, but rather than use it to test which function to call after every screen update, he uses it to set a function variable that is installed in the appropriate hook.
He mentions, but does not elaborate on, the need to use funcall
to actually call the function in the variable. That doesn’t matter here because the variable is used by hook mechanism and not called directly by Zamansky’s code.
The second aspect is how to define the boolean variable. He first considers using devar
instead of setq
but explains that the proper way of doing it in this instance is with defcustom
. Doing it that way allows the user to set the variable using the Emacs Custom interface. That way, the variable can be set once and the values will persist between Emacs invocations but can still be changed whenever the user desires.
Even if you’re familiar with Lisp from, say, Common Lisp or Scheme, the defcustom
form will be new and is worth learning about. The video is 11 minutes, 59 seconds so you’ll probably have to schedule some time but as usual with Zamansky’s videos, it will be time well spent.