changeset 107843:64cb38b81502

(define-minor-mode): A nil argument to the minor mode turns the mode ON.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 12 Apr 2010 21:03:04 -0400
parents 992ffbd77e15
children 17333bba44b4
files etc/NEWS lisp/ChangeLog lisp/emacs-lisp/easy-mmode.el
diffstat 3 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS	Mon Apr 12 19:49:29 2010 -0400
+++ b/etc/NEWS	Mon Apr 12 21:03:04 2010 -0400
@@ -140,6 +140,8 @@
 
 * Incompatible Lisp Changes in Emacs 24.1
 
+** Passing a nil argument to a minor mode function now turns the mode
+   ON unconditionally.
 
 * Lisp changes in Emacs 24.1
 
--- a/lisp/ChangeLog	Mon Apr 12 19:49:29 2010 -0400
+++ b/lisp/ChangeLog	Mon Apr 12 21:03:04 2010 -0400
@@ -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.
--- a/lisp/emacs-lisp/easy-mmode.el	Mon Apr 12 19:49:29 2010 -0400
+++ b/lisp/emacs-lisp/easy-mmode.el	Mon Apr 12 21:03:04 2010 -0400
@@ -222,15 +222,10 @@
 	 (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))