1. Home
  2. Computing & Technology
  3. Linux

Non-ASCII Rebinding
Emacs Documentation

By , About.com Guide

Non-ASCII Characters on the Keyboard

If your keyboard has keys that send non-ASCII characters, such as accented letters, rebinding these keys is a bit tricky. There are two solutions you can use. One is to specify a keyboard coding system, using set-keyboard-coding-system (see Specify Coding). Then you can bind these keys in the usual way1, like this:

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

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

If you don't specify the keyboard coding system, that approach won't work. Instead, you need to find out the actual code that the terminal sends. The easiest way to do this in Emacs is to create an empty buffer with C-x b temp <RET>, make it unibyte with M-x toggle-enable-multibyte-characters <RET>, then type the key to insert the character into this buffer.

Move point before the character, then type C-x =. This displays a message in the minibuffer, showing the character code in three ways, octal, decimal and hexadecimal, all within a set of parentheses. Use the second of the three numbers, the decimal one, inside the vector to bind:

(global-set-key [decimal-code] 'some-function)

If you bind 8-bit characters like this in your init file, you may find it convenient to specify that it is unibyte. See Enabling Multibyte.


Footnotes


* Emacs Manual Index

Explore Linux
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Software
  5. Editors
  6. Emacs
  7. Emacs Documentation - Non-ASCII Rebinding

©2009 About.com, a part of The New York Times Company.

All rights reserved.