Function: read-extended-command

read-extended-command is a byte-compiled function defined in simple.el.gz.

Signature

(read-extended-command &optional PROMPT)

Documentation

Read and return name of command to invoke via execute-extended-command.

Use read-extended-command-predicate to determine which commands to include among completion candidates.

This function activates the read-extended-command-mode(var)/read-extended-command-mode(fun) minor mode when reading the command name.

Probably introduced at or before Emacs version 28.1.

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun read-extended-command (&optional prompt)
  "Read and return name of command to invoke via `execute-extended-command'.
Use `read-extended-command-predicate' to determine which commands
to include among completion candidates.

This function activates the `read-extended-command-mode' minor
mode when reading the command name."
  (let ((default-predicate read-extended-command-predicate)
        (read-extended-command-predicate read-extended-command-predicate)
        already-typed ret)
    ;; If we have a prompt (which is the name of the version of the
    ;; command), then set up the predicate from
    ;; `extended-command-versions'.
    (if (not prompt)
        (setq prompt (caar extended-command-versions))
      (setq read-extended-command-predicate
            (funcall (cadr (assoc prompt extended-command-versions)))))
    ;; Normally this will only execute once.
    (while (not (stringp ret))
      (when (consp (setq ret (catch 'cycle
                               (read-extended-command-1 prompt
                                                        already-typed))))
        ;; But if the user hit `M-X', then we `throw'ed out to that
        ;; `catch', and we cycle to the next setting.
        (let ((next (or (cadr (memq (assoc prompt extended-command-versions)
                                    extended-command-versions))
                        ;; Last one; cycle back to the first.
                        (car extended-command-versions))))
          ;; Restore the user's default predicate.
          (setq read-extended-command-predicate default-predicate)
          ;; Then calculate the next.
          (setq prompt (car next)
                read-extended-command-predicate (funcall (cadr next))
                already-typed ret))))
    ret))