From 45c0bbb9215eacf9627478a0d60bfb3b716bf657 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 8 Sep 2020 23:10:50 +0200 Subject: [PATCH] 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. --- doc/lispref/minibuf.texi | 2 ++ lisp/minibuffer.el | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index cca06c70a51..d30114f768b 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -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 diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 6deb1eb0778..62a33f3e2dd 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -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) -- 2.39.5