Previous: Create convenience commands to load a derivative theme, Up: Build on top of the Modus themes [Index]
The modus-themes-theme function is responsible for instantiating a
theme and registering it for use by the various Modus commands that
act on a theme (Build on top of the Modus themes). Due to how Emacs
themes are designed to be bound to files, modus-themes-theme can
only work if the given theme file is already loaded. Otherwise our
function is never called and the theme is never created.
To this end, users need to call the function modus-themes-activate
with each theme they want as an argument. Remember that themes are
files with a ‘-theme.el’ suffix inside one of the directories listed
in the value of the variable custom-theme-load-path. In its simplest
form, the activation looks as follows, assuming the theme’s file
‘modus-solarized-dark-theme.el’ exists:
(modus-themes-activate 'modus-solarized-dark)
To load multiple themes at once we can define a function like the following:
(defun my-modus-derivatives-activate-themes (directory) "Activate all themes in DIRECTORY. This makes all Modus derivatives available to commands such as `modus-themes-select' if `modus-themes-include-derivatives-mode' is enabled." (let* ((files (directory-files directory :full-path "-theme\\.el")) (names (mapcar (lambda (file) (intern (replace-regexp-in-string "-theme\\.el" "" file))) files))) (mapc #'modus-themes-activate names)))
Then call it thus:
(my-modus-derivatives-activate-themes "/path/to/my/custom/theme/directory/")
Again, remember that the directory is in the custom-theme-load-path:
(add-to-list 'custom-theme-load-path "/path/to/my/custom/theme/directory/")