emacs-which-key
emacs-which-key copied to clipboard
FR Tell which keymap is displayed
In some cases (all?), user does not know which keymap is currently shown. (edit : i mean the name of the keymap, like help-map)
I do not find a way to expose it (though i will be able to investigate, but sometimes this requires exploring lisp code)
For example, when pressing "h" for help , you might have a way to insert it in Help buffer ? i know there are cases its not one single keymap that is exposed, but a virtual keymap (i think C-c).
but maybe do you have a way, at least, to expose this dummy keymap name? if you are fine with the idea but do not want to work maybe i can dig a bit
The procedure which-key uses to inspect the currently available keys does not produce a keymap name, and as far as I know this information is not readily available from Emacs. There are round-a-bout ways to figure it out (something like inspect all keymaps, determine which are active, determine which keys are available from which maps, etc.), but I don't know of an easy one.
Also, I'm not sure this is very useful information. There are many keymaps that overlay each other on a typical system, so the more important piece of information is the current key prefix, not the name of the keymap. If only one keymap were available at a time, the situation would be different of course.
I think this has come up a couple of times before, but I'm not seeing the corresponding bug report right now.
about round-a-bout, this could not work properly in all cases.
regarding usefulness, i think Emacs is so nice because we learn it's internals in order to customize or even improve it. Of course in vanilla Emacs knowing stuff like x-meta-9-map is not that useful! still when the user presses Control+h it is nice to show him what is this map. (Yes info is also in Emacs manual, sure.) More importantly, the use case is that which-key can display any keymap. it might display ibuffer keymap , dired keymap, custom keymap, evil keymaps.
and i think it would be useful to others as well; eg the noble "describe-keymap" might like the user to be able to easily identify keymap names.
i guess i would ask Emacs if it's possible to know
- is there a read-key active?
- otherwise, terminal map? otherwise, minor mode map - is there a prefix key active? otherwise major mode map - is there a prefix key active? and so on
It's still not that simple. Which-key doesn't display individual maps. It displays all active bindings, which may or may not come from the same keymap.
Your C-h
example is a good example of the complications. Yes, pressing C-h
displays help-map
by default, but C-h
is bound to help-command, a dummy function which is
fsetto
help-map. There's no way to determine that fact interactively to my knowledge. You have to inspect the source to see that. So after pressing
C-h` which-key can see the active bindings but the only way I can think of for it to be able to say "most of these come from help-map" is to inspect all of the maps and see which has the most overlap with the currently active bindings. This seems like a lot of work and quite error prone.
Given the name of a keymap you can inspect it in several ways already, but going backwards from active bindings to a keymap name is not straightforward.
yes i think you are right there is no way at the moment. So i suggest to open a bug against Emacs. I can do this eventually.
I doubt such a bug report would be well received, but you could try of course.
@justbur ok let's try. Just describing the feature request is already hard. Here it is https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29141