From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner Newsgroups: gmane.emacs.devel Subject: Re: Unexpected behavior of format-number with format-prompt Date: Sat, 09 Nov 2024 11:02:58 -0800 Message-ID: <87v7ww6xi5.fsf@breatheoutbreathe.in> References: <875xp0b00l.fsf@breatheoutbreathe.in> <86h68jqyut.fsf@gnu.org> <87jzdfp2zg.fsf@gmx.net> <86ses3p0c3.fsf@gnu.org> <87fro3ox37.fsf@gmx.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8680"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Stephen Berman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 09 20:10:32 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t9qqu-00025E-6I for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Nov 2024 20:10:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9qqH-0001ch-4X; Sat, 09 Nov 2024 14:09:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9qjn-000880-Vf for emacs-devel@gnu.org; Sat, 09 Nov 2024 14:03:12 -0500 Original-Received: from out-179.mta0.migadu.com ([91.218.175.179]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9qjl-0006IT-Ou for emacs-devel@gnu.org; Sat, 09 Nov 2024 14:03:11 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1731178985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hjqSqa0UwGFS4GfUmM32Y2w/+nsKKPkZZE+mW79+aiU=; b=mjb0EWvsByz/kWNeX40Si5wm56u2R5u9Gk8WgG4SucT7fCYF9gnmi6mBlPuC3b5hK0Ehl1 O2hkRD+1ltOU6ON48l84H9c0puURosE5IR/cGx3Or7YHnlJzx0iEWHQjF9CKpA7e9LYAD3 +n9UjbPzfeKLxt7BesjTydwlibdZ6Ws= In-Reply-To: <87fro3ox37.fsf@gmx.net> (Stephen Berman's message of "Thu, 07 Nov 2024 16:57:48 +0100") X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.179; envelope-from=joseph@breatheoutbreathe.in; helo=out-179.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 09 Nov 2024 14:09:50 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325347 Archived-At: Stephen Berman writes: > On Thu, 07 Nov 2024 16:47:40 +0200 Eli Zaretskii wrote: > >>> From: Stephen Berman >>> Cc: Joseph Turner , emacs-devel@gnu.org >>> Date: Thu, 07 Nov 2024 14:50:27 +0100 >>> >>> > 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) >> >> This assumes that using the same format as >> minibuffer-default-prompt-format necessarily means that format-prompt >> is being used. I'm not sure we can rely on that, it's too ad-hoc. > > The patch itself does not assume format-prompt but only checks whether > the prompt uses minibuffer-default-prompt-format (which format-prompt > does); the following also prompt with "Enter (default 42): ": > > (read-number (concat "Enter" > (format minibuffer-default-prompt-format 42) > ": ")) > > (read-number (concat "Enter:" > (format minibuffer-default-prompt-format 42) > ": ") > 42) > > So the reference to format-prompt in the comment I added is misleading > and should be either removed or revised, e.g.: "If PROMPT uses > `minibuffer-default-prompt-format' (as e.g. with `format-prompt'), don't > duplicate DEFAULT in the prompt string." I like your idea, but the DEFAULT argument passed to `format-prompt' may be different from the DEFAULT argument passed to `read-number', so the regex may not match. For example, (read-number (format-prompt "Read number" "three") 3) would still prompt with Read number (default three) (default 3): [ Also /s/string-match/string-match-p ] I think we're better off documenting the idiosyncrasy in the `read-number' docstring as Eli suggested. Thanks! Joseph