Fix `M-X TAB' completion for commands marked for multiple modes

* lisp/simple.el (command-completion-using-modes-p): Fix
completion over commands that are defined for multiple modes
(bug#50228).
This commit is contained in:
Lars Ingebrigtsen 2021-08-27 17:27:52 +02:00
parent 61323c6d76
commit 185759e07a

View file

@ -2070,7 +2070,7 @@ This function uses the `read-extended-command-predicate' user option."
"Say whether SYMBOL has been marked as a mode-specific command in BUFFER."
;; Check the modes.
(let ((modes (command-modes symbol)))
;; Common case: Just a single mode.
;; Common fast case: Just a single mode.
(if (null (cdr modes))
(or (provided-mode-derived-p
(buffer-local-value 'major-mode buffer) (car modes))
@ -2078,13 +2078,7 @@ This function uses the `read-extended-command-predicate' user option."
(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)
(seq-intersection modes global-minor-modes #'eq))))
(command-completion-with-modes-p modes buffer))))
(defun command-completion-default-include-p (symbol buffer)
"Say whether SYMBOL should be offered as a completion.