comparison lisp/emacs-lisp/easy-mmode.el @ 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 1d1d5d9bd884
children c46b2d0614cb
comparison
equal deleted inserted replaced
107842:992ffbd77e15 107843:64cb38b81502
220 ;; Use `toggle' rather than (if ,mode 0 1) so that using 220 ;; Use `toggle' rather than (if ,mode 0 1) so that using
221 ;; repeat-command still does the toggling correctly. 221 ;; repeat-command still does the toggling correctly.
222 (interactive (list (or current-prefix-arg 'toggle))) 222 (interactive (list (or current-prefix-arg 'toggle)))
223 (let ((,last-message (current-message))) 223 (let ((,last-message (current-message)))
224 (setq ,mode 224 (setq ,mode
225 (cond 225 (if (eq arg 'toggle)
226 ((eq arg 'toggle) (not ,mode)) 226 (not ,mode)
227 (arg (> (prefix-numeric-value arg) 0)) 227 ;; A nil argument also means ON now.
228 (t 228 (> (prefix-numeric-value arg) 0)))
229 (if (null ,mode) t
230 (message
231 "Toggling %s off; better pass an explicit argument."
232 ',mode)
233 nil))))
234 ,@body 229 ,@body
235 ;; The on/off hooks are here for backward compatibility only. 230 ;; The on/off hooks are here for backward compatibility only.
236 (run-hooks ',hook (if ,mode ',hook-on ',hook-off)) 231 (run-hooks ',hook (if ,mode ',hook-on ',hook-off))
237 (if (called-interactively-p 'any) 232 (if (called-interactively-p 'any)
238 (progn 233 (progn