Function: execute-extended-command-for-buffer
execute-extended-command-for-buffer is an interactive and
byte-compiled function defined in simple.el.gz.
Signature
(execute-extended-command-for-buffer PREFIXARG &optional COMMAND-NAME TYPED)
Documentation
Query user for a command relevant for the current mode, and then execute it.
This is like execute-extended-command, but it limits the
completions to commands that are particularly relevant to the
current buffer. This includes commands that have been marked as
being specially designed for the current major mode (and enabled
minor modes), as well as commands bound in the active local key
maps.
Probably introduced at or before Emacs version 28.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun execute-extended-command-for-buffer (prefixarg &optional
command-name typed)
"Query user for a command relevant for the current mode, and then execute it.
This is like `execute-extended-command', but it limits the
completions to commands that are particularly relevant to the
current buffer. This includes commands that have been marked as
being specially designed for the current major mode (and enabled
minor modes), as well as commands bound in the active local key
maps."
(declare (interactive-only command-execute))
(interactive
(let* ((execute-extended-command--last-typed nil)
(keymaps
;; The major mode's keymap and any active minor modes.
(nconc
(and (current-local-map) (list (current-local-map)))
(mapcar
#'cdr
(seq-filter
(lambda (elem)
(symbol-value (car elem)))
minor-mode-map-alist))))
(read-extended-command-predicate
(lambda (symbol buffer)
(or (command-completion-using-modes-p symbol buffer)
(where-is-internal symbol keymaps)))))
(list current-prefix-arg
(read-extended-command)
execute-extended-command--last-typed)))
(with-suppressed-warnings ((interactive-only execute-extended-command))
(execute-extended-command prefixarg command-name typed)))