2

Solved! helm-descbinds solved the problem.

https://github.com/emacs-helm/helm-descbinds

Thank you for your help.


I was trying to work out if I could build a simple script to narrow down key bindings, somewhat similar to IDO. I know of Icicle, but for some reason I didn't like it.

During my search I ran into many problems and beging to think that the only way out is to run:

(describe-bindings)

and then try to parse Help buffer.

Is there a way to get pre-parsed flat list of biding? I got lost trying to understand the keymap structure.

I guess recursively parsing the keymap structure is too much work. Is there a simple solution?

This is example of my early progress.

https://github.com/bigos/Pyrulis/blob/master/Emacs/key-bindings-lister/lisp/key-bindings-lister.el

After a while of trying, looks like getting the info from Help buffer didnt work. I got some strange structures with the string and when I tried to use print, it didn't print what I wanted. Perhaps I will have to parse the keymap?

After playing with keymap for a while, I think this is the way to go. More in my github link.

My last attempt.

;;; run in ielm like this: (my-list-bindings 11)
;;; n=11 for global
(defun my-list-bindings (n)
  "almost clean way of listing key bindings"
  (map-keymap
   (lambda (x y)
     (print "!!!!!!!!!!!!!!!!!!!!!")
     (princ x)
     (if (eq x 'menu-bar)
         (print "*** skipping menu bar ***")
       (print y)))
   (elt (current-active-maps) n )))
3
  • 1
    Can you clarify what you mean by "narrow down"?
    – Dan
    Commented Jan 1, 2016 at 22:31
  • M-x describe-bindings will show you all bindings. C-h m (M-x describe-mode) is also handy to list bindings by mode.
    – ReneFroger
    Commented Jan 2, 2016 at 0:14
  • descibe-bindings gives me many thousands of bindings that I'm not interested at the moment. I wonder if there's a better way to search than using C-s Commented Jan 2, 2016 at 3:05

1 Answer 1

5

If I understand correctly, you're trying to see what key bindings are available at any instant in time.

In that case, try helm-descbinds, which works with helm. Key bindings are organized by major mode, minor modes, and the global map. You can then use a regular expression to narrow down your choice, e.g. ^C-x\ [a-z] to find all bindings that begin with C-x and are followed by a letter from a-z.

You can also try discover-my-major, which lists all the key bindings of your current major mode, along with an apropos-like description of what they do. I find that it is useful when I'm trying to learn a new major mode.

0

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.