From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: Unexpected behavior of format-number with format-prompt Date: Sat, 09 Nov 2024 22:51:24 +0100 Message-ID: <87fro0t6sj.fsf@gmx.net> References: <875xp0b00l.fsf@breatheoutbreathe.in> <86h68jqyut.fsf@gnu.org> <87jzdfp2zg.fsf@gmx.net> <86ses3p0c3.fsf@gnu.org> <87fro3ox37.fsf@gmx.net> <87v7ww6xi5.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8084"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Joseph Turner Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 09 22:52:09 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 1t9tNI-0001wl-Pb for ged-emacs-devel@m.gmane-mx.org; Sat, 09 Nov 2024 22:52:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9tMq-0004Ix-Gm; Sat, 09 Nov 2024 16:51:40 -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 1t9tMo-0004Im-Ry for emacs-devel@gnu.org; Sat, 09 Nov 2024 16:51:38 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9tMm-0005T5-U3; Sat, 09 Nov 2024 16:51:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1731189086; x=1731793886; i=stephen.berman@gmx.net; bh=oTecxS5E14Ls9yPp0MG+hlf5Rz2mrzheAhOk6yQ99po=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=GQZeCLrPaMT1bJqWwHsDD19YyXIiwmW76GQLEMadvQ5KYN/eWxwjaw9vIfWdueYB D4tLjFfn1BAoy+U/Rv6hHAIpl71vWv7vO4nqCMEkljJCldhO8SCIvKH4de8d+cRgq ikIMvhFDKXM7MHkCB/d8KsfuYeUNX/49HHsQK1DIvxL9zUJryk4Hjkc0ms3BgzyAS qpyr18wirqcvk9cUjzyrf+h1DCES3qJu78fcgPy0GXm8s6QpXZIMxG7CiITzq4vxH n77iZRM+RjvOF1cz5BeHZ5dPFPx3iipjgnMn/yZgkjrdYd9DSFa1E9yN0yfs4FKJZ 5JVdsVOxz6yiCZb6dQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([88.130.48.32]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mqs4Z-1teIIu3oKf-00dUBR; Sat, 09 Nov 2024 22:51:26 +0100 In-Reply-To: <87v7ww6xi5.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Sat, 09 Nov 2024 11:02:58 -0800") X-Provags-ID: V03:K1:TCTy7BoXW9echJ4C9Qa8KcAiCDxoOliFxsj9drqjgxWF4IT+iHD 86HM3nKRmxntFNvP/4rwUY8Y9dBzoejeU3JExh/MQFm3lj4rWkWgj+VM3muzorP1DzaZbL9 1NhHTNctlGhpALgWTUkKzNqVOyI3PxbIx8jI8G0fCDz44oKnF3uOafnyjwjr78xjnU05t52 3s4AaHGVOCO5T0EYii3mw== UI-OutboundReport: notjunk:1;M01:P0:W4iXFyaO7VY=;hX7D7FkdVIHGC0P9XgLJVbXVB0w v3leGE9do/GCNTbOi4nADKBHBuC9TLz7RfHBmo4pyKDwcfL1bpSyvnpSm4qv1RjroB4mMJo/p RhEeCGwfyAdaUpu3IEIy2msvBKuQg0wvH3z1+jUPisUKPoc/QOyzcxQW4xOxi2+utPJ1js8g3 QCfhRvsPmNG/mHbyZftTDVXQtdxZR06pKEaJOMe7q1ygTezh8QxwsnGVJCjWuW4jnQammJ/uL QiijPtEa+b46JNfcDir5JUCp+5c5dPpz7upJZG4RRlxkVH69hzuNjmeyJYvbkTUeMJs6xgaqm Q6H4UxuG9efyFUhbGRT3faSMj1mNkr682jqhw4i9uVXxTIMnLn8Jo7scIPbeDZkEmZNfmCeNV Yfk0BOVETfbmSWtr1MPHwAda+NsBxaPmwOeb65owJ7e1Opc36ChY+8QJQQVakPYkKNxleKdZU 4cdPUgiaeYPhny19VUPHJhF69rNRdhGmlRyLRqT0K6ONQ94NZNvd42QyxieR+Gy1muEDIEyxt uBA4oenl/5YwfwXM8jsce2zogRBwA1/CxpOMomjSWluqSeABBnmnHq3d8DM/ChtkxZ0oR9zFg iaB1crHIuF4JLp0PVFRN3akt1Sq0WTdD9v6n7fRATi57t0AF5Qexiu+tCrzyqJbXDC5iTBlD0 SDgtMsAJZ9q1VT05C+SBjKZWwmyvIUFpG7aXT6edlnOMIhtmjLh89Kq+D6iNYhjWKwjm3w/DG W2IAqo+nQUn0IFViWAQotlpBZP/bEZWobjxB4I7ul2j1MVjFPVGKk8nN3CESIsu4hYqGAi/j Received-SPF: pass client-ip=212.227.15.15; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:325352 Archived-At: On Sat, 09 Nov 2024 11:02:58 -0800 Joseph Turner wrote: > 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): In all uses of format-prompt I checked in the Emacs sources, the same value is passed to the DEFAULT argument of both format-prompt and its caller (e.g. read-string). Do you have a realistic use case (i.e. discounting willfully misleading or mischievous programming) in mind where this is not so? I couldn't find or come up with one, but maybe I missed it or didn't think hard enough. > [ Also /s/string-match/string-match-p ] I just followed the current code in `read-number', which already uses `string-match'. Perhaps that should be changed regardless of my patch? > I think we're better off documenting the idiosyncrasy in the > `read-number' docstring as Eli suggested. That's certainly the path of least risk, though I can't think of a plausible use where my patch would result in duplication in the prompt string. Steve Berman