From: Stefan Monnier Date: Tue, 13 Apr 2010 01:03:04 +0000 (-0400) Subject: (define-minor-mode): A nil argument to the minor mode turns the mode ON. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~527 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3b7e1d5fe9e2876b870dd49ac459639bad7a7e17;p=emacs.git (define-minor-mode): A nil argument to the minor mode turns the mode ON. --- diff --git a/etc/NEWS b/etc/NEWS index 5932d85dbc0..ba254a30370 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -140,6 +140,8 @@ Secret Service API requires D-Bus for communication. * 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 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 05ecc80f7eb..48a88fd0d0a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-04-13 Stefan Monnier + + * 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 * vc-dir.el (vc-dir-kill-line): New command. diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 13e08667839..2849f4cf154 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -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))