I am running Fedora 40 which I installed a few months ago. I noticed that F10 in my Emacs does not run the function that I have assigned to it in Emacs: in fact, Emacs does not see the F10 key any longer (and I am pretty sure that this started happening when I upgraded to Fedora 40: it was working fine in Fedora 38 - I skipped Fedora 39).
I can tell that Emacs does not see the key by using C-h C-k, the help function to describe a key, and pressing F10. Usually, the key is echoed in Emacs's echo area and the command bound to it is reported. In the F10 case, nothing is echoed in the echo area. Instead the File menu is dropped down.
That behavior seems to be somewhat general: both Firefox and Thunderbird exhibit the same behavior, which is another reason to conclude that the desktop environment is what's doing this. Not every application does this however: in gnome-terminal and xterm, F10 apparently just generates an escape sequence: ^[[21~.
I did gsettings list-recursively and found one entry using F10: that looked promising, so I set it to empty:
$ gsettings get org.gnome.desktop.interface menubar-accel 'F10' $ gsettings set org.gnome.desktop.interface menubar-accel '' $ gsettings get org.gnome.desktop.interface menubar-accel '' but that didn't do anything AFAICT (after various levels of restarting: restarting Emacs, logging out and back in, rebooting, shutting down and starting from scratch). As far as I know, all the graphical widget thingies (Settings, Tweaks, etc.) are using the Gsettings API underneath, so this should have found the culprit - but no dice.
Since Emacs is built with libgtk-3.0, I also tried a GTK setting as described in this answer but that also did not make any difference.
Although my main interest is to free up F10 from whoever its current master is and allow it to be passed to Emacs, I'd also be interested in any tips/hacks/methods you have come up with to deal with similar problems. Any ideas?
Version info:
- OS: Fedora 40
- Kernel: Linux 6.9.12-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Jul 27 15:56:15 UTC 2024 x86_64 GNU/Linux
- Gnome: 46.3
- Emacs: bleeding-edge upstream, unreleased (31.0.50), but it also happens in the Emacs that comes with Fedora 40: GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) of 2024-07-16
If more information is needed, I'd be happy to supply it: please let me know.
UPDATE: in response to the comment by David G. below, xev does see F10 (and so do gnome-terminal and xterm as mentioned above, and of course whatever makes the File menu to drop down in the case of Emacs, Firefox and Thunderbird). The problem is not that it is not seen: the problem is that it is grabbed before I want it to be grabbed and I don't know what grabs it. That's what I'm trying to find out in the hope that I can convince that something to keep its hands off my F10 :)
In response to further comments by David G. (thanks for the responses and for keeping me honest!), I tried emacs -Q which starts Emacs without any initialization files (either site-init (site-start.el or user-init or early-init). But the GTK suggestion is intriguing. I built an Emacs without a toolkit at all and it behaves as expected wrt to F10: the key is visible and I can bind it to a command. I then found this section in the GTK documentation: it's about GTK4 and I cannot find the equivalent in the GTK3 documentation, but I'm assuming that the behavior is the same in the two versions. I'm no GTK programmer, so I don't know how to turn this behavior off yet, but it seems clear that David G. was right when he fingered the GTK interface in Emacs as the culprit.
C-h C-konly does the second. I can't remember details of the first stage. I would recommend trying a basic debugging program, likexev, to see if it receives F10. This will let you determine if the problem is in emacs or something external to it.C-h kuses the same primitiveread-key-sequenceas the REPL does, so no, that's not correct. It also does something more: it reports the raw key sequence, before any translation keymaps. In the case ofF10, it reports nothing because it doesn't see it. It has no such problem withF9orF11or any other function key: it can see all of them fine.xevcan seeF10, butxevis at a much lower level: it gets its hands on it before the desktop environment.Alt-F2: that's not the strange thing -gsettings get org.gnome.desktop.wm.keybindings panel-run-dialogsays<Alt>F2, so it is clear that it is intercepted. The strange thing is thatF10no longer appears ingsettingsbut it still drops down theFilemenu (and not only in Emacs).<Alt>F2is also intercepted beforexev. I suspectF10is being intercepted inside emacs, probably in the GTK interface, possibly in site lisp.<Alt>F2is intercepted beforexev: I was wrong thatxevgets its hands on it early. OTOH, starting Emacs withemacs -Qi.e. no site-init or user-init file still shows the problem, so if the problem is in Emacs, it is in its core. I've updated the question with some possible ways forward - e.g. building Emacs without GTK. I'll update again after I get some sleep. Thanks!