Next: , Previous: , Up: Top   [Contents]

2 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:


value should be a widget type.


value should be a list of possible members of the specified type. For hooks, this is a list of function names.


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:


Use the :set method to initialize the variable. Do not initialize it if already bound. This is the default :initialize method.


Always use set-default to initialize the variable, even if a :set method has been specified.


If the variable is already bound, reset it by calling the :set method with the value returned by the :get method.


Like custom-initialize-reset, but use set-default to initialize the variable if it is not bound and has not been set already.


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.


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.


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 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."

Next: , Previous: , Up: Top   [Contents]