summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2002-08-15 01:06:05 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2002-08-15 01:06:05 +0000
commit5ddfa187e9b9a4287f7396feb951fbb03c823597 (patch)
tree80ff2beb3f727e27f38256ec0b0103ab672aa8a4 /lisp/emacs-lisp
parent1a4914f3407207b69a7ec96cec337fdc5125f3cf (diff)
downloademacs-5ddfa187e9b9a4287f7396feb951fbb03c823597.tar.gz
emacs-5ddfa187e9b9a4287f7396feb951fbb03c823597.tar.bz2
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/emacs-lisp')
-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.
(let* ((mode-name (symbol-name mode))
(pretty-name (easy-mmode-pretty-mode-name mode lighter))
(globalp nil)
- (togglep t) ;; This should never be nil -- rms.
(group nil)
(extra-args nil)
(keymap-sym (if (and keymap (symbolp keymap)) keymap
@@ -172,16 +171,22 @@ use either \\[customize] or the function `%s'."
,(or doc
(format (concat "Toggle %s on or off.
Interactively, with no prefix argument, toggle the mode.
-With universal prefix ARG " (unless togglep "(or if ARG is nil) ") "turn mode on.
+With universal prefix ARG turn mode on.
With zero or negative ARG turn mode off.
\\{%s}") pretty-name keymap-sym))
- ;; Make no arg by default in an interactive call,
- ;; so that repeating the command toggles again.
- (interactive "P")
+ ;; Use `toggle' rather than (if ,mode 0 1) so that using
+ ;; repeat-command still does the toggling correctly.
+ (interactive (list (or current-prefix-arg 'toggle)))
(setq ,mode
- (if arg
- (> (prefix-numeric-value arg) 0)
- ,(if togglep `(not ,mode) t)))
+ (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))))
,@body
;; The on/off hooks are here for backward compatibility only.
(run-hooks ',hook (if ,mode ',hook-on ',hook-off))
@@ -266,9 +271,9 @@ in which `%s' turns it on."
;; Setup hook to handle future mode changes and new buffers.
(if ,global-mode
(progn
- (add-hook 'find-file-hooks ',buffers)
+ (add-hook 'find-file-hook ',buffers)
(add-hook 'change-major-mode-hook ',cmmh))
- (remove-hook 'find-file-hooks ',buffers)
+ (remove-hook 'find-file-hook ',buffers)
(remove-hook 'change-major-mode-hook ',cmmh))
;; Go through existing buffers.