I am looking for a function that returns a function (preferably quoted) for a given key binding. I know about C-h k
(e.g. M-x describe-key
), but I am looking for a lower-level function. (My use case is that I want to save a previous key binding before rebinding it.)
I found the aptly-named key-binding
after reading the source code for describe-key
:
key-binding is a built-in function in `C source code'.
(key-binding KEY &optional ACCEPT-DEFAULT NO-REMAP POSITION)
Return the binding for command KEY in current keymaps. KEY is a string or vector, a sequence of keystrokes. The binding is probably a symbol with a function definition.
bind-key
, which is part ofuse-package
(github.com/jwiegley/use-package). It's a nice wrapper for defining keys that let's you easily see all your personal bindings and what they've replaced. – glucas Dec 15 '14 at 22:25