emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected behavior of format-number with format-prompt


From: Stephen Berman
Subject: Re: Unexpected behavior of format-number with format-prompt
Date: Thu, 07 Nov 2024 14:50:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

On Thu, 07 Nov 2024 09:36:42 +0200 Eli Zaretskii <eliz@gnu.org> wrote:

>> From: Joseph Turner <joseph@breatheoutbreathe.in>
>> Date: Wed, 06 Nov 2024 12:06:02 -0800
>>
>> When used with `read-string' (and other read-* functions),
>> `format-prompt' DTRT:
>>
>> (let ((default "foo"))
>>   (read-string (format-prompt "Read" default) default))
>>
>> The prompt looks like: "Read (default foo): "
>>
>> However, `read-number' adds its own default argument:
>>
>> (let ((default 1))
>>   (read-number (format-prompt "Read" default) default))
>>
>> Prompt looks like: "Read (default 1) (default 1): "
>>
>> This patch makes the behavior of `read-number' consistent with other
>> read-* functions:
>
> Thanks.
>
> First, this should have been sent to our issue tracker, via
> report-emacs-bug or submit-emacs-patch.
>
> 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.

Maybe something like the attached patch is acceptable?  With it,
evaluating each of the following prompts with "Enter (default 42): "

(read-number "Enter: " 42)
(read-number (format-prompt "Enter" 42))
(read-number (format-prompt "Enter" 42) 42)

Steve Berman

Attachment: txtD0e50k5Q8X.txt
Description: read-number patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]