1619 |
@cindex rebinding non-@acronym{ASCII} keys |
@cindex rebinding non-@acronym{ASCII} keys |
1620 |
@cindex non-@acronym{ASCII} keys, binding |
@cindex non-@acronym{ASCII} keys, binding |
1621 |
|
|
1622 |
If your keyboard has keys that send non-@acronym{ASCII} characters, such as |
If your keyboard has keys that send non-@acronym{ASCII} |
1623 |
accented letters, rebinding these keys is a bit tricky. There are two |
characters, such as accented letters, rebinding these keys |
1624 |
solutions you can use. One is to specify a keyboard coding system, |
must be done by using a vector like this@footnote{Note that |
1625 |
using @code{set-keyboard-coding-system} (@pxref{Specify Coding}). |
you should avoid the string syntax for binding |
1626 |
Then you can bind these keys in the usual way@footnote{Note that you |
non-@acronym{ASCII} characters, since they will be |
1627 |
should avoid the string syntax for binding 8-bit characters, since |
interpreted as meta keys. @xref{Strings of Events,,,elisp, |
1628 |
they will be interpreted as meta keys. @xref{Strings of |
The Emacs Lisp Reference Manual}.}: |
|
Events,,,elisp, The Emacs Lisp Reference Manual}.}, like this: |
|
1629 |
|
|
1630 |
@example |
@example |
1631 |
(global-set-key [?@var{char}] 'some-function) |
(global-set-key [?@var{char}] 'some-function) |
1634 |
@noindent |
@noindent |
1635 |
Type @kbd{C-q} followed by the key you want to bind, to insert @var{char}. |
Type @kbd{C-q} followed by the key you want to bind, to insert @var{char}. |
1636 |
|
|
1637 |
Since this puts a non-@acronym{ASCII} character in the @file{.emacs}, you should |
Since this puts a non-@acronym{ASCII} character in the @file{.emacs}, |
1638 |
specify the proper coding system for that file. @xref{Init Syntax}. |
you should specify for that file a coding system that supports |
1639 |
Specify the same coding system for the file that you use for your |
that character. @xref{Init Syntax}. |
1640 |
keyboard. |
|
1641 |
|
@strong{Warning:} if you change the keyboard encoding, such that the code that |
1642 |
If you don't specify a keyboard coding system, that approach won't |
@kbd{C-q} inserts becomes different, you'll need to edit the |
1643 |
work. Instead, you need to find out the actual code that the terminal |
Lisp expression accordingly. |
|
sends. The easiest way to do this in Emacs is to create an empty |
|
|
buffer with @kbd{C-x b temp @key{RET}}, make it unibyte with @kbd{M-x |
|
|
toggle-enable-multibyte-characters @key{RET}}, then type the key to |
|
|
insert the character into this buffer. |
|
|
|
|
|
Move point before the character, then type @kbd{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: |
|
1644 |
|
|
1645 |
@example |
@strong{Warning:} @kbd{C-q} will insert the wrong code if you visit |
1646 |
(global-set-key [@var{decimal-code}] 'some-function) |
the file @file{.emacs} in a unibyte buffer, so don't do that. |
|
@end example |
|
|
|
|
|
If you bind 8-bit characters like this in your init file, you may find it |
|
|
convenient to specify that it is unibyte. @xref{Enabling Multibyte}. |
|
1647 |
|
|
1648 |
@node Mouse Buttons |
@node Mouse Buttons |
1649 |
@subsection Rebinding Mouse Buttons |
@subsection Rebinding Mouse Buttons |