From: Lars Ingebrigtsen Date: Sun, 19 Jun 2022 13:47:45 +0000 (+0200) Subject: Make M-S-x output better in mode that have bindings for `undefined' X-Git-Tag: emacs-29.0.90~1447^2~1611 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7bfb35f8a7b364877c5a07297f16bc38d00f1989;p=emacs.git 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). --- 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)))