This commit is contained in:
Stefan Monnier 2023-03-27 17:14:27 -04:00
commit 624416a2ae
7 changed files with 97 additions and 41 deletions

View file

@ -452,15 +452,23 @@ No problems result if this variable is not bound.
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.
Each of KEY VALUE is a pair of CL-style keyword arguments. :predicate
specifies which major modes the globalized minor mode should be switched on
in. 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.
The :predicate argument specifies in which major modes should the
globalized minor mode be switched on. The value should be t (meaning
switch on the minor mode in all major modes), nil (meaning don't
switch on in any major mode), a list of modes (meaning switch on only
in those modes and their descendants), or a list (not MODES...),
meaning switch on in any major mode except MODES. The value can also
mix all of these forms, see the info node `Defining Minor Modes' for
details.
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
@ -512,7 +520,7 @@ on if the hook has explicitly disabled it.
(setq turn-on-function
`(lambda ()
(require 'easy-mmode)
(when (easy-mmode--globalized-predicate-p ,(car predicate))
(when (easy-mmode--globalized-predicate-p ,MODE-predicate)
(funcall ,turn-on-function)))))
(_ (push keyw extra-keywords) (push (pop body) extra-keywords))))