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

From: Pip Cet <[email-masked]>
Date: Thu, 03 Jul 2025 17:43:25 +0000

"Stefan Monnier via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\"" <[email-masked]> 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