GNU bug report logs - #67836
29.1.90; map-y-or-n-p doesn't terminate when run in a kmacro in batch mode

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; Reported by: Spencer Baugh <sbaugh@HIDDEN>; dated Fri, 15 Dec 2023 15:40:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 17:25:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 12:25:01 2023
Received: from localhost ([127.0.0.1]:55902 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEYPN-00036I-FM
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 12:25:01 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:35602)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rEYPK-00035o-Q4
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 12:24:59 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rEYPE-0005YU-Bz; Sat, 16 Dec 2023 12:24:52 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=+Mu0otrM+NI9tRBmuA3Q2Lf2M56QCer2p22J8pwk7DM=; b=FkERbiRakV1Qrm7Hm+HG
 kAWTGXq7Y9VG3dhOAow9ddoTZkRDVcwAMjWmgUeEGAVPK/u5TWqt2XWf0BpeqSdud4FvLUeLGqy9Q
 Uj9eCVHX7ONFhfkwP7TfzZDi3YXjyu6uUsrA7x/7SU5f40g75f4B9lQALUxpR4pQuXhTTVKLmPmSi
 lDLg7SDNMxIys9zkTCcodgkT+aLuDNgq57YzbkO0BioZy8CAJJsyByORBbF1JWtI3KMevc+rCbGXD
 eZ+SI6dScawsh7PSsPByG4D16L06ptOggthbn4Pfp6Bz9Tx6e87cO0nQNB1t2rlwE9sfJIaBkIqbK
 pCsOBEJiaaJzxQ==;
Date: Sat, 16 Dec 2023 19:24:32 +0200
Message-Id: <83o7eqkqlr.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvfs022jl3.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Sat, 16 Dec 2023 11:55:21 -0500)
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
 <835y0yo9cf.fsf@HIDDEN> <87o7eqthpu.fsf@HIDDEN>
 <834jgimezh.fsf@HIDDEN> <jwvbkaq42yd.fsf-monnier+emacs@HIDDEN>
 <83v88ykuqh.fsf@HIDDEN> <jwvfs022jl3.fsf-monnier+emacs@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <at> debbugs.gnu.org, sbaugh@HIDDEN
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: -3.3 (---)

> From: Stefan Monnier <monnier@HIDDEN>
> Cc: sbaugh@HIDDEN,  sbaugh@HIDDEN,  67836 <at> debbugs.gnu.org
> Date: Sat, 16 Dec 2023 11:55:21 -0500
> 
> >> There's a tension where fixing such problems at low-level can have
> >> longer term benefits (at the cost of backward incompatibilities), so
> >> I think the best is to start by sending a patch that fixes the problem
> >> at the place you judge to be The Right Place™.
> > There's no disagreement on this level, the disagreement is about
> > where's The Right Place™ ;-)
> 
> But before submitting the bug&patch there's no way to know that.

I think there is: look at how general the original issue is, and
compare that with the range of applications in Emacs that the
proposed solution will affect.  That is what I do, and I don't suppose
you are saying that my judgment is arbitrary.

But I'm okay if that judgment is left to me, I just thought that
understanding my considerations well enough could make the process
more efficient.  If not, so be it.

> It's best if we don't try to second guess what the other one will think
> is best.  Instead, we start by stating what we judge to be best, and
> then we can reconcile differences via discussions.

That is true, but having heard the same arguments from me N times, I
presume one can guess what I will say one the N+1st opportunity.

> > You don't think we should be able to "ding" without signaling an
> > error?
> 
> I think we should, but in practice `ding` should almost never be called
> from "normal" ELisp code.

So you think we should be able to do that in theory but not in
practice? ;-)

> >From that point of view, the fact that `ding` itself signals an error
> when used from a keyboard macro is a bit weird.

That's a feature, I believe.




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

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 16:55:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 11:55:36 2023
Received: from localhost ([127.0.0.1]:55871 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEXwu-0005Ox-64
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 11:55:36 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:23274)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rEXwo-0005OU-UQ
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 11:55:34 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 676C9441D7D;
 Sat, 16 Dec 2023 11:55:24 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1702745722;
 bh=w/No46gLxafvgMp+cdjBcMKabzzpB0SsqWysRik+r+o=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=IHZq3hMnPwiw4CVoQAYPE35IBWmmhXudXOvUwWU7Zbj3vHhKtVw1D3w9hC3Pn7SNb
 1BiH4PPU7xHeJRs+y0C2wggaJpueimGAj0vEO4baH37P9JDvlGG+TRwT7pcG+fhi4x
 yawRcFONPA6N7M+HUyaBBKEC81BnYCcNaR2l58sF6ebZSb/xUxAFYnLIB54b22L1y5
 tTSV6E8pcARGdz8cuqXtCsM3MxGb9GSxH9Dq0Vwiwv1pbVJq5f9SA7ftqdvZv/VXDG
 z+G16Z0pFoKE3hWzH1FXVkcIeR4jhBWKCVhI1WDOka5VdliPU8qwiMkBbq1chFZ8lJ
 zpaR8Vja8lmxA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6A6AB441D75;
 Sat, 16 Dec 2023 11:55:22 -0500 (EST)
Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 34F10120E15;
 Sat, 16 Dec 2023 11:55:22 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
In-Reply-To: <83v88ykuqh.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 16 Dec
 2023 17:55:18 +0200")
Message-ID: <jwvfs022jl3.fsf-monnier+emacs@HIDDEN>
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
 <835y0yo9cf.fsf@HIDDEN> <87o7eqthpu.fsf@HIDDEN>
 <834jgimezh.fsf@HIDDEN> <jwvbkaq42yd.fsf-monnier+emacs@HIDDEN>
 <83v88ykuqh.fsf@HIDDEN>
Date: Sat, 16 Dec 2023 11:55:21 -0500
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-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.062 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <at> debbugs.gnu.org, sbaugh@HIDDEN
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: -3.3 (---)

>> Could you two point me to examples of uses of the
>> techniques you propose?  I'm curious to see how they compare.
> I'd start by grepping our test suite for "mock".

Thanks.  I found some uses in `shadowfile-tests.el` as well as one in
`tramp-test47-read-password`.

That got me to

    grep "(symbol-function .\?'read" test/**/*.el

which points to many more uses.

>> There's a tension where fixing such problems at low-level can have
>> longer term benefits (at the cost of backward incompatibilities), so
>> I think the best is to start by sending a patch that fixes the problem
>> at the place you judge to be The Right Place=E2=84=A2.
> There's no disagreement on this level, the disagreement is about
> where's The Right Place=E2=84=A2 ;-)

But before submitting the bug&patch there's no way to know that.
It's best if we don't try to second guess what the other one will think
is best.  Instead, we start by stating what we judge to be best, and
then we can reconcile differences via discussions.

The only really important aspect is to accept that opinions can differ
and that we may not always get what we want (and have the humility to
accept that even when we're convinced we're right, because even in that
case, we may just be missing the point :-)

>> Regarding `ding` in particular.  I don't really know what should be its
>> behavior in general.  I've always been surprised that it (usually)
>> doesn't actually signal an error even though its intention is to signal
>> to the user that there was a problem.
> You don't think we should be able to "ding" without signaling an
> error?

I think we should, but in practice `ding` should almost never be called
from "normal" ELisp code.  Most ELisp code signals an error instead
(which is then caught by the command loop which in turn emits a ding).

From that point of view, the fact that `ding` itself signals an error
when used from a keyboard macro is a bit weird.


        Stefan





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

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 15:56:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 10:56:25 2023
Received: from localhost ([127.0.0.1]:55820 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEX1c-0001UW-S0
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 10:56:25 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:35888)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rEX1a-0001UI-Fi
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 10:56:23 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rEX1S-0007lE-VF; Sat, 16 Dec 2023 10:56:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=nswXLrdl46F73k2/CzcxX6/qG+Eouv9IgNZTMzIU/WI=; b=PwRWCU/wVmQJfj8wNRAf
 XOUonm1j2+F/34zFqdNiVUSoLO25gzdxrnuC+Mf6nKlc5K7zNwWB6LJAHT+1bbXwai7bZ/EvZ17wS
 RU9cX+ml4RzyQbXlzDqXETyYmPg0z7X3ZlIZXP1PKJvzj+XdzApdfbmrUuV5Rlc5Z1KeczaK6KPgc
 NJZpg58NeU5GP1+uTYV2VHb0SnLBNw/JJnCrSmChZiB4Cs96dHoGGTeGz7lU6f8RnyMoef69ctaOI
 HO180US1+G00bzWYMC8pczrEYOqz2JjZhjWFQPHXa+S9BwjioAV8EvPQgkpYmdSEhIqcYgCOJASn+
 jwOegdvb//d5GQ==;
Date: Sat, 16 Dec 2023 17:55:18 +0200
Message-Id: <83v88ykuqh.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvbkaq42yd.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Sat, 16 Dec 2023 10:11:47 -0500)
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
 <835y0yo9cf.fsf@HIDDEN> <87o7eqthpu.fsf@HIDDEN>
 <834jgimezh.fsf@HIDDEN> <jwvbkaq42yd.fsf-monnier+emacs@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <at> debbugs.gnu.org, sbaugh@HIDDEN
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: -3.3 (---)

> From: Stefan Monnier <monnier@HIDDEN>
> Cc: sbaugh@HIDDEN,  sbaugh@HIDDEN,  67836 <at> debbugs.gnu.org
> Date: Sat, 16 Dec 2023 10:11:47 -0500
> 
> > One way is by mocking of functions that read input.  AFAIR we do that
> > in several places in the test suite (which I always run in batch
> > mode).
> 
> Interesting!
> I wrote a few test cases which needed such interaction, and I used
> neither of those approaches: I relied on `unread-command-events`.
> Take a look at
> 
>     grep unread-command-events test/**/*.el

Yes, that is also possible.  But that will not fit Spencer's bill,
AFAIU.

> Could you two point me to examples of uses of the
> techniques you propose?  I'm curious to see how they compare.

I'd start by grepping our test suite for "mock".

> BTW, regarding mocking, it might be a good idea to make sure
> `bitch_at_user` is always called via `Qding` so that its behavior can be
> adjusted via mocking.

No objections.

> There's a tension where fixing such problems at low-level can have
> longer term benefits (at the cost of backward incompatibilities), so
> I think the best is to start by sending a patch that fixes the problem
> at the place you judge to be The Right Place™.

There's no disagreement on this level, the disagreement is about
where's The Right Place™ ;-)

> Regarding `ding` in particular.  I don't really know what should be its
> behavior in general.  I've always been surprised that it (usually)
> doesn't actually signal an error even though its intention is to signal
> to the user that there was a problem.

You don't think we should be able to "ding" without signaling an
error?  Ringing a bell is also a means to attract attention; on modern
GUI desktops, for example, this will produce some visual cue even when
the frame is minimized and otherwise invisible.

> IOW, I guess what I'd expect is that ELisp code basically never calls
> `ding` directly but that it's called from the command-loop when it
> catches an error.  And that suggests that maybe it should be the
> command-loop's responsibility to exit the keyboard macro when it catches
> an error, which in turn suggests that `bitch_at_user` when called from
> a keyboard macro should signal a "real" error rather than a user-error.

Since I disagree that 'ding' should only be a side effect of signaling
an error, I also disagree with your conclusion from that premise.




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

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 15:12:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 10:12:05 2023
Received: from localhost ([127.0.0.1]:55704 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEWKj-0000uO-2J
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 10:12:05 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45378)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rEWKg-0000tl-2j
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 10:12:04 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E2F52441CFB;
 Sat, 16 Dec 2023 10:11:55 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1702739514;
 bh=5DR9jar2V7Zs7j/OV4vYhOfjgKScqJLaGZYcN/D67oY=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=oE3EDR0EoAlLfjYkztnSN3f6ngm9ZpYeGPZc/tCSV86Hi35T9rknsI0WqycRKeqF8
 CntFqLhlTQxXnD6nU54rWbM0USmoqwuzWl3KlwqTOu9PtU53mDpWGwfIEBNwoXVvQa
 SJxSzekJb04zM6sIzYtbUYEOe0hgndD5NLdkvblTj9357GmfQhl0Y9/b+6i4ShoT0s
 IeBKvWkIO9GgR2mXJKUsF9g/yZYNfJH8B94aDHhAsqf8Sws3JxkgX9HxZx0d9t5QgL
 LPu6v7CbIAR5ydeZ61oEyC0qA8AqV5F4qUBJBdyqLPjN8J78ADkteAK/4qTFsbP5J0
 0Qcbkr6hYUZ0w==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4FC14440B31;
 Sat, 16 Dec 2023 10:11:54 -0500 (EST)
Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 220B0120E2C;
 Sat, 16 Dec 2023 10:11:54 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
In-Reply-To: <834jgimezh.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 16 Dec
 2023 15:52:34 +0200")
Message-ID: <jwvbkaq42yd.fsf-monnier+emacs@HIDDEN>
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
 <835y0yo9cf.fsf@HIDDEN> <87o7eqthpu.fsf@HIDDEN>
 <834jgimezh.fsf@HIDDEN>
Date: Sat, 16 Dec 2023 10:11:47 -0500
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-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.146 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <at> debbugs.gnu.org, sbaugh@HIDDEN
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: -3.3 (---)

>> >> I suspect keyboard macros have not been used very much in batch mode
>> >> over the last 32 years.
>> >
>> > I actually question the wisdom of doing so.  It isn't what keyboard
>> > macros are for.
>>=20
>> How else can one test keyboard interaction with Emacs commands,
>> including their interactive specs?  I see no way to do that other than
>> with keyboard macros.  I'd be happy to hear that there's a better way,
>> though.
>
> One way is by mocking of functions that read input.  AFAIR we do that
> in several places in the test suite (which I always run in batch
> mode).

Interesting!
I wrote a few test cases which needed such interaction, and I used
neither of those approaches: I relied on `unread-command-events`.
Take a look at

    grep unread-command-events test/**/*.el

For some examples.  Could you two point me to examples of uses of the
techniques you propose?  I'm curious to see how they compare.

BTW, regarding mocking, it might be a good idea to make sure
`bitch_at_user` is always called via `Qding` so that its behavior can be
adjusted via mocking.

>> Often, a low-level change to Emacs is in fact acceptable.  I have little
>> way of knowing whether any given low-level change is acceptable, other
>> than by sending it in and seeing what others say.  I hope it is OK if I
>> continue to do that.
>
> It is definitely okay, and your work is certainly appreciated.  I'm
> just trying to explain the POV of the Emacs maintainers, in the hope
> that you could look for solutions in places other than low-level code
> which is used all over Emacs, when problems are specific to some
> higher-level API or specific situation.  That would make the review
> and acceptance of the changes more efficient, and will probably
> prevent you from doing extra unnecessary work.

There's a tension where fixing such problems at low-level can have
longer term benefits (at the cost of backward incompatibilities), so
I think the best is to start by sending a patch that fixes the problem
at the place you judge to be The Right Place=E2=84=A2.

Regarding `ding` in particular.  I don't really know what should be its
behavior in general.  I've always been surprised that it (usually)
doesn't actually signal an error even though its intention is to signal
to the user that there was a problem.

As a user, after I see/hear a "ding", I expect that Emacs has not done
any further processing.  Yet that's not what `ding` does.

IOW, I guess what I'd expect is that ELisp code basically never calls
`ding` directly but that it's called from the command-loop when it
catches an error.  And that suggests that maybe it should be the
command-loop's responsibility to exit the keyboard macro when it catches
an error, which in turn suggests that `bitch_at_user` when called from
a keyboard macro should signal a "real" error rather than a user-error.


        Stefan





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

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 13:53:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 08:53:10 2023
Received: from localhost ([127.0.0.1]:54258 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEV6K-0002aS-C5
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 08:53:10 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:46378)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rEV6F-0002Zq-Dg
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 08:53:07 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rEV67-0001mk-9W; Sat, 16 Dec 2023 08:52:55 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=TW3TsftiV/Mz0NQ4Ckon2zd5JohoXLR9hD5TsasW37Q=; b=aBPU11hLe0Ca
 oqO9S5Wn8EgQ9Cu3BCc6ZoFEKX0mhjUN0KmUdUlVyKl4lP9AdCXl19jymrGi4/44HCxhtLpjJqEQn
 cUqIt+xORqg2/QifVRpDZLeoF0r0U5Xq7p8M0rmsLdvq3wfMDmjLOOgmtBrMF9KUnjt4XqvL6Knxr
 mxVlpBGJjPcCdSPMrhlnTzttPqCMZ10mivw+GDodiVKmdaPQzMlMIN5QsccTQ5jfp2tD792sNEAuO
 syh2Ql7VyGKTBSfh/AJqGlJ7Srw+ZD/ZclVuwAPqF7z7gmd9AWS9eTpoadF5JXRvulkjHrK6Muze4
 H4d4JeF/Qb6WS11TzIsEmw==;
Date: Sat, 16 Dec 2023 15:52:34 +0200
Message-Id: <834jgimezh.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: sbaugh@HIDDEN
In-Reply-To: <87o7eqthpu.fsf@HIDDEN> (sbaugh@HIDDEN)
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in a
 kmacro in batch mode
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
 <835y0yo9cf.fsf@HIDDEN> <87o7eqthpu.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <at> debbugs.gnu.org, monnier@HIDDEN
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: -3.3 (---)

> From: sbaugh@HIDDEN
> Date: Sat, 16 Dec 2023 13:13:25 +0000 (UTC)
> Cc: Stefan Monnier <monnier@HIDDEN>, sbaugh@HIDDEN,
> 	67836 <at> debbugs.gnu.org
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> >> 
> >> I suspect keyboard macros have not been used very much in batch mode
> >> over the last 32 years.
> >
> > I actually question the wisdom of doing so.  It isn't what keyboard
> > macros are for.
> 
> How else can one test keyboard interaction with Emacs commands,
> including their interactive specs?  I see no way to do that other than
> with keyboard macros.  I'd be happy to hear that there's a better way,
> though.

One way is by mocking of functions that read input.  AFAIR we do that
in several places in the test suite (which I always run in batch
mode).

> There is definitely at least one bug, since the docstring of ding
> currently erroneously says:
> 
> Also, unless an argument is given,
> terminate any keyboard macro currently executing.
> 
> Making ding match its docstring was one way to fix this bug.  If you
> don't want to do that, could you apply this patch or something like it?

Will look into the documentation issue, once we agree on resolving
this bug that way.

> Often, a low-level change to Emacs is in fact acceptable.  I have little
> way of knowing whether any given low-level change is acceptable, other
> than by sending it in and seeing what others say.  I hope it is OK if I
> continue to do that.

It is definitely okay, and your work is certainly appreciated.  I'm
just trying to explain the POV of the Emacs maintainers, in the hope
that you could look for solutions in places other than low-level code
which is used all over Emacs, when problems are specific to some
higher-level API or specific situation.  That would make the review
and acceptance of the changes more efficient, and will probably
prevent you from doing extra unnecessary work.




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

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 13:13:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 08:13:37 2023
Received: from localhost ([127.0.0.1]:54212 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEUU4-0001wh-HO
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 08:13:37 -0500
Received: from s.wfbtzhsw.outbound-mail.sendgrid.net ([159.183.224.105]:12838)
 by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from
 <bounces+21787432-3ce5-67836=debbugs.gnu.org@HIDDEN>)
 id 1rEUU0-0001wH-WE
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 08:13:35 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com;
 h=from:subject:in-reply-to:references:mime-version:to:cc:content-type:
 content-transfer-encoding:cc:content-type:from:subject:to;
 s=s1; bh=C2XArPQX8IcQrxNHP4Sek5C0juM+Wfy1a/ZVp9hUGYs=;
 b=fEs/BQbhyxQGV6TGiJqfjrUHM6yNnLlICyl39oAVr2/lklxUKSNFX3776OMHdG++2KLM
 SaKtEGIQ6lsgS/n3e86P7RzLYitLfabypGrtdc0OwtLBNUvdNZh5P8a6mj5m2vhTRHfFyP
 E4a+afMJj6chTv/FaiHilBqNNKB40EJ2n/6CJPFWDE0qhUDLtvJuKy229nl56HRaJR8SLb
 C3gfdNZ356M1bOogN8OII2rdkjjrRjbBBMms5tp+/CEnLH483DuCbxD1vKm5G4JYD3tQey
 o9LoFimvznjbndp00eI+0beVQb0krfBNSGYgfJdlpe0p/8u8NU2y+W2yvSyljahQ==
Received: by filterdrecv-656b5b4c75-bxvxc with SMTP id
 filterdrecv-656b5b4c75-bxvxc-1-657DA275-D
 2023-12-16 13:13:25.794439474 +0000 UTC m=+5164416.910093035
Received: from earth.catern.com (unknown) by geopod-ismtpd-38 (SG) with ESMTP
 id WgBOI-LtTOieNadoaOUYfw Sat, 16 Dec 2023 13:13:25.689 +0000 (UTC)
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=74.101.51.129;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=gnu.org 
Received: from localhost (unknown [74.101.51.129])
 by earth.catern.com (Postfix) with ESMTPSA id 0B4BC63D12;
 Sat, 16 Dec 2023 08:11:41 -0500 (EST)
From: sbaugh@HIDDEN
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in a
 kmacro in batch mode
In-Reply-To: <835y0yo9cf.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 16 Dec
 2023 10:11:28 +0200")
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
 <835y0yo9cf.fsf@HIDDEN>
Date: Sat, 16 Dec 2023 13:13:25 +0000 (UTC)
Message-ID: <87o7eqthpu.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbKZOSQAksqExCrpny52H2?=
 =?us-ascii?Q?GoXR7wEQtTg1IhblspRxWX3KPT1UP7LDPedk4p3?=
 =?us-ascii?Q?lvEon3Km6XlacEVzXvudiF1J+J7OBdxfk1OCS7F?=
 =?us-ascii?Q?IsvkDpPpHJzNbiSNGpgmgnh9fNGVqYgjZjmoN1a?=
 =?us-ascii?Q?Ecu8JMHcVtTlaLL1ByuUz+AqAtY8q4bVyYQ=3D=3D?=
To: Eli Zaretskii <eliz@HIDDEN>
X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q==
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Eli Zaretskii <eliz@HIDDEN> writes: >> From: Stefan Monnier
 <monnier@HIDDEN> >> Cc: Spencer Baugh <sbaugh@HIDDEN>,
 67836 <at> debbugs.gnu.org >> Date: Fri, 15 Dec 2023 17:55:43 -0500 >> [...] 
 Content analysis details:   (1.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [159.183.224.105 listed in wl.mailspike.net]
 1.3 RCVD_IN_VALIDITY_RPBL  RBL: Relay in Validity RPBL,
 https://senderscore.org/blocklistlookup/
 [159.183.224.105 listed in bl.score.senderscore.com]
 0.0 UNPARSEABLE_RELAY      Informational: message has unparseable relay
 lines -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <at> debbugs.gnu.org,
 Stefan Monnier <monnier@HIDDEN>
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.3 (/)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Stefan Monnier <monnier@HIDDEN>
>> Cc: Spencer Baugh <sbaugh@HIDDEN>,  67836 <at> debbugs.gnu.org
>> Date: Fri, 15 Dec 2023 17:55:43 -0500
>> 
>> > Thanks, but let's please find a fix that doesn't make the tail wag the
>> > dog.  I don't want to make a change in bitch_at_user, which will
>> > affect every possible use of it in batch mode, something that we have
>> > been doing for eons.
>> 
>> I suspect keyboard macros have not been used very much in batch mode
>> over the last 32 years.
>
> I actually question the wisdom of doing so.  It isn't what keyboard
> macros are for.

How else can one test keyboard interaction with Emacs commands,
including their interactive specs?  I see no way to do that other than
with keyboard macros.  I'd be happy to hear that there's a better way,
though.

I'd like to add tests of interactive specs to the Emacs test suite, so
certainly I want to find a solution which is acceptable to you.

>> >> ding's docstring states that it terminates keyboard macros.  But, due
>> >> to what seems to be an oversight, it does not do that while executing
>> >> in batch mode.
>> > As the code clearly shows, it isn't an oversight.
>> 
>> AFAICT the current logic of code can be traced back to:
>> 
>>     commit 4588ec205730239596486e8ad4d18d541917199a
>>     Author: Jim Blandy <jimb@HIDDEN>
>>     Date:   Wed Jul 3 12:10:07 1991 +0000
>>     
>>         Initial revision
>>     
>>     diff --git a/src/dispnew.c b/src/dispnew.c
>>     --- /dev/null
>>     +++ b/src/dispnew.c
>>     @@ -0,0 +1813,9 @@
>>     +{
>>     +  if (noninteractive)
>>     +    putchar (07);
>>     +  else if (!INTERACTIVE)  /* Stop executing a keyboard macro. */
>>     +    error ("Keyboard macro terminated by a command ringing the bell");
>>     +  else
>>     +    ring_bell ();
>>     +  fflush (stdout);
>>     +}
>> 
>> I'm not sure this code can be said to show clearly that it's not
>> an oversight.
>> I read it to say that the author did not consider the intersection of
>> 
>>     noninteractive
>> and
>>     !INTERACTIVE
>
> Maybe so (we could ask Jim if we wanted, he is still around), but in
> any case I'm not interested in changing how bitch_at_user works
> 30-something years after it was coded, and has worked well since then.
> I'm okay with fixing this particular problem, but not via changes to
> bitch_at_user or any similar low-level functionality used everywhere.
> Such changes are IMO acceptable only if they fix a clear bug, which is
> not the case here.

There is definitely at least one bug, since the docstring of ding
currently erroneously says:

Also, unless an argument is given,
terminate any keyboard macro currently executing.

Making ding match its docstring was one way to fix this bug.  If you
don't want to do that, could you apply this patch or something like it?

--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6111,8 +6111,8 @@ DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
 
 DEFUN ("ding", Fding, Sding, 0, 1, 0,
        doc: /* Beep, or flash the screen.
-Also, unless an argument is given,
-terminate any keyboard macro currently executing.  */)
+Also, unless an argument is given or the symbol `noninteractive' is
+non-nil, terminate any keyboard macro currently executing.  */)
   (Lisp_Object arg)
 {
   if (!NILP (arg))

I will send a separate patch to fix map-y-or-n-p.

> Spencer, I already noted once that many of your patches have this
> problem: you take some problem which happens to you in a very
> specialized use case, and propose to fix that by changes that affect
> all of Emacs.  This isn't going to fly in Emacs in general, since
> Emacs is a very old and stable program, where almost all of the old
> low-level code was tested by decades of usage, and any significant
> changes there run high risk of breaking something.  And yet you keep
> coming up with changes which do precisely that.  Please try to see
> things from the POV of the Emacs maintainers, and look for ways of
> fixing those problems either by much more localized changes, or maybe
> even just in your own code.  TIA.

As I said, there's definitely at least one bug.  I could either:

- make two separate changes, to fix the docstring of ding and separately
  fix map-y-or-n-p's infinite loop

- make one change (to make ding terminate keyboard macros in batch mode)
  which fixes both issues

All else being equal, making one change is better than making two
changes.  But in this case, the one change is a low-level change.

Often, a low-level change to Emacs is in fact acceptable.  I have little
way of knowing whether any given low-level change is acceptable, other
than by sending it in and seeing what others say.  I hope it is OK if I
continue to do that.




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

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


Received: (at 67836) by debbugs.gnu.org; 16 Dec 2023 08:12:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 03:12:04 2023
Received: from localhost ([127.0.0.1]:53924 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEPmF-0000as-56
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 03:12:04 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:58900)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rEPm8-0000aH-86
 for 67836 <at> debbugs.gnu.org; Sat, 16 Dec 2023 03:12:02 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rEPm1-0002iB-6z; Sat, 16 Dec 2023 03:11:49 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=HZv1VnQ19P4PsmXWcGljqWvxuZDwB+AuUgPpc7A5JSE=; b=bbDyDDdoQ4j4
 FGe3mK5P0AEbOgegkk9AxnT40L+y+K0QDtj/wu04HxrCh7l4ML3lUl0ZtLA4ufU4i4toFlJwAOfu+
 QCAUzj1DQ4xUB1FMonUxPCg+9GAB2nooyXPhHCz279xxoUpjkyje80yDJBmYFDOkdHzfeiBw49HYw
 r9rSBsBJ57tVlGf7Qg/3rQuH0KttTvQ7zftlxt/NNdq2+ft9JGV0l2E2joVSSnGtYBOhqWUa/f4Bd
 dsNJQtIb0P4d4bGTPTc0hbvJK18jGLhkiyIY7Jt0luuNZgiPx5yP6+p63fH4OBfloXUtlYrFaHx1b
 UU4mGi8FxRPqDvqasFduqw==;
Date: Sat, 16 Dec 2023 10:11:28 +0200
Message-Id: <835y0yo9cf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Fri, 15 Dec 2023 17:55:43 -0500)
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN> <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: sbaugh@HIDDEN, 67836 <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: -3.3 (---)

> From: Stefan Monnier <monnier@HIDDEN>
> Cc: Spencer Baugh <sbaugh@HIDDEN>,  67836 <at> debbugs.gnu.org
> Date: Fri, 15 Dec 2023 17:55:43 -0500
> 
> > Thanks, but let's please find a fix that doesn't make the tail wag the
> > dog.  I don't want to make a change in bitch_at_user, which will
> > affect every possible use of it in batch mode, something that we have
> > been doing for eons.
> 
> I suspect keyboard macros have not been used very much in batch mode
> over the last 32 years.

I actually question the wisdom of doing so.  It isn't what keyboard
macros are for.

> >> ding's docstring states that it terminates keyboard macros.  But, due
> >> to what seems to be an oversight, it does not do that while executing
> >> in batch mode.
> > As the code clearly shows, it isn't an oversight.
> 
> AFAICT the current logic of code can be traced back to:
> 
>     commit 4588ec205730239596486e8ad4d18d541917199a
>     Author: Jim Blandy <jimb@HIDDEN>
>     Date:   Wed Jul 3 12:10:07 1991 +0000
>     
>         Initial revision
>     
>     diff --git a/src/dispnew.c b/src/dispnew.c
>     --- /dev/null
>     +++ b/src/dispnew.c
>     @@ -0,0 +1813,9 @@
>     +{
>     +  if (noninteractive)
>     +    putchar (07);
>     +  else if (!INTERACTIVE)  /* Stop executing a keyboard macro. */
>     +    error ("Keyboard macro terminated by a command ringing the bell");
>     +  else
>     +    ring_bell ();
>     +  fflush (stdout);
>     +}
> 
> I'm not sure this code can be said to show clearly that it's not
> an oversight.
> I read it to say that the author did not consider the intersection of
> 
>     noninteractive
> and
>     !INTERACTIVE

Maybe so (we could ask Jim if we wanted, he is still around), but in
any case I'm not interested in changing how bitch_at_user works
30-something years after it was coded, and has worked well since then.
I'm okay with fixing this particular problem, but not via changes to
bitch_at_user or any similar low-level functionality used everywhere.
Such changes are IMO acceptable only if they fix a clear bug, which is
not the case here.

Spencer, I already noted once that many of your patches have this
problem: you take some problem which happens to you in a very
specialized use case, and propose to fix that by changes that affect
all of Emacs.  This isn't going to fly in Emacs in general, since
Emacs is a very old and stable program, where almost all of the old
low-level code was tested by decades of usage, and any significant
changes there run high risk of breaking something.  And yet you keep
coming up with changes which do precisely that.  Please try to see
things from the POV of the Emacs maintainers, and look for ways of
fixing those problems either by much more localized changes, or maybe
even just in your own code.  TIA.




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

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


Received: (at 67836) by debbugs.gnu.org; 15 Dec 2023 22:55:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 15 17:55:54 2023
Received: from localhost ([127.0.0.1]:53723 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEH61-0007dJ-U5
	for submit <at> debbugs.gnu.org; Fri, 15 Dec 2023 17:55:54 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:24766)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rEH5z-0007d2-B6
 for 67836 <at> debbugs.gnu.org; Fri, 15 Dec 2023 17:55:52 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5A47310009E;
 Fri, 15 Dec 2023 17:55:45 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1702680944;
 bh=Vq9yGjzLNIonr8713Nqw2IqU0i2Q7KZpBW/vuO2REDA=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=dAxY7yvjDBpzPnDtwMB2jcURqIeCMG01EQCwU//T/GHPAJG2SmRtd5qlpBEmnmYwm
 7kfE5RabX507uEfsLBB59NWiR556T+EM44cCTarbvg5uL53CwJCSm2JbsuCwBROHnY
 SdILFVAN1e9w4jtqunBh1X06R11POUwshw4TlWRhuP5kxzU/m0pVuarj+pLY9tMcnd
 E6eVjsMmNkP1hxeISHbZITm9Kh3egk3oXWc+9DZcSahBW+JXdevfgUyovEmlMYMuQs
 yX3BdjJbWo9bo0R71+duhSvTz11KGh7YYW8oKNwQHZ2vv5UxlLMn60SLXrrtcJ52Qx
 RTViYUBqpYtzA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 67A3510001D;
 Fri, 15 Dec 2023 17:55:44 -0500 (EST)
Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3DD08120D88;
 Fri, 15 Dec 2023 17:55:44 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
In-Reply-To: <83msubo2vw.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 15 Dec
 2023 18:18:43 +0200")
Message-ID: <jwv1qbn5bfj.fsf-monnier+emacs@HIDDEN>
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
 <83msubo2vw.fsf@HIDDEN>
Date: Fri, 15 Dec 2023 17:55:43 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.032 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: Spencer Baugh <sbaugh@HIDDEN>, 67836 <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: -3.3 (---)

> Thanks, but let's please find a fix that doesn't make the tail wag the
> dog.  I don't want to make a change in bitch_at_user, which will
> affect every possible use of it in batch mode, something that we have
> been doing for eons.

I suspect keyboard macros have not been used very much in batch mode
over the last 32 years.

>> ding's docstring states that it terminates keyboard macros.  But, due
>> to what seems to be an oversight, it does not do that while executing
>> in batch mode.
> As the code clearly shows, it isn't an oversight.

AFAICT the current logic of code can be traced back to:

    commit 4588ec205730239596486e8ad4d18d541917199a
    Author: Jim Blandy <jimb@HIDDEN>
    Date:   Wed Jul 3 12:10:07 1991 +0000
    
        Initial revision
    
    diff --git a/src/dispnew.c b/src/dispnew.c
    --- /dev/null
    +++ b/src/dispnew.c
    @@ -0,0 +1813,9 @@
    +{
    +  if (noninteractive)
    +    putchar (07);
    +  else if (!INTERACTIVE)  /* Stop executing a keyboard macro. */
    +    error ("Keyboard macro terminated by a command ringing the bell");
    +  else
    +    ring_bell ();
    +  fflush (stdout);
    +}

I'm not sure this code can be said to show clearly that it's not
an oversight.
I read it to say that the author did not consider the intersection of

    noninteractive
and
    !INTERACTIVE


-- Stefan





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

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


Received: (at 67836) by debbugs.gnu.org; 15 Dec 2023 16:18:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 15 11:18:58 2023
Received: from localhost ([127.0.0.1]:53390 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEAtu-0005PH-4W
	for submit <at> debbugs.gnu.org; Fri, 15 Dec 2023 11:18:58 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:60452)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rEAtr-0005P3-EW
 for 67836 <at> debbugs.gnu.org; Fri, 15 Dec 2023 11:18:56 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rEAtl-0001jt-Fy; Fri, 15 Dec 2023 11:18:49 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=6eo/dBLfOU9XfkZLOzizuy9PriCbx1fNnyLeeSKA5H0=; b=nvCzRJhRDa0d
 rJruPdnAa5PsVxpaYUcPha46iDXtV4hN7WBNBJDsx4YwDN0PqkxtNDvlJcNy0qz826phy/PGl6L9O
 5gA0jDrEjRkWZ4mni9VOUQIphKKrahuFWKv9Bo2lsDLNhpGsD3IQ8Y6JoMoLQ6w4NSuWPyZPIE2QI
 U95F+JBZiEfAa4t+w6cmQ8CwCyOnXOCOcX4DhmEVomDA86RyLTKaHrPW+hUIVzBYJ1LamWrgBz1qn
 WZ6IOJBQsySOFpPZcmUDCPmDgdwU97In56NAKeJCe4o5+6cdpYvTKfoSmHJ4K5owuRAuWlU5wT+g9
 oAP0ZsIv4/IYlws0ARFUBw==;
Date: Fri, 15 Dec 2023 18:18:43 +0200
Message-Id: <83msubo2vw.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <ier7clfwjv4.fsf@HIDDEN> (message from Spencer Baugh on
 Fri, 15 Dec 2023 10:44:47 -0500)
Subject: Re: bug#67836: 29.1.90;
 map-y-or-n-p doesn't terminate when run in a kmacro in batch mode
References: <iera5qbwk54.fsf@HIDDEN> <ier7clfwjv4.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67836
Cc: 67836 <at> debbugs.gnu.org, monnier@HIDDEN
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: -3.3 (---)

> Cc: Stefan Monnier <monnier@HIDDEN>
> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Fri, 15 Dec 2023 10:44:47 -0500
> 
> Patch fixing this.

Thanks, but let's please find a fix that doesn't make the tail wag the
dog.  I don't want to make a change in bitch_at_user, which will
affect every possible use of it in batch mode, something that we have
been doing for eons.  If there's a particular problem with
map-y-or-n-p in batch mode, and if the scenario where you find the
problem is important enough, let's please find a solution that targets
only that special situation.

> ding's docstring states that it terminates keyboard macros.  But, due
> to what seems to be an oversight, it does not do that while executing
> in batch mode.

As the code clearly shows, it isn't an oversight.




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

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


Received: (at 67836) by debbugs.gnu.org; 15 Dec 2023 15:44:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 15 10:44:55 2023
Received: from localhost ([127.0.0.1]:53379 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEAMw-0005KM-L2
	for submit <at> debbugs.gnu.org; Fri, 15 Dec 2023 10:44:55 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:40195)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1rEAMu-0005K9-OY
 for 67836 <at> debbugs.gnu.org; Fri, 15 Dec 2023 10:44:53 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: 67836 <at> debbugs.gnu.org
Subject: Re: bug#67836: 29.1.90; map-y-or-n-p doesn't terminate when run in
 a kmacro in batch mode
In-Reply-To: <iera5qbwk54.fsf@HIDDEN> (Spencer Baugh's message of
 "Fri, 15 Dec 2023 10:38:47 -0500")
References: <iera5qbwk54.fsf@HIDDEN>
Date: Fri, 15 Dec 2023 10:44:47 -0500
Message-ID: <ier7clfwjv4.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67836
Cc: Stefan Monnier <monnier@HIDDEN>
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 (-)

--=-=-=
Content-Type: text/plain


Patch fixing this.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Make-ding-terminate-keyboard-macros-even-in-batch-mo.patch

From f894cbede9b65e6449c80393efb9d3417c9f661c Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri, 15 Dec 2023 09:57:19 -0500
Subject: [PATCH] Make ding terminate keyboard macros even in batch mode

ding's docstring states that it terminates keyboard macros.  But, due
to what seems to be an oversight, it does not do that while executing
in batch mode.

Generally, this means that some functions may infinite loop while run
in a keyboard macro in batch mode.

One concrete example: map-y-or-n-p will infinite-loop if run in a
keyboard macro while in batch mode.

Now ding properly terminates keyboard macros while running in batch
mode.  A test showing map-y-or-n-p behaves correctly in keyboard
macros is included.

* src/dispnew.c (bitch_at_user): Always signal while in a keyboard
macro, even if in batch mode. (bug#67836)
* test/lisp/emacs-lisp/map-ynp-tests.el (map-ynp-tests-simple-call)
(test-map-ynp-kmacro): Add.
---
 src/dispnew.c                         |  6 ++--
 test/lisp/emacs-lisp/map-ynp-tests.el | 46 +++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 test/lisp/emacs-lisp/map-ynp-tests.el

diff --git a/src/dispnew.c b/src/dispnew.c
index e4037494775..645311be8c0 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6185,14 +6185,14 @@ DEFUN ("ding", Fding, Sding, 0, 1, 0,
 void
 bitch_at_user (void)
 {
-  if (noninteractive)
-    putchar (07);
-  else if (!INTERACTIVE)  /* Stop executing a keyboard macro.  */
+  if (!NILP (Vexecuting_kbd_macro))  /* Stop executing a keyboard macro.  */
     {
       const char *msg
 	= "Keyboard macro terminated by a command ringing the bell";
       Fsignal (Quser_error, list1 (build_string (msg)));
     }
+  else if (noninteractive)
+    putchar (07);
   else
     ring_bell (XFRAME (selected_frame));
 }
diff --git a/test/lisp/emacs-lisp/map-ynp-tests.el b/test/lisp/emacs-lisp/map-ynp-tests.el
new file mode 100644
index 00000000000..4f5d10ee7f9
--- /dev/null
+++ b/test/lisp/emacs-lisp/map-ynp-tests.el
@@ -0,0 +1,46 @@
+;;; map-ynp-tests.el --- Tests for map-ynp.el        -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023 Free Software Foundation, Inc.
+
+;; Author: Spencer Baugh <sbaugh@HIDDEN>
+;; Maintainer: emacs-devel@HIDDEN
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests for map-ynp.el.
+
+;;; Code:
+
+(require 'ert)
+
+(defun map-ynp-tests-simple-call ()
+  (map-y-or-n-p ""  #'ignore '(1)))
+
+(ert-deftest test-map-ynp-kmacro ()
+  "Test that map-y-or-n-p in a kmacro terminates on end of input"
+  (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET y"))
+  (should-error
+   (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET")))
+  (unless noninteractive
+    (let ((noninteractive t))
+      (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET y"))
+      (should-error
+       (execute-kbd-macro (read-kbd-macro "M-: (map-ynp-tests-simple-call) RET"))))))
+
+(provide 'map-ynp-tests)
+;;; map-ynp-tests.el ends here
-- 
2.39.3


--=-=-=--




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

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


Received: (at submit) by debbugs.gnu.org; 15 Dec 2023 15:39:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 15 10:39:05 2023
Received: from localhost ([127.0.0.1]:53370 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEAHI-0005Bc-Bj
	for submit <at> debbugs.gnu.org; Fri, 15 Dec 2023 10:39:05 -0500
Received: from lists.gnu.org ([2001:470:142::17]:49820)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1rEAHF-0005B3-Sg
 for submit <at> debbugs.gnu.org; Fri, 15 Dec 2023 10:39:02 -0500
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 <sbaugh@HIDDEN>)
 id 1rEAH4-0000AJ-JX
 for bug-gnu-emacs@HIDDEN; Fri, 15 Dec 2023 10:38:50 -0500
Received: from mxout5.mail.janestreet.com ([64.215.233.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1rEAH2-0007a1-Fu
 for bug-gnu-emacs@HIDDEN; Fri, 15 Dec 2023 10:38:50 -0500
From: Spencer Baugh <sbaugh@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.1.90; map-y-or-n-p doesn't terminate when run in a kmacro in
 batch mode
Date: Fri, 15 Dec 2023 10:38:47 -0500
Message-ID: <iera5qbwk54.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN;
 helo=mxout5.mail.janestreet.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001,
 RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
Cc: Stefan Monnier <monnier@HIDDEN>
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.1 (/)


1. Create a file "broken.el" containing:
(defun broken ()
  (map-y-or-n-p ""  #'ignore '(1)))
(execute-kbd-macro (read-kbd-macro "M-: (broken) RET"))
2. emacs -Q -l ./broken.el
3. Emacs properly executes the keyboard macro and errors.
4. emacs -Q --batch -l ./broken.el
5. Notice Emacs infinite loops, printing the map-y-or-n-p prompt repeatedly.

map-y-or-n-p in a keyboard macro terminates in non-batch Emacs because
it calls (ding), which terminates the currently running keyboard macro.
However, (ding) doesn't terminate keyboard macros in batch mode.  This
seems to just be an oversight.

A patch to fix this by making (ding) always terminate keyboard macros
will follow.

(BTW, when not running in a keyboard macro, map-y-or-n-p will error in
batch Emacs, but only because of a separate bug where it runs (listp
last-nonmenu-event) to decide whether to use menus, which returns true
since last-nonmenu-event is nil.  I may fix this separately.)


In GNU Emacs 29.1.90 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-11-20 built on
 igm-qws-u22796a
Repository revision: dd8669b14b8a2b9a6d214a9d142dd8ac604f83d2
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.9 (Green Obsidian)

Configured using:
 'configure --config-cache --with-x-toolkit=lucid
 --with-gif=ifavailable'

Configured features:
CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM
XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  global-undo-tree-mode: t
  bug-reference-prog-mode: t
  delete-selection-mode: t
  global-so-long-mode: t
  pixel-scroll-precision-mode: t
  jane-fe-minor-mode: t
  jane-fe-jenga-minor-mode: t
  editorconfig-mode: t
  which-function-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  shell-dirtrack-mode: t
  server-mode: t
  windmove-mode: t
  savehist-mode: t
  save-place-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Features:
(shadow emacsbug make-mode finder lisp-mnt autoinsert etags org-agenda
pcmpl-gnu canlock nndraft nnmh nnfolder term ehelp cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
flow-fill shr-color qp smiley gnus-cite gnus-async gnus-bcklg gnus-agent
gnus-srvr gnus-score score-mode nnvirtual nntp gnus-ml gnus-msg
disp-table nndoc gnus-cache gnus-dup mm-archive debbugs-gnu
debbugs-compat debbugs soap-client rng-xsd rng-dt rng-util xsd-regexp
two-column evil-tests evil-test-helpers evil evil-integration undo-tree
evil-maps evil-commands evil-jumps evil-command-window evil-types
evil-search evil-ex evil-macros evil-repeat evil-states evil-core
evil-common cl evil-digraphs elp evil-vars latexenc fileloop textsec
uni-scripts idna-mapping uni-confusable textsec-check mail-extr wdired
doctor xscheme scheme apropos tramp-adb tramp-archive tramp-cmds
tramp-container tramp-ftp tramp-gvfs tramp-sh tramp-cache time-stamp
emoji-labels emoji multisession sqlite comp comp-cstr info-look flyspell
ispell pcmpl-unix emacs-news-mode reposition mode-local hippie-exp
vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc-dir cus-start sql log-view
vc-fe vc-hg vc magit-imenu git-rebase vc-git vc-dispatcher face-remap
hl-line display-line-numbers tabify man misc dired-aux rect sort
sh-script treesit thai-util thai-word ucs-normalize mule-util completion
dabbrev external-completion org-element org-persist org-id org-refile
avl-tree generator oc-basic ol-eww eww xdg url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg
dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap
nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range gnus-win
ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex ol-bbdb
ol-w3m ol-doi org-link-doi jane-aide cl-print misearch multi-isearch
pulse bug-reference shortdoc help-fns radix-tree executable
url-http-ntlm ntlm hmac-md5 hex-util md4 network-stream url-cache
url-http url-gw nsm codeium find-dired goto-addr let-alist delsel
so-long jane-fe-read-feature pixel-scroll cua-base tramp tramp-loaddefs
trampver tramp-integration tramp-compat parse-time iso8601 ffap
jane-merlin merlin-imenu merlin-xref merlin-cap merlin jane-async-merlin
jane-completion grep jane-common site-start jane-customization
jane-comint org-protocol jane-fe-project xref files-x jane-fe-menu
ecaml_plugin view gopcaml magit-bookmark bookmark image+ advice
image-file image-converter editorconfig editorconfig-core
editorconfig-core-handle editorconfig-fnmatch whitespace jane-auto-modes
vba-mode markdown-mode color jane jane-yasnippet jane-micro-features ert
ewoc debug backtrace jane-diff unified-test-mode shell-file core
core-buffer core-error jane-sexp jane-python jane-ocaml
jane-tuareg-theme tuareg tuareg-compat tuareg-opam skeleton flymake-proc
flymake warnings thingatpt smie caml-types caml-help caml-emacs
find-file compile jane-cr jane-codeium jane-align jane-deprecated
jane-smerge gnu-elpa-keyring-update jane-ocp-indent ocp-indent
jane-eglot yasnippet-autoloads swiper-autoloads htmlize-autoloads
eglot-autoloads editorconfig-autoloads codeium-autoloads jane-autoloads
jane-util ob-shell page-ext dired-x magit-extras project magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff
smerge-mode diff diff-mode git-commit log-edit message sendmail
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader pcvs-util
add-log magit-core magit-autorevert autorevert filenotify magit-margin
magit-transient magit-process with-editor shell server magit-mode
transient edmacro kmacro magit-git magit-section magit-utils crm dash
gnus nnheader gnus-util text-property-search mail-utils range mm-util
mail-prsvr cl-extra help-mode windmove org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-src ob-comint org-pcomplete pcomplete
org-list org-footnote org-faces org-entities time-date noutline outline
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol rx org-fold
org-fold-core org-keys oc org-loaddefs find-func cal-menu calendar
cal-loaddefs org-version org-compat org-macs format-spec gdb-mi bindat
gud easy-mmode comint ansi-osc ansi-color ring vundo modus-vivendi-theme
modus-themes pcase savehist saveplace cus-edit pp cus-load icons
wid-edit adaptive-wrap-autoloads csv-mode-autoloads
cyberpunk-theme-autoloads evil-autoloads exwm-autoloads helm-autoloads
helm-core-autoloads async-autoloads ivy-autoloads magit-autoloads
git-commit-autoloads finder-inf magit-section-autoloads dash-autoloads
popup-autoloads url-http-ntlm-autoloads url-auth vc-hgcmd-autoloads
vundo-autoloads info with-editor-autoloads xelb-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo x-toolkit xinput2 x multi-tty
make-network-process emacs)

Memory information:
((conses 16 3200047 267481)
 (symbols 48 76910 1)
 (strings 32 371340 77106)
 (string-bytes 1 16177813)
 (vectors 16 163678)
 (vector-slots 8 3169215 359463)
 (floats 8 850 969)
 (intervals 56 550774 4661)
 (buffers 976 591))




Acknowledgement sent to Spencer Baugh <sbaugh@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#67836; 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: Sat, 20 Jan 2024 12:30:02 UTC

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