aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/easy-mmode.el25
1 files changed, 15 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index b1149c7d848..50b0f76c338 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -107,7 +107,6 @@ BODY contains code that will be executed each time the mode is (dis)activated.
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) ;; This should never be nil -- rms.
111 (group nil) 110 (group nil)
112 (extra-args nil) 111 (extra-args nil)
113 (keymap-sym (if (and keymap (symbolp keymap)) keymap 112 (keymap-sym (if (and keymap (symbolp keymap)) keymap
@@ -172,16 +171,22 @@ use either \\[customize] or the function `%s'."
172 ,(or doc 171 ,(or doc
173 (format (concat "Toggle %s on or off. 172 (format (concat "Toggle %s on or off.
174Interactively, with no prefix argument, toggle the mode. 173Interactively, with no prefix argument, toggle the mode.
175With universal prefix ARG " (unless togglep "(or if ARG is nil) ") "turn mode on. 174With universal prefix ARG turn mode on.
176With zero or negative ARG turn mode off. 175With zero or negative ARG turn mode off.
177\\{%s}") pretty-name keymap-sym)) 176\\{%s}") pretty-name keymap-sym))
178 ;; Make no arg by default in an interactive call, 177 ;; Use `toggle' rather than (if ,mode 0 1) so that using
179 ;; so that repeating the command toggles again. 178 ;; repeat-command still does the toggling correctly.
180 (interactive "P") 179 (interactive (list (or current-prefix-arg 'toggle)))
181 (setq ,mode 180 (setq ,mode
182 (if arg 181 (cond
183 (> (prefix-numeric-value arg) 0) 182 ((eq arg 'toggle) (not ,mode))
184 ,(if togglep `(not ,mode) t))) 183 (arg (> (prefix-numeric-value arg) 0))
184 (t
185 (if (null ,mode) t
186 (message
187 "Toggling %s off; better pass an explicit argument."
188 ',mode)
189 nil))))
185 ,@body 190 ,@body
186 ;; The on/off hooks are here for backward compatibility only. 191 ;; The on/off hooks are here for backward compatibility only.
187 (run-hooks ',hook (if ,mode ',hook-on ',hook-off)) 192 (run-hooks ',hook (if ,mode ',hook-on ',hook-off))
@@ -266,9 +271,9 @@ in which `%s' turns it on."
266 ;; Setup hook to handle future mode changes and new buffers. 271 ;; Setup hook to handle future mode changes and new buffers.
267 (if ,global-mode 272 (if ,global-mode
268 (progn 273 (progn
269 (add-hook 'find-file-hooks ',buffers) 274 (add-hook 'find-file-hook ',buffers)
270 (add-hook 'change-major-mode-hook ',cmmh)) 275 (add-hook 'change-major-mode-hook ',cmmh))
271 (remove-hook 'find-file-hooks ',buffers) 276 (remove-hook 'find-file-hook ',buffers)
272 (remove-hook 'change-major-mode-hook ',cmmh)) 277 (remove-hook 'change-major-mode-hook ',cmmh))
273 278
274 ;; Go through existing buffers. 279 ;; Go through existing buffers.