5

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.)

  • Not an answer, but perhaps of interest given your question: check out bind-key, which is part of use-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
6

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.

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.