Go to the first, previous, next, last section, table of contents.


Easy-Mmode

The easy-mmode package provides a convenient way of implementing a minor mode; with it, you can specify all about a simple minor mode in one self-contained definition.

Macro: easy-mmode-define-minor-mode mode doc &optional init-value mode-indicator keymap
This macro defines a new minor mode whose name is mode (a symbol).

This macro defines a command named mode which toggles the minor mode, and has doc as its documentation string.

It also defines a variable named mode, which is set to t or nil by enabling or disabling the mode. The variable is initialized to init-value.

The string mode-indicator says what to display in the mode line when the mode is enabled; if it is nil, the mode is not displayed in the mode line.

The optional argument keymap specifies the keymap for the minor mode. It can be a variable name, whose value is the keymap, or it can be an alist specifying bindings in this form:

(key-sequence . definition)

Here is an example of using easy-mmode-define-minor-mode:

(easy-mmode-define-minor-mode hungry-mode
  "Toggle Hungry mode.
With no argument, this command toggles the mode. 
Non-null prefix argument turns on the mode.
Null prefix argument turns off the mode.

When Hungry mode is enabled, the control delete key
gobbles all preceding whitespace except the last.
See the command \\[hungry-electric-delete]."
 ;; The initial value.
 nil
 ;; The indicator for the mode line.
 " Hungry"
 ;; The minor mode bindings.
 '(("\C-\^?" . hungry-electric-delete)
   ("\C-\M-\^?"
    . (lambda () 
        (interactive)
        (hungry-electric-delete t)))))

This defines a minor mode named "Hungry mode", a command named hungry-mode to toggle it, a variable named hungry-mode which indicates whether the mode is enabled, and a variable named hungry-mode-map which holds the keymap that is active when the mode is enabled. It initializes the keymap with key bindings for C-DEL and C-M-DEL.


Go to the first, previous, next, last section, table of contents.