Function: erc-define-minor-mode
erc-define-minor-mode is a function alias and autoloaded for
define-minor-mode, defined in easy-mmode.el.gz.
This macro is obsolete since 28.1; use define-minor-mode instead.
Signature
(erc-define-minor-mode MODE DOC [KEYWORD VAL ... &rest BODY])
Documentation
Define a new minor mode MODE.
This defines the toggle command MODE and (by default) a control variable MODE (you can override this with the :variable keyword, see below). DOC is the documentation for the mode toggle command.
The defined mode command takes one optional (prefix) argument. Interactively with no prefix argument, it toggles the mode. A prefix argument enables the mode if the argument is positive, and disables it otherwise.
When called from Lisp, the mode command toggles the mode if the
argument is toggle, disables the mode if the argument is a
non-positive integer, and enables the mode otherwise (including
if the argument is omitted or nil or a positive integer).
If DOC is nil, give the mode command a basic doc-string documenting what its argument does. If the word "ARG" does not appear in DOC, a paragraph is added to DOC explaining usage of the mode argument.
BODY contains code to execute each time the mode is enabled or disabled.
It is executed after toggling the mode, and before running MODE-hook.
Before the actual body code, you can write keyword arguments, i.e.
alternating keywords and values. If you provide BODY, then you must
provide at least one keyword argument (e.g. `:lighter nil`).
The following special keywords are supported (other keywords are passed
to defcustom if the minor mode is global):
:global GLOBAL If non-nil specifies that the minor mode is not meant to be
buffer-local, so don't make the variable MODE buffer-local.
By default, the mode is buffer-local.
:init-value VAL the initial value of the mode's variable.
Note that the minor mode function won't be called by setting
this option, so the value *reflects* the minor mode's natural
initial state, rather than *setting* it.
In the vast majority of cases it should be nil.
Not used if you also specify :variable.
:lighter SPEC Text displayed in the mode line when the mode is on.
:keymap MAP Keymap bound to the mode keymap. Defaults to MODE-map.
If non-nil, it should be an unquoted variable name (whose value
is a keymap), or an expression that returns either a keymap or
a list of (KEY . BINDING) pairs where KEY and BINDING are
suitable for define-key. If you supply a KEYMAP argument
that is not a symbol, this macro defines the variable MODE-map
and gives it the value that KEYMAP specifies.
:interactive VAL Whether this mode should be a command or not. The default
is to make it one; use nil to avoid that. If VAL is a list,
it's interpreted as a list of major modes this minor mode
is useful in.
:variable PLACE The location to use instead of the variable MODE to store
the state of the mode. This can be simply a different
named variable, or a generalized variable.
PLACE can also be of the form (GET . SET), where GET is
an expression that returns the current state, and SET is
a function that takes one argument, the new state, which should
be assigned to PLACE. If you specify a :variable, this function
does not define a MODE variable (nor any of the terms used
in :variable).
:after-hook A single Lisp form which is evaluated after the mode hooks
have been run. It should not be quoted.
For example, you could write
(define-minor-mode foo-mode "If enabled, foo on you!"
:lighter " Foo" :require 'foo :global t :group 'hassle :version "27.5"
...BODY CODE...)
For backward compatibility with the Emacs<21 calling convention, the keywords can also be preceded by the obsolete triplet INIT-VALUE LIGHTER KEYMAP.
Aliases
easy-mmode-define-minor-mode (obsolete since 30.1)
erc-define-minor-mode (obsolete since 28.1)