Previous: , Up: Modes   [Contents][Index]


8.3 Mode Functions

Function: defmode name &key :setup-function :cleanup-function :major-p :precedence :transparent-p :documentation

This function defines a new mode named name, and enters it in mode-names. If major-p is supplied and is not nil then the mode is a major mode; otherwise it is a minor mode.

Setup-function and cleanup-function are functions which are invoked with the buffer affected, after the mode is turned on, and before it is turned off, respectively. These functions typically are used to make buffer-local key or variable bindings and to remove them when the mode is turned off.

Precedence is only meaningful for a minor mode. The precedence of a minor mode determines the order in which it in a buffer’s list of modes. When searching for values in the current environment, minor modes are searched in order, so the precedence of a minor mode determines which value is found when there are several definitions.

Transparent-p determines whether key bindings local to the defined mode are transparent. Transparent key bindings are invoked in addition to the first normal key binding found rather than shadowing less local key bindings.

Documentation is some introductory text about the mode. Commands such as Describe Mode use this.

Function: mode-documentation name

This function returns the documentation for the mode named name.

Hemlock Variable: Buffer Major Mode Hook
Function: buffer-major-mode buffer

buffer-major-mode returns the name of buffer’s major mode. The major mode may be changed with setf; then Buffer Major Mode Hook is invoked with buffer and the new mode.

Hemlock Variable: Buffer Minor Mode Hook
Function: buffer-minor-mode buffer name

buffer-minor-mode returns t if the minor mode name is active in buffer, nil otherwise. A minor mode may be turned on or off by using setf; then Buffer Minor Mode Hook is invoked with buffer, name and the new value.

Function: mode-variables name

Returns the string-table of mode local variables.

Function: mode-major-p name

Returns t if name is the name of a major mode, or nil if it is the name of a minor mode. It is an error for name not to be the name of a mode.


Previous: Major and Minor Modes, Up: Modes   [Contents][Index]