[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 45c0bbb: Allow DEFAULT in format-prompt to be a list

From: Lars Ingebrigtsen
Subject: master 45c0bbb: Allow DEFAULT in format-prompt to be a list
Date: Tue, 8 Sep 2020 17:11:08 -0400 (EDT)

branch: master
commit 45c0bbb9215eacf9627478a0d60bfb3b716bf657
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 cca06c7..d30114f 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 6deb1eb..62a33f3 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."
@@ -3866,7 +3869,10 @@ return value."
      (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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]