diff options
| author | Stefan Monnier | 2002-08-15 01:06:05 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-08-15 01:06:05 +0000 |
| commit | 5ddfa187e9b9a4287f7396feb951fbb03c823597 (patch) | |
| tree | 80ff2beb3f727e27f38256ec0b0103ab672aa8a4 /lisp | |
| parent | 1a4914f3407207b69a7ec96cec337fdc5125f3cf (diff) | |
| download | emacs-5ddfa187e9b9a4287f7396feb951fbb03c823597.tar.gz emacs-5ddfa187e9b9a4287f7396feb951fbb03c823597.zip | |
(easy-mmode-define-global-mode): Use find-file-hook instead of find-file-hooks.
(define-minor-mode): Get rid of this silly `togglep'.
Add an explicit `toggle' argument (used for interactive calls).
Emit a warning when a nil argument turns the mode off.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 25 |
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. |
| 174 | Interactively, with no prefix argument, toggle the mode. | 173 | Interactively, with no prefix argument, toggle the mode. |
| 175 | With universal prefix ARG " (unless togglep "(or if ARG is nil) ") "turn mode on. | 174 | With universal prefix ARG turn mode on. |
| 176 | With zero or negative ARG turn mode off. | 175 | With 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. |