Subject: Re: bug#78916: 31.0.50; C-g fails to exit loop

From: Eli Zaretskii <[email-masked]>
Date: Mon, 30 Jun 2025 22:00:02 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: Mike Kupfer <[email-masked]>,  [email-masked]
> 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.