2

I'm a recent convert to helm. helm-M-x displays commands and includes key-bindings in parens after the command name. helm-apropos displays commands and other things. I'd like it to display the key bindings for commands that have them the same way as helm-M-x does.

3

Welcome to helm, you will like it ;)

One way to do it is to just overwrite the original function which builds the source for the apropos command candidates with this:

(defun helm-def-source--emacs-commands (&optional default)
  (helm-build-in-buffer-source "Commands"
    :init `(lambda ()
             (helm-apropos-init 'commandp ,default))
    :fuzzy-match helm-apropos-fuzzy-match
    :filtered-candidate-transformer (and (null helm-apropos-fuzzy-match)
                                         'helm-apropos-default-sort-fn)

    :candidate-transformer 'helm-M-x-transformer-1
    :nomark t
    :action '(("Describe Function" . helm-describe-function)
              ("Find Function" . helm-find-function)
              ("Info lookup" . helm-info-lookup-symbol))))

The added part is this:

:candidate-transformer 'helm-M-x-transformer-1

which adds the keybindings to the candidates list. Just load this function after you loaded helm in your init file.

  • 1
    Thanks, I figured it was something like that but wasn't sure of which function to modify, the format to add the transformer (other places use :fc-transformer) or if helm-M-x-transformer-1 was exactly right (if all it does is add the keybinding it seems like it could have a better name). – Howard Aug 26 '15 at 1:24
  • @hatschipuh, how come I get a (wrong-type-argument listp helm-M-x-transformer-1) error? – Emacs User Aug 26 '15 at 2:52
  • @EmacsUser I don't know, somehow at your side it seems that it is expecting helm-M-x-transformer-1 to be a list of functions? Try to use :candidate-transformer '(helm-M-x-transformer-1) instead. – clemera Aug 26 '15 at 9:59
  • 1
    Not work for me, no key bindings in the list of helm-apropos like helm-M-x – CodyChan May 27 '17 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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