]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow DEFAULT in format-prompt to be a list
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 8 Sep 2020 21:10:50 +0000 (23:10 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 8 Sep 2020 21:10:50 +0000 (23:10 +0200)
* 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
lisp/minibuffer.el

index cca06c70a5149c470124c6e111d1ad77041b72c0..d30114f768b194290766e1cae5cd01c7855ae4ae 100644 (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
index 6deb1eb0778629f1035d5449eea9fd1095d19740..62a33f3e2ddd11bdc4917a6c09c5b19e505b7eaa 100644 (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)