0

For the past several weeks, I've experienced an erratic and hard-to-diagnose behavior: the C-g key binding sometimes doesn't work. Strangely, this problem doesn't affect alternative bindings of keyboard-quit. For example, if I bind keyboard-quit to M-q, when C-g doesn't trigger this command, M-q still triggers it.

Because this happens only sometimes and in ways that are hard to predict, bisecting my config file can be very time-consuming. I will do that as a measure of last resort, but I was wondering if anyone has ideas of what might be going on, so I can explore these first. Thanks.

Pablo
  • 313
  • 2
  • 8
  • 1
    Did you read the GNU Emacs Manual "51 Quitting and Aborting" ? – yarl Mar 08 '24 at 22:59
  • Is C-g still bound to keyboard-quit? – NickD Mar 08 '24 at 23:29
  • If both keys are bound to keyboard-quit and only one of them is erratic under the same circumstances, then the only explanation I can think of is that your keyboard is flaky. Have you tried another keyboard? – NickD Mar 08 '24 at 23:46
  • Thanks for the comments. Yes, I read that section of the manual.

    Yes, C-g is bound to keyboard-quit. But when C-g doesn't work, it is not recognized as a key event. For instance, C-h k C-g does nothing (whereas when C-g does work, C-h k C-g shows the keyboard-quit binding). I know this is very weird behavior, but it is what I'm experiencing.

    – Pablo Mar 08 '24 at 23:57
  • NickD, I'm using an external keyboard, but I'm almost certain that I also tried my laptop keyboard. However, I will confirm this next time I experience the issue. Thank you for the suggestion. – Pablo Mar 09 '24 at 00:01
  • Confirmed: it's not an issue with the keyboard. – Pablo Mar 09 '24 at 00:06
  • Another data point: something equivalent happens with the command transient-quit-one, which is by default bound to C-g in transient-base-map. When this mode is active, e.g. after invoking magit-status, C-g will often fail to trigger transient-quit-one. But if I re-bind it to M-q, that key sequence will always work. I don't think I ever experienced such puzzling behavior in Emacs before. – Pablo Mar 09 '24 at 00:15
  • Instrument keyboard-quit with edebug and see if Emacs stops there every time you press C-g or M-q. At least that will tell you whether you get to the command every time. Do that in a throw-away session: you probably don't want to do that in your working Emacs. – NickD Mar 09 '24 at 17:21
  • Edebug is triggered only sometimes when I press C-g but always when I press M-q, in line with the behavior described previously.

    keyboard-quit seems like a red herring at this point; I think this issue is instead only related to the C-g key sequence, since it also affects transient-quit-one and any other command bound to it. E.g. after evaluating (define-key (current-global-map) (kbd "C-g") #'emacs-version) the Emacs version is shown only sometimes after pressing C-g.

    – Pablo Mar 09 '24 at 19:04

0 Answers0