Make format-prompt interpret a nil default value as "no default"

* doc/lispref/minibuf.texi (Text from Minibuffer): Document it.

* lisp/help-fns.el (describe-function): Adjust the caller.

* lisp/minibuffer.el (format-prompt): Interpret a nil default
value as "no default".
This commit is contained in:
Lars Ingebrigtsen 2020-08-30 15:22:20 +02:00
parent 6ac270dcd3
commit 130bf51c41
3 changed files with 10 additions and 5 deletions

View file

@ -437,6 +437,9 @@ passed to @code{format} (@pxref{Formatting Strings}).
@code{minibuffer-default-prompt-format} can be @samp{""}, in which
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.
@end defun
@node Object from Minibuffer

View file

@ -151,9 +151,7 @@ When called from lisp, FUNCTION may also be a function object."
(let* ((fn (function-called-at-point))
(enable-recursive-minibuffers t)
(val (completing-read
(if fn
(format-prompt "Describe function" fn)
"Describe function: ")
(format-prompt "Describe function" fn)
#'help--symbol-completion-table
(lambda (f) (or (fboundp f) (get f 'function-documentation)))
t nil nil

View file

@ -3863,12 +3863,16 @@ the minibuffer was activated, and execute the forms."
If FORMAT-ARGS is nil, PROMPT is used as a plain string. If
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."
it. See `format' for details.
If DEFAULT is nil, no \"default value\" string is included in the
return value."
(concat
(if (null format-args)
prompt
(apply #'format prompt format-args))
(format minibuffer-default-prompt-format default)
(and default
(format minibuffer-default-prompt-format default))
": "))
(provide 'minibuffer)