GNU bug report logs - #65736
30.0.50; Extending the use of format-prompt

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Stephen Berman <stephen.berman@HIDDEN>; Keywords: patch; dated Mon, 4 Sep 2023 16:32:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 65736 <at> debbugs.gnu.org:


Received: (at 65736) by debbugs.gnu.org; 25 Feb 2025 23:19:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 25 18:19:39 2025
Received: from localhost ([127.0.0.1]:48975 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tn4DC-0000Wr-IP
	for submit <at> debbugs.gnu.org; Tue, 25 Feb 2025 18:19:39 -0500
Received: from mout.gmx.net ([212.227.15.15]:55929)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <stephen.berman@HIDDEN>)
 id 1tn4D9-0000WZ-IB
 for 65736 <at> debbugs.gnu.org; Tue, 25 Feb 2025 18:19:36 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
 s=s31663417; t=1740525568; x=1741130368; i=stephen.berman@HIDDEN;
 bh=ecCrNVHlgS1dUioIGokc//E6bJw/9mO12PF6DSWVrjI=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date:
 Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc:
 content-transfer-encoding:content-type:date:from:message-id:
 mime-version:reply-to:subject:to;
 b=aw12MdNAMddsXNp/+i/F1GJBDm0pkoR7QA4nWtlUzc0LiajUzdyPtFlZ2CksLL58
 YP7I9vpT8TFHq5p9So72ApdiyeNWkWwXiMCpmVqBcRV8gxPD23/rYFYW+Qlr6KBeB
 yZm1fMjZzstQXdDpUSVKlt+aFSfW9VfwpkMJPlLC65fmS5R1w5tn/Z4TL6sC0OoxK
 naY0Bf1YtrfXi68/7QnWBWvsQKIshDK/MwvzDrLpezbsFnTpbLh2C0I8X3OSe2NJC
 Pk6i03v5BBdzNZM8gkH0u2u2EzFh0Z3t1ZNY9h1Q0Cs3FH/UULvxOC0jUK/vmdcy1
 FQkSuOrDQ2iEcYuvzg==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from strobelfssd ([88.130.50.54]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7Jza-1tfMa42fZE-00A55i; Wed, 26
 Feb 2025 00:19:28 +0100
From: Stephen Berman <stephen.berman@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>
Subject: Re: bug#65736: 30.0.50; Extending the use of format-prompt
In-Reply-To: <CADwFkm=H6yNPjZ+JC1qy89i_Sf=Xk-6C04c+XAsJMZ5_qObjUw@HIDDEN>
References: <87jzt599yc.fsf@HIDDEN>
 <CADwFkm=H6yNPjZ+JC1qy89i_Sf=Xk-6C04c+XAsJMZ5_qObjUw@HIDDEN>
Date: Wed, 26 Feb 2025 00:19:26 +0100
Message-ID: <87jz9dr4sh.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Provags-ID: V03:K1:XQR0x74/F6nbAcJ9tZWdZ6fC1QPYPKnGoW1xcxu2QIdmKAnYGjM
 m25TvtyuJ0vauI0ZCdJux1HTu6qS82JYAgRJCdg/4QbyPexO87AdPZQOoJZU3itQbIiuAJG
 Xwdhf9s6F/l0Nh9MdCXRsQBdP4Lo0kM5Q4Y9z+2XSF/388tf2rWkYpIzsiIdQRx7S+XFbus
 A667QeTrwohwKDL+gKINw==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:HQOD+0fFA5o=;68fYAaD/phjD7AX5O9CfHwNa72p
 gljrEbg0+/6wCkQdsGvwyh+a1Y5hVMdLghCQHRJ967KEqMDRAkdZAEnRZJpsexFB8CzM99W5Z
 etjSLiq4x9vq/+5IeHty7+UFBrXs40sH4PxxoHLcqoFP6CFB0UMoNvw6nP3h5gmbgJAnr33xc
 AsiFyccUGFlOl+Pcm0z8Nfc1GiXLCuPQqzJvEs0Zb2wqhaIkF2SvbQzkkOWNUKeUld3XOUeV5
 Qjwo1z7vrUiU+G7tznxnK8L46E03VTqKkP7aELGwQVHmeYu1JEiHkK5pp3DU24sHl8zAWKmGz
 TSLmGh9a+bA8WLIPkl4WZv1BbDGyEdYjyYQgdC0TbfRja9pN4T996OJZchoKj69ZbeBxDM67u
 IrMy7IAZf19foOVA9UjEzqU0NhxNmzoSJzLYies4hQpDGf2YbSG+Li0xK26ivi5iPKT0MOFZi
 d5tpIiWU8MpPLWtw8ksrEXQ9ZTMS+Zq37IiBJ+J136BjmM3GL6ozamaWzkjFYHPS8nlWwDfOM
 RXRqi/0yr3lc2J43YdT037tNirV5/WhK33fFzUg22e7H9K+NPGCnnAMmrPWQ9ojeAO8aUcb7r
 XHw7qgoGp34tNjlvjE2qw/qOKoNL2nFobx8L1VkM1WDwO+OvKrVkh208NGwPS0ISXefHqRz1K
 KSn++uKsZil8MrnoAPmbI5E4slsGntQzSofXky3rg2z2LR0FqCR+7AjG7MIooxenyVQDqyWB0
 pfat6xZDNt1YqsGjKG7LrsCND3I6/yukKRoiuXiA/N1zYlrH6VKYJ+kkbAqEz6uIbfkEOfJxl
 kPD4kEfhqI4mMEriwzy2uVxM82sUE22U9ZGBAPqG1V+pKcAmWBZdE6hfqobdIfF0pjiB6q/te
 pLIdefjMPCKrJ4daBdtx4BgMPUxdCT3Qd/NwUXnb7pD9atvysOgvHIrwAt18gLlNdIc9OmUei
 FfRIurvvd+bstTvu1CQPKC0QPOI4ndLyFkRMgimPfVQlHR8MTdqrzyHqU9q28narStQ+srhdK
 NrdL2wP1Jg+ssPhA5OgMiItrn2zGSWJqRgogpd46kgeLzrJHq+IeJRPxbhUrFA+v/oceMH9J4
 kbKW3vlr34b+lJ+OOwDv0WtUIUz4mnhjNtaxedInuTVprD+hDmQG7rM1Wqw8qZyfA1f2hS8T4
 cdTpRelfMbdq7zENf2xRMruzylFV58cKtDLpgwgcCPPOWvCn1IVWfIdlWAU8w5AJSvYx1tXk0
 GVUvUT6dwQVBYBlE50lNzddE7Vs/0cczF9+LckPjO3hpVMJNZVkrXewdRW2W7DPYAD+cv5Qx2
 4dWVYwIw4xBud+5IErOVFcjrfsYkpz9qz0qeUsOWg7b+8+8MFZK6xpbAPIlk1BhgO3G5xuLGQ
 uWSIIJzsyDYXzLlBzQDhPZ8ALlIIQUzO/LanTpfULZG760UrbDHtVS61zprt2QRgVSf3kuT+L
 NJm+CAA==
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 65736
Cc: 65736 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

On Sun, 23 Feb 2025 01:26:11 +0000 Stefan Kangas <stefankangas@HIDDEN> w=
rote:

> Stephen Berman <stephen.berman@HIDDEN> writes:
>
>> 0. emacs -Q
>> 1. Invoke read-buffer with a prompt containg grave-style quoting and
>>    with no default buffer argument, e.g.:
>>    M-: (read-buffer "Enter `buffer': ")
>> =3D> This displays the prompt in the minibuffer with grave-style quoting,
>>    i.e. as it appears in the invocation.
>> 2. Repeat step 1 but add a default buffer argument, e.g.:
>>    M-: (read-buffer "Enter `buffer': " "*scratch*")
>> =3D> This displays the prompt in the minibuffer with curve-style quoting:
>>    Enter =E2=80=98buffer=E2=80=99 (default *scratch*):
>>
>> The different appearances of the prompt with and without the presence of
>> a default argument is due to commit 50512e36c7, which passes the prompt
>> string to format-prompt when read-buffer has a non-nil default argument
>> DEF, but not when DEF is nil.  (The purpose of that commit was to
>> replace occurrences of prompts containing the string "(default %s)" by
>> invocations of the then recently introduced function format-prompt; the
>> fact that this function also calls substitute-command-keys was not a
>> concern for that commit and its effect was presumably for that reason
>> overlooked.)
>>
>> I think the simplest fix is to pass PROMPT to format-prompt regardless
>> of the presence of a default argument of read-buffer, as in the first
>> attached patch.
>>
>> But having substitute-command-keys always apply to the prompt string of
>> read-buffer raises the question whether it should apply more generally
>> to prompt strings.  In fact, commit 50512e36c7 did change numerous
>> mostly mode-specific prompts in several Lisp libraries to pass the
>> prompt to format-prompt, but in almost all cases those prompts are fixed
>> strings where applying substitute-command-keys makes no difference.  But
>> with read-buffer the prompt string is provided by the caller, so its
>> appearance could be affected by substitute-command-keys.
>>
>> By default, read-buffer calls (in C) completing-read, which by default
>> calls read-from-minibuffer, and indeed most, if not all, other functions
>> that prompt for minibuffer input end up calling read-from-minibuffer.
>> So passing the prompt string to format-prompt in read-from-minibuffer,
>> as in the second attached patch (which should be applied instead of the
>> first patch), would achieve a higher degree of consistency and
>> simplicity in Emacs in the handling of prompts for minibuffer input, at
>> least by default.  (With functions that accept a user-defined function,
>> like read-buffer-function with read-buffer, it would be up to the user
>> to decide whether or not to use format-prompt, if the function does not
>> invoke read-from-minibuffer.)
>>
>> If this change (the second patch) is accepted, it will probably require
>> adjustments in the Emacs code base, e.g. to avoid double invocations of
>> format-prompt.  This would partly undo the changes made in 50512e36c7.
>> I'd be willing to make the needed adjustments in Emacs.
>
> (Sorry for the long delay in replying here.)
>
> I think what you write here makes sense.  Could you please resend the
> patches as formatted by something like
>
>     git format-patch -1
>
> and with a proper ChangeLog message as per CONTRIBUTE?
>
> I think that would facilitate reviewing the patches, especially the
> second one which seems to be a change in behavior that we would need to
> agree on.

Last November there was a discussion on emacs-devel about read-number
(starting at
https://lists.gnu.org/archive/html/emacs-devel/2024-11/msg00216.html),
which uses read-from-minibuffer but also exceptionally has its own
nonstandard handling of the default value of the prompt string.  In that
thread I proposed a change to read-number that allows it to use
minibuffer-default-prompt-format (which format-prompt uses), but Eli
found that change too ad hoc and preferred to document recommending
against using format-prompt in read-number (and this was done in
emacs-30).  So I think the idea of making read-from-minibuffer use
format-prompt as in the second patch is not viable.  Is there still any
interest in just changing read-buffer as in the first patch?

Steve Berman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65736; Package emacs. Full text available.

Message received at 65736 <at> debbugs.gnu.org:


Received: (at 65736) by debbugs.gnu.org; 23 Feb 2025 01:26:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 22 20:26:20 2025
Received: from localhost ([127.0.0.1]:58162 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tm0lA-0008HM-DG
	for submit <at> debbugs.gnu.org; Sat, 22 Feb 2025 20:26:20 -0500
Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:56429)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1tm0l8-0008H4-3T
 for 65736 <at> debbugs.gnu.org; Sat, 22 Feb 2025 20:26:18 -0500
Received: by mail-ed1-x535.google.com with SMTP id
 4fb4d7f45d1cf-5e02eba02e8so4476930a12.0
 for <65736 <at> debbugs.gnu.org>; Sat, 22 Feb 2025 17:26:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1740273972; x=1740878772; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=+g5gIGkrGUfpE7Lk4qZRdL1J5FZPucdNw+Jqnnt4tJE=;
 b=DRYaKy3d8ZlULLIwF2ULhKgVviQdh1LJC2txOazT8WeWfR4pcMRk8z5BZNc/L+I/Jx
 3UHIn/d8bHgBtl4MbsIezT5hRY8Px6WFgfl4Vs4yzUD20XoJ3JrVCumY2qRuh8KCRRV8
 78KYCB9dyqNazaVVGOm1b0pFYZQ9j5+DgmlmTGJhxJ6UrbYTEWnqguoQewrglty2N9+S
 /GF2q93D20MEFmQm+Pj5nRxFKmytk6kJqCHc2CnzhSIFetktAOzeSTDJGTrz5gKTJIVH
 xT7qfOHqXDd8DZMQpyBQ1NegzpqbYB0CZEkvDVc+Bb51s+kpC6DXkjT0J+J78KFy4e+q
 PZUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1740273972; x=1740878772;
 h=content-transfer-encoding:cc:to:subject:message-id:date
 :mime-version:references:in-reply-to:from:x-gm-message-state:from:to
 :cc:subject:date:message-id:reply-to;
 bh=+g5gIGkrGUfpE7Lk4qZRdL1J5FZPucdNw+Jqnnt4tJE=;
 b=raME6xIKhOX0xuprSQkJ2ucOQ0lq2AAaqR+aYcKMGo7i2KgdiRPmZYQidiKClb5DU0
 bn+R6QlU6TqKhlnCg9rFS51f9UJugnbPFclgXG+QNCGgHfd32nUzk3Ab1dgYpTLwI5Dc
 1oGc5VxfvoLViq1Zqe1DWe+u2G8Mk/yRef5CT4nU6ZM04VyhNUEs5mHfRsEpzYeD9b3F
 LOSYxYHfmL0QqmA5ML50Y1cphbU4MXXI+HPBvdzvSdXAMOX417wVBy/ZRvMDAvmn3smt
 6OQOlQ/QTkbxT3+ode95Yx7sBK+OFtLjl2oj0pOxJofjeYVSJ4f/yxmPdk9/0TtC7nYQ
 pLFg==
X-Gm-Message-State: AOJu0Yzldfhjk9w+mBg1h+aUIct40qiiPi+TeLkbomQoy61NR1wc9Ii9
 Hr9Or2oLFXUvxCzBTinoq8Pz2815hW7XP92qyxlwq5gPKq+SvEQUvSGiuUNW4J0E43k7pR3lBGg
 gTJxJ2Uz6OHbTWR7rSCIvHZb3G0vASwG61zKyfw==
X-Gm-Gg: ASbGncsRwPfYjE5fO3NEPIIjojZQ0IcykbqxKhnLSYBCmw9DeyDv6jEh7rzQV4Ti6zt
 1ifFqUCJN0FVWizosrfJkmFcX4wEx4Sfyg939aGeNS3+eQEZOP/nu5tG33347KhGgETyxKuyufX
 hrfKlA8gDw
X-Google-Smtp-Source: AGHT+IG2wNY41A9FRMP814kWFQyfAy23spOkVmoxhcTZKP6J2pg8BwAj6lHAqHJJudkkSXElxgBZ0FydBomcz7h+w5E=
X-Received: by 2002:a05:6402:3554:b0:5dc:5a34:1296 with SMTP id
 4fb4d7f45d1cf-5e0b70ef77dmr8286461a12.16.1740273971726; Sat, 22 Feb 2025
 17:26:11 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sun, 23 Feb 2025 01:26:11 +0000
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <87jzt599yc.fsf@HIDDEN>
References: <87jzt599yc.fsf@HIDDEN>
MIME-Version: 1.0
Date: Sun, 23 Feb 2025 01:26:11 +0000
X-Gm-Features: AWEUYZkrE6PiTLGucXpDUyZphCpK9YIYMWDufCbBOsh-tGhSj21LrXLMMNCvDzE
Message-ID: <CADwFkm=H6yNPjZ+JC1qy89i_Sf=Xk-6C04c+XAsJMZ5_qObjUw@HIDDEN>
Subject: Re: bug#65736: 30.0.50; Extending the use of format-prompt
To: Stephen Berman <stephen.berman@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 65736
Cc: 65736 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stephen Berman <stephen.berman@HIDDEN> writes:

> 0. emacs -Q
> 1. Invoke read-buffer with a prompt containg grave-style quoting and
>    with no default buffer argument, e.g.:
>    M-: (read-buffer "Enter `buffer': ")
> =3D> This displays the prompt in the minibuffer with grave-style quoting,
>    i.e. as it appears in the invocation.
> 2. Repeat step 1 but add a default buffer argument, e.g.:
>    M-: (read-buffer "Enter `buffer': " "*scratch*")
> =3D> This displays the prompt in the minibuffer with curve-style quoting:
>    Enter =E2=80=98buffer=E2=80=99 (default *scratch*):
>
> The different appearances of the prompt with and without the presence of
> a default argument is due to commit 50512e36c7, which passes the prompt
> string to format-prompt when read-buffer has a non-nil default argument
> DEF, but not when DEF is nil.  (The purpose of that commit was to
> replace occurrences of prompts containing the string "(default %s)" by
> invocations of the then recently introduced function format-prompt; the
> fact that this function also calls substitute-command-keys was not a
> concern for that commit and its effect was presumably for that reason
> overlooked.)
>
> I think the simplest fix is to pass PROMPT to format-prompt regardless
> of the presence of a default argument of read-buffer, as in the first
> attached patch.
>
> But having substitute-command-keys always apply to the prompt string of
> read-buffer raises the question whether it should apply more generally
> to prompt strings.  In fact, commit 50512e36c7 did change numerous
> mostly mode-specific prompts in several Lisp libraries to pass the
> prompt to format-prompt, but in almost all cases those prompts are fixed
> strings where applying substitute-command-keys makes no difference.  But
> with read-buffer the prompt string is provided by the caller, so its
> appearance could be affected by substitute-command-keys.
>
> By default, read-buffer calls (in C) completing-read, which by default
> calls read-from-minibuffer, and indeed most, if not all, other functions
> that prompt for minibuffer input end up calling read-from-minibuffer.
> So passing the prompt string to format-prompt in read-from-minibuffer,
> as in the second attached patch (which should be applied instead of the
> first patch), would achieve a higher degree of consistency and
> simplicity in Emacs in the handling of prompts for minibuffer input, at
> least by default.  (With functions that accept a user-defined function,
> like read-buffer-function with read-buffer, it would be up to the user
> to decide whether or not to use format-prompt, if the function does not
> invoke read-from-minibuffer.)
>
> If this change (the second patch) is accepted, it will probably require
> adjustments in the Emacs code base, e.g. to avoid double invocations of
> format-prompt.  This would partly undo the changes made in 50512e36c7.
> I'd be willing to make the needed adjustments in Emacs.

(Sorry for the long delay in replying here.)

I think what you write here makes sense.  Could you please resend the
patches as formatted by something like

    git format-patch -1

and with a proper ChangeLog message as per CONTRIBUTE?

I think that would facilitate reviewing the patches, especially the
second one which seems to be a change in behavior that we would need to
agree on.

Thanks in advance.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65736; Package emacs. Full text available.
Added tag(s) patch. Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Sep 2023 16:31:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 04 12:31:42 2023
Received: from localhost ([127.0.0.1]:52417 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qdCUH-0007P6-E6
	for submit <at> debbugs.gnu.org; Mon, 04 Sep 2023 12:31:42 -0400
Received: from lists.gnu.org ([2001:470:142::17]:44372)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stephen.berman@HIDDEN>) id 1qdCUB-0007Op-CZ
 for submit <at> debbugs.gnu.org; Mon, 04 Sep 2023 12:31:39 -0400
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 <stephen.berman@HIDDEN>)
 id 1qdCU6-0007pP-0T
 for bug-gnu-emacs@HIDDEN; Mon, 04 Sep 2023 12:31:30 -0400
Received: from mout.gmx.net ([212.227.17.20])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <stephen.berman@HIDDEN>)
 id 1qdCU2-00037Z-Vv
 for bug-gnu-emacs@HIDDEN; Mon, 04 Sep 2023 12:31:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=s31663417; t=1693845084; x=1694449884; i=stephen.berman@HIDDEN;
 bh=RRfq8xAqfOJVDXDL0/eypltsZFtOho9IPmI7VDW/Akw=;
 h=X-UI-Sender-Class:From:To:Subject:Date;
 b=oh9o1Nnu7Sxuenb1jjgNYO8QsO2XFO6ONNJ1+N2zhhQQgH7XOAYSu129WFecZplBwUTPk5D
 88vVjcqKQd6OAUQwXnaUg/1JzvTLsEjT/lAi1cPRXYJrhi+MmFSFiIddY3vUCRGS7x9S//ckf
 WWb+3KaOlgHzYIBmYH/Nd5NfFz5uTFuLZkf8GFMvHVJf7r8f8lR76qFA5Gep0hvdCKUFponMc
 Ixc5mF1ArmviivIxnTjke5F6sgu0aUS4SyRRXf7+ZmBJcp70Tcn7+EDUxJUXTzAw17OweZhuy
 NrVnFOc4Iqtv6tRd2Z6T22rif9FL5rqgIqNV9T5vLWzfoTfLyJAg==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from strobelfssd ([94.134.196.62]) by mail.gmx.net (mrgmx104
 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mn2aN-1ptzmF0SsZ-00k4Ua for
 <bug-gnu-emacs@HIDDEN>; Mon, 04 Sep 2023 18:31:24 +0200
From: Stephen Berman <stephen.berman@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; Extending the use of format-prompt
Date: Mon, 04 Sep 2023 18:31:23 +0200
Message-ID: <87jzt599yc.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Provags-ID: V03:K1:up5I1hfnKR4uF2j1XayZdwvB6JhfyfRgIVuTPRJQniacMmMHyan
 /gz9pFfXlivQzdtXdZz199mETokNw06PARMxsOl6IqYihIhjX0YMmxm/6hL2iPCH1RdXc23
 NtxFSNwxUcWKUIssO21/Uxyy/763VMM91Clx/9m6sqKS0yOe/dFEUuNavtYST3dxjrSDSRM
 eix/mbrxzKugU9i1F9vsg==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:+T76QsfvqQQ=;bu7WDe4JITVI3Sv3S38+96Sz3vm
 dGinps+8VghIS6oDHU3XxTvHXaDmWSBIDsBv6kwsKMQhxEdsd6Pt1d+rabS9XWWPQi30qn9b9
 4S81CcbrswwlmDzRFeWi+vrFkPdsa4nlOzt3qPdEoutQ90UwX16nND3gCi3f+P7a8dNQlmWIr
 VXmI+oHPEQ2I4UvunQFdLZrbjNdjq9zhZldirLXdH4+/GrRrU0h839NHU3HN1wDLB19Oo7/BB
 gWSy2mSmISF1QMC6v7AJ6W4jN3snEprUUb+FbOJT6nxPsmZNOSOWBdPztEx3+eOLjFXM5pnWs
 CeTfd2tXBGjL0c5K8BPWvLSvX1O5Sum0jHn4TNVxgeeM9TMVIN3z5qab0/7ekmBkTJT8tT9o3
 xLAOOfp5ZngriBGDpcAZ2WCUEGku5uubx6FPbema72tmeUZPxexb+fqw2FUS3jIlWIyqEW4QO
 N9gTa9SOo9hh5dY2e+STH41dbVvwXn0AJJu9EQn7XNwFv2aK9BFN3rvgdhCF8lcdOfE07a5QH
 qQ/w3z1nDrD/niYJUBkZSPODZUIBCb5GO7XW6ivns7yRVDnjq1wnK5BcRwsE8/6IUmd5GmKwP
 iJOWFBf2ctZJPFXhFdTswiLlyUmfeJjQH21GDzQBayOhsnKYGF9l7YQuf3+9A32QHePLZgmLL
 CoE1gc2SRK2g/bCrxO08ljYo5GgOtpUCyLxKsZEJjESvrPracA+RZHeX03UXuuefZZ6diStfj
 zwYEnCIg+U5Np7HL+qnTk9QoxmshFafONEbkkEkJPZfsLvQyVsVvXi35HVhm0nn/Ec+3J9CtC
 rScIQmY4HElrVo8oHeyjOVt5i4oz1FzUWfsj+aGzu5fNFiDs3X52cVlWutz23YigkJi6EBEgV
 woweOSlXNKijmY4xGtcinuIhKzVXF7S3P0wa5IFmB51AsdnQplBbbFTTGC/RnTmkVCU0ntZsq
 JtKzYnfZ+OF+qQ1eldyZC8KZn7I=
Received-SPF: pass client-ip=212.227.17.20;
 envelope-from=stephen.berman@HIDDEN; helo=mout.gmx.net
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

0. emacs -Q
1. Invoke read-buffer with a prompt containg grave-style quoting and
   with no default buffer argument, e.g.:
   M-: (read-buffer "Enter `buffer': ")
=3D> This displays the prompt in the minibuffer with grave-style quoting,
   i.e. as it appears in the invocation.
2. Repeat step 1 but add a default buffer argument, e.g.:
   M-: (read-buffer "Enter `buffer': " "*scratch*")
=3D> This displays the prompt in the minibuffer with curve-style quoting:
   Enter =E2=80=98buffer=E2=80=99 (default *scratch*):=20=20

The different appearances of the prompt with and without the presence of
a default argument is due to commit 50512e36c7, which passes the prompt
string to format-prompt when read-buffer has a non-nil default argument
DEF, but not when DEF is nil.  (The purpose of that commit was to
replace occurrences of prompts containing the string "(default %s)" by
invocations of the then recently introduced function format-prompt; the
fact that this function also calls substitute-command-keys was not a
concern for that commit and its effect was presumably for that reason
overlooked.)

I think the simplest fix is to pass PROMPT to format-prompt regardless
of the presence of a default argument of read-buffer, as in the first
attached patch.

But having substitute-command-keys always apply to the prompt string of
read-buffer raises the question whether it should apply more generally
to prompt strings.  In fact, commit 50512e36c7 did change numerous
mostly mode-specific prompts in several Lisp libraries to pass the
prompt to format-prompt, but in almost all cases those prompts are fixed
strings where applying substitute-command-keys makes no difference.  But
with read-buffer the prompt string is provided by the caller, so its
appearance could be affected by substitute-command-keys.

By default, read-buffer calls (in C) completing-read, which by default
calls read-from-minibuffer, and indeed most, if not all, other functions
that prompt for minibuffer input end up calling read-from-minibuffer.
So passing the prompt string to format-prompt in read-from-minibuffer,
as in the second attached patch (which should be applied instead of the
first patch), would achieve a higher degree of consistency and
simplicity in Emacs in the handling of prompts for minibuffer input, at
least by default.  (With functions that accept a user-defined function,
like read-buffer-function with read-buffer, it would be up to the user
to decide whether or not to use format-prompt, if the function does not
invoke read-from-minibuffer.)

If this change (the second patch) is accepted, it will probably require
adjustments in the Emacs code base, e.g. to avoid double invocations of
format-prompt.  This would partly undo the changes made in 50512e36c7.
I'd be willing to make the needed adjustments in Emacs.

Steve Berman


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment
Content-Description: read-buffer patch
Content-Transfer-Encoding: quoted-printable

diff --git a/src/minibuf.c b/src/minibuf.c
index 58adde1bf66..a1cbf4747f5 100644
=2D-- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1502,34 +1502,30 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, =
1, 4, 0,
   specbind (Qcompletion_ignore_case,
 	    read_buffer_completion_ignore_case ? Qt : Qnil);

-  if (NILP (Vread_buffer_function))
-    {
-      if (!NILP (def))
-	{
-	  /* A default value was provided: we must change PROMPT,
-	     editing the default value in before the colon.  To achieve
-	     this, we replace PROMPT with a substring that doesn't
-	     contain the terminal space and colon (if present).  They
-	     are then added back using Fformat.  */
+  /* For backward compatibility we accept prompt strings ending with a
+     colon and a space, but we have to delete them, if present, before
+     passing PROMPT to `format-prompt', which automatically appends
+     these characters to PROMPT.  */

-	  if (STRINGP (prompt))
-	    {
-	      s =3D SSDATA (prompt);
-	      len =3D SBYTES (prompt);
-	      if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ')
-		len =3D len - 2;
-	      else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D=
 ' '))
-		len--;
-
-	      prompt =3D make_specified_string (s, -1, len,
-					      STRING_MULTIBYTE (prompt));
-	    }
+  if (STRINGP (prompt))
+    {
+      s =3D SSDATA (prompt);
+      len =3D SBYTES (prompt);
+      if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ')
+	len =3D len - 2;
+      else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D =
' '))
+	len--;
+
+      prompt =3D make_specified_string (s, -1, len,
+				      STRING_MULTIBYTE (prompt));
+    }

-	  prompt =3D CALLN (Ffuncall, intern("format-prompt"),
-			  prompt,
-			  CONSP (def) ? XCAR (def) : def);
-	}
+  prompt =3D CALLN (Ffuncall, intern("format-prompt"),
+		  prompt,
+		  CONSP (def) ? XCAR (def) : def);

+  if (NILP (Vread_buffer_function))
+    {
       result =3D Fcompleting_read (prompt, intern ("internal-complete-buf=
fer"),
 				 predicate, require_match, Qnil,
 				 Qbuffer_name_history, def, Qnil);

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment
Content-Description: read-from-minibuffer patch
Content-Transfer-Encoding: quoted-printable

diff --git a/src/minibuf.c b/src/minibuf.c
index 58adde1bf66..4318cab04cb 100644
=2D-- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1343,10 +1343,34 @@ DEFUN ("read-from-minibuffer", Fread_from_minibuff=
er,
   (Lisp_Object prompt, Lisp_Object initial_contents, Lisp_Object keymap, =
Lisp_Object read, Lisp_Object hist, Lisp_Object default_value, Lisp_Object=
 inherit_input_method)
 {
   Lisp_Object histvar, histpos, val;
+  char *s;
+  ptrdiff_t len;

   barf_if_interaction_inhibited ();

   CHECK_STRING (prompt);
+
+  /* For backward compatibility we accept prompt strings ending with a
+     colon and a space, but we have to delete them, if present, before
+     passing PROMPT to `format-prompt', which automatically appends
+     these characters to PROMPT.  */
+
+  if (STRINGP (prompt))
+    {
+      s =3D SSDATA (prompt);
+      len =3D SBYTES (prompt);
+      if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ')
+	len =3D len - 2;
+      else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D =
' '))
+	len--;
+
+      prompt =3D make_specified_string (s, -1, len,
+				      STRING_MULTIBYTE (prompt));
+    }
+
+  prompt =3D CALLN (Ffuncall, intern("format-prompt"), prompt,
+		  CONSP (default_value) ? XCAR (default_value) : default_value);
+
   if (NILP (keymap))
     keymap =3D Vminibuffer_local_map;
   else
@@ -1473,8 +1497,7 @@ DEFUN ("read-variable", Fread_variable, Sread_variab=
le, 1, 2, 0,

 DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 4, 0,
        doc: /* Read the name of a buffer and return it as a string.
-Prompt with PROMPT, which should be a string ending with a colon and a sp=
ace.
-Provides completion on buffer names the user types.
+Prompt with string PROMPT.  Provides completion on buffer names the user =
types.
 Optional second arg DEF is value to return if user enters an empty line,
  instead of that empty string.
  If DEF is a list of default values, return its first element.
@@ -1492,8 +1515,6 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1,=
 4, 0,
    Lisp_Object predicate)
 {
   Lisp_Object result;
-  char *s;
-  ptrdiff_t len;
   specpdl_ref count =3D SPECPDL_INDEX ();

   if (BUFFERP (def))
@@ -1503,37 +1524,9 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1=
, 4, 0,
 	    read_buffer_completion_ignore_case ? Qt : Qnil);

   if (NILP (Vread_buffer_function))
-    {
-      if (!NILP (def))
-	{
-	  /* A default value was provided: we must change PROMPT,
-	     editing the default value in before the colon.  To achieve
-	     this, we replace PROMPT with a substring that doesn't
-	     contain the terminal space and colon (if present).  They
-	     are then added back using Fformat.  */
-
-	  if (STRINGP (prompt))
-	    {
-	      s =3D SSDATA (prompt);
-	      len =3D SBYTES (prompt);
-	      if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ')
-		len =3D len - 2;
-	      else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D=
 ' '))
-		len--;
-
-	      prompt =3D make_specified_string (s, -1, len,
-					      STRING_MULTIBYTE (prompt));
-	    }
-
-	  prompt =3D CALLN (Ffuncall, intern("format-prompt"),
-			  prompt,
-			  CONSP (def) ? XCAR (def) : def);
-	}
-
-      result =3D Fcompleting_read (prompt, intern ("internal-complete-buf=
fer"),
-				 predicate, require_match, Qnil,
-				 Qbuffer_name_history, def, Qnil);
-    }
+    result =3D Fcompleting_read (prompt, intern ("internal-complete-buffe=
r"),
+			       predicate, require_match, Qnil,
+			       Qbuffer_name_history, def, Qnil);
   else
     result =3D (NILP (predicate)
 	      /* Partial backward compatibility for older read_buffer_functions
@@ -1978,7 +1971,7 @@ DEFUN ("all-completions", Fall_completions, Sall_com=
pletions, 2, 4, 0,
 =0C
 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
        doc: /* Read a string in the minibuffer, with completion.
-PROMPT is a string to prompt with; normally it ends in a colon and a spac=
e.
+PROMPT is a string to prompt with.
 COLLECTION can be a list of strings, an alist, an obarray or a hash table=
.
 COLLECTION can also be a function to do the completion itself.
 PREDICATE limits completion to a subset of COLLECTION.

--=-=-=--




Acknowledgement sent to Stephen Berman <stephen.berman@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#65736; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 25 Feb 2025 23:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.