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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47286 in the body.
You can then email your comments to 47286 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Sat, 20 Mar 2021 22:24:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Gabriel <gabriel376 <at> hotmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 20 Mar 2021 22:24:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
This patches replaces several occurences of the hardcoded minibuffer
default prompt "(default %s)" with a call to 'format-prompt'. It also
removes the suffix ": ", when applicable, that is automatically handled
by 'format-prompt'.
[0001-Replace-minibuffer-default-prompt-default-s-with-for.patch (text/x-diff, attachment)]
[Message part 3 (text/plain, inline)]
Thread on emacs-devel:
https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00817.html
Let me know if something is missing, wrong or can be improved in this
patch.
Regards,
Gabriel
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Sun, 21 Mar 2021 06:08:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 47286 <at> debbugs.gnu.org (full text, mbox):
> From: Gabriel <gabriel376 <at> hotmail.com>
> Date: Sat, 20 Mar 2021 19:22:52 -0300
>
> This patches replaces several occurences of the hardcoded minibuffer
> default prompt "(default %s)" with a call to 'format-prompt'. It also
> removes the suffix ": ", when applicable, that is automatically handled
> by 'format-prompt'.
Thanks. A minor nit about formatting the commit log messages in such
cases, where the same change is made in many places.
> * lisp/cmuscheme.el (scheme-load-file, scheme-compile-file): Remove
> prompt suffix ": ".
>
> * lisp/comint.el (comint-get-source): Use 'format-prompt'.
>
> * lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
> (viper-query-replace): Remove prompt suffix ": ".
> (viper-read-string-with-history): Use 'format-prompt'.
>
> * lisp/eshell/esh-mode.el (eshell-find-tag): Remove prompt suffix ": ".
>
> * lisp/gnus/gnus-sum.el (gnus-articles-to-read)
> (gnus-summary-search-article-forward)
> (gnus-summary-search-article-backward): Use 'format-prompt'.
Instead of having a long series of basically identical text, it is
better to format this as follows:
* lisp/cmuscheme.el (scheme-load-file, scheme-compile-file):
* lisp/comint.el (comint-get-source):
* lisp/emulation/viper-cmd.el (viper-quote-region, viper-kill-buffer)
(viper-query-replace, viper-read-string-with-history):
* lisp/eshell/esh-mode.el (eshell-find-tag):
* lisp/gnus/gnus-sum.el (gnus-articles-to-read)
(gnus-summary-search-article-forward)
(gnus-summary-search-article-backward):
* lisp/international/mule-cmds.el (set-input-method, toggle-input-method)
(describe-input-method, set-language-environment)
(describe-language-environment):
* lisp/mh-e/mh-gnus.el (mh-mml-minibuffer-read-disposition)
(mh-insert-letter)
* lisp/mh-e/mh-mime.el (mh-display-with-external-viewer)
(mh-mime-save-parts, mh-mh-forward-message)
(mh-mml-query-cryptographic-method): Remove prompt suffix and
use 'format-prompt'.
That is, have the list of files and functions, and put the description
of the change only in the last one. IME, this makes the long list
easier to read and understand.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Sun, 21 Mar 2021 15:54:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 47286 <at> debbugs.gnu.org (full text, mbox):
Gabriel <gabriel376 <at> hotmail.com> writes:
> * lisp/progmodes/project.el (project--completing-read-strict)
> (project--completing-read-strict): Use 'format-prompt'.
Mmm, project.el is released on ELPA as a :core package; IIUC it strives
for backward-compatibility as far back as Emacs 26.1
(cf. Package-Requires field at the top of the file), so maybe it's a bit
early to use format-prompt there?
Apologies if I'm misunderstanding something.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Sun, 21 Mar 2021 18:24:01 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>
> That is, have the list of files and functions, and put the description
> of the change only in the last one. IME, this makes the long list
> easier to read and understand.
Hi Eli, thank you for your suggestion, looks much better! I will make
sure my next patches follow this format, if applicable.
Patch with commit message updated:
[0001-Replace-default-s-with-format-prompt.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Sun, 21 Mar 2021 18:32:02 GMT)
Full text and
rfc822 format available.
Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:
>
> Mmm, project.el is released on ELPA as a :core package; IIUC it strives
> for backward-compatibility as far back as Emacs 26.1
> (cf. Package-Requires field at the top of the file), so maybe it's a bit
> early to use format-prompt there?
>
> Apologies if I'm misunderstanding something.
Hi Kevin,
Thanks for pointing it out. I just searched for the current source tree
of master branch for ocurrences of "(default %s)", so I am not sure if I
changed some package that shouldn't be update. If so, I will promptly
update the patch.
Perhaps project.el could use a similar fallback that exists on
cperl-mode.el (commit 3a95f4fc12df0a570ad413e099a22bf901b7346d):
;; Available in Emacs 28: format-prompt
(defalias 'cperl--format-prompt
(if (fboundp 'format-prompt) 'format-prompt
(lambda (msg default)
(if default (format "%s (default %s): " msg default)
(concat msg ": ")))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Sun, 21 Mar 2021 18:58:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 47286 <at> debbugs.gnu.org (full text, mbox):
On 21.03.2021 20:31, Gabriel wrote:
> Thanks for pointing it out. I just searched for the current source tree
> of master branch for ocurrences of "(default %s)", so I am not sure if I
> changed some package that shouldn't be update. If so, I will promptly
> update the patch.
>
> Perhaps project.el could use a similar fallback that exists on
> cperl-mode.el (commit 3a95f4fc12df0a570ad413e099a22bf901b7346d):
>
> ;; Available in Emacs 28: format-prompt
> (defalias 'cperl--format-prompt
> (if (fboundp 'format-prompt) 'format-prompt
> (lambda (msg default)
> (if default (format "%s (default %s): " msg default)
> (concat msg ": ")))))
Sounds reasonable to me.
Also note that project--completing-read-strict includes as (string-equal
default "") check added in 2be537e64.
Perhaps format-prompt could use it as well.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Mon, 22 Mar 2021 00:04:02 GMT)
Full text and
rfc822 format available.
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)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Mon, 22 Mar 2021 00:50:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 47286 <at> debbugs.gnu.org (full text, mbox):
On 22.03.2021 02:03, Gabriel wrote:
> 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 ?
Yup.
> 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.
My (weak) preference would be on "no": whether the prompt is showing an
extra ":" should be apparent from very brief testing of the code. It's
not like it will show up only if DEFAULT is non-nil, for instance.
So no need to complicate the implementation.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Mon, 22 Mar 2021 19:07:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 47286 <at> debbugs.gnu.org (full text, mbox):
Gabriel <gabriel376 <at> hotmail.com> writes:
> Thanks for pointing it out. I just searched for the current source tree
> of master branch for ocurrences of "(default %s)", so I am not sure if I
> changed some package that shouldn't be update. If so, I will promptly
> update the patch.
The files that have a line like
;; Package-Requires: ((emacs "26.1") (xref "1.0.2"))
or similar should be handled with more care, yes -- they have to be
backwards-compatible, and `format-prompt' is new in Emacs 28. So if you
could re-spin the patch without changes to files like that, I'll get it
applied (it looks good otherwise).
There are some packages that are maintained for older Emacs versions,
too, but we unfortunately have no markup to say that explicitly.
Looking over the list, I think this affects only these two files, and
should also be removed from the patch:
lisp/progmodes/cc-styles.el
lisp/progmodes/verilog-mode.el
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Tue, 23 Mar 2021 03:49:02 GMT)
Full text and
rfc822 format available.
Message #32 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>
> The files that have a line like
>
> ;; Package-Requires: ((emacs "26.1") (xref "1.0.2"))
>
> or similar should be handled with more care, yes -- they have to be
> backwards-compatible, and `format-prompt' is new in Emacs 28. So if you
> could re-spin the patch without changes to files like that, I'll get it
> applied (it looks good otherwise).
>
> There are some packages that are maintained for older Emacs versions,
> too, but we unfortunately have no markup to say that explicitly.
> Looking over the list, I think this affects only these two files, and
> should also be removed from the patch:
>
> lisp/progmodes/cc-styles.el
> lisp/progmodes/verilog-mode.el
Hi Lars,
Thanks so much for your review. Here is an updated patch that removes
the mentioned files (project.el, cc-styles.el and verilog-mode.el) and
updates the 'format-prompt' function with the suggestion from Dmitry
Gutov to consider an empty DEFAULT as nil. Let me know if something
could be improved.
[0001-Replace-default-s-with-format-prompt.patch (text/x-diff, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#47286
; Package
emacs
.
(Wed, 24 Mar 2021 09:33:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 47286 <at> debbugs.gnu.org (full text, mbox):
Gabriel <gabriel376 <at> hotmail.com> writes:
> Thanks so much for your review. Here is an updated patch that removes
> the mentioned files (project.el, cc-styles.el and verilog-mode.el) and
> updates the 'format-prompt' function with the suggestion from Dmitry
> Gutov to consider an empty DEFAULT as nil. Let me know if something
> could be improved.
Looks good to me (although that latter change could probably have been a
separate patch for clarity). Pushed now to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 24 Mar 2021 09:33:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 28.1, send any further explanations to
47286 <at> debbugs.gnu.org and Gabriel <gabriel376 <at> hotmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Wed, 24 Mar 2021 09:33:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 21 Apr 2021 11:24:07 GMT)
Full text and
rfc822 format available.
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.