emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master b535c8b 2/2: Add a new variable `global-minor-modes'


From: Lars Ingebrigtsen
Subject: master b535c8b 2/2: Add a new variable `global-minor-modes'
Date: Mon, 15 Feb 2021 07:08:29 -0500 (EST)

branch: master
commit b535c8ba8735409b43ec9b1ce99a966cfa1383b1
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a new variable `global-minor-modes'
    
    * doc/lispref/modes.texi (Minor Modes): Document it.
    * lisp/simple.el (global-minor-modes): New variable.
    (completion-in-mode-p): Use it.
    (completion-with-modes-p): Use it.
    
    * lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Support it.
---
 doc/lispref/modes.texi        |  5 +++++
 etc/NEWS                      |  8 +++++++-
 lisp/emacs-lisp/easy-mmode.el | 13 ++++++++-----
 lisp/simple.el                | 13 ++++++++++---
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 192ffb6..e1299b5 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1466,6 +1466,11 @@ This buffer-local variable lists the currently enabled 
minor modes in
 the current buffer, and is a list of symbols.
 @end defvar
 
+@defvar global-minor-modes
+This variable lists the currently enabled global minor modes, and is a
+list of symbols.
+@end defvar
+
 @defvar minor-mode-list
 The value of this variable is a list of all minor mode commands.
 @end defvar
diff --git a/etc/NEWS b/etc/NEWS
index eeaed3b..7f32f7b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2297,7 +2297,13 @@ that is not compatible with byte code in previous Emacs 
versions.
 +++
 ** New buffer-local variable 'local-minor-modes'.
 This permanently buffer-local variable holds a list of currently
-enabled minor modes in the current buffer (as a list of symbols).
+enabled non-global minor modes in the current buffer (as a list of
+symbols).
+
++++
+** New variable 'global-minor-modes'.
+This variable holds a list of currently enabled global minor modes (as
+a list of symbols).
 
 +++
 ** 'define-minor-mode'  now takes an :interactive argument.
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index c48ec50..4a9e580 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -330,11 +330,14 @@ or call the function `%s'."))))
                    nil)
                   (t
                    t)))
-           (unless ,globalp
-             ;; Keep `local-minor-modes' up to date.
-             (setq local-minor-modes (delq ',modefun local-minor-modes))
-             (when ,getter
-               (push ',modefun local-minor-modes)))
+           ;; Keep minor modes list up to date.
+           ,@(if globalp
+                 `((setq global-minor-modes (delq ',modefun 
global-minor-modes))
+                   (when ,getter
+                     (push ',modefun global-minor-modes)))
+               `((setq local-minor-modes (delq ',modefun local-minor-modes))
+                 (when ,getter
+                   (push ',modefun local-minor-modes))))
            ,@body
            ;; The on/off hooks are here for backward compatibility only.
            (run-hooks ',hook (if ,getter ',hook-on ',hook-off))
diff --git a/lisp/simple.el b/lisp/simple.el
index cb7496d..aafbb3e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -138,6 +138,10 @@ messages are highlighted; this helps to see what messages 
were visited."
   nil
   "Overlay highlighting the current error message in the `next-error' buffer.")
 
+(defvar global-minor-modes nil
+  "A list of the currently enabled global minor modes.
+This is a list of symbols.")
+
 (defcustom next-error-hook nil
   "List of hook functions run by `next-error' after visiting source file."
   :type 'hook
@@ -1985,14 +1989,16 @@ BUFFER, or any of the active minor modes in BUFFER."
             (or (provided-mode-derived-p
                  (buffer-local-value 'major-mode buffer) (car modes))
                 (memq (car modes)
-                      (buffer-local-value 'local-minor-modes buffer)))
+                      (buffer-local-value 'local-minor-modes buffer))
+                (memq (car modes) global-minor-modes))
           ;; Uncommon case: Multiple modes.
           (apply #'provided-mode-derived-p
                  (buffer-local-value 'major-mode buffer)
                  modes)
           (seq-intersection modes
                             (buffer-local-value 'local-minor-modes buffer)
-                            #'eq)))))
+                            #'eq)
+          (seq-intersection modes global-minor-modes #'eq)))))
 
 (defun completion-with-modes-p (modes buffer)
   "Say whether MODES are in action in BUFFER.
@@ -2004,7 +2010,8 @@ or (if one of MODES is a minor mode), if it is switched 
on in BUFFER."
       ;; It's a minor mode.
       (seq-intersection modes
                         (buffer-local-value 'local-minor-modes buffer)
-                        #'eq)))
+                        #'eq)
+      (seq-intersection modes global-minor-modes #'eq)))
 
 (defun completion-button-p (category buffer)
   "Return non-nil if there's a button of CATEGORY at point in BUFFER."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]