I'm following the "trick" described here to add new key bindings to my .emacs file: http://www.gnu.org/software/emacs/manual/html_node/efaq/Binding-keys-to-commands.html

However, it's resulting in lines like this in my .emacs file:

(global-set-key [24 4] (quote some-command))

Instead of [24 4] I want it to explicitly mention the human-readable key commands C-x C-d. Otherwise when I'm looking at my .emacs file I can't make sense of [24 4] and forget what keys I've bound things to.

1) what should I replace [24 4] with in my .emacs file to make it human-readable?

2) Is there a way to use the above "trick" and have it generate the human-readable key command instead of numerals?

2 Answers 2


You can use the function key-description to convert the sequence into a more readable form -

(key-description [24 4])
=> "C-x C-d"

and then convert it back using the function kbd, so you can say

(global-set-key (kbd "C-x C-d") 'some-command)

So using kbd you can skip the trick mentioned and just write your keybindings directly. It's a little more typing than other representations but it's definitely easier to read.

To see how to write a given key, hit C-h c then the key(s) - this calls describe-key-briefly and outputs something in the message area like "M-Q runs the command fill-paragraph" or "<C-M-f7> is undefined".


In Emacs lisp, characters are written ?<char>, and just like in C they are treated like integers, so instead of 24 you can write ?\C-x or ?\^x and instead of you can write ?\C-d or ?\^d, so over all, I'd write it [?\C-x ?\C-d].

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .