Variable: read-extended-command-predicate
read-extended-command-predicate is a customizable variable defined in
simple.el.gz.
Value
transient-command-completion-not-suffix-only-p
Documentation
Predicate to use to determine which commands to include when completing.
If it's nil, include all the commands.
If it's a function, it will be called with two parameters: the
symbol of the command and the current buffer. The predicate should
return non-nil if the command should be considered as a completion
candidate for \M-x in that buffer.
Several predicate functions suitable for various optional behaviors are available:
command-completion-default-include-p
This excludes from completion candidates those commands
which have been marked specific to modes other than the
current buffer's mode. Commands that are not specific
to any mode are included. If a command has a
(declare completion... form which specifies a predicate,
that predicate will be called to determine whether to
include the command in the completion candidates.
command-completion-using-modes-p
This includes in completion candidates only commands
marked as specific to the current buffer's mode.
command-completion-using-modes-and-keymaps-p
This includes commands marked as specific to the current
buffer's modes and commands that have keybindings in the
current buffer's active local keymaps. It also includes
several commands, like Customize commands, which should
always be available.
This variable was added, or its default value changed, in Emacs 28.1.
Probably introduced at or before Emacs version 28.1.
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defcustom read-extended-command-predicate nil
"Predicate to use to determine which commands to include when completing.
If it's nil, include all the commands.
If it's a function, it will be called with two parameters: the
symbol of the command and the current buffer. The predicate should
return non-nil if the command should be considered as a completion
candidate for \\`M-x' in that buffer.
Several predicate functions suitable for various optional behaviors
are available:
`command-completion-default-include-p'
This excludes from completion candidates those commands
which have been marked specific to modes other than the
current buffer's mode. Commands that are not specific
to any mode are included. If a command has a
`(declare completion...' form which specifies a predicate,
that predicate will be called to determine whether to
include the command in the completion candidates.
`command-completion-using-modes-p'
This includes in completion candidates only commands
marked as specific to the current buffer's mode.
`command-completion-using-modes-and-keymaps-p'
This includes commands marked as specific to the current
buffer's modes and commands that have keybindings in the
current buffer's active local keymaps. It also includes
several commands, like Customize commands, which should
always be available."
:version "28.1"
:group 'completion
:type '(choice (const :tag "Don't exclude any commands" nil)
(const :tag "Exclude commands irrelevant to current buffer's mode"
command-completion-default-include-p)
(const :tag "Include only commands relevant to current buffer's mode"
command-completion-using-modes-p)
(const :tag "Commands relevant to current buffer's mode or bound in its keymaps"
command-completion-using-modes-and-keymaps-p)
(function :tag "Other predicate function")))