From 7bfb35f8a7b364877c5a07297f16bc38d00f1989 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 19 Jun 2022 15:47:45 +0200 Subject: [PATCH] Make M-S-x output better in mode that have bindings for `undefined' * lisp/simple.el (command-completion-using-modes-p): Speed up case when there's no command modes. (execute-extended-command-for-buffer): Make M-S-x output better (bug#46665). --- lisp/simple.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 99c951b24b8..f2b3d82a7a5 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2299,7 +2299,7 @@ This function uses the `read-extended-command-predicate' user option." (defun command-completion-using-modes-p (symbol buffer) "Say whether SYMBOL has been marked as a mode-specific command in BUFFER." ;; Check the modes. - (let ((modes (command-modes symbol))) + (when-let ((modes (command-modes symbol))) ;; Common fast case: Just a single mode. (if (null (cdr modes)) (or (provided-mode-derived-p @@ -2539,7 +2539,16 @@ maps." (read-extended-command-predicate (lambda (symbol buffer) (or (command-completion-using-modes-p symbol buffer) - (where-is-internal symbol keymaps))))) + ;; Include commands that are bound in a keymap in the + ;; current buffer. + (and (where-is-internal symbol keymaps) + ;; But not if they have a command predicate that + ;; says that they shouldn't. (This is the case + ;; for `ignore' and `undefined' and similar + ;; commands commonly found in keymaps.) + (or (null (get symbol 'completion-predicate)) + (funcall (get symbol 'completion-predicate) + symbol buffer))))))) (list current-prefix-arg (read-extended-command) execute-extended-command--last-typed))) -- 2.39.2