GNU bug report logs - #78916
31.0.50; C-g fails to exit loop

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: Mike Kupfer <kupfer@HIDDEN>; dated Fri, 27 Jun 2025 21:37:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 78916) by debbugs.gnu.org; 3 Jul 2025 17:43:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 03 13:43:41 2025
Received: from localhost ([127.0.0.1]:51347 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uXNyH-0000SC-0u
	for submit <at> debbugs.gnu.org; Thu, 03 Jul 2025 13:43:41 -0400
Received: from mail-24418.protonmail.ch ([109.224.244.18]:17157)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1uXNyC-0000Qw-Ny
 for 78916 <at> debbugs.gnu.org; Thu, 03 Jul 2025 13:43:38 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1751564610; x=1751823810;
 bh=tJPx3DZngcaEr9arcMI9UhbJvhVwipMsRPOgnO1F7/s=;
 h=Date:To:From:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=rLEG3mIAT+AzgN9FFb1vsLFfaGX6reJuhawzCQe3comcRElo5fyVXo0mWy0T8lQPB
 zbF8tXRUOaqtnHLWbuG8jD/gcaI8dN9lNaPjhjOzqCF5vyvqFFlPniNfjTzXaONzGh
 oGG1/vkD4rV28oDezG5BjBMHmQiEhPiFBgnDukxKXrA8P6GqG4X6FxVepTiygnJLsl
 Eeb4zs/bVhf2S1MUU97kbwvIsgK2vJZoYDG/Jmw6BanNxZ6lf6E2YyQL4EldiqFDnV
 Q+tzuJFG90fTVdv0OSq5SXtu9ssW3fhKJqX6IsARlVlEVeoJhTFyYw0wPzfzyC+YkH
 HmcXyFbrpQ/fQ==
Date: Thu, 03 Jul 2025 17:43:25 +0000
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>,
 78916 <at> debbugs.gnu.org, kupfer@HIDDEN
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
Message-ID: <87tt3tw4p4.fsf@HIDDEN>
In-Reply-To: <jwv7c0pfi0c.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
 <jwvo6u36452.fsf-monnier+emacs@HIDDEN> <86seje2597.fsf@HIDDEN>
 <jwvsejeheiw.fsf-monnier+emacs@HIDDEN> <867c0p24gf.fsf@HIDDEN>
 <jwv7c0pfi0c.fsf-monnier+emacs@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 6684413696862384874232d65ee185e4b1ccdfed
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 78916
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.8 (/)

"Stefan Monnier via \"Bug reports for GNU Emacs, the Swiss army knife of te=
xt editors\"" <bug-gnu-emacs@HIDDEN> writes:

>> I agree that calling keyboard-quit is better.
>
> So, I suggest the patch below.

I'd just like to note that this breaks badly if quitchar is changed.
That doesn't mean we shouldn't apply this patch, it means we should
remove the vestigial support for changing quitchar from keyboard.c

(However, there are other good reason not to apply this patch, and
simply fix read-key to optionally allow quitting instead.  There is no
reason to make Lisp users choose between having to handle quit
themselves (which currently requires mucking about with low-level input
details such as determining quitchar) and having to handle low-level
events themselves.  Most users don't want to do either thing.

And we definitely need to fix

   (while t (message "%S" (read-key)))

destroying your session.  It's simply a bug in keyboard.c that this
isn't recognized by the triple-C-g code in GUI sessions, or the
double-C-g code in terminal sessions.

IMHO, no further replacements of read-event by read-key should be
performed until we've made the latter function less hostile to novice
Lisp hackers.)

Pip





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

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


Received: (at 78916) by debbugs.gnu.org; 3 Jul 2025 16:02:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 03 12:02:30 2025
Received: from localhost ([127.0.0.1]:50335 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uXMOM-0002sC-A5
	for submit <at> debbugs.gnu.org; Thu, 03 Jul 2025 12:02:30 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36146)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uXMOK-0002rj-A2
 for 78916 <at> debbugs.gnu.org; Thu, 03 Jul 2025 12:02:29 -0400
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 1uXMOE-00045n-EB; Thu, 03 Jul 2025 12:02:22 -0400
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=lWx7jOpmAq1niTOXeAryFwS8av6MVGIT8eGD9NtFvi8=; b=C1TqHe5EN5Ln
 aKJSmoySyjxhnyivgDCs8vOJBFtjaL+6ydhAwd+OfYs879pXrOa0j7lZaE4KBuYWNZl7I/eXVA4vT
 iQlN9O92Sj2wMu7vhDt6yWLtRWJ/4NkG16deR3B9gzA//WP40b4ZpiooLT15wW0CiG7KoqaXi2En4
 GIJ9/GI+1cmNNCLcm5LFPgZQG9LPsVDOQ8RDQgs7oA4R5vFQJ9KxQdyXxCLxWhMw/7XaksTmSCM68
 GbHRdre70pN7IoV2IR5FRcnX14u4qb9ahuH15/uahv7JjwRbV0Jy5NaLV4PTUg5uplfeyHoqr5YD7
 SYwOfggN4nvK2nysj1AG0w==;
Date: Thu, 03 Jul 2025 19:01:39 +0300
Message-Id: <86h5ztz2jg.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwv7c0pfi0c.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Thu, 03 Jul 2025 10:48:51 -0400)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
 <jwvo6u36452.fsf-monnier+emacs@HIDDEN> <86seje2597.fsf@HIDDEN>
 <jwvsejeheiw.fsf-monnier+emacs@HIDDEN> <867c0p24gf.fsf@HIDDEN>
 <jwv7c0pfi0c.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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: 78916 <at> debbugs.gnu.org,  kupfer@HIDDEN
> Date: Thu, 03 Jul 2025 10:48:51 -0400
> 
> > I agree that calling keyboard-quit is better.
> 
> So, I suggest the patch below.

Thanks.

> diff --git a/lisp/subr.el b/lisp/subr.el
> index 69f6e4dbab8..0a1d676445b 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -4047,14 +4047,19 @@ y-or-n-p
>               ((memq answer '(skip act)) nil)
>               ((eq answer 'recenter)
>                (recenter) t)
> +             ;; Explicitly handle the other non-commands, to avoid
> +             ;; conflicts with possible commands of the same name.
> +             ((memq answer '( act-and-show act-and-exit exit edit
> +                              edit-replacement edit-replacement-exact-case
> +                              delete-and-edit automatic backup
> +                              undo undo-all help))
> +              t)
>               ((eq answer 'scroll-up)
>                (ignore-errors (scroll-up-command)) t)
>               ((eq answer 'scroll-down)
>                (ignore-errors (scroll-down-command)) t)
> -             ((eq answer 'scroll-other-window)
> -              (ignore-errors (scroll-other-window)) t)
> -             ((eq answer 'scroll-other-window-down)
> -              (ignore-errors (scroll-other-window-down)) t)
> +             ((functionp answer)
> +              (call-interactively answer) t)

Why not 'commandp'?




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

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


Received: (at 78916) by debbugs.gnu.org; 3 Jul 2025 14:49:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 03 10:49:08 2025
Received: from localhost ([127.0.0.1]:49498 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uXLFL-0001US-R0
	for submit <at> debbugs.gnu.org; Thu, 03 Jul 2025 10:49:08 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:26378)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uXLFI-0001T5-C9
 for 78916 <at> debbugs.gnu.org; Thu, 03 Jul 2025 10:49:05 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A155D4415B5;
 Thu,  3 Jul 2025 10:48:58 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751554133;
 bh=OkBIONaE7WfL2O+ePPbzdoKp3w8Sa2bfBiH/BeAImwg=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=HoEEfPpyKo09dw6uV8fmS3TOWIAelZBClH6bNu1paEB10YKTtwQO5Mm2djonFIGHF
 eslxULfPPJDV2+XH6Qa9b9DN+6xr1WTEWLWIQj8qtzXwPRh7JXLcWWz+rPODbmkph+
 hOthJClA7DdsMwvk8Pbb9v7dun3t3/OO5dGKde/Xcot/rizhts2uRLgVSfkea/47FS
 Z7b2YLBMzSJn0h2sdtWc2V5jn9tRScy9YRqIBUqj4x6uQSiP3HlBIxaUjUZHTSu0Lv
 fSSnegbXgbNUKCz5E4cU35Zw0DemRu7hEt2gSJ8Gia0nmBqpnl6bF2xgc07vwfwa8a
 Wzzmsbm5aCzCQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E9DC74413D1;
 Thu,  3 Jul 2025 10:48:52 -0400 (EDT)
Received: from pastel (unknown [104.247.225.139])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BDD9D1204E6;
 Thu,  3 Jul 2025 10:48:52 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <867c0p24gf.fsf@HIDDEN>
Message-ID: <jwv7c0pfi0c.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
 <jwvo6u36452.fsf-monnier+emacs@HIDDEN> <86seje2597.fsf@HIDDEN>
 <jwvsejeheiw.fsf-monnier+emacs@HIDDEN> <867c0p24gf.fsf@HIDDEN>
Date: Thu, 03 Jul 2025 10:48:51 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.285 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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.1 (---)

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

> I agree that calling keyboard-quit is better.

So, I suggest the patch below.


        Stefan

--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=replace.patch

diff --git a/lisp/replace.el b/lisp/replace.el
index 9939273594f..f61a6445c4b 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -2491,16 +2491,17 @@ query-replace-map
     (define-key map [f1] 'help)
     (define-key map [help] 'help)
     (define-key map "?" 'help)
-    (define-key map "\C-g" 'quit)
-    (define-key map "\C-]" 'quit)
-    (define-key map "\C-v" 'scroll-up)
-    (define-key map "\M-v" 'scroll-down)
-    (define-key map [next] 'scroll-up)
-    (define-key map [prior] 'scroll-down)
-    (define-key map [?\C-\M-v] 'scroll-other-window)
-    (define-key map [M-next] 'scroll-other-window)
-    (define-key map [?\C-\M-\S-v] 'scroll-other-window-down)
-    (define-key map [M-prior] 'scroll-other-window-down)
+    (define-key map "\C-g" #'keyboard-quit)
+    (define-key map "\C-]" #'keyboard-quit)
+    ;; FIXME: Should we use `scroll-(up|down)-command' here instead?
+    (define-key map "\C-v" #'scroll-up)
+    (define-key map "\M-v" #'scroll-down)
+    (define-key map [next] #'scroll-up)
+    (define-key map [prior] #'scroll-down)
+    (define-key map [?\C-\M-v] #'scroll-other-window)
+    (define-key map [M-next] #'scroll-other-window)
+    (define-key map [?\C-\M-\S-v] #'scroll-other-window-down)
+    (define-key map [M-prior] #'scroll-other-window-down)
     ;; Binding ESC would prohibit the M-v binding.  Instead, callers
     ;; should check for ESC specially.
     ;; (define-key map "\e" 'exit-prefix)
@@ -2509,11 +2510,13 @@ query-replace-map
   "Keymap of responses to questions posed by commands like `query-replace'.
 The \"bindings\" in this map are not commands; they are answers.
 The valid answers include `act', `skip', `act-and-show',
-`act-and-exit', `exit', `exit-prefix', `recenter', `scroll-up',
-`scroll-down', `scroll-other-window', `scroll-other-window-down',
-`edit', `edit-replacement', `edit-replacement-exact-case',
+`act-and-exit', `exit', `exit-prefix', `recenter', `edit',
+`edit-replacement', `edit-replacement-exact-case',
 `delete-and-edit', `automatic', `backup', `undo', `undo-all',
-`quit', and `help'.
+and `help'.
+This said, valid answers can also be interactive functions.
+Functions that can make sense here include `scroll-up', `scroll-down',
+`scroll-other-window', `scroll-other-window-down', and `keyboard-quit'.
 
 This keymap is used by `y-or-n-p' as well as `query-replace'.")
 
diff --git a/lisp/subr.el b/lisp/subr.el
index 69f6e4dbab8..0a1d676445b 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4047,14 +4047,19 @@ y-or-n-p
              ((memq answer '(skip act)) nil)
              ((eq answer 'recenter)
               (recenter) t)
+             ;; Explicitly handle the other non-commands, to avoid
+             ;; conflicts with possible commands of the same name.
+             ((memq answer '( act-and-show act-and-exit exit edit
+                              edit-replacement edit-replacement-exact-case
+                              delete-and-edit automatic backup
+                              undo undo-all help))
+              t)
              ((eq answer 'scroll-up)
               (ignore-errors (scroll-up-command)) t)
              ((eq answer 'scroll-down)
               (ignore-errors (scroll-down-command)) t)
-             ((eq answer 'scroll-other-window)
-              (ignore-errors (scroll-other-window)) t)
-             ((eq answer 'scroll-other-window-down)
-              (ignore-errors (scroll-other-window-down)) t)
+             ((functionp answer)
+              (call-interactively answer) t)
              ((or (memq answer '(exit-prefix quit)) (eq key ?\e))
               (signal 'quit nil) t)
              (t t)))

--=-=-=--





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

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


Received: (at 78916) by debbugs.gnu.org; 3 Jul 2025 06:06:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jul 03 02:06:55 2025
Received: from localhost ([127.0.0.1]:41996 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uXD5z-0006RH-9q
	for submit <at> debbugs.gnu.org; Thu, 03 Jul 2025 02:06:55 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:52356)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uXD5u-0006QK-RA
 for 78916 <at> debbugs.gnu.org; Thu, 03 Jul 2025 02:06:53 -0400
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 1uXD5n-0004Jq-7L; Thu, 03 Jul 2025 02:06:43 -0400
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=uFeYGcTkGrmH8CTlKospnrPueX4+urAwFtV4jESbcVA=; b=YDCoTJHUX73K
 KaRnVzxW9Ew3UmhqwhKjb4d4am+rGad0iOelnypvd/nAK6loqxRYWU9hcg281KgvAt7uDcxvtdFk1
 Ivm2OhhkSuq1F6DwBQ4qibn2LxcO3vxCYyQFvGpyAYdZpC+vgCg0bwUlgE4b1zN1qkbzYryIVlJk1
 v1IN8fjxZt5xERw8kNhNdC/eHaOCMDu2YmUmG5qXRoRcOiPjjUD2YJT2XsjWRsIiiv31EwDxeuSi9
 sVMhbjr954uM1oZURcpLZLpHigAbbGZwIDdyRq7ViK+3Gc/s6CpRKDXyI/Sag7NGj++L0msUb/mZu
 5t4vXx65gT3EoiCKHV0zxA==;
Date: Thu, 03 Jul 2025 09:06:40 +0300
Message-Id: <867c0p24gf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvsejeheiw.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Wed, 02 Jul 2025 10:14:39 -0400)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
 <jwvo6u36452.fsf-monnier+emacs@HIDDEN> <86seje2597.fsf@HIDDEN>
 <jwvsejeheiw.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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: kupfer@HIDDEN,  78916 <at> debbugs.gnu.org
> Date: Wed, 02 Jul 2025 10:14:39 -0400
> 
> >> > and it happened in the past because C-g would quite right away, so
> >> > there was no need to re-read it.  Right?
> >> 
> >> I agree that we want to signal `quit` right away here (and I think both
> >> for `C-g` and for `C-]`) rather than "unread" them.  The question is how
> >> we want to do it:
> >> 
> >> - (signal 'quit nil)
> >> - call `keyboard-quit`.
> >> - call whatever is bound to `C-g` in the normal keymaps.
> >
> > If you explain the difference between the first tow, I could try
> > making up my mind.
> 
> I know as much as you do in this respect (i.e. the difference is
> whatever `keyboard-quit` does before calling `(signal 'quit nil)`).
> 
> Also:
> 
> - (signal 'quit nil) is what C-g does/did when we use(d) `read-event`.
> - `keyboard-quit` is what `C-g` does when it's handled via the global-map.
> 
> To me, the current situation sounds like a case where the `C-g` is
> received by an "interactive loop" so I'd leaning towards handling it via
> `keyboard-quit`, whereas (signal 'quit nil) is what is used when
> interrupting *running* code.

I agree that calling keyboard-quit is better.




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

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


Received: (at 78916) by debbugs.gnu.org; 2 Jul 2025 14:14:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 02 10:14:50 2025
Received: from localhost ([127.0.0.1]:37536 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWyEc-0002hZ-FR
	for submit <at> debbugs.gnu.org; Wed, 02 Jul 2025 10:14:50 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12226)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uWyEZ-0002gm-Q9
 for 78916 <at> debbugs.gnu.org; Wed, 02 Jul 2025 10:14:48 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B470C809D3;
 Wed,  2 Jul 2025 10:14:41 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751465680;
 bh=VO8b1q3I9GYLmgmmXctHtuuDkuMh2KRGSn6gDBNn40U=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=iLfEtdrJPDKMr5hHD3138fPz0K/9HtvemQPhl9xdkITTm46SSa/vqdsqOcG3vsfKL
 paX8C1tWN1YPdDo5+BN0Xk036d+sL/EC4err9awLPOCV6/xQ3gldoagks8jvWw7EUH
 X62KLQICJ314OWFhE+3rRHhJhII588/ZaZQrW+ViRdm2qU0DKsACerjP+b7IsvPcUM
 NwyGmv9cPygnSpQHqt/TiAtDdOPllmJZWq/hvoF617ZTMZKY11UFIk+CyrG1x4IA0Y
 +rkAcFLLROv2gmeHXdMePRoACzaCFPqfVaymfWNSN6Getp/1OWPlQVcKO3ApGHCX1f
 LwHK4w6QvMuKQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9CC1380672;
 Wed,  2 Jul 2025 10:14:40 -0400 (EDT)
Received: from pastel (unknown [104.247.225.139])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7115B120223;
 Wed,  2 Jul 2025 10:14:40 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <86seje2597.fsf@HIDDEN>
Message-ID: <jwvsejeheiw.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
 <jwvo6u36452.fsf-monnier+emacs@HIDDEN> <86seje2597.fsf@HIDDEN>
Date: Wed, 02 Jul 2025 10:14:39 -0400
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.299 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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.1 (---)

>> > and it happened in the past because C-g would quite right away, so
>> > there was no need to re-read it.  Right?
>> 
>> I agree that we want to signal `quit` right away here (and I think both
>> for `C-g` and for `C-]`) rather than "unread" them.  The question is how
>> we want to do it:
>> 
>> - (signal 'quit nil)
>> - call `keyboard-quit`.
>> - call whatever is bound to `C-g` in the normal keymaps.
>
> If you explain the difference between the first tow, I could try
> making up my mind.

I know as much as you do in this respect (i.e. the difference is
whatever `keyboard-quit` does before calling `(signal 'quit nil)`).

Also:

- (signal 'quit nil) is what C-g does/did when we use(d) `read-event`.
- `keyboard-quit` is what `C-g` does when it's handled via the global-map.

To me, the current situation sounds like a case where the `C-g` is
received by an "interactive loop" so I'd leaning towards handling it via
`keyboard-quit`, whereas (signal 'quit nil) is what is used when
interrupting *running* code.

>> [ With a subsidiary question of whether we do it by changing the code
>>   that handles a key bound to `quit` or whether we just change the
>>   binding to something else like `keyboard-quit`.  ]
>
> Currently 'quit' in replace.el is not handled, so it is a kind-of
> dummy binding.  It doesn't have any code that handles it.  Or what did
> I miss?

Yes, "any" other symbol would be handled in the same way, i.e. it's
handled by the default code that unreads the event and exits the Q&R.


        Stefan





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

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


Received: (at 78916) by debbugs.gnu.org; 2 Jul 2025 11:39:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 02 07:39:27 2025
Received: from localhost ([127.0.0.1]:35989 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWvoE-0004zE-Si
	for submit <at> debbugs.gnu.org; Wed, 02 Jul 2025 07:39:27 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:55598)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uWvoB-0004y2-QA
 for 78916 <at> debbugs.gnu.org; Wed, 02 Jul 2025 07:39:24 -0400
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 1uWvo4-0006Nl-9a; Wed, 02 Jul 2025 07:39:16 -0400
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=gW3zIugj4B8WVV8Lm2pIftnsFMs+npN86XqFCtVv+jE=; b=hiyb2BWU7Rwc
 u2lfK6ouYVMUy0RDko8/+E5Y+ZUwmgVvyJ4j9Kq61EaV27txPCnq6s6YFKa7W5gH35T+vN/Oua5r0
 NWiV4QWMyMTQQYHIf5QXRfQJ8B4d4iTl80HG8Vgnld4f5UZjtbwwrhKIAPf/aW46V3IZ11jTQ/aet
 p15pKAbWJDFSxwb57JXIqCWgPYh1SLeLsVAImvUC14vzkmAy/iYx79pCtONC5y1QULBk31svXfzr+
 nc1F7+AnpfyVxIzTWNRUR9ZGBWRQuspcwl1H1g0Xl0c7rLJmlbWyhU8ZhRq0fNrsQ3jZSv6xoieXU
 C+xrYSEGzQsWmr6akZUCNA==;
Date: Wed, 02 Jul 2025 14:39:07 +0300
Message-Id: <86qzyy255w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: rms@HIDDEN
In-Reply-To: <E1uWmvs-0005e8-Aj@HIDDEN> (message from Richard
 Stallman on Tue, 01 Jul 2025 22:10:44 -0400)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN> <E1uWmvs-0005e8-Aj@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, monnier@HIDDEN, kupfer@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: Richard Stallman <rms@HIDDEN>
> Cc: eliz@HIDDEN, 78916 <at> debbugs.gnu.org, kupfer@HIDDEN
> Date: Tue, 01 Jul 2025 22:10:44 -0400
> 
> C-g and C-] are intentionally different.  C-g quits out of commands,
> while C-] exis a recursive edit.  The two commands exist because
> they are different, and both useful.

That is true in general, but we are talking about the effects of these
two inside query-replace, where they both are bound to the same
function.

> We want to fix the bug that affects C-g.  But what should C-] do here?
> 
> Its definition is to quit out of the innermos recursive edit.
> But I don't think there is a recursive edit going on in this example.
> query-replace-regexp doesn't use a recursive edit to read
> the user's input.
> 
> Quitting out of the current command seems like a reaosnable think
> for C-] to do when there is no recursive edit in progress.

Exactly.  So in this case C-g and C-] are supposed to have the same
effect, I think.




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

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


Received: (at 78916) by debbugs.gnu.org; 2 Jul 2025 11:37:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jul 02 07:37:27 2025
Received: from localhost ([127.0.0.1]:35980 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWvmI-0004hu-FS
	for submit <at> debbugs.gnu.org; Wed, 02 Jul 2025 07:37:26 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43680)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uWvmB-0004gG-Ix
 for 78916 <at> debbugs.gnu.org; Wed, 02 Jul 2025 07:37:23 -0400
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 1uWvm4-00067f-6r; Wed, 02 Jul 2025 07:37:12 -0400
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=sk1FMGSLB0L8r5RiEjpVhPNtsUM0nT3Wdil66aV9fis=; b=Ahxc9nmGCkXz
 HIFl1t91EXfpsYj8yVR0ymYocZk984CXM7mjBEFNrU4vLeO6hTjD22r7OKvIY0Gs5qDeR4s4cvB25
 btsPCfScq6ADi4XDZ8MzkNpoggMS9EEiN9UbiyR9/US6GtkV5Z3Bhjq60Dm+RL6Cc+zM/cGFf5NF9
 jPZTLJb7A1D5nRhWkCx0wExIgvb8JheUFcd/uAiuCT1Os6EituI88wjDnj03vfhWhnTWB+x7Mb2/1
 o02t8ICWOTMP5ru3Ems3xQYP0a+jZQUYh9eoN6tj67hp/YG4++UB1cwgp0/2WFczJnnyGthjwwXbM
 O1E7ZMBPeQEqgMA8aZxqnA==;
Date: Wed, 02 Jul 2025 14:37:08 +0300
Message-Id: <86seje2597.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvo6u36452.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Tue, 01 Jul 2025 16:47:40 -0400)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
 <jwvo6u36452.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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: kupfer@HIDDEN,  78916 <at> debbugs.gnu.org
> Date: Tue, 01 Jul 2025 16:47:40 -0400
> 
> > and it happened in the past because C-g would quite right away, so
> > there was no need to re-read it.  Right?
> 
> I agree that we want to signal `quit` right away here (and I think both
> for `C-g` and for `C-]`) rather than "unread" them.  The question is how
> we want to do it:
> 
> - (signal 'quit nil)
> - call `keyboard-quit`.
> - call whatever is bound to `C-g` in the normal keymaps.

If you explain the difference between the first tow, I could try
making up my mind.

> [ With a subsidiary question of whether we do it by changing the code
>   that handles a key bound to `quit` or whether we just change the
>   binding to something else like `keyboard-quit`.  ]

Currently 'quit' in replace.el is not handled, so it is a kind-of
dummy binding.  It doesn't have any code that handles it.  Or what did
I miss?




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

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


Received: (at 78916) by debbugs.gnu.org; 2 Jul 2025 02:13:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 01 22:13:18 2025
Received: from localhost ([127.0.0.1]:59839 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWmyJ-0007ME-WA
	for submit <at> debbugs.gnu.org; Tue, 01 Jul 2025 22:13:17 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:38492)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <rms@HIDDEN>) id 1uWmyG-0007Kq-MY
 for 78916 <at> debbugs.gnu.org; Tue, 01 Jul 2025 22:13:13 -0400
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 <rms@HIDDEN>)
 id 1uWmyB-0004Tf-7C; Tue, 01 Jul 2025 22:13:07 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From:
 mime-version; bh=13FQ1RfaWBl0vTEruc9DDx3onmr8qYSvvANHXQkJ+QY=; b=RSm2bzXtvEKL
 OxwQw1hI+mdQT0pDAonoGqcQOIhDj7o9Mt0lzyykMvD+tZfWTkPkF4NfUH98IiVgox0n969U+wpYo
 LVKWXcKvWWD1K5sk/7Igs73vmeCEmma8M/u3Dobi32fJkvPocGFKXG2TJ42utMc6kwuZVJBZa6L+l
 MWIkchdN86Hgv6E/e40zAXUOta4MwPGfEwklNlG21Do/zvmxuGZLaPYa62yO0M56dgOvEVk7L3yLh
 WpDILpJAfQQXIco+Pkxo/Y3HyyazKFpSJb1BkeQDJK1+Hy36sQkkDBsuIMxO2uu+0gaGW86bHf99E
 2A1Tpxpt6zyjz1Z5Cu/PrA==;
Received: from rms by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <rms@HIDDEN>)
 id 1uWmy4-00060v-5S; Tue, 01 Jul 2025 22:13:00 -0400
Content-Type: text/plain; charset=Utf-8
From: Richard Stallman <rms@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
Message-Id: <E1uWmy4-00060v-5S@HIDDEN>
Date: Tue, 01 Jul 2025 22:13:00 -0400
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, eliz@HIDDEN, kupfer@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>
Reply-To: rms@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

C-g and C-] are intentionally different.  C-g quits out of commands,
while C-] exis a recursive edit.  The two commands exist because
they are different, and both useful.

We want to fix the bug that affects C-g.  But what should C-] do here?

Its definition is to quit out of the innermos recursive edit.
But I don't think there is a recursive edit going on in this example.
query-replace-regexp doesn't use a recursive edit to read
the user's input.

Quitting out of the current command seems like a reaosnable think
for C-] to do when there is no recursive edit in progress.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






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

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


Received: (at 78916) by debbugs.gnu.org; 2 Jul 2025 02:11:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 01 22:11:04 2025
Received: from localhost ([127.0.0.1]:59832 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWmw9-00073K-W8
	for submit <at> debbugs.gnu.org; Tue, 01 Jul 2025 22:11:04 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:55000)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <rms@HIDDEN>) id 1uWmw0-00071I-Uh
 for 78916 <at> debbugs.gnu.org; Tue, 01 Jul 2025 22:10:58 -0400
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 <rms@HIDDEN>)
 id 1uWmvt-0003t5-1U; Tue, 01 Jul 2025 22:10:45 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From:
 mime-version; bh=13FQ1RfaWBl0vTEruc9DDx3onmr8qYSvvANHXQkJ+QY=; b=V7y2J/SoPcQj
 PXFkgrqDAg/giwBniHPfyhJCVBpPk1Ogshs6Sz1SIhTu95nzxeTUvC+jc7rQcSf3XrE14fK0BG55/
 PKZXeRZVF8XjlQKkaiot8n+aYuzoAlJ0F5MJyplzt6YmENFFr8RRbvJRqavLyGLy6oATDXlLcxM1W
 RL/uBRVcq/leGhg3zAOjDxAywJ/pTuzx7LQbnb0FbmFD/qf62I2Bc2PFIqggYNmA/Q11oPHlIOtma
 LdjFpOPtKpwRJj4ekI46OtUT/I1bhMHKGHnM5F28Wyt36fjYYsEdLZKSsq1yL1gmzjQU0GH27EYnl
 dlB1c/F6PX/GkyPmPIl6ZA==;
Received: from rms by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <rms@HIDDEN>)
 id 1uWmvs-0005e8-Aj; Tue, 01 Jul 2025 22:10:44 -0400
Content-Type: text/plain; charset=Utf-8
From: Richard Stallman <rms@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
Message-Id: <E1uWmvs-0005e8-Aj@HIDDEN>
Date: Tue, 01 Jul 2025 22:10:44 -0400
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, eliz@HIDDEN, kupfer@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>
Reply-To: rms@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

C-g and C-] are intentionally different.  C-g quits out of commands,
while C-] exis a recursive edit.  The two commands exist because
they are different, and both useful.

We want to fix the bug that affects C-g.  But what should C-] do here?

Its definition is to quit out of the innermos recursive edit.
But I don't think there is a recursive edit going on in this example.
query-replace-regexp doesn't use a recursive edit to read
the user's input.

Quitting out of the current command seems like a reaosnable think
for C-] to do when there is no recursive edit in progress.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






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

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


Received: (at 78916) by debbugs.gnu.org; 1 Jul 2025 20:47:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 01 16:47:59 2025
Received: from localhost ([127.0.0.1]:58955 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWhtV-0001sA-JV
	for submit <at> debbugs.gnu.org; Tue, 01 Jul 2025 16:47:58 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:51172)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uWhtS-0001qe-B5
 for 78916 <at> debbugs.gnu.org; Tue, 01 Jul 2025 16:47:55 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 72943809A6;
 Tue,  1 Jul 2025 16:47:48 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751402867;
 bh=abEqyWbcQYepKAIy318PaerTMj/zJ54XMSSV7sO9U4s=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=kBy6TP48M4B9SnMO7YOEgw9B88Tfofd6cXCYk8fw3wT5QXDzjIz8KR28pnquX5xFD
 IkEnlrLEcxFqAsWAvuOczdXc9oscOEiiNOp2wJpvIsJOQVgxIYWzrpx9XSvXlYQsEq
 DNnOFt4YJC4K9hdePz5MStG131OVuVqRfY4jlG6nndrLhws2DAdnU9LRtDVnwUDjkW
 DQWUpSGja+9XkzJqdaBWQiRQRWPrfUgQCr0T5YC4hHWHZz41Ys2KCNGilILwkHcmqf
 TyTsGVzIyxpjGXUEInmkkGRG2Munz7UdmyFFrmfpowJaQC9/gzqXith9QbbW50s1EA
 qPrpaSyleIXgg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9005680823;
 Tue,  1 Jul 2025 16:47:47 -0400 (EDT)
Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6749A120919;
 Tue,  1 Jul 2025 16:47:47 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <86ikkc2kx8.fsf@HIDDEN>
Message-ID: <jwvo6u36452.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN> <86ikkc2kx8.fsf@HIDDEN>
Date: Tue, 01 Jul 2025 16:47:40 -0400
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.170 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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 (---)

>> His Q&R call is inside a loop:
>> 
>>          (while (re-search-forward "bug#[[:digit:]]+:" nil t)
>>            (search-backward "(\"bug")
>>            (let (end (start (point)))
>>              (forward-sexp)
>>              (setq end (point))
>>              (query-replace-regexp "\\(\"bug#[[:digit:]]+:\\).*\"" "\\1\""
>>              		    nil start end))))
>> 
>> so when we exit one we enter the next (as long as there's another match
>> for the main regexp, that is).
>
> OK, but then the issue here is not about query-replace-regexp at all,
> isn't it?  It's about whether C-g is "re-read" after exiting
> query-replace-regexp, and when it is re-read, does it quit.  Or am I
> missing something?

I think you're right.  Which is why I think the intention was not to
"unread it" but rather to give it its "normal" behavior (which the code
tries to do by "unreading" the input, but failing to take into account
that there's no guarantee exiting Q&R will get us back to a normal
command loop).

>> - The behavior of `q`: exit the Q&R and continue with whatever may follow.
>> - The behavior of `C-]`: exit the Q&R and also continue with whatever
>>   may follow, but without consuming the `C-]` so next time we read a key
>>   we'll get this `C-]`.
>> - The old behavior of `C-g` (which we definitely want to recover): abort
>>   the current command.
> If C-g is not consumed, it will produce the expected effect, right?

Hmm... it depends what happens when we exit Q&R and what you think is
"the expected effect".

> If so, the problem seems to be that this is what's expected here,

I don't know what you're trying to say here.

> and it happened in the past because C-g would quite right away, so
> there was no need to re-read it.  Right?

I agree that we want to signal `quit` right away here (and I think both
for `C-g` and for `C-]`) rather than "unread" them.  The question is how
we want to do it:

- (signal 'quit nil)
- call `keyboard-quit`.
- call whatever is bound to `C-g` in the normal keymaps.

[ With a subsidiary question of whether we do it by changing the code
  that handles a key bound to `quit` or whether we just change the
  binding to something else like `keyboard-quit`.  ]


        Stefan





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

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


Received: (at 78916) by debbugs.gnu.org; 1 Jul 2025 11:46:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 01 07:46:46 2025
Received: from localhost ([127.0.0.1]:55413 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWZRk-0000O1-0g
	for submit <at> debbugs.gnu.org; Tue, 01 Jul 2025 07:46:46 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47596)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uWZRf-0000MN-8j
 for 78916 <at> debbugs.gnu.org; Tue, 01 Jul 2025 07:46:40 -0400
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 1uWZRY-0003kv-CS; Tue, 01 Jul 2025 07:46:32 -0400
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=dzadoXt5o2pO9AJjAmrBCGojuPCDGSJE6mzZDs7KGlM=; b=n3Cf2bPfisE3
 sI9WeCQrVkqfFRRCZP9k+L9MmQuTatHChc5SuDspKqIu+DLP6wUCzO15Mewi04NtVGUaTnsUJuEit
 MEoRtWO3lsAK7AczC78miwoegPbT77wvjD5G5GCxFe9aKSUgPsPBwgKb+Vs4Gxd9wx3iW5/P40imn
 WB3gQubL0y727XK/jEMlk5otnBtfb3GysIRe0crXO1rPZMCoicFjL5ivobCNiJcrSlgBS0LlPl+yF
 xW+5puA1ejIjPHRGHQ+po5VF70unk7Ea4ne/bGq23iUEfqoZEnjAewyQ2CE7CxF68+Ysb+xnpgHV4
 WXcRiEK8pPxsw1iYokp3nw==;
Date: Tue, 01 Jul 2025 14:46:27 +0300
Message-Id: <86ikkc2kx8.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvms9povsf.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Mon, 30 Jun 2025 16:15:17 -0400)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
 <jwvms9povsf.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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: kupfer@HIDDEN,  78916 <at> debbugs.gnu.org
> Date: Mon, 30 Jun 2025 16:15:17 -0400
> 
> Eli Zaretskii [2025-06-30 22:00:02] wrote:
> 
> >> From: Stefan Monnier <monnier@HIDDEN>
> >> Cc: Mike Kupfer <kupfer@HIDDEN>,  78916 <at> debbugs.gnu.org
> >> Date: Mon, 30 Jun 2025 12:01:02 -0400
> >> 
> >> >> > - Both keys behave like the "old C-g".
> >> >> > ?
> >> >> I'm fine with that.
> >> > Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
> >> > the difference between them?
> >> 
> >> Hmm... so `q` is bound to `exit` which consumes the key and exits the
> >> Q&R loop.  In contrast `C-g` and `C-]` were bound to `quit` which is
> >> not handled exlicitly by the Q&R loop, instead it just pushes the event
> >> back on the `unread-commend-events` before exiting the loop, so in
> >> Mike's test case, `q` exits the inner Q&R and passes to the next,
> >> whereas `C-]` aborts all the subsequent Q&R calls after which it runs
> >> the global binding of `C-[`.
> >
> > I think I understand what you are saying about the difference between
> > 'q' and 'C-g', but I don't see any nested query-replace in Mike's test
> > case, or what did I miss?  Or maybe I misunderstood what you mean by
> > "the next"?
> 
> His Q&R call is inside a loop:
> 
>          (while (re-search-forward "bug#[[:digit:]]+:" nil t)
>            (search-backward "(\"bug")
>            (let (end (start (point)))
>              (forward-sexp)
>              (setq end (point))
>              (query-replace-regexp "\\(\"bug#[[:digit:]]+:\\).*\"" "\\1\""
>              		    nil start end))))
> 
> so when we exit one we enter the next (as long as there's another match
> for the main regexp, that is).

OK, but then the issue here is not about query-replace-regexp at all,
isn't it?  It's about whether C-g is "re-read" after exiting
query-replace-regexp, and when it is re-read, does it quit.  Or am I
missing something?

> > In any case, this difference between 'q' and 'C-g' is not explained in
> > the user manual.  The manual uses different wording to describe them,
> > but my interpretation of the text is that they have the same effect.
> 
> So in effect we've had 3 "identical" yet subtly different behaviors for
> years:
> 
> - The behavior of `q`: exit the Q&R and continue with whatever may follow.
> - The behavior of `C-]`: exit the Q&R and also continue with whatever
>   may follow, but without consuming the `C-]` so next time we read a key
>   we'll get this `C-]`.
> - The old behavior of `C-g` (which we definitely want to recover): abort
>   the current command.

If C-g is not consumed, it will produce the expected effect, right?
If so, the problem seems to be that this is what's expected here, and
it happened in the past because C-g would quite right away, so there
was no need to re-read it.  Right?




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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 20:15:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 16:15:33 2025
Received: from localhost ([127.0.0.1]:49433 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWKua-0000Xg-Qq
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 16:15:33 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12689)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uWKuW-0000WK-0B
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 16:15:30 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7EDD410013E;
 Mon, 30 Jun 2025 16:15:22 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751314521;
 bh=L3gmMnjAIKPIhtKVY73JZqn8oXgF81Y9oHx/o+mLyCM=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=Tvh4dB5ApLZ2uYq7OLh4Na9nMCZ3epxUU+MxAhb4jk2mRjk/lPeYFK090hXbUZ2UI
 rmo6odKFYRz82wPKNEztjksS2eM6m2jSAmEyyCU58PYUH5bl4Xdy0WUYgJTYqh7tbF
 Z1oluyV3YrLGnsTYQ9GxtCLI+/zw7cw/V6iw61Tr0HTxmeUvbM3oX3znIn6+Ps7Ywc
 Sf4vOp70Ap4vCtnEX4KygZSDNHG4f59Gb4GsKZH+Q/TZqw0yHh9YB11306axr0fsCF
 Pmrgo7Lx8Y4uJOfokzRC1hHVnTdPErv3bNxynx0fv7Xg8OCzX/BrWLPtgsVWdO7fPi
 RfFNtglhRJAYg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7772310002E;
 Mon, 30 Jun 2025 16:15:21 -0400 (EDT)
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 63AA612045B;
 Mon, 30 Jun 2025 16:15:21 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <86wm8t2gy5.fsf@HIDDEN>
Message-ID: <jwvms9povsf.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <86wm8t2gy5.fsf@HIDDEN>
Date: Mon, 30 Jun 2025 16:15:17 -0400
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.096 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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.1 (---)

Eli Zaretskii [2025-06-30 22:00:02] wrote:

>> From: Stefan Monnier <monnier@HIDDEN>
>> Cc: Mike Kupfer <kupfer@HIDDEN>,  78916 <at> debbugs.gnu.org
>> Date: Mon, 30 Jun 2025 12:01:02 -0400
>> 
>> >> > - Both keys behave like the "old C-g".
>> >> > ?
>> >> I'm fine with that.
>> > Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
>> > the difference between them?
>> 
>> Hmm... so `q` is bound to `exit` which consumes the key and exits the
>> Q&R loop.  In contrast `C-g` and `C-]` were bound to `quit` which is
>> not handled exlicitly by the Q&R loop, instead it just pushes the event
>> back on the `unread-commend-events` before exiting the loop, so in
>> Mike's test case, `q` exits the inner Q&R and passes to the next,
>> whereas `C-]` aborts all the subsequent Q&R calls after which it runs
>> the global binding of `C-[`.
>
> I think I understand what you are saying about the difference between
> 'q' and 'C-g', but I don't see any nested query-replace in Mike's test
> case, or what did I miss?  Or maybe I misunderstood what you mean by
> "the next"?

His Q&R call is inside a loop:

         (while (re-search-forward "bug#[[:digit:]]+:" nil t)
           (search-backward "(\"bug")
           (let (end (start (point)))
             (forward-sexp)
             (setq end (point))
             (query-replace-regexp "\\(\"bug#[[:digit:]]+:\\).*\"" "\\1\""
             		    nil start end))))

so when we exit one we enter the next (as long as there's another match
for the main regexp, that is).

> In practice, typing 'q' stops query-replace and leaves point at the
> last match where Emacs asked me whether to replace.  And 'C-g' does
> the same, AFAICT.
> If I'm right, then what would be an example where 'q' and 'C-g' would
> behave differently?

`C-g` (and `C-]`) behave just like "`q` followed by C-g/C-]".
Usually hitting C-g or C-] right after `q` has no effect, which is why
they are often perceived as doing the same, but in the above loop the
difference becomes more significant.

> In any case, this difference between 'q' and 'C-g' is not explained in
> the user manual.  The manual uses different wording to describe them,
> but my interpretation of the text is that they have the same effect.

So in effect we've had 3 "identical" yet subtly different behaviors for
years:

- The behavior of `q`: exit the Q&R and continue with whatever may follow.
- The behavior of `C-]`: exit the Q&R and also continue with whatever
  may follow, but without consuming the `C-]` so next time we read a key
  we'll get this `C-]`.
- The old behavior of `C-g` (which we definitely want to recover): abort
  the current command.


        Stefan





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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 19:41:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 15:41:01 2025
Received: from localhost ([127.0.0.1]:48984 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWKN7-0004HR-LF
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 15:41:00 -0400
Received: from mail-10630.protonmail.ch ([79.135.106.30]:53357)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1uWKN3-0004Gd-Tz
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 15:40:56 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1751312447; x=1751571647;
 bh=oBbqjLCNxllQxtVCVZsru1r2wLwP3NWxV7xu63UApYc=;
 h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=qKzcKc1ntRbZDtohvFnS7WTowefJdBjDHQhtE30WdkqwGgh044XjYKFEK794wR7Wx
 bz1169e2SG6JE77i5tKX9ZhLy8AHS4K02cHix2lvkyiTTwXMHI5AqCXHv1F+FsEaxP
 u/fL2TvxOy8ifQpLh2yLUqnyDoDc2byVkRviM8H4a+OSrNt3R/S0PREVc3KCvJNXUj
 Iabz3BVSdCPjxFmmcCnEwfGRgGzLBx65vXt6WquO3/YqU+tdkQT3/F1+U5FV1l1zBW
 /iDwJUL084g0cIiEQORrg/rde9t6VUMmoF1ywBdz8Ok4DsD49+NFRgQa4MwE168vOF
 LkO6loleyRo7A==
Date: Mon, 30 Jun 2025 19:40:43 +0000
To: Eli Zaretskii <eliz@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
Message-ID: <87v7odxbk8.fsf@HIDDEN>
In-Reply-To: <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN> <34220.1751153312@HIDDEN>
 <86a55r5dv2.fsf@HIDDEN> <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 2f8a5f9b22df4b250bbb26bff48845f4584cdf8c
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>,
 Mike Kupfer <kupfer@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.8 (/)

Pip Cet <pipcet@HIDDEN> writes:

> "Stefan Monnier via \"Bug reports for GNU Emacs, the Swiss army knife of =
text editors\"" <bug-gnu-emacs@HIDDEN> writes:
>
>>>> > - Both keys behave like the "old C-g".
>>>> > ?
>>>> I'm fine with that.
>>> Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
>>> the difference between them?
>>
>> Hmm... so `q` is bound to `exit` which consumes the key and exits the
>> Q&R loop.  In contrast `C-g` and `C-]` were bound to `quit` which is
>> not handled exlicitly by the Q&R loop, instead it just pushes the event
>> back on the `unread-commend-events` before exiting the loop, so in
>> Mike's test case, `q` exits the inner Q&R and passes to the next,
>> whereas `C-]` aborts all the subsequent Q&R calls after which it runs
>> the global binding of `C-[`.
>
>> I get the impression that the intention of the `replace.el` code when it
>> pushes the event back on `unread-commend-events` is to make it run
>> whichever binding is currently active "outside" (i.e. global or local
>> keymap).
>>
>> IOW, we have many different ways to skin this cat and I'm not sure which
>> is best.
>
> I'd just like to speak out in favor of making read-key take an extra
> argument to make it handle C-g the way read-event does; IIUC, the lack
> of this argument is the real problem here.  If we don't, we should be
> very careful about replacing read-event by read-key, and revert most
> such changes.

This patch (which doesn't include documentation changes yet) would make

    (read-key prompt nil t)

DTRT, I think.  I've looked at a few callers of read-key and they should
probably pass t as the can-quit argument, too, because most of them want
to quit for C-g and try to do so, with varying degrees of success.

I've yet to verify this fixes the original F-key issue which prompted
the change to read-key in the first place.  It does appear to fix the
buggy behavior observed by the OP.

From dd850c5da3591e00dfd2fe1dd3e6d901a53e7176 Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@HIDDEN>
Subject: [PATCH 1/3] Add optional 'can-quit' argument to 'read-key'
 (bug#78916)

* lisp/subr.el (read-key): Add 'can-quit' argument and pass it on.
* src/callint.c (Fcall_interactively):
* src/keyboard.c (command_loop_1):
(read_menu_command): Adjust accordingly.
(read_key_sequence): Quit after read_char if can_quit is set.
(read_key_sequence_vs):
(Fread_key_sequence):
(Fread_key_sequence_vector): Add extra argument.
---
 lisp/subr.el   |  5 +++--
 src/callint.c  |  4 ++--
 src/keyboard.c | 32 ++++++++++++++++++++------------
 3 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index 69f6e4dbab8..b06d45d449f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3425,7 +3425,7 @@ read-key-full-map
=20
 (defvar read-key-delay 0.01) ;Fast enough for 100Hz repeat rate, hopefully=
.
=20
-(defun read-key (&optional prompt disable-fallbacks)
+(defun read-key (&optional prompt disable-fallbacks can-quit)
   "Read a key from the keyboard, return the event thus read.
 Contrary to `read-event' this will not return a raw event but instead will
 obey the input decoding and translations usually done by `read-key-sequenc=
e'.
@@ -3505,7 +3505,8 @@ read-key
              map))
           (let* ((keys
                   (catch 'read-key (read-key-sequence-vector prompt nil t
-                                                             nil nil t)))
+                                                             nil nil t
+                                                             can-quit)))
                  (key (aref keys 0)))
             (if (and (> (length keys) 1)
                      (memq key '(mode-line header-line tab-line
diff --git a/src/callint.c b/src/callint.c
index e0246e5d594..38ffa8804d3 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -538,7 +538,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall=
_interactively, 1, 3, 0,
 =09=09=09=09Qface, Qminibuffer_prompt, callint_message);
 =09    args[i] =3D Fread_key_sequence (callint_message,
 =09=09=09=09=09  Qnil, Qnil, Qnil, Qnil,
-=09=09=09=09=09  Qnil);
+=09=09=09=09=09  Qnil, Qnil);
 =09    unbind_to (speccount1, Qnil);
 =09    visargs[i] =3D Fkey_description (args[i], Qnil);
=20
@@ -569,7 +569,7 @@ DEFUN ("call-interactively", Fcall_interactively, Scall=
_interactively, 1, 3, 0,
 =09=09=09=09Qface, Qminibuffer_prompt, callint_message);
 =09    args[i] =3D Fread_key_sequence_vector (callint_message,
 =09=09=09=09=09=09 Qnil, Qt, Qnil, Qnil,
-=09=09=09=09=09=09 Qnil);
+=09=09=09=09=09=09 Qnil, Qnil);
 =09    visargs[i] =3D Fkey_description (args[i], Qnil);
 =09    unbind_to (speccount1, Qnil);
=20
diff --git a/src/keyboard.c b/src/keyboard.c
index 8b2ebd215d2..93149910fa7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1311,7 +1311,7 @@ some_mouse_moved (void)
=20
 enum { READ_KEY_ELTS =3D 30 };
 static int read_key_sequence (Lisp_Object *, Lisp_Object,
-                              bool, bool, bool, bool, bool);
+                              bool, bool, bool, bool, bool, bool);
 static void adjust_point_for_property (ptrdiff_t, bool);
=20
 static Lisp_Object
@@ -1422,7 +1422,7 @@ command_loop_1 (void)
       raw_keybuf_count =3D 0;
       Lisp_Object keybuf[READ_KEY_ELTS];
       int i =3D read_key_sequence (keybuf, Qnil, false, true, true, false,
-=09=09=09=09 false);
+=09=09=09=09 false, false);
=20
       /* A filter may have run while we were reading the input.  */
       if (! FRAME_LIVE_P (XFRAME (selected_frame)))
@@ -1698,7 +1698,7 @@ read_menu_command (void)
=20
   Lisp_Object keybuf[READ_KEY_ELTS];
   int i =3D read_key_sequence (keybuf, Qnil, false, true, true, true,
-=09=09=09     false);
+=09=09=09     false, false);
=20
   unbind_to (count, Qnil);
=20
@@ -10544,7 +10544,7 @@ restore_reading_key_sequence (int old_reading_key_s=
equence)
 read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
 =09=09   bool dont_downcase_last, bool can_return_switch_frame,
 =09=09   bool fix_current_buffer, bool prevent_redisplay,
-=09=09   bool disable_text_conversion_p)
+=09=09   bool disable_text_conversion_p, bool can_quit)
 {
   specpdl_ref count =3D SPECPDL_INDEX ();
=20
@@ -10867,6 +10867,11 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Objec=
t prompt,
 =09    key =3D read_char (prevent_redisplay ? -2 : NILP (prompt),
 =09=09             current_binding, last_nonmenu_event,
                              &used_mouse_menu, NULL);
+=09    if (can_quit && EQ (key, make_fixnum (quit_char)))
+=09      {
+=09=09Vquit_flag =3D Qt;
+=09=09maybe_quit ();
+=09      }
 =09    used_mouse_menu_history[t] =3D used_mouse_menu;
 =09    if ((FIXNUMP (key) && XFIXNUM (key) =3D=3D -2) /* wrong_kboard_jmpb=
uf */
 =09=09/* When switching to a new tty (with a new keyboard),
@@ -11546,7 +11551,8 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Obje=
ct continue_echo,
 =09=09      Lisp_Object dont_downcase_last,
 =09=09      Lisp_Object can_return_switch_frame,
 =09=09      Lisp_Object cmd_loop, bool allow_string,
-=09=09      bool disable_text_conversion)
+=09=09      bool disable_text_conversion,
+=09=09      bool can_quit)
 {
   specpdl_ref count =3D SPECPDL_INDEX ();
=20
@@ -11574,7 +11580,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Obje=
ct continue_echo,
   Lisp_Object keybuf[READ_KEY_ELTS];
   int i =3D read_key_sequence (keybuf, prompt, ! NILP (dont_downcase_last)=
,
 =09=09=09     ! NILP (can_return_switch_frame), false, false,
-=09=09=09     disable_text_conversion);
+=09=09=09     disable_text_conversion, can_quit);
=20
 #if 0  /* The following is fine for code reading a key sequence and
 =09  then proceeding with a lengthy computation, but it's not good
@@ -11596,7 +11602,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Obje=
ct continue_echo,
 =09=09     (i, keybuf)));
 }
=20
-DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 6, =
0,
+DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 7, =
0,
        doc: /* Read a sequence of keystrokes and return as a string or vec=
tor.
 The sequence is sufficient to specify a non-prefix command in the
 current local and global maps.
@@ -11650,23 +11656,25 @@ Second (optional) arg CONTINUE-ECHO, if non-nil, =
means this key echos
 being sent.  */)
   (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcas=
e_last,
    Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop,
-   Lisp_Object disable_text_conversion)
+   Lisp_Object disable_text_conversion, Lisp_Object can_quit)
 {
   return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
 =09=09=09       can_return_switch_frame, cmd_loop, true,
-=09=09=09       !NILP (disable_text_conversion));
+=09=09=09       !NILP (disable_text_conversion),
+=09=09=09       !NILP (can_quit));
 }
=20
 DEFUN ("read-key-sequence-vector", Fread_key_sequence_vector,
-       Sread_key_sequence_vector, 1, 6, 0,
+       Sread_key_sequence_vector, 1, 7, 0,
        doc: /* Like `read-key-sequence' but always return a vector.  */)
   (Lisp_Object prompt, Lisp_Object continue_echo, Lisp_Object dont_downcas=
e_last,
    Lisp_Object can_return_switch_frame, Lisp_Object cmd_loop,
-   Lisp_Object disable_text_conversion)
+   Lisp_Object disable_text_conversion, Lisp_Object can_quit)
 {
   return read_key_sequence_vs (prompt, continue_echo, dont_downcase_last,
 =09=09=09       can_return_switch_frame, cmd_loop, false,
-=09=09=09       !NILP (disable_text_conversion));
+=09=09=09       !NILP (disable_text_conversion),
+=09=09=09       !NILP (can_quit));
 }
 =0C
 /* Return true if input events are pending.  */
--=20
2.50.0

From 395ec08d4f5d31f2d6d6022fb40c4c90d44b8aeb Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@HIDDEN>
Subject: [PATCH 2/3] Make C-g quit again in perform-replace (bug#78916)

* lisp/replace.el (perform-replace): Pass 't' as 'can-quit' argument
to 'read-key'.
---
 lisp/replace.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/replace.el b/lisp/replace.el
index 9939273594f..1d115949599 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -3103,7 +3103,7 @@ perform-replace
                                    replacement-presentation))))
                     ;; Use `read-key' so that escape sequences on TTYs
                     ;; are properly mapped back to the intended key.
-=09=09    (setq key (read-key prompt)))
+=09=09    (setq key (read-key prompt nil t)))
 =09=09  ;; Necessary in case something happens during
 =09=09  ;; read-event that clobbers the match data.
 =09=09  (set-match-data real-match-data)
--=20
2.50.0





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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 19:14:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 15:14:32 2025
Received: from localhost ([127.0.0.1]:48634 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWJxY-0000hm-2J
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 15:14:32 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:40668)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uWJxT-0000gM-Bv
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 15:14:29 -0400
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 1uWJxM-0001XN-B1; Mon, 30 Jun 2025 15:14:21 -0400
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=Ei18USTmb+kx1oFgQInt1eOBvQ9UVOqW3EjXZHU/7/8=; b=kFYrU7KLfq7X
 mzU0zuLprylLtSEF86GBkwvlcJVrFKw6UJgn5m8ORqNKcRaN7+3JlOEKFnCtcDswEKhd65o1WSczV
 X1uInWehBsEfj7EFpbVgGhoPhxIcJgn7gqK64HWujB2YV4rGPiBiILUM1Rpo2qtW+/jKF10oiI8rs
 r3IHxXl34Unh5Pp6R/7MuXXe8DoSRbha/n19ninVzTs2DlmITwW9WLRC4Z9g8juYu+JESpkt22CWT
 k7TotcmnSLUPXP7Z1WhE23GGs0tWJoCZHIuq15kxKTZuqdo6FwRS11WJ2x++YFb4tllPFXuP9zaRx
 POcjiEjapXVURZrwFTA4mw==;
Date: Mon, 30 Jun 2025 22:14:17 +0300
Message-Id: <86qzz12gae.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Pip Cet <pipcet@HIDDEN>
In-Reply-To: <871pr1yu2g.fsf@HIDDEN> (message from Pip Cet on Mon, 30
 Jun 2025 18:15:40 +0000)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN> <34220.1751153312@HIDDEN>
 <86a55r5dv2.fsf@HIDDEN> <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> <871pr1yu2g.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, monnier@HIDDEN, kupfer@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 (---)

> Date: Mon, 30 Jun 2025 18:15:40 +0000
> From: Pip Cet <pipcet@HIDDEN>
> 
> (I still think it would be easiest to give up on a single C-g signaling
> a quit; if we move to requiring two C-g's, both of which are ordinary
> input up to the point where the second one triggers a quit, all the
> special cases go away.)

IMO, we will be lynched if we make such a change in Emacs.




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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 19:00:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 15:00:19 2025
Received: from localhost ([127.0.0.1]:48432 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWJjl-0007HR-7c
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 15:00:19 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:58314)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uWJjf-0007D5-6C
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 15:00:13 -0400
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 1uWJjY-0008RR-Tt; Mon, 30 Jun 2025 15:00:04 -0400
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=ZssOs3L7BTRHq7lWHIzsoXobiHfIG9bL64cQSjcXvy4=; b=YY+wBbe1MTK7
 2VeGHc9g6jILDcu70iJD5xUYn+JKTyS8rp+ffl32rJRvA/h72deJp0pQw9pkk0VUS3b3YML5eEFhp
 WKXRc6Ma6N2eqqOo1bou5aLRPHNxp/4ye2B4exG4NgYy7Cf73HTLhQPY3wZnfkt1TEOKIMM6i4o3U
 2WT5K39XaBSWFxNy3tP+Wxzap3ojPja5VJ8i4t1Ro4GH9kflk5jO2uplNiZyAuvrMcLTNjqRMoINW
 44qB9czRM8z73F3dq/GX4+7dCdrZLsf6xlvCKo/MXO2Bph1TJdVsEYQkSgsu76fKfBV0aC29wkiKC
 sVKFIxcrEoTafxnLydTeNg==;
Date: Mon, 30 Jun 2025 22:00:02 +0300
Message-Id: <86wm8t2gy5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Mon, 30 Jun 2025 12:01:02 -0400)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, kupfer@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: Mike Kupfer <kupfer@HIDDEN>,  78916 <at> debbugs.gnu.org
> Date: Mon, 30 Jun 2025 12:01:02 -0400
> 
> >> > - Both keys behave like the "old C-g".
> >> > ?
> >> I'm fine with that.
> > Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
> > the difference between them?
> 
> Hmm... so `q` is bound to `exit` which consumes the key and exits the
> Q&R loop.  In contrast `C-g` and `C-]` were bound to `quit` which is
> not handled exlicitly by the Q&R loop, instead it just pushes the event
> back on the `unread-commend-events` before exiting the loop, so in
> Mike's test case, `q` exits the inner Q&R and passes to the next,
> whereas `C-]` aborts all the subsequent Q&R calls after which it runs
> the global binding of `C-[`.

I think I understand what you are saying about the difference between
'q' and 'C-g', but I don't see any nested query-replace in Mike's test
case, or what did I miss?  Or maybe I misunderstood what you mean by
"the next"?

In practice, typing 'q' stops query-replace and leaves point at the
last match where Emacs asked me whether to replace.  And 'C-g' does
the same, AFAICT.

If I'm right, then what would be an example where 'q' and 'C-g' would
behave differently?

In any case, this difference between 'q' and 'C-g' is not explained in
the user manual.  The manual uses different wording to describe them,
but my interpretation of the text is that they have the same effect.




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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 18:15:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 14:15:58 2025
Received: from localhost ([127.0.0.1]:47849 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWJ2q-0001P9-4t
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 14:15:58 -0400
Received: from mail-24416.protonmail.ch ([109.224.244.16]:57751)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <pipcet@HIDDEN>)
 id 1uWJ2l-0001NE-7J
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 14:15:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail3; t=1751307343; x=1751566543;
 bh=uUyvMDU57u1ah2lCJVEuwVDUAauOsxN60HcUFDDT9jU=;
 h=Date:To:From:Subject:Message-ID:In-Reply-To:References:
 Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
 Message-ID:BIMI-Selector;
 b=PcYvlTebaDReVFI6sj48XL5fbniid+V8qskOJpUyOtscM6ctV7KBpyjsNbWf+wS0M
 PZ+U++ocrOK++PzDGlUYbLgGCn7A1fUaTqY6/muLTWG73Q6ujb0BEr0TmZmZcklXTy
 yIQxqH3ATo+Si7e1qkhurypEMR1UBV/psc47vyT14kIxI4Q/1SVBq8VTfiOFWhEmim
 woLQHNTNmrIDUV4CNm1OT4cTTH1CCPQjOz6kokmtH0KB5hXsqyRraKBRRq5CfGT9vN
 t1uEwZQy7XIidRxMpZmDlApo3MscWJm/y9KSvro/eSGTWiZ7Zkwx2vRf8cXuKOjI/b
 ArkjOXDTO1lTw==
Date: Mon, 30 Jun 2025 18:15:40 +0000
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>,
 78916 <at> debbugs.gnu.org, Mike Kupfer <kupfer@HIDDEN>
From: Pip Cet <pipcet@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
Message-ID: <871pr1yu2g.fsf@HIDDEN>
In-Reply-To: <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN> <34220.1751153312@HIDDEN>
 <86a55r5dv2.fsf@HIDDEN> <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
 <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN>
Feedback-ID: 112775352:user:proton
X-Pm-Message-ID: 95ce1d1160d30718843405320f947cf8561d5adf
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 78916
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.8 (/)

"Stefan Monnier via \"Bug reports for GNU Emacs, the Swiss army knife of te=
xt editors\"" <bug-gnu-emacs@HIDDEN> writes:

>>> > - Both keys behave like the "old C-g".
>>> > ?
>>> I'm fine with that.
>> Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
>> the difference between them?
>
> Hmm... so `q` is bound to `exit` which consumes the key and exits the
> Q&R loop.  In contrast `C-g` and `C-]` were bound to `quit` which is
> not handled exlicitly by the Q&R loop, instead it just pushes the event
> back on the `unread-commend-events` before exiting the loop, so in
> Mike's test case, `q` exits the inner Q&R and passes to the next,
> whereas `C-]` aborts all the subsequent Q&R calls after which it runs
> the global binding of `C-[`.

> I get the impression that the intention of the `replace.el` code when it
> pushes the event back on `unread-commend-events` is to make it run
> whichever binding is currently active "outside" (i.e. global or local
> keymap).
>
> IOW, we have many different ways to skin this cat and I'm not sure which
> is best.

I'd just like to speak out in favor of making read-key take an extra
argument to make it handle C-g the way read-event does; IIUC, the lack
of this argument is the real problem here.  If we don't, we should be
very careful about replacing read-event by read-key, and revert most
such changes.

Switching from read-event to read-key should be possible without the
(sometimes) undesirable change in C-g behavior.  That doesn't mean we
can't change the C-g/quit relationship at some future point; there's no
consensus to change behavior now (not even to make C-g and C-] the
same), so we shouldn't.

(I still think it would be easiest to give up on a single C-g signaling
a quit; if we move to requiring two C-g's, both of which are ordinary
input up to the point where the second one triggers a quit, all the
special cases go away.)

Pip





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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 16:01:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 12:01:21 2025
Received: from localhost ([127.0.0.1]:46002 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWGwZ-0001Kr-Oz
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 12:01:20 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54554)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uWGwV-0001JN-ME
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 12:01:17 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 14BDE100374;
 Mon, 30 Jun 2025 12:01:10 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751299263;
 bh=Lt9FSt4WV4V8HYdVG2Ehsbfjow1gOVMyhH4v/VHes5U=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=ClsxMObrNx3F0SzyDASS9Zm9nUSbUu/LawV8eOqaprbG4qkkKe0Vahkly3+00Tayp
 Xxwgd3gdB+DAvC2h2rZA25T5uuaRLJ+KeuHQZ/tunjbjyYfSCkXz3/qnh4SsL/sCcZ
 P3jJWNKm+7s2tUkxO1U3c0aV9GMPtByTUSn0pHnlDeaMO0XZbGeAObo4HU2QY29ZgH
 zhsJOVqH41jhFFPuz2ugYKBW2ad5TiNfVkR4jcpAHd4Rv/h1mx6ge8zPFs48hByd/d
 8GF+p0Z+pa2bctePoQTWAgWuNFTwqzF1DopgbnIo75s24K/FHC7nIfvL0640pRJ2ba
 WTCHmToTcrBQA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5F40610013E;
 Mon, 30 Jun 2025 12:01:03 -0400 (EDT)
Received: from alfajor (bras-base-mtrlpq42zf4-grc-26-174-93-231-66.dsl.bell.ca
 [174.93.231.66])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4A52212008F;
 Mon, 30 Jun 2025 12:01:03 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <86o6u54emc.fsf@HIDDEN>
Message-ID: <jwvfrfh6xl4.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
 <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN> <86o6u54emc.fsf@HIDDEN>
Date: Mon, 30 Jun 2025 12:01:02 -0400
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
 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, Mike Kupfer <kupfer@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.1 (---)

>> > - Both keys behave like the "old C-g".
>> > ?
>> I'm fine with that.
> Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
> the difference between them?

Hmm... so `q` is bound to `exit` which consumes the key and exits the
Q&R loop.  In contrast `C-g` and `C-]` were bound to `quit` which is
not handled exlicitly by the Q&R loop, instead it just pushes the event
back on the `unread-commend-events` before exiting the loop, so in
Mike's test case, `q` exits the inner Q&R and passes to the next,
whereas `C-]` aborts all the subsequent Q&R calls after which it runs
the global binding of `C-[`.

I get the impression that the intention of the `replace.el` code when it
pushes the event back on `unread-commend-events` is to make it run
whichever binding is currently active "outside" (i.e. global or local
keymap).

IOW, we have many different ways to skin this cat and I'm not sure which
is best.  We can do something like:

    @@ -2491,7 +2491,7 @@ query-replace-map
         (define-key map [f1] 'help)
         (define-key map [help] 'help)
         (define-key map "?" 'help)
    -    (define-key map "\C-g" 'quit)
    -    (define-key map "\C-]" 'quit)
    +    (define-key map "\C-g" #'keyboard-quit)
    +    (define-key map "\C-]" #'keyboard-quit)
         (define-key map "\C-v" 'scroll-up)
         (define-key map "\M-v" 'scroll-down)

or we can do something like:

    @@ -3328,6 +3328,9 @@ perform-replace
     			 (replace-dehighlight)
     			 (save-excursion (recursive-edit))
     			 (setq replaced t))
    +			((eq def 'quit)
    +			 ;; FIXME: Should we call `keyboard-quit'?
    +			 (signal 'quit nil))
                             ((commandp def t)
                              (call-interactively def))
     			;; Note: we do not need to treat `exit-prefix'

or we can do something like:

    diff --git a/lisp/replace.el b/lisp/replace.el
    index 9939273594f..62cabb45c09 100644
    --- a/lisp/replace.el
    +++ b/lisp/replace.el
    @@ -2491,7 +2491,7 @@ query-replace-map
         (define-key map [f1] 'help)
         (define-key map [help] 'help)
         (define-key map "?" 'help)
    -    (define-key map "\C-g" 'quit)
    -    (define-key map "\C-]" 'quit)
    +    (define-key map "\C-g" 'normal-binding)
    +    (define-key map "\C-]" 'normal-binding)
         (define-key map "\C-]" 'quit)
         (define-key map "\C-v" 'scroll-up)
         (define-key map "\M-v" 'scroll-down)
    @@ -3328,6 +3328,12 @@ perform-replace
     			 (replace-dehighlight)
     			 (save-excursion (recursive-edit))
     			 (setq replaced t))
    +			((eq def 'normal-binding)
    +			 (let ((cmd (key-binding (vector key))))
    +			   (setq this-command cmd)
    +			   (setq keep-going nil)
    +			   (setq done t)
    +			   (execute-command cmd)))
                             ((commandp def t)
                              (call-interactively def))
     			;; Note: we do not need to treat `exit-prefix'

I lean towards the first option.


        Stefan





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

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


Received: (at 78916) by debbugs.gnu.org; 30 Jun 2025 12:07:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 30 08:07:39 2025
Received: from localhost ([127.0.0.1]:41863 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uWDIQ-0004Nx-SV
	for submit <at> debbugs.gnu.org; Mon, 30 Jun 2025 08:07:39 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:53236)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uWDIN-0004N2-LA
 for 78916 <at> debbugs.gnu.org; Mon, 30 Jun 2025 08:07:36 -0400
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 1uWDIG-0001iQ-LU; Mon, 30 Jun 2025 08:07:28 -0400
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=w1w4cq0WpjTAlxuox/nulR8md6RyPmcRBNJ5oKbfloY=; b=YUVZsrMp9cZ4
 sGOPbn/4ol2r4LoOaXweo0FtEn/hfh0SiYpr8QoKRcefrYZm82xIBEVq83Npg0YIKsfaXgvKXPL/b
 HDH8yrcvfffq1T9/d7VmDGzEeuvNCS9FxWGXIQt8hF1YYXOVDlMTZ4fRm+j6Nzp7kMzNGu2bl+XwJ
 s0cNkgu/rGezK7pVda8Plt5wAP7Yp8VUax0V9dTNYlgQ/KU8nWycFe6tPa+Ag5xeszPuCSgljU0zK
 VR7bSRxSDA8WFAoPBOF7sptrWSgSj86o7daKjpb5l8sN1O4mcxtTkUTc/N4xtwHAJxDtKvdDFWRs7
 SVbj5h5UUrNye93vLA7gcw==;
Date: Mon, 30 Jun 2025 15:07:23 +0300
Message-Id: <86o6u54emc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Mike Kupfer <kupfer@HIDDEN>
In-Reply-To: <19433.1751218460@HIDDEN> (message from Mike Kupfer on
 Sun, 29 Jun 2025 10:34:20 -0700)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN> <34220.1751153312@HIDDEN>
 <86a55r5dv2.fsf@HIDDEN> <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
 <19433.1751218460@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <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: Mike Kupfer <kupfer@HIDDEN>
> cc: Eli Zaretskii <eliz@HIDDEN>, 78916 <at> debbugs.gnu.org
> Comments: In-reply-to Stefan Monnier <monnier@HIDDEN>
>    message dated "Sun, 29 Jun 2025 12:17:20 -0400."
> Date: Sun, 29 Jun 2025 10:34:20 -0700
> 
> Stefan Monnier wrote:
> 
> > So IIUC the consensus is:
> > 
> > - Both keys behave like the "old C-g".
> > 
> > ?
> 
> I'm fine with that.

Same, but does it mean 'C-g' will do the same as 'q'?  If not, what is
the difference between them?




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

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


Received: (at 78916) by debbugs.gnu.org; 29 Jun 2025 17:34:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 29 13:34:35 2025
Received: from localhost ([127.0.0.1]:58790 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVvvH-0007U0-4U
	for submit <at> debbugs.gnu.org; Sun, 29 Jun 2025 13:34:35 -0400
Received: from shell1.rawbw.com ([198.144.192.42]:65389 ident=root)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kupfer@HIDDEN>) id 1uVvv9-0007Sh-AM
 for 78916 <at> debbugs.gnu.org; Sun, 29 Jun 2025 13:34:33 -0400
Received: from bach.localdomain (135-180-175-182.dsl.dynamic.sonic.net
 [135.180.175.182] (may be forged)) (authenticated bits=0)
 by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 55THYKHB016280
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Sun, 29 Jun 2025 10:34:25 -0700 (PDT)
 (envelope-from kupfer@HIDDEN)
X-Authentication-Warning: shell1.rawbw.com: Host
 135-180-175-182.dsl.dynamic.sonic.net [135.180.175.182] (may be forged)
 claimed to be bach.localdomain
From: Mike Kupfer <kupfer@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-reply-to: <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN> <34220.1751153312@HIDDEN>
 <86a55r5dv2.fsf@HIDDEN> <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
Comments: In-reply-to Stefan Monnier <monnier@HIDDEN>
 message dated "Sun, 29 Jun 2025 12:17:20 -0400."
X-Mailer: MH-E 8.6+git; nmh 1.8-RC2; Emacs 31.0.50
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <19432.1751218460.1@HIDDEN>
Date: Sun, 29 Jun 2025 10:34:20 -0700
Message-ID: <19433.1751218460@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, Eli Zaretskii <eliz@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 (-)

Stefan Monnier wrote:

> So IIUC the consensus is:
> 
> - Both keys behave like the "old C-g".
> 
> ?

I'm fine with that.

mike




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

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


Received: (at 78916) by debbugs.gnu.org; 29 Jun 2025 16:17:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 29 12:17:35 2025
Received: from localhost ([127.0.0.1]:58357 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVuij-0003Rb-Ut
	for submit <at> debbugs.gnu.org; Sun, 29 Jun 2025 12:17:35 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58461)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uVuih-0003QM-OK
 for 78916 <at> debbugs.gnu.org; Sun, 29 Jun 2025 12:17:32 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id ED738440945;
 Sun, 29 Jun 2025 12:17:25 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751213840;
 bh=9NIfABBTcH7Hl2oTNI7HwPAyYZKAhkPXhjWbEQlGo0I=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=ZwKOFlwAP/WSL8AaS5Wdam2zeYQA9bOuW62vRZBoTUN8JHnJql5Iz86H4PZg3lTp2
 SP4gs4WfMUBNM4U8FO/cansa3mW7kqaF1/Q1UO/3NNWiuJAYXSKthW4AASUvM1tWaX
 4nOd8HVedj5etSEoxk9RbeAs9AbttK7apXKvb10Zx47irOpiOZeDVrw4/Y8W17JHZa
 aB+pNVgmUjN4tRKviwj5WTE1fFDmJ9ID/AYzpsKgHe58GkZNboXWJMcGGp3lrQ0ZR7
 NvP9d9r1pW+TeaKhSBBy3dv/CXf+G1YdxNByyCHQLc/De+LXpURrZEqVoVivLHKPLk
 0x9yXTF3hC6og==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D944744018C;
 Sun, 29 Jun 2025 12:17:20 -0400 (EDT)
Received: from pastel (unknown [104.247.225.139])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id ACCC112089B;
 Sun, 29 Jun 2025 12:17:20 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <86a55r5dv2.fsf@HIDDEN>
Message-ID: <jwvo6u6ldzg.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
 <34220.1751153312@HIDDEN> <86a55r5dv2.fsf@HIDDEN>
Date: Sun, 29 Jun 2025 12:17:20 -0400
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.289 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <at> debbugs.gnu.org, Mike Kupfer <kupfer@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 (---)

>> > So what do we want:
>> > 
>> > - Both keys behave like the "old C-g".
>> > - Both keys behave like the "old C-]" (i.e. what we have now).
>> > - Reintroduce the difference of behavior between `C-g` and `C-]`,
>> >   presumably by giving them different bindings in `query-replace-map.
>> 
>> Is there a use case for the current behavior?  I definitely want to have
>> the "old C-g" behavior available.  I think it makes sense for C-g to
>> provide that behavior.
>
> Agreed.

So IIUC the consensus is:

- Both keys behave like the "old C-g".

?


        Stefan





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

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


Received: (at 78916) by debbugs.gnu.org; 29 Jun 2025 05:14:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 29 01:14:04 2025
Received: from localhost ([127.0.0.1]:54015 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVkMe-0007dh-9T
	for submit <at> debbugs.gnu.org; Sun, 29 Jun 2025 01:14:04 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:59038)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uVkMb-0007c1-SK
 for 78916 <at> debbugs.gnu.org; Sun, 29 Jun 2025 01:14:02 -0400
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 1uVkMW-00030V-5g; Sun, 29 Jun 2025 01:13:56 -0400
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=jGIH4SFmaFGajSwYKFoS43/byEVbmW/LIjai9U2B3nw=; b=IMnj8gP/hqds
 8o5phFPpMJ7pwxSv9r4nMONEDx7Y0CVLF8dd4jsINRqTr4EZ0oEJdYm/iOuZ3Wu4UF3LdsXdeGDW0
 fb+eXSwMb1M2yjBfelPpGGRkjwmc6KeHgGvcvOwcv/2KH+MuRqb6kTmvM/D53mWufFBXtsRxWIUQD
 PO7mFr427uDJf1Y0vsx8LJiuIs8N2dbSU5xR5uhiq8BWL5DU5UsHC32dbq/sw87dH2rZABuZgqjKo
 n2L0VPyHIEYJzkdh4UZv2K+70koCqGW3N1Ai3+NmTZcvMXG3/yt2SjQx82+9uJOKG2A6hkPfsmewi
 OoxPeWG5lkPwlR6CsxreRg==;
Date: Sun, 29 Jun 2025 08:13:53 +0300
Message-Id: <86a55r5dv2.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Mike Kupfer <kupfer@HIDDEN>
In-Reply-To: <34220.1751153312@HIDDEN> (message from Mike Kupfer on
 Sat, 28 Jun 2025 16:28:32 -0700)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN> <34220.1751153312@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <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: 78916 <at> debbugs.gnu.org
> From: Mike Kupfer <kupfer@HIDDEN>
> Comments: In-reply-to Stefan Monnier <monnier@HIDDEN>
>  message dated "Sat, 28 Jun 2025 15:14:34 -0400."
> Date: Sat, 28 Jun 2025 16:28:32 -0700
> 
> Stefan Monnier wrote:
> 
> > So what do we want:
> > 
> > - Both keys behave like the "old C-g".
> > - Both keys behave like the "old C-]" (i.e. what we have now).
> > - Reintroduce the difference of behavior between `C-g` and `C-]`,
> >   presumably by giving them different bindings in `query-replace-map.
> 
> Is there a use case for the current behavior?  I definitely want to have
> the "old C-g" behavior available.  I think it makes sense for C-g to
> provide that behavior.

Agreed.




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

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


Received: (at 78916) by debbugs.gnu.org; 28 Jun 2025 23:28:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 28 19:28:45 2025
Received: from localhost ([127.0.0.1]:52736 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVeyR-0002jk-PF
	for submit <at> debbugs.gnu.org; Sat, 28 Jun 2025 19:28:45 -0400
Received: from shell1.rawbw.com ([198.144.192.42]:10623 ident=root)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kupfer@HIDDEN>) id 1uVeyN-0002iv-Ih
 for 78916 <at> debbugs.gnu.org; Sat, 28 Jun 2025 19:28:40 -0400
Received: from bach.localdomain (135-180-175-182.dsl.dynamic.sonic.net
 [135.180.175.182] (may be forged)) (authenticated bits=0)
 by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 55SNSWRF014178
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Sat, 28 Jun 2025 16:28:38 -0700 (PDT)
 (envelope-from kupfer@HIDDEN)
X-Authentication-Warning: shell1.rawbw.com: Host
 135-180-175-182.dsl.dynamic.sonic.net [135.180.175.182] (may be forged)
 claimed to be bach.localdomain
From: Mike Kupfer <kupfer@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-reply-to: <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
 <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
Comments: In-reply-to Stefan Monnier <monnier@HIDDEN>
 message dated "Sat, 28 Jun 2025 15:14:34 -0400."
X-Mailer: MH-E 8.6+git; nmh 1.8-RC2; Emacs 31.0.50
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <34219.1751153312.1@HIDDEN>
Date: Sat, 28 Jun 2025 16:28:32 -0700
Message-ID: <34220.1751153312@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <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 (-)

Stefan Monnier wrote:

> In `master`, they now both behave in the same way.  I think the fact
> that the behave the same way is good/right since they have the same
> binding in the keymap.

That makes sense.

> So what do we want:
> 
> - Both keys behave like the "old C-g".
> - Both keys behave like the "old C-]" (i.e. what we have now).
> - Reintroduce the difference of behavior between `C-g` and `C-]`,
>   presumably by giving them different bindings in `query-replace-map.

Is there a use case for the current behavior?  I definitely want to have
the "old C-g" behavior available.  I think it makes sense for C-g to
provide that behavior.  Different bindings in query-replace-map seems
like a clean way to achieve that.

thanks,
mike




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

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


Received: (at 78916) by debbugs.gnu.org; 28 Jun 2025 19:14:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 28 15:14:48 2025
Received: from localhost ([127.0.0.1]:52083 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVb0h-0004lB-91
	for submit <at> debbugs.gnu.org; Sat, 28 Jun 2025 15:14:48 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:62448)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
 id 1uVb0d-0004kO-9z
 for 78916 <at> debbugs.gnu.org; Sat, 28 Jun 2025 15:14:45 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 00F3F80925;
 Sat, 28 Jun 2025 15:14:37 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1751138076;
 bh=3WgH3xs+OAH7h9fNoPfCLFrYB6CIq+xhtXagkU8SOSQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=ADb9YPmKad2ENc7sqlq5SezH91lccMt+mxAvLKR00N+c/4zkDnA82Qd+57FMq0HL3
 rrzYoAYPVhEVDFTDecLqKYAbUkJiDh2LMA/hlWP9+splH0marSZcheh0BHhyTbIJ0U
 xrZjr8qWi+/oA8/lHgwVshFwdy2lAQMFPrugdPn5ueBnZQiWbyHXhyRSEeXXUMlzWy
 H1IKxnipS0u62y/qOVnZyuLcs2rG4krtukhcg0qFZZES/oQCgqoKlwdTqww6LBac5K
 NUEXZHdjlBAWSAgl9LXRyiPYgmzjp3bCz2QSgJ5C1zInqRL6HBe+hTOfk5oIaQVFd7
 qxKt1w/l8kUxQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 19859801B1;
 Sat, 28 Jun 2025 15:14:36 -0400 (EDT)
Received: from pastel (unknown [104.247.225.139])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id CFE7C1204C9;
 Sat, 28 Jun 2025 15:14:35 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Mike Kupfer <kupfer@HIDDEN>
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
In-Reply-To: <24453.1751060166@HIDDEN>
Message-ID: <jwv1pr3pu18.fsf-monnier+emacs@HIDDEN>
References: <24453.1751060166@HIDDEN>
Date: Sat, 28 Jun 2025 15:14:34 -0400
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.309 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
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <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 (---)

Hi Mike,

> 2. Evaluate the following defun:
>
> (defun do-test ()
>   (while (re-search-forward "bug#[[:digit:]]+:" nil t)
>     (search-backward "(\"bug")
>     (let (end (start (point)))
>       (forward-sexp)
>       (setq end (point))
>       (query-replace-regexp "\\(\"bug#[[:digit:]]+:\\).*\"" "\\1\""
> 			    nil start end))))
>
> 3. Visit the test data file.  With point at the start of the buffer, run
> the do-test function, and press space a couple times.  Now press C-g.
>
> Expected behavior:
>
>   The do-test function stops executing, and point is left at the same
>   position where you pressed C-g.  (This is the behavior I see with
>   Emacs 30 and with a build derived from Emacs master 648453c04d9.)
>
> Observed behavior:
>
>   point progresses through the remaining sexps, without giving you any
>   query-replace prompt.  When do-test has finished, point is now after
>   '"bug#78900:"'.

[ Thanks for your report.  I think this is a great data-point for the
  recent discussion around making `read-event` consistently return `C-g`
  (instead of signaling `quit`).  ]

In `query-replace-map` we have:

    (define-key map "\C-g" 'quit)
    (define-key map "\C-]" 'quit)

In Emacs<31 `C-g` gave what you describe as "Expected behavior", and
`C-]` gave what you describe as "Observed behavior".

In `master`, they now both behave in the same way.  I think the fact
that the behave the same way is good/right since they have the same
binding in the keymap.

So what do we want:

- Both keys behave like the "old C-g".
- Both keys behave like the "old C-]" (i.e. what we have now).
- Reintroduce the difference of behavior between `C-g` and `C-]`,
  presumably by giving them different bindings in `query-replace-map.


        Stefan





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

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


Received: (at 78916) by debbugs.gnu.org; 28 Jun 2025 06:51:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 28 02:51:14 2025
Received: from localhost ([127.0.0.1]:46406 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVPP7-0002Wr-FN
	for submit <at> debbugs.gnu.org; Sat, 28 Jun 2025 02:51:14 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:33186)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1uVPP3-0002Vh-V3
 for 78916 <at> debbugs.gnu.org; Sat, 28 Jun 2025 02:51:11 -0400
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 1uVPOx-0000xT-H8; Sat, 28 Jun 2025 02:51:03 -0400
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=BB3yd7FqA0MqtApqpWEZRP91o35ffV405EGL0rG7VCA=; b=aWmLlRJkTMHM
 lOOrzsCuQmSp+z5ezinPYZHmVoyEFsLS5ctGu1zFVRDFf9KCAOklDQS31uSZCqitz0DQV/tCh4pFo
 iP/FCHOZNJoCdH+AhdCMNvz/ry+p9iNCtBWRLZlohzJcYVkZFxVk9oM4dblri8tW51t9YPje+FHWU
 YoN8cMoPri8RMGa1zeHieAKISoVuqooDWRtrQ1S16lzrFSAivCvR6H04m52CVGUuUsYvgumYGszb0
 CjQ5gF2vKjOBpb4+Q2FQY/wCp2W3OatR+ULeE7HJmn+x2htflELSikHbgIa/YO1LW4GemJj3hmb68
 ZK3EOc/1O0ur3B4I+J5OmA==;
Date: Sat, 28 Jun 2025 09:51:00 +0300
Message-Id: <86y0tc8iln.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Mike Kupfer <kupfer@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <24453.1751060166@HIDDEN> (message from Mike Kupfer on
 Fri, 27 Jun 2025 14:36:06 -0700)
Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop
References: <24453.1751060166@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 78916
Cc: 78916 <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: Mike Kupfer <kupfer@HIDDEN>
> Date: Fri, 27 Jun 2025 14:36:06 -0700
> 
> Recipe from 'emacs -Q':
> 
> 1. Save the test-data attachment to a file.
> 
> 2. Evaluate the following defun:
> 
> (defun do-test ()
>   (while (re-search-forward "bug#[[:digit:]]+:" nil t)
>     (search-backward "(\"bug")
>     (let (end (start (point)))
>       (forward-sexp)
>       (setq end (point))
>       (query-replace-regexp "\\(\"bug#[[:digit:]]+:\\).*\"" "\\1\""
> 			    nil start end))))
> 
> 3. Visit the test data file.  With point at the start of the buffer, run
> the do-test function, and press space a couple times.  Now press C-g.
> 
> Expected behavior:
> 
>   The do-test function stops executing, and point is left at the same
>   position where you pressed C-g.  (This is the behavior I see with
>   Emacs 30 and with a build derived from Emacs master 648453c04d9.)
> 
> Observed behavior:
> 
>   point progresses through the remaining sexps, without giving you any
>   query-replace prompt.  When do-test has finished, point is now after
>   '"bug#78900:"'.
> 
> The git hash reported below by 'report-emacs-bug' includes a few Lisp
> changes that I believe are unrelated to the issue, and which are
> unchanged from the Emacs master build that works as expected.  The
> corresponding git hash from master (for the buggy build) is a002ca79ee7.

I think the offending commit is this:

 commit 772c4f036c38efd2a81d3643ad0bd718033d3b7f
 Author:     Stefan Monnier <monnier@HIDDEN>
 AuthorDate: Thu May 22 09:32:33 2025 -0400
 Commit:     Stefan Monnier <monnier@HIDDEN>
 CommitDate: Thu May 22 09:33:14 2025 -0400

     (perform-replace): Make it work with F-keys in TTYs (bug#78113)

     * lisp/replace.el (perform-replace): Use `read-key`.
     * test/lisp/replace-tests.el (replace-tests-with-undo): Adjust accordingly.

The build from commit cb1b65f3923d5dcb88767f6736603ffbc4272557, 3
commits before that, doesn't exhibit this problem.




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

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


Received: (at submit) by debbugs.gnu.org; 27 Jun 2025 21:36:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 27 17:36:33 2025
Received: from localhost ([127.0.0.1]:43567 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1uVGkK-000230-KG
	for submit <at> debbugs.gnu.org; Fri, 27 Jun 2025 17:36:33 -0400
Received: from lists.gnu.org ([2001:470:142::17]:56200)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <kupfer@HIDDEN>) id 1uVGkH-00022Q-UK
 for submit <at> debbugs.gnu.org; Fri, 27 Jun 2025 17:36:30 -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 <kupfer@HIDDEN>) id 1uVGkB-0005Py-PT
 for bug-gnu-emacs@HIDDEN; Fri, 27 Jun 2025 17:36:23 -0400
Received: from shell1.rawbw.com ([198.144.192.42])
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <kupfer@HIDDEN>) id 1uVGk9-0002ST-Mc
 for bug-gnu-emacs@HIDDEN; Fri, 27 Jun 2025 17:36:23 -0400
Received: from bach.localdomain (135-180-175-182.dsl.dynamic.sonic.net
 [135.180.175.182] (may be forged)) (authenticated bits=0)
 by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 55RLa6Yt065692
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO)
 for <bug-gnu-emacs@HIDDEN>; Fri, 27 Jun 2025 14:36:12 -0700 (PDT)
 (envelope-from kupfer@HIDDEN)
X-Authentication-Warning: shell1.rawbw.com: Host
 135-180-175-182.dsl.dynamic.sonic.net [135.180.175.182] (may be forged)
 claimed to be bach.localdomain
From: Mike Kupfer <kupfer@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 31.0.50; C-g fails to exit loop
X-Mailer: MH-E 8.6+git; nmh 1.8-RC2; Emacs 31.0.50
X-Debbugs-Cc: 
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Date: Fri, 27 Jun 2025 14:36:06 -0700
Message-ID: <24453.1751060166@HIDDEN>
Received-SPF: pass client-ip=198.144.192.42; envelope-from=kupfer@HIDDEN;
 helo=shell1.rawbw.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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

Recipe from 'emacs -Q':

1. Save the test-data attachment to a file.


--=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename=test-data
Content-Description: test data

  ("bug#78903:" -100 739429 s) ("bug#78907:" -100 739428 s)
  ("bug#78902:" -100 739429 s) ("bug#78637:" -100 739429 s)
  ("bug#78897:" -100 739428 s) ("bug#78900:" -100 739428 s)


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


2. Evaluate the following defun:

(defun do-test ()
  (while (re-search-forward "bug#[[:digit:]]+:" nil t)
    (search-backward "(\"bug")
    (let (end (start (point)))
      (forward-sexp)
      (setq end (point))
      (query-replace-regexp "\\(\"bug#[[:digit:]]+:\\).*\"" "\\1\""
			    nil start end))))

3. Visit the test data file.  With point at the start of the buffer, run
the do-test function, and press space a couple times.  Now press C-g.

Expected behavior:

  The do-test function stops executing, and point is left at the same
  position where you pressed C-g.  (This is the behavior I see with
  Emacs 30 and with a build derived from Emacs master 648453c04d9.)

Observed behavior:

  point progresses through the remaining sexps, without giving you any
  query-replace prompt.  When do-test has finished, point is now after
  '"bug#78900:"'.

The git hash reported below by 'report-emacs-bug' includes a few Lisp
changes that I believe are unrelated to the issue, and which are
unchanged from the Emacs master build that works as expected.  The
corresponding git hash from master (for the buggy build) is a002ca79ee7.

In GNU Emacs 31.0.50 (build 11, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.16.0, Xaw scroll bars) of 2025-06-26 built on bach
Repository revision: 272a10db724bf17aa4af0e958d3b41c996d22c4a
Repository branch: master-mdk
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure --prefix=/usr/new --enable-checking'

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

Important settings:
  value of $LC_TIME: C
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
  server-mode: t
  shell-dirtrack-mode: t
  delete-selection-mode: t
  display-time-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow mh-identity mh-tool-bar mh-letter mh-show goto-addr thingatpt
gnus-cite mh-mime mh-acros mh-xface mh-utils emacsbug lisp-mnt files-x
mdk-mail gnus-mh gnus-msg mh-comp mh-scan mh-gnus gnus-dup nnmh
gnus-score score-mode 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
browse-url xdg url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util url-parse
auth-source cl-seq eieio eieio-core cl-macs json map byte-opt gv
bytecomp byte-compile url-vars mail-source utf7 nnoo parse-time iso8601
gnus-spec gnus-int gnus-range gnus-win gnus nnheader range wid-edit mh-e
mh-buffers mh-loaddefs message sendmail mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr mailabbrev mail-utils gmm-utils mailheader server warnings
timeclock noutline outline icons cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs advice shell
pcomplete comint subr-x ansi-osc ansi-color ring xcscope delsel time vc
cl-loaddefs cl-lib vc-dispatcher mdk-hacks 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 touch-screen
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 x multi-tty move-toolbar make-network-process tty-child-frames
emacs)

Memory information:
((conses 16 179700 20237) (symbols 48 18865 0) (strings 32 55102 2372)
 (string-bytes 1 1569839) (vectors 16 32210)
 (vector-slots 8 312579 6626) (floats 8 225 15) (intervals 56 310 0)
 (buffers 984 13))

--=-=-=--




Acknowledgement sent to Mike Kupfer <kupfer@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#78916; 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: Thu, 3 Jul 2025 17:45:02 UTC

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