GNU bug report logs -
#47286
28.0.50; [PATCH] Replace "(default %s)" with 'format-prompt'
Previous Next
Reported by: Gabriel <gabriel376 <at> hotmail.com>
Date: Sat, 20 Mar 2021 22:24:02 UTC
Severity: minor
Tags: fixed, patch
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dgutov <at> yandex.ru> writes:
> Also note that project--completing-read-strict includes as (string-equal default
> "") check added in 2be537e64.
>
> Perhaps format-prompt could use it as well.
Do you mean to add a new check to 'format-prompt' to consider an empty
DEFAULT as nil, e.g., to not show it on minibuffer prompt in case the
value of the DEFAULT argument is an empty string ?
Also, maybe another useful check for 'format-prompt' would remove the
": " suffix from the PROMPT argument, to avoid displaying something like
"prompt: : ", which could avoid regressions when migrating existing
code.
Example of the new 'format-prompt':
(defun format-prompt (prompt default &rest format-args)
"Format PROMPT with DEFAULT according to `minibuffer-default-prompt-format'.
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.
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 or an empty string, no \"default value\" string
is included in the return value."
(let* ((suffix ": ")
(prompt (if (string-suffix-p suffix prompt)
(substring prompt 0 (* -1 (length suffix)))
prompt))
(default (if (equal "" default)
nil
default))
(formatted-prompt (if (null format-args)
prompt
(apply #'format prompt format-args)))
(formatted-default (and default
(format minibuffer-default-prompt-format
(if (consp default)
(car default)
default)))))
(concat formatted-prompt
formatted-default
suffix)))
This bug report was last modified 4 years and 63 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.