4

While in the results buffer of helm-projectile-grep, I know I can use C-<up> and C-<down> to visit the files with the matches, but I would like to rebind those keys.

Normally I would use C-h k to run describe-key on the C-<up> sequence, then use the function name in global-set-key.

But typing C-h k in the results buffer (which I'm assuming in Helm's case is an expanded minibuffer, not sure about the terminology) only appends k to the search string, ignoring the C-h.

So how do I find out which function a key sequence is bound to in that situation?

1
  • I'm not familiar with Helm, but I think it doesn't use a minibuffer, or if it does it uses a non-standard keymap, so a generic minibuffer answer is not applicable. Commented Oct 21, 2017 at 22:56

2 Answers 2

2

Helm redefines a lot of standard key bindings, including the ones to get help (which I find extremely rude).

A workaround is to add a binding for help on a key that Helm doesn't rebind, at least while you're investigating, for example:

(global-set-key [C-f1] 'help-command)

Then use C-f1 k in the context where you want to identify a key.

It may be more useful to directly ask Emacs where the key is bound. describe-key does this in Emacs 25. If you're using an older version, see How can I find out in which keymap a key is bound? — bind a key to Malabarba locate-key-binding, use it while in Helm, and later go and see the result in the *Messages* buffer.

1
  • I tried (global-set-key [C-f1] 'help-command), but it had the same effect as C-h k: the C-h / C-f1 part gets ignored, and the k gets appended to the search pattern. Using Malabarba's locate-key-binding (taken from here) and looking at *Messages* gave me helm-follow-action-forward and helm-follow-action-backward which is what I was looking for. Thank you! Commented Oct 22, 2017 at 13:53
1

You can issue a command (such as C-h k) that uses the minibuffer from the minibuffer itself only if you set enable-recursive-minibuffers to non-nil.

But most likely what you really want here is to get help on a minibuffer keymap. For that, use C-h M-k (describe-keymap) from library help-fns+.el.

There are a few minibuffer keymaps. You might need to check more than one with C-h M-k, depending on which ones are being used for what you are interested in.

See the Elisp manual, nodes Completion Commands and Text from Minibuffer for descriptions of the minibuffer keymap variables.

For example, you might try C-h M-k minibuffer-local-keymap.

On the other hand, if Helm uses its own keymaps in the minibuffer then you might need to enter the name of one of those when prompted by C-h M-k.

Keep in mind also that a minor-mode keymap overrides the predefined minibuffer keymaps, which are local maps.


If you used Icicles (but Helm and Icicles are probably incompatible) then you can see which keys are available anytime, in any given context, including in the minibuffer.

  • If the minibuffer is active then M-S-TAB at any point shows you the key completions. If no prefix key has been pressed yet then it shows you the top-level key bindings available in the minibuffer at that time. The key = command bindings are shown as completion candidates in buffer *Completions*. You can filter them by key name or command name or both. And keys that are bound locally (i.e., in a local keymap) are highlighted specially.

  • If the minibuffer is not active then S-TAB gives you the same behavior: it shows the available key completions at any time.

See Icicles - Key Completion.

4
  • You've answered the title question, but the question was really about Helm, and I think your answer doesn't apply to Helm, because as you suspect Helm has its own keymaps. Commented Oct 21, 2017 at 22:56
  • @Gilles: I expected that someone might offer a Helm-specific answer. But I also understood the question as being about keys in the minibuffer - as was asked. You've edited it to a quite different question now - perhaps more accurate, perhaps not. Yet you've still left the tag minibuffer! Is this about keys (bound in what buffer? what mode?) that act on a results buffer? Is it about keys bound in a minibuffer? Is a minibuffer active at the time? Is it about keys in a results buffer, or is about keys in another buffer that have an effect on a results buffer (a la an effect on *Completions*?
    – Drew
    Commented Oct 21, 2017 at 23:26
  • I only edited the title to match the body. I think that the minibuffer is active when browsing the results of helm-projectile-grep (even though a lot of the action happens in another buffer, in the same style as *Completions*). But since Helm rebinds C-h and f1, the standard ways to get help are not available. Even M-x doesn't work if it's helmified, which it is in the recommended Helm configuration; M-: does work if you don't helmify it and you enable recursive minibuffers. Commented Oct 21, 2017 at 23:31
  • I hadn't been able to use describe-keymap to test your answer because of a random helm/spacemacs bug, but now that I fixed it, I was also able to run the command, describe the helm-map keymap and find the C-up / C-down bindings, so thank you! Commented Oct 22, 2017 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.