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.
C-gstill bound tokeyboard-quit? – NickD Mar 08 '24 at 23:29keyboard-quitand 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:46Yes,
– Pablo Mar 08 '24 at 23:57C-gis bound tokeyboard-quit. But whenC-gdoesn't work, it is not recognized as a key event. For instance,C-h k C-gdoes nothing (whereas whenC-gdoes work,C-h k C-gshows thekeyboard-quitbinding). I know this is very weird behavior, but it is what I'm experiencing.transient-quit-one, which is by default bound toC-gintransient-base-map. When this mode is active, e.g. after invokingmagit-status,C-gwill often fail to triggertransient-quit-one. But if I re-bind it toM-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:15keyboard-quitwithedebugand see if Emacs stops there every time you pressC-gorM-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:21C-gbut always when I pressM-q, in line with the behavior described previously.
– Pablo Mar 09 '24 at 19:04keyboard-quitseems like a red herring at this point; I think this issue is instead only related to theC-gkey sequence, since it also affectstransient-quit-oneand 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 pressingC-g.