Next: Complete example of a private theme derived from Modus, Up: Complete example of a Modus derivative theme [Index]
For package developers, the following snippet needs to be included in each theme file (Complete example of a private theme derived from Modus):
;;;; Add themes from this package to the `custom-theme-load-path' ;;;###autoload (when load-file-name (let ((dir (file-name-directory load-file-name))) (add-to-list 'custom-theme-load-path dir)))
If the package provides many themes, then the above snippet can be
included in a shared file that is then loaded via require in the
individual theme files.
For example, the family of themes that includes ‘prot-light-theme.el’ and ‘prot-dark-theme.el’ has a shared library which is ‘prot-themes.el’ and therein we find at least the following:
;; Package headers here for prot-themes.el... ;; Any other shared definitions... ;;;; Add themes from this package to the `custom-theme-load-path' ;;;###autoload (when load-file-name (let ((dir (file-name-directory load-file-name))) (add-to-list 'custom-theme-load-path dir))) (provide 'prot-themes) ;;; prot-themes.el ends here
Then each individual theme can look like this (Complete example of a custom theme with its own palette):
(require 'prot-themes) (modus-themes-theme 'prot-light 'prot-themes "My demo `prot-light' theme." 'light 'modus-operandi-palette nil nil)
The contents of such a package will be of this form:
Common file with all the shared definitions.
The light theme.
The dark theme.
The shared file can be skipped if the only piece of common code is
the aforementioned snippet about the custom-theme-load-path. Simply
add that snippet to the bottom of each theme file, like this:
(modus-themes-theme 'prot-light 'prot-themes "My demo `prot-light' theme." 'light 'modus-operandi-palette nil nil) ;;;###autoload (when load-file-name (let ((dir (file-name-directory load-file-name))) (add-to-list 'custom-theme-load-path dir)))
The package is then a collection of ‘NAME-theme.el’ files and nothing more.
In principle, a package derived from Modus does not need to define any
commands or user options. What is shown in this section is enough.
Packages such as the ef-themes and standard-themes are exceptions
because they existed for years before they were based on Modus and
must remain backward compatible.