From: Lars Ingebrigtsen Date: Sun, 14 Feb 2021 19:24:23 +0000 (+0100) Subject: Make completion-with-modes-p work with minor modes, too X-Git-Tag: emacs-28.0.90~3732 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=02869b6c67d90ba5e75d37e9a83de9c831898fbc;p=emacs.git Make completion-with-modes-p work with minor modes, too * lisp/simple.el (completion-with-modes-p): Work with minor modes, too. --- diff --git a/lisp/simple.el b/lisp/simple.el index 015fa9e4d55..02d3b7df5f6 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))