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.

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

cperl--format-prompt org-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.

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)
       prompt
     (apply #'format prompt format-args))
   (and default
        (or (not (stringp default))
            (length> default 0))
        (format minibuffer-default-prompt-format
                (if (consp default)
                    (car default)
                  default)))
   ": "))