[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r107163: Doc updates for define-minor
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r107163: Doc updates for define-minor-mode argument behavior |
Date: |
Tue, 07 Feb 2012 00:26:54 -0800 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 107163
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Tue 2012-02-07 00:26:54 -0800
message:
Doc updates for define-minor-mode argument behavior
* doc/lispref/modes.texi (Defining Minor Modes):
Expand on args of defined minor modes.
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode):
Doc fixes for the macro and the mode it defines.
modified:
doc/lispref/ChangeLog
doc/lispref/modes.texi
etc/NEWS
lisp/ChangeLog
lisp/emacs-lisp/easy-mmode.el
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog 2012-02-07 06:34:52 +0000
+++ b/doc/lispref/ChangeLog 2012-02-07 08:26:54 +0000
@@ -1,3 +1,8 @@
+2012-02-07 Glenn Morris <address@hidden>
+
+ * modes.texi (Defining Minor Modes):
+ Expand on args of defined minor modes.
+
2012-02-07 Chong Yidong <address@hidden>
* variables.texi (Creating Buffer-Local): Minor clarification
=== modified file 'doc/lispref/modes.texi'
--- a/doc/lispref/modes.texi 2012-02-06 00:58:38 +0000
+++ b/doc/lispref/modes.texi 2012-02-07 08:26:54 +0000
@@ -1380,11 +1380,21 @@
@defmac define-minor-mode mode doc [init-value [lighter [keymap]]]
address@hidden address@hidden
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. By default, it also
-defines a variable named @var{mode}, which is set to @code{t} or
address@hidden 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.
+
+The toggle command takes one optional (prefix) argument.
+If called interactively with no argument it toggles the mode on or off.
+A positive prefix argument enables the mode, any other prefix argument
+disables it. From Lisp, an argument of @code{toggle} toggles the mode,
+whereas an omitted or @code{nil} argument enables the mode.
+This makes it easy to enable the minor mode in a major mode hook, for example.
+If @var{doc} is nil, the macro supplies a default documentation string
+explaining the above.
+
+By default, it also defines a variable named @var{mode}, which is set to
address@hidden 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
@@ -1478,9 +1488,10 @@
@smallexample
(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.
+Interactively with no argument, this command toggles the mode.
+A positive prefix argument enables the mode, any other prefix
+argument disables it. From Lisp, argument omitted or nil enables
+the mode, `toggle' toggles the state.
When Hungry mode is enabled, the control delete key
gobbles all preceding whitespace except the last.
@@ -1509,13 +1520,7 @@
@smallexample
(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]."
+...rest of documentation as before..."
;; The initial value.
:init-value nil
;; The indicator for the mode line.
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2012-02-07 07:43:54 +0000
+++ b/etc/NEWS 2012-02-07 08:26:54 +0000
@@ -1012,8 +1012,11 @@
view-file has since Emacs 22 (ie, it won't enable View mode if the
major-mode is special).
-** Passing a nil argument to a minor mode function now turns the mode
-ON unconditionally.
+** Passing a nil argument to a minor mode defined by define-minor-mode
+now turns the mode ON unconditionally. This is so that you can write, e.g.
+ (add-hook 'text-mode-hook 'foo-minor-mode)
+to enable foo-minor-mode in Text mode buffers, thus removing the need
+for `turn-on-foo-minor-mode' style functions.
+++
** During startup, Emacs no longer adds entries for `menu-bar-lines'
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-02-07 03:46:18 +0000
+++ b/lisp/ChangeLog 2012-02-07 08:26:54 +0000
@@ -1,5 +1,8 @@
2012-02-07 Glenn Morris <address@hidden>
+ * emacs-lisp/easy-mmode.el (define-minor-mode):
+ Doc fixes for the macro and the mode it defines.
+
* image.el (imagemagick-types-inhibit): Doc fix.
* cus-start.el (imagemagick-render-type): Add it.
=== modified file 'lisp/emacs-lisp/easy-mmode.el'
--- a/lisp/emacs-lisp/easy-mmode.el 2012-02-01 02:17:17 +0000
+++ b/lisp/emacs-lisp/easy-mmode.el 2012-02-07 08:26:54 +0000
@@ -90,6 +90,14 @@
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.
+With a prefix argument, it enables the mode if the argument is
+positive and otherwise disables it. When called from Lisp, it
+enables the mode if the argument is omitted or nil, and toggles
+the mode if the argument is `toggle'. If DOC is nil this
+function adds a basic doc-string stating these facts.
+
Optional INIT-VALUE is the initial value of the mode's variable.
Optional LIGHTER is displayed in the modeline when the mode is on.
Optional KEYMAP is the default keymap bound to the mode keymap.
@@ -242,7 +250,7 @@
(format (concat "Toggle %s on or off.
With a prefix argument ARG, enable %s if ARG is
positive, and disable it otherwise. If called from Lisp, enable
-the mode if ARG is omitted or nil.
+the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'.
\\{%s}") pretty-name pretty-name keymap-sym))
;; Use `toggle' rather than (if ,mode 0 1) so that using
;; repeat-command still does the toggling correctly.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r107163: Doc updates for define-minor-mode argument behavior,
Glenn Morris <=