(let ((predicate (or predicate read-extended-command-predicate))
(default (and (commandp (symbol-at-point))
(format "%S" (symbol-at-point)))))
- ;; Read a string, completing from and restricting to the set of
- ;; all defined commands. Save the command read on the
- ;; extended-command history list.
- (completing-read
- (format-prompt
- (concat (cond
- ((eq current-prefix-arg '-) "- ")
- ((and (consp current-prefix-arg)
- (eq (car current-prefix-arg) 4))
- "C-u ")
- ((and (consp current-prefix-arg)
- (integerp (car current-prefix-arg)))
- (format "%d " (car current-prefix-arg)))
- ((integerp current-prefix-arg)
- (format "%d " current-prefix-arg)))
- ;; This isn't strictly correct if `execute-extended-command'
- ;; is bound to anything else (e.g. [menu]).
- ;; It could use (key-description (this-single-command-keys)),
- ;; but actually a prompt other than "M-x" would be confusing,
- ;; because "M-x" is a well-known prompt to read a command
- ;; and it serves as a shorthand for "Extended command: ".
- (or prompt "M-x"))
- default)
- (completion-table-with-metadata
- obarray
- `((category . command)
- ;; TODO: Add a `narrow-completions-function' using
- ;; `command-completion--command-for-this-buffer-function', and
- ;; also for filtering out obsolete commands.
- ,@(when completions-detailed
- '((affixation-function . read-extended-command--affixation)))))
- (lambda (sym)
- (and (commandp sym)
- (or (null predicate)
- (condition-case-unless-debug err
- (funcall predicate sym minibuffer--original-buffer)
- (error (message "read-extended-command-predicate: %s: %s"
- sym (error-message-string err)))))))
- t nil 'extended-command-history default)))
+ (minibuffer-with-setup-hook
+ (lambda ()
+ (setq-local minibuffer-alternative-action
+ (cons #'describe-function "describe")))
+ ;; Read a string, completing from and restricting to the set of
+ ;; all defined commands. Save the command read on the
+ ;; extended-command history list.
+ (completing-read
+ (format-prompt
+ (concat (cond
+ ((eq current-prefix-arg '-) "- ")
+ ((and (consp current-prefix-arg)
+ (eq (car current-prefix-arg) 4))
+ "C-u ")
+ ((and (consp current-prefix-arg)
+ (integerp (car current-prefix-arg)))
+ (format "%d " (car current-prefix-arg)))
+ ((integerp current-prefix-arg)
+ (format "%d " current-prefix-arg)))
+ ;; This isn't strictly correct if `execute-extended-command'
+ ;; is bound to anything else (e.g. [menu]).
+ ;; It could use (key-description (this-single-command-keys)),
+ ;; but actually a prompt other than "M-x" would be confusing,
+ ;; because "M-x" is a well-known prompt to read a command
+ ;; and it serves as a shorthand for "Extended command: ".
+ (or prompt "M-x"))
+ default)
+ (completion-table-with-metadata
+ obarray
+ `((category . command)
+ ;; TODO: Add a `narrow-completions-function' using
+ ;; `command-completion--command-for-this-buffer-function', and
+ ;; also for filtering out obsolete commands.
+ ,@(when completions-detailed
+ '((affixation-function . read-extended-command--affixation)))))
+ (lambda (sym)
+ (and (commandp sym)
+ (or (null predicate)
+ (condition-case-unless-debug err
+ (funcall predicate sym minibuffer--original-buffer)
+ (error (message "read-extended-command-predicate: %s: %s"
+ sym (error-message-string err)))))))
+ t nil 'extended-command-history default))))
(defun command-completion-using-modes-p (symbol buffer)
"Say whether SYMBOL has been marked as a mode-specific command in BUFFER."