aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-09-08 23:10:50 +0200
committerLars Ingebrigtsen2020-09-08 23:10:50 +0200
commit45c0bbb9215eacf9627478a0d60bfb3b716bf657 (patch)
tree78797d6d0b84cc5e86ffa731ba1ca5933869e6d1
parent9c42f1f7f0a34dcfaee92c10964a61ee49770ac3 (diff)
downloademacs-45c0bbb9215eacf9627478a0d60bfb3b716bf657.tar.gz
emacs-45c0bbb9215eacf9627478a0d60bfb3b716bf657.zip
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.
-rw-r--r--doc/lispref/minibuf.texi2
-rw-r--r--lisp/minibuffer.el8
2 files changed, 9 insertions, 1 deletions
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.
440 440
441If @var{default} is @code{nil}, there is no default value, and 441If @var{default} is @code{nil}, there is no default value, and
442therefore no ``default value'' string is included in the result value. 442therefore no ``default value'' string is included in the result value.
443If @var{default} is a non-@code{nil} list, the first element of the
444list is used in the prompt.
443@end defun 445@end defun
444 446
445@node Object from Minibuffer 447@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
3859string, and FORMAT-ARGS are the arguments to be substituted into 3859string, and FORMAT-ARGS are the arguments to be substituted into
3860it. See `format' for details. 3860it. See `format' for details.
3861 3861
3862If DEFAULT is a list, the first element is used as the default.
3863If not, the element is used as is.
3864
3862If DEFAULT is nil, no \"default value\" string is included in the 3865If DEFAULT is nil, no \"default value\" string is included in the
3863return value." 3866return value."
3864 (concat 3867 (concat
@@ -3866,7 +3869,10 @@ return value."
3866 prompt 3869 prompt
3867 (apply #'format prompt format-args)) 3870 (apply #'format prompt format-args))
3868 (and default 3871 (and default
3869 (format minibuffer-default-prompt-format default)) 3872 (format minibuffer-default-prompt-format
3873 (if (consp default)
3874 (car default)
3875 default)))
3870 ": ")) 3876 ": "))
3871 3877
3872(provide 'minibuffer) 3878(provide 'minibuffer)