Allow DEFAULT in format-prompt to be a list

* doc/lispref/minibuf.texi (Text from Minibuffer): Document it.

* lisp/minibuffer.el (format-prompt): Allow DEFAULT to be a list
(and use the first element).  This is how many of the prompting
functions interpret their default parameters.
This commit is contained in:
Lars Ingebrigtsen 2020-09-08 23:10:50 +02:00
parent 9c42f1f7f0
commit 45c0bbb921
2 changed files with 9 additions and 1 deletions

View file

@ -440,6 +440,8 @@ case no default values are displayed.
If @var{default} is @code{nil}, there is no default value, and
therefore no ``default value'' string is included in the result value.
If @var{default} is a non-@code{nil} list, the first element of the
list is used in the prompt.
@end defun
@node Object from Minibuffer

View file

@ -3859,6 +3859,9 @@ 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, no \"default value\" string is included in the
return value."
(concat
@ -3866,7 +3869,10 @@ return value."
prompt
(apply #'format prompt format-args))
(and default
(format minibuffer-default-prompt-format default))
(format minibuffer-default-prompt-format
(if (consp default)
(car default)
default)))
": "))
(provide 'minibuffer)