6

Magit implements multi-key bindings in a nonstandard way: the first key runs a command that displays a “popup”, i.e. a buffer in a special mode that displays usage instructions, and the second key is bound in that special mode. That second key invokes magit-invoke-popup-action which looks up the event that invoked it in a table.

This breaks Emacs's help mechanism: if I want to know what command a key binding invokes, C-h c or C-h k isn't helpful. If I use these commands before the first key (the one that brings the popup), I get the help for the command that displays the popup (e.g. C-h c c → “c runs the command magit-commit-popup”). If I use these commands before the second key (the one that runs in the popup buffer), I get the help for the generic second-key lookup function (e.g. c C-h c c → “c runs the command magit-invoke-popup-action”). And if I want to look up the key that invokes a command, C-h w truthfully tells me that the command isn't bound to any key — it's hidden behind the popup.

How can I find out Magit's key binding information from within Emacs? I am not interested in loading the documentation in Info and searching through it. I want to obtain the information automatically, following Emacs's self-documented principles, and accurately even if the documentation isn't up-to-date or I'm using customized key bindings.

1 Answer 1

5

You can use ? <key>. Inside popups ? is bound to magit-popup-help. It would make sense for C-h k to be bound to that command too. So I have done that now.

2
  • I'm not sure if it makes sense to rebind C-h c and C-h k: it could get confusing. If you do rebind, make it C-h k, not C-h c, since ? is analogous to C-h k. What about the other direction (C-h w)? How do I go from magit-commit to c c? That's the direction I care most about. Commented Aug 1, 2016 at 22:03
  • Indeed, I got the two keys confused. There's no way of going the other way. Complications like this are one of the reasons why I intend to replace magit-popup with a better implementation, likely to be named transient. Commented Aug 1, 2016 at 22:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.