[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unexpected behavior of format-number with format-prompt
From: |
Joseph Turner |
Subject: |
Re: Unexpected behavior of format-number with format-prompt |
Date: |
Sat, 09 Nov 2024 11:18:50 -0800 |
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Wed, 06 Nov 2024 23:44:00 -0800
>> From: Joseph Turner <joseph@breatheoutbreathe.in>
>> CC: emacs-devel@gnu.org
>>
>> >First, this should have been sent to our issue tracker, via
>> >report-emacs-bug or submit-emacs-patch.
>>
>> Got it. Shall I do this now?
>
> Too late. Please remember this for the future.
>
>> >More to the point: we cannot possibly change the behavior of
>> >read-number in such a backward-incompatible way. Especially since
>> >this behavior is old, and explicitly called out in the doc string. It
>> >is perhaps unfortunate that read-number behaves differently in this
>> >manner, but I'm afraid we will have to live with this.
>>
>> That makes sense. Can we apply the info manual change?
>
> I think this change should be in the doc string of read-number, not in
> the manual. One reason is that read-number is not documented in the
> manual, while the description of this nit logically belongs to it, not
> to format-prompt.
I agree. How about this?
>From 29dbfe3436ca93afd195c0e10b2c22d58b22e52c Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Sat, 9 Nov 2024 11:15:25 -0800
Subject: [PATCH] * lisp/subr.el (read-number): Document collision with
format-prompt
---
lisp/subr.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index b56512aac05..6472c9d6916 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3424,9 +3424,10 @@ read-number-history
(defun read-number (prompt &optional default hist)
"Read a numeric value in the minibuffer, prompting with PROMPT.
DEFAULT specifies a default value to return if the user just types RET.
-The value of DEFAULT is inserted into PROMPT.
-HIST specifies a history list variable. See `read-from-minibuffer'
-for details of the HIST argument.
+For historical reasons, the value of DEFAULT is always inserted into
+PROMPT, so it's recommended to use `format' instead of `format-prompt'
+to generate PROMPT. HIST specifies a history list variable. See
+`read-from-minibuffer' for details of the HIST argument.
This function is used by the `interactive' code letter \"n\"."
(let ((n nil)
--
2.46.0
> (Btw, the same effect could be achieved if
> minibuffer-default-prompt-format is bound to the empty string, right?)
format-prompt also uses minibuffer-default-prompt-format internally, so
minibuffer-default-prompt-format would need to be to nil for the
read-number call but not the format-prompt call.
I suppose you could do this, but IMO the meaning is not all that clear:
(let ((default-prompt (format-prompt "Read number" "three"))
(minibuffer-default-prompt-format ""))
(read-number default-prompt 3))
Thanks!
Joseph
- Unexpected behavior of format-number with format-prompt, Joseph Turner, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt, Eli Zaretskii, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt, Joseph Turner, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt, Eli Zaretskii, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt,
Joseph Turner <=
- Re: Unexpected behavior of format-number with format-prompt, Eli Zaretskii, 2024/11/14
- Re: Unexpected behavior of format-number with format-prompt, Joseph Turner, 2024/11/15
- Re: Unexpected behavior of format-number with format-prompt, Eli Zaretskii, 2024/11/15
- Re: Unexpected behavior of format-number with format-prompt, Joseph Turner, 2024/11/16
Re: Unexpected behavior of format-number with format-prompt, Stephen Berman, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt, Eli Zaretskii, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt, Stephen Berman, 2024/11/07
- Re: Unexpected behavior of format-number with format-prompt, Joseph Turner, 2024/11/09
- Re: Unexpected behavior of format-number with format-prompt, Stephen Berman, 2024/11/09
- Re: Unexpected behavior of format-number with format-prompt, Joseph Turner, 2024/11/10