comparison lisp/emacs-lisp/easy-mmode.el @ 42236:a31cdf6c9173

(define-minor-mode): Make no arg by default in an interactive call, so that repeating the command toggles again.
author Richard M. Stallman <rms@gnu.org>
date Fri, 21 Dec 2001 14:09:00 +0000
parents 7047bd7df7fb
children 1576fb3105fe
comparison
equal deleted inserted replaced
42235:103ed59cfd30 42236:a31cdf6c9173
105 ((keywordp keymap) (push keymap body) (setq keymap nil))) 105 ((keywordp keymap) (push keymap body) (setq keymap nil)))
106 106
107 (let* ((mode-name (symbol-name mode)) 107 (let* ((mode-name (symbol-name mode))
108 (pretty-name (easy-mmode-pretty-mode-name mode lighter)) 108 (pretty-name (easy-mmode-pretty-mode-name mode lighter))
109 (globalp nil) 109 (globalp nil)
110 (togglep t) ;why would you ever want to toggle? 110 (togglep t) ;; This should never be nil -- rms.
111 (group nil) 111 (group nil)
112 (extra-args nil) 112 (extra-args nil)
113 (keymap-sym (if (and keymap (symbolp keymap)) keymap 113 (keymap-sym (if (and keymap (symbolp keymap)) keymap
114 (intern (concat mode-name "-map")))) 114 (intern (concat mode-name "-map"))))
115 (hook (intern (concat mode-name "-hook"))) 115 (hook (intern (concat mode-name "-hook")))
173 (format (concat "Toggle %s on or off. 173 (format (concat "Toggle %s on or off.
174 Interactively, with no prefix argument, toggle the mode. 174 Interactively, with no prefix argument, toggle the mode.
175 With universal prefix ARG " (unless togglep "(or if ARG is nil) ") "turn mode on. 175 With universal prefix ARG " (unless togglep "(or if ARG is nil) ") "turn mode on.
176 With zero or negative ARG turn mode off. 176 With zero or negative ARG turn mode off.
177 \\{%s}") pretty-name keymap-sym)) 177 \\{%s}") pretty-name keymap-sym))
178 (interactive (list (or current-prefix-arg (if ,mode 0 1)))) 178 ;; Make no arg by default in an interactive call,
179 ;; so that repeating the command toggles again.
180 (interactive)
179 (setq ,mode 181 (setq ,mode
180 (if arg 182 (if arg
181 (> (prefix-numeric-value arg) 0) 183 (> (prefix-numeric-value arg) 0)
182 ,(if togglep `(not ,mode) t))) 184 ,(if togglep `(not ,mode) t)))
183 ,@body 185 ,@body