The Customization Library

Declaring Groups

Use defgroup to declare new customization groups.

Function: defgroup symbol members doc [keyword value]...
Declare symbol as a customization group containing members. symbol does not need to be quoted.

doc is the group documentation.

members should be an alist of the form ((name widget)...) where name is a symbol and widget is a widget for editing that symbol. Useful widgets are custom-variable for editing variables, custom-face for editing faces, and custom-group for editing groups.

Internally, custom uses the symbol property custom-group to keep track of the group members, and group-documentation for the documentation string.

The following additional keyword's are defined:

:prefix
value should be a string. If the string is a prefix for the name of a member of the group, that prefix will be ignored when creating a tag for that member.

Declaring Variables

Use defcustom to declare user editable variables.

Function: defcustom symbol value doc [keyword value]...
Declare symbol as a customizable variable that defaults to value. Neither symbol nor value needs to be quoted. If symbol is not already bound, initialize it to value.

doc is the variable documentation.

The following additional keyword's are defined:

:type
value should be a widget type.
:options
value should be a list of possible members of the specified type. For hooks, this is a list of function names.
:initialize
value should be a function used to initialize the variable. It takes two arguments, the symbol and value given in the defcustom call. Some predefined functions are:
custom-initialize-set
Use the :set method to initialize the variable. Do not initialize it if already bound. This is the default :initialize method.
custom-initialize-default
Always use set-default to initialize the variable, even if a :set method has been specified.
custom-initialize-reset
If the variable is already bound, reset it by calling the :set method with the value returned by the :get method.
custom-initialize-changed
Like custom-initialize-reset, but use set-default to initialize the variable if it is not bound and has not been set already.
:set
value should be a function to set the value of the symbol. It takes two arguments, the symbol to set and the value to give it. The default is set-default.
:get
value should be a function to extract the value of symbol. The function takes one argument, a symbol, and should return the current value for that symbol. The default is default-value.
:require
value should be a feature symbol. Each feature will be required when the `defcustom' is evaluated, or when Emacs is started if the user has saved this option.

See section `Sexp Types' in The Widget Library, for information about widgets to use together with the :type keyword.

Internally, custom uses the symbol property custom-type to keep track of the variables type, standard-value for the program specified default value, saved-value for a value saved by the user, and variable-documentation for the documentation string.

Use custom-add-option to specify that a specific function is useful as an member of a hook.

Function: custom-add-option symbol option
To the variable symbol add option.

If symbol is a hook variable, option should be a hook member. For other types variables, the effect is undefined."

Declaring Faces

Faces are declared with defface.

Function: defface face spec doc [keyword value]...

Declare face as a customizable face that defaults to spec. face does not need to be quoted.

If face has been set with `custom-set-face', set the face attributes as specified by that function, otherwise set the face attributes according to spec.

doc is the face documentation.

spec should be an alist of the form `((display atts)...)'.

atts is a list of face attributes and their values. The possible attributes are defined in the variable `custom-face-attributes'.

The atts of the first entry in spec where the display matches the frame should take effect in that frame. display can either be the symbol `t', which will match all frames, or an alist of the form `((req item...)...)'

For the display to match a FRAME, the req property of the frame must match one of the item. The following req are defined:

type
(the value of (window-system))
Should be one of x or tty.
class
(the frame's color support)
Should be one of color, grayscale, or mono.
background
(what color is used for the background text)
Should be one of light or dark.

Internally, custom uses the symbol property face-defface-spec for the program specified default face properties, saved-face for properties saved by the user, and face-documentation for the documentation string.

Usage for Package Authors

The recommended usage for the author of a typical emacs lisp package is to create one group identifying the package, and make all user options and faces members of that group. If the package has more than around 20 such options, they should be divided into a number of subgroups, with each subgroup being member of the top level group.

The top level group for the package should itself be member of one or more of the standard customization groups. There exists a group for each finder keyword. Press C-h p to see a list of finder keywords, and add you group to each of them, using the :group keyword.

Utilities

These utilities can come in handy when adding customization support.

Widget: custom-manual
Widget type for specifying the info manual entry for a customization option. It takes one argument, an info address.

Function: custom-add-to-group group member widget
To existing group add a new member of type widget, If there already is an entry for that member, overwrite it.

Function: custom-add-link symbol widget
To the custom option symbol add the link widget.

Function: custom-add-load symbol load
To the custom option symbol add the dependency load. load should be either a library file name, or a feature name.

Function: customize-menu-create symbol &optional name
Create menu for customization group symbol. If optional name is given, use that as the name of the menu. Otherwise the menu will be named `Customize'. The menu is in a format applicable to easy-menu-define.

The Init File

When you save the customizations, call to custom-set-variables, custom-set-faces are inserted into the file specified by custom-file. By default custom-file is your `.emacs' file. If you use another file, you must explicitly load it yourself. The two functions will initialize variables and faces as you have specified.

Wishlist