emacs-diffs
[Top][All Lists]
Advanced

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

master 02869b6 1/2: Make completion-with-modes-p work with minor modes,


From: Lars Ingebrigtsen
Subject: master 02869b6 1/2: Make completion-with-modes-p work with minor modes, too
Date: Sun, 14 Feb 2021 14:34:20 -0500 (EST)

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

    Make completion-with-modes-p work with minor modes, too
    
    * lisp/simple.el (completion-with-modes-p): Work with minor modes,
    too.
---
 lisp/simple.el | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 015fa9e..02d3b7d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1974,7 +1974,7 @@ This function uses the `read-extended-command-predicate' 
user option."
 (defun completion-in-mode-p (symbol buffer)
   "Say whether SYMBOL should be offered as a completion.
 This is true if the command is applicable to the major mode in
-BUFFER."
+BUFFER, or any of the active minor modes in BUFFER."
   (or (null (command-modes symbol))
       ;; It's derived from a major mode.
       (apply #'provided-mode-derived-p
@@ -1986,9 +1986,16 @@ BUFFER."
                         #'eq)))
 
 (defun completion-with-modes-p (modes buffer)
-  (apply #'provided-mode-derived-p
-         (buffer-local-value 'major-mode buffer)
-         modes))
+  "Say whether MODES are in action in BUFFER.
+This is the case if either the major mode is derived from one of MODES,
+or (if one of MODES is a minor mode), if it is switched on in BUFFER."
+  (or (apply #'provided-mode-derived-p
+             (buffer-local-value 'major-mode buffer)
+             modes)
+      ;; It's a minor mode.
+      (seq-intersection modes
+                        (buffer-local-value 'minor-modes buffer)
+                        #'eq)))
 
 (defun read-extended-command--affixation (command-names)
   (with-selected-window (or (minibuffer-selected-window) (selected-window))



reply via email to

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