(define-minor-mode): A nil argument to the minor mode turns the mode ON.
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 13 Apr 2010 01:03:04 +0000 (21:03 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Tue, 13 Apr 2010 01:03:04 +0000 (21:03 -0400)
etc/NEWS
lisp/ChangeLog
lisp/emacs-lisp/easy-mmode.el

index 5932d85..ba254a3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -140,6 +140,8 @@ Secret Service API requires D-Bus for communication.
 \f
 * Incompatible Lisp Changes in Emacs 24.1
 
+** Passing a nil argument to a minor mode function now turns the mode
+   ON unconditionally.
 \f
 * Lisp changes in Emacs 24.1
 
index 05ecc80..48a88fd 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-13  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * emacs-lisp/easy-mmode.el (define-minor-mode): Passing a nil argument
+       to the minor mode function now turns the mode ON unconditionally.
+
 2010-04-12  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * vc-dir.el (vc-dir-kill-line): New command.
index 13e0866..2849f4c 100644 (file)
@@ -222,15 +222,10 @@ With zero or negative ARG turn mode off.
         (interactive (list (or current-prefix-arg 'toggle)))
         (let ((,last-message (current-message)))
            (setq ,mode
-                 (cond
-                  ((eq arg 'toggle) (not ,mode))
-                  (arg (> (prefix-numeric-value arg) 0))
-                  (t
-                   (if (null ,mode) t
-                     (message
-                      "Toggling %s off; better pass an explicit argument."
-                      ',mode)
-                     nil))))
+                 (if (eq arg 'toggle)
+                     (not ,mode)
+                   ;; A nil argument also means ON now.
+                   (> (prefix-numeric-value arg) 0)))
            ,@body
            ;; The on/off hooks are here for backward compatibility only.
            (run-hooks ',hook (if ,mode ',hook-on ',hook-off))