Next: , Previous: , Up: Miscellaneous  

5.1: Emacs Lisp Programming Techniques

Q5.1.1: What is the difference in key sequences between XEmacs/SXEmacs and GNU Emacs?

Erik Naggum writes;

Emacs has a legacy of keyboards that produced characters with modifier bits, and therefore map a variety of input systems into this scheme even today. XEmacs is instead optimized for X events. This causes an incompatibility in the way key sequences are specified, but both Emacs and XEmacs will accept a key sequence as a vector of lists of modifiers that ends with a key, e.g., to bind M-C-a, you would say [(meta control a)] in both Emacsen. XEmacs has an abbreviated form for a single key, just (meta control a). Emacs has an abbreviated form for the Control and the Meta modifiers to string-characters (the ASCII characters), as in ‘\M-\C-a’. XEmacs users need to be aware that the abbreviated form works only for one-character key sequences, while Emacs users need to be aware that the string-character is rather limited. Specifically, the string-character can accommodate only 256 different values, 128 of which have the Meta modifier and 128 of which have not. In each of these blocks, only 32 characters have the Control modifier. Whereas [(meta control A)] differs from [(meta control a)] because the case differs, ‘\M-\C-a’ and ‘\M-\C-A’ do not. Programmers are advised to use the full common form, both because it is more readable and less error-prone, and because it is supported by both Emacsen.

Another (even safer) way to be sure of the key-sequences is to use the read-kbd-macro function, which takes a string like ‘C-c <up>’, and converts it to the internal key representation of the Emacs you use. The function is available under all Emacsen.

Next: , Previous: , Up: Miscellaneous