You can define a Custom theme using an interface similar to the customization buffer, by typing
M-x customize-create-theme. This switches to a buffer named
*Custom Theme*. It also offers to insert some common Emacs faces into the theme (a convenience, since Custom themes are often used to customize faces). If you answer no, the theme will initially contain no settings.
Near the top of the
*Custom Theme* buffer, there are editable fields where you can enter the theme’s name and description. The name can be anything except ‘
user’. The description is the one that will be shown when you invoke
M-x describe-theme for the theme. Its first line should be a brief one-sentence summary; in the buffer made by
M-x customize-themes, this sentence is displayed next to the theme name.
To add a new setting to the theme, use the ‘
[Insert Additional Face]’ or ‘
[Insert Additional Variable]’ buttons. Each button reads a face or variable name using the minibuffer, with completion, and inserts a customization entry for the face or variable. You can edit the variable values or face attributes in the same way as in a normal customization buffer. To remove a face or variable from the theme, uncheck the checkbox next to its name.
After specifying the Custom theme’s faces and variables, type
C-x C-s (
custom-theme-write) or use the buffer’s ‘
[Save Theme]’ button. This saves the theme file, named
name is the theme name, in the directory named by
*Custom Theme* buffer, you can view and edit an existing Custom theme by activating the ‘
[Visit Theme]’ button and specifying the theme name. You can also add the settings of another theme into the buffer, using the ‘
[Merge Theme]’ button. You can import your non-theme settings into a Custom theme by using the ‘
[Merge Theme]’ button and specifying the special theme named ‘
A theme file is simply an Emacs Lisp source file, and loading the Custom theme works by loading the Lisp file. Therefore, you can edit a theme file directly instead of using the
*Custom Theme* buffer. See Custom Themes in The Emacs Lisp Reference Manual, for details.