Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse (kbd) function?

Tags:

emacs

elisp

I was wondering if there is a reverse (kbd) function, one I could use to get from a keycode a meaningful description of it, e.g., C-b from 2.

Usually (format "%c" x) does work, but not for the previous example as well as for many others, as keybindings, specially on Emacs, are often more complicated than a single character, and even when they are indeed a single character, they can be a whitespace or a Tab.

It seems that the documentation functions use themselves the function (describe-buffer-bindings), which is written in C and therefore immutable, and I'd like to avoid that route, if possible, and manipulate the data in my way to provide fancier features.

like image 528
konr Avatar asked Sep 03 '11 08:09

konr


1 Answers

You're probably looking for (key-description KEYS &optional PREFIX).

For example: (key-description [2]) and (key-description (kbd "C-b")) evaluate to "C-b".

like image 197
nschum Avatar answered Oct 16 '22 09:10

nschum