Next: Arrange to activate your derivative themes, Previous: Determine what counts as a Modus theme, Up: Build on top of the Modus themes [Index]
[ NOTE: Users of many Modus derivatives do not need to do anything of
what is described herein. Just enable the modus-themes-include-derivatives-mode. ]
In the previous section, we explored the mechanics of the
modus-themes-get-themes (Determine what counts as a Modus theme).
Independent of that method, developers can use the macro
modus-themes-define-derivative-command to define small wrappers for
Modus commands that load a theme only for a specific family of Modus
derivatives (Build on top of the Modus themes).
The modus-themes-define-derivative-command takes two mandatory
arguments:
the family of the Modus themes derivatives, such as ef-themes.
the suffix of the command-to-be-defined. It is one among
the symbols listed in modus-themes-define-derivative-command-known-suffixes.
The suffix is appended to ‘FAMILY’ to derive the symbol of the
command. For example, if ‘SUFFIX’ is ‘rotate’ and ‘FAMILY’ is
ef-themes, then the symbol is ef-themes-rotate.
Here is how it actually looks in the source code of the Ef themes:
;;;###autoload (autoload 'ef-themes-rotate "ef-themes") (modus-themes-define-derivative-command ef-themes rotate)
This is what the macroexpanded form looks like:
(defun ef-themes-rotate () "Like `modus-themes-rotate' but only consider members of the `ef-themes'" (interactive) (cl-letf (((symbol-function 'modus-themes-get-themes) (lambda () (modus-themes-get-all-known-themes 'ef-themes)))) (call-interactively 'modus-themes-rotate)))
Sometimes, it makes no sense to re-use an existing Modus command (e.g.
because the developer wants to introduce a user option to affect what
the command is doing), though this approach with the cl-letf can
still prove useful.