summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/easy-mmode.el
diff options
context:
space:
mode:
authorStephen Leake <stephen_leake@stephe-leake.org>2019-09-10 03:37:51 -0700
committerStephen Leake <stephen_leake@stephe-leake.org>2019-09-10 03:37:51 -0700
commit3d442312889ef2d14c07282d0aff6199d00cc165 (patch)
tree74034ca2dded6ed233d0701b4cb5c10a0b5e9034 /lisp/emacs-lisp/easy-mmode.el
parentac1a2e260e8ece34500b5879f766b4e54ee57b94 (diff)
parent74e9799bd89484b8d15bdd6597c68fc00d07e7f7 (diff)
downloademacs-3d442312889ef2d14c07282d0aff6199d00cc165.tar.gz
emacs-3d442312889ef2d14c07282d0aff6199d00cc165.tar.bz2
emacs-3d442312889ef2d14c07282d0aff6199d00cc165.zip
Merge commit '74e9799bd89484b8d15bdd6597c68fc00d07e7f7'
Diffstat (limited to 'lisp/emacs-lisp/easy-mmode.el')
-rw-r--r--lisp/emacs-lisp/easy-mmode.el38
1 files changed, 22 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index be531aab849..bbc3a27504c 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -363,18 +363,21 @@ No problems result if this variable is not bound.
;;;###autoload
(defalias 'define-global-minor-mode 'define-globalized-minor-mode)
;;;###autoload
-(defmacro define-globalized-minor-mode (global-mode mode turn-on &rest keys)
+(defmacro define-globalized-minor-mode (global-mode mode turn-on &rest body)
"Make a global mode GLOBAL-MODE corresponding to buffer-local minor MODE.
TURN-ON is a function that will be called with no args in every buffer
and that should try to turn MODE on if applicable for that buffer.
-KEYS is a list of CL-style keyword arguments. As the minor mode
- defined by this function is always global, any :global keyword is
- ignored. Other keywords have the same meaning as in `define-minor-mode',
- which see. In particular, :group specifies the custom group.
- The most useful keywords are those that are passed on to the
- `defcustom'. It normally makes no sense to pass the :lighter
- or :keymap keywords to `define-globalized-minor-mode', since these
- are usually passed to the buffer-local version of the minor mode.
+Each of KEY VALUE is a pair of CL-style keyword arguments. As
+ the minor mode defined by this function is always global, any
+ :global keyword is ignored. Other keywords have the same
+ meaning as in `define-minor-mode', which see. In particular,
+ :group specifies the custom group. The most useful keywords
+ are those that are passed on to the `defcustom'. It normally
+ makes no sense to pass the :lighter or :keymap keywords to
+ `define-globalized-minor-mode', since these are usually passed
+ to the buffer-local version of the minor mode.
+BODY contains code to execute each time the mode is enabled or disabled.
+ It is executed after toggling the mode, and before running GLOBAL-MODE-hook.
If MODE's set-up depends on the major mode in effect when it was
enabled, then disabling and reenabling MODE should make MODE work
@@ -384,7 +387,9 @@ call another major mode in their body.
When a major mode is initialized, MODE is actually turned on just
after running the major mode's hook. However, MODE is not turned
-on if the hook has explicitly disabled it."
+on if the hook has explicitly disabled it.
+
+\(fn GLOBAL-MODE MODE TURN-ON [KEY VALUE]... BODY...)"
(declare (doc-string 2))
(let* ((global-mode-name (symbol-name global-mode))
(mode-name (symbol-name mode))
@@ -404,12 +409,12 @@ on if the hook has explicitly disabled it."
keyw)
;; Check keys.
- (while (keywordp (setq keyw (car keys)))
- (setq keys (cdr keys))
+ (while (keywordp (setq keyw (car body)))
+ (pop body)
(pcase keyw
- (:group (setq group (nconc group (list :group (pop keys)))))
- (:global (setq keys (cdr keys)))
- (_ (push keyw extra-keywords) (push (pop keys) extra-keywords))))
+ (:group (setq group (nconc group (list :group (pop body)))))
+ (:global (pop body))
+ (_ (push keyw extra-keywords) (push (pop body) extra-keywords))))
`(progn
(progn
@@ -446,7 +451,8 @@ See `%s' for more information on %s."
;; Go through existing buffers.
(dolist (buf (buffer-list))
(with-current-buffer buf
- (if ,global-mode (funcall #',turn-on) (when ,mode (,mode -1))))))
+ (if ,global-mode (funcall #',turn-on) (when ,mode (,mode -1)))))
+ ,@body)
;; Autoloading define-globalized-minor-mode autoloads everything
;; up-to-here.