From 56afad3af8190c412b8db05a7a1c3f35afee1b3b Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 30 Jan 2012 21:03:09 -0800 Subject: [PATCH] Document define-minor-mode's new :variable keyword in the lispref. * doc/lispref/modes.texi (Defining Minor Modes): Document define-minor-mode's new :variable keyword. * etc/NEWS: Markup. --- doc/lispref/ChangeLog | 5 +++++ doc/lispref/modes.texi | 21 ++++++++++++++++----- etc/NEWS | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 8f949eb24dd..4103dea0f8e 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2012-01-31 Glenn Morris + + * modes.texi (Defining Minor Modes): + Document define-minor-mode's new :variable keyword. + 2012-01-29 Chong Yidong * syntax.texi (Syntax Class Table): Tweak description of newline diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 53120d72bd1..5536006ecbe 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -1351,11 +1351,11 @@ implementing a mode in one self-contained definition. @defmac define-minor-mode mode doc [init-value [lighter [keymap]]] keyword-args@dots{} body@dots{} This macro defines a new minor mode whose name is @var{mode} (a symbol). It defines a command named @var{mode} to toggle the minor -mode, with @var{doc} as its documentation string. It also defines a -variable named @var{mode}, which is set to @code{t} or @code{nil} by -enabling or disabling the mode. The variable is initialized to -@var{init-value}. Except in unusual circumstances (see below), this -value must be @code{nil}. +mode, with @var{doc} as its documentation string. By default, it also +defines a variable named @var{mode}, which is set to @code{t} or +@code{nil} by enabling or disabling the mode. The variable is +initialized to @var{init-value}. Except in unusual circumstances (see +below), this value must be @code{nil}. The string @var{lighter} says what to display in the mode line when the mode is enabled; if it is @code{nil}, the mode is not displayed @@ -1410,6 +1410,17 @@ This is equivalent to specifying @var{lighter} positionally. @item :keymap @var{keymap} This is equivalent to specifying @var{keymap} positionally. + +@item :variable @var{place} +This replaces the default variable @var{mode}, used to store the state +of the mode. If you specify this, the @var{mode} variable is not +defined, and any @var{init-value} argument is unused. @var{place} +can be a different named variable (which you must define yourself), or +anything that can be used with the @code{setf} function +(@pxref{Generalized Variables,,, cl, Common Lisp Extensions}). +@var{place} can also be a cons @code{(@var{get} . @var{set})}, +where @var{get} is an expression that returns the current state, +and @var{set} is a function of one argument (a state) that sets it. @end table Any other keyword arguments are passed directly to the diff --git a/etc/NEWS b/etc/NEWS index 3635b560b1f..8a588f397cb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1293,6 +1293,7 @@ on-the-fly spell checking for comments and strings. *** Enabled globalized minor modes can be disabled in specific modes, by running (FOO-mode-hook 0) via a mode hook. ++++ *** `define-minor-mode' accepts a new keyword :variable. +++ -- 2.39.2