Function: format-prompt
format-prompt is a byte-compiled function defined in minibuffer.el.gz.
Signature
(format-prompt PROMPT DEFAULT &rest FORMAT-ARGS)
Documentation
Format PROMPT with DEFAULT according to minibuffer-default-prompt-format.
If FORMAT-ARGS is nil, PROMPT is used as a plain string. If
FORMAT-ARGS is non-nil, PROMPT is used as a format control
string, and FORMAT-ARGS are the arguments to be substituted into
it. See format for details.
Both PROMPT and minibuffer-default-prompt-format are run
through substitute-command-keys (which see). In particular,
this means that single quotes may be displayed by equivalent
characters, according to the capabilities of the terminal.
If DEFAULT is a list, the first element is used as the default. If not, the element is used as is.
If DEFAULT is nil or an empty string, no "default value" string is included in the return value.
Probably introduced at or before Emacs version 28.1.
Aliases
org-format-prompt
cperl--format-prompt
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun format-prompt (prompt default &rest format-args)
"Format PROMPT with DEFAULT according to `minibuffer-default-prompt-format'.
If FORMAT-ARGS is nil, PROMPT is used as a plain string. If
FORMAT-ARGS is non-nil, PROMPT is used as a format control
string, and FORMAT-ARGS are the arguments to be substituted into
it. See `format' for details.
Both PROMPT and `minibuffer-default-prompt-format' are run
through `substitute-command-keys' (which see). In particular,
this means that single quotes may be displayed by equivalent
characters, according to the capabilities of the terminal.
If DEFAULT is a list, the first element is used as the default.
If not, the element is used as is.
If DEFAULT is nil or an empty string, no \"default value\" string
is included in the return value."
(concat
(if (null format-args)
(substitute-command-keys prompt)
(apply #'format (substitute-command-keys prompt) format-args))
(and default
(or (not (stringp default))
(length> default 0))
(format (substitute-command-keys minibuffer-default-prompt-format)
(if (consp default)
(car default)
default)))
": "))