diff options
| author | Lars Ingebrigtsen | 2020-09-08 23:10:50 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-09-08 23:10:50 +0200 |
| commit | 45c0bbb9215eacf9627478a0d60bfb3b716bf657 (patch) | |
| tree | 78797d6d0b84cc5e86ffa731ba1ca5933869e6d1 | |
| parent | 9c42f1f7f0a34dcfaee92c10964a61ee49770ac3 (diff) | |
| download | emacs-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.texi | 2 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 8 |
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 | ||
| 441 | If @var{default} is @code{nil}, there is no default value, and | 441 | If @var{default} is @code{nil}, there is no default value, and |
| 442 | therefore no ``default value'' string is included in the result value. | 442 | therefore no ``default value'' string is included in the result value. |
| 443 | If @var{default} is a non-@code{nil} list, the first element of the | ||
| 444 | list 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 | |||
| 3859 | string, and FORMAT-ARGS are the arguments to be substituted into | 3859 | string, and FORMAT-ARGS are the arguments to be substituted into |
| 3860 | it. See `format' for details. | 3860 | it. See `format' for details. |
| 3861 | 3861 | ||
| 3862 | If DEFAULT is a list, the first element is used as the default. | ||
| 3863 | If not, the element is used as is. | ||
| 3864 | |||
| 3862 | If DEFAULT is nil, no \"default value\" string is included in the | 3865 | If DEFAULT is nil, no \"default value\" string is included in the |
| 3863 | return value." | 3866 | return 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) |