The macro kbd doesn't work for all desired input. For example, this results in an error:

(kbd "C-H-left")
edmacro-parse-keys: C-H- must prefix a single character, not left

and should be written as:

(kbd "C-H-<left>")

There is an alternative (vector) syntax:

[?\C-\H-x home]

but this representation also isn't unique: the vector above has the same meaning as

[(control hyper x) home]

Also, (kbd "RET") isn't [return], but ?\C-m. Same with (kbd "DEL") and others.

Forms (kbd "\e\eq") and [?\e \?M-q] represent the same key sequence, but have different values:

(kbd "\e\eq")  ; evaluated to "^[^[q"

[?\e \?M-q]    ; evaluated to [27 134217841]

Are all these syntax rules available in Emacs >= v22.x?

Which syntax is consistent and regular? Which mini-language describing key sequences has fewer special cases?

I found that I need to consult references every time I make a new key binding. Consider binding ESC M-H-kp-2 C-PgUp or similar.

  • 2
    Could you please clarify what you want to ask in your question? "What syntax is preferred?" is pretty broad and will elicit opinion-based answers. If you mean something like "what's the cleanest syntax" or "what's the least error-prone syntax" (or something else), please edit the post to reflect it. – Dan Feb 12 '16 at 17:47
  • Where are less special cases in syntax of mini-language? – gavenkoa Feb 12 '16 at 18:33
  • Why should I care of difference between \r and RET or <RET> or [return]?? – gavenkoa Feb 12 '16 at 18:34