]> git.eshelyaron.com Git - emacs.git/commitdiff
Make M-S-x output better in mode that have bindings for `undefined'
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 19 Jun 2022 13:47:45 +0000 (15:47 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 19 Jun 2022 13:47:45 +0000 (15:47 +0200)
* 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

index 99c951b24b8c084c39803557e3f470a3031e2a83..f2b3d82a7a598aa71862efda0dee0eaae98845a5 100644 (file)
@@ -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)))