Previous: Find Init, Up: Init File

48.4.5 Non-ASCII Characters in Init Files

Language and coding systems may cause problems if your init file contains non-ASCII characters, such as accented letters, in strings or key bindings.

If you want to use non-ASCII characters in your init file, you should put a ‘-*-coding: coding-system-*- tag on the first line of the init file, and specify a coding system that supports the character(s) in question. See Recognize Coding. This is because the defaults for decoding non-ASCII text might not yet be set up by the time Emacs reads those parts of your init file which use such strings, possibly leading Emacs to decode those strings incorrectly. You should then avoid adding Emacs Lisp code that modifies the coding system in other ways, such as calls to set-language-environment.

To bind non-ASCII keys, you must use a vector (see Init Rebinding). The string syntax cannot be used, since the non-ASCII characters will be interpreted as meta keys. For instance:

     (global-set-key [?char] 'some-function)

Type C-q, followed by the key you want to bind, to insert char.

Warning: if you change the keyboard encoding, or change between multibyte and unibyte mode, or anything that would alter which code C-q would insert for that character, this key binding may stop working. It is therefore advisable to use one and only one coding system, for your init file as well as the files you edit. For example, don't mix the ‘latin-1’ and ‘latin-9’ coding systems.