1081 |
* Init Rebinding:: Rebinding keys with your init file, @file{.emacs}. |
* Init Rebinding:: Rebinding keys with your init file, @file{.emacs}. |
1082 |
* Function Keys:: Rebinding terminal function keys. |
* Function Keys:: Rebinding terminal function keys. |
1083 |
* Named ASCII Chars:: Distinguishing @key{TAB} from @kbd{C-i}, and so on. |
* Named ASCII Chars:: Distinguishing @key{TAB} from @kbd{C-i}, and so on. |
1084 |
* Non-ASCII Rebinding:: Rebinding non-ASCII characters such as Latin-1. |
* Non-ASCII Rebinding:: Rebinding non-@acronym{ASCII} characters such as Latin-1. |
1085 |
* Mouse Buttons:: Rebinding mouse buttons in Emacs. |
* Mouse Buttons:: Rebinding mouse buttons in Emacs. |
1086 |
* Disabling:: Disabling a command means confirmation is required |
* Disabling:: Disabling a command means confirmation is required |
1087 |
before it can be executed. This is done to protect |
before it can be executed. This is done to protect |
1405 |
you can specify them in your @file{.emacs} file by using their Lisp |
you can specify them in your @file{.emacs} file by using their Lisp |
1406 |
syntax. (@xref{Init File}.) |
syntax. (@xref{Init File}.) |
1407 |
|
|
1408 |
The simplest method for doing this works for ASCII characters and |
The simplest method for doing this works for @acronym{ASCII} characters and |
1409 |
Meta-modified ASCII characters only. This method uses a string to |
Meta-modified @acronym{ASCII} characters only. This method uses a string to |
1410 |
represent the key sequence you want to rebind. For example, here's how |
represent the key sequence you want to rebind. For example, here's how |
1411 |
to bind @kbd{C-z} to @code{shell}: |
to bind @kbd{C-z} to @code{shell}: |
1412 |
|
|
1436 |
(global-set-key "\C-x\t" 'indent-rigidly) |
(global-set-key "\C-x\t" 'indent-rigidly) |
1437 |
@end example |
@end example |
1438 |
|
|
1439 |
These examples show how to write some other special ASCII characters |
These examples show how to write some other special @acronym{ASCII} characters |
1440 |
in strings for key bindings: |
in strings for key bindings: |
1441 |
|
|
1442 |
@example |
@example |
1446 |
@end example |
@end example |
1447 |
|
|
1448 |
When the key sequence includes function keys or mouse button events, |
When the key sequence includes function keys or mouse button events, |
1449 |
or non-ASCII characters such as @code{C-=} or @code{H-a}, you must use |
or non-@acronym{ASCII} characters such as @code{C-=} or @code{H-a}, you must use |
1450 |
the more general method of rebinding, which uses a vector to specify the |
the more general method of rebinding, which uses a vector to specify the |
1451 |
key sequence. |
key sequence. |
1452 |
|
|
1458 |
the character as it would appear in a string. |
the character as it would appear in a string. |
1459 |
|
|
1460 |
Here are examples of using vectors to rebind @kbd{C-=} (a control |
Here are examples of using vectors to rebind @kbd{C-=} (a control |
1461 |
character not in ASCII), @kbd{C-M-=} (not in ASCII because @kbd{C-=} |
character not in @acronym{ASCII}), @kbd{C-M-=} (not in @acronym{ASCII} because @kbd{C-=} |
1462 |
is not), @kbd{H-a} (a Hyper character; ASCII doesn't have Hyper at |
is not), @kbd{H-a} (a Hyper character; @acronym{ASCII} doesn't have Hyper at |
1463 |
all), @key{F7} (a function key), and @kbd{C-Mouse-1} (a |
all), @key{F7} (a function key), and @kbd{C-Mouse-1} (a |
1464 |
keyboard-modified mouse button): |
keyboard-modified mouse button): |
1465 |
|
|
1490 |
delimit the vector. |
delimit the vector. |
1491 |
|
|
1492 |
Language and coding systems can cause problems with key bindings |
Language and coding systems can cause problems with key bindings |
1493 |
for non-ASCII characters. @xref{Non-ASCII Rebinding}. |
for non-@acronym{ASCII} characters. @xref{Non-ASCII Rebinding}. |
1494 |
|
|
1495 |
@node Function Keys |
@node Function Keys |
1496 |
@subsection Rebinding Function Keys |
@subsection Rebinding Function Keys |
1535 |
key. |
key. |
1536 |
|
|
1537 |
A key sequence which contains function key symbols (or anything but |
A key sequence which contains function key symbols (or anything but |
1538 |
ASCII characters) must be a vector rather than a string. The vector |
@acronym{ASCII} characters) must be a vector rather than a string. The vector |
1539 |
syntax uses spaces between the elements, and square brackets around the |
syntax uses spaces between the elements, and square brackets around the |
1540 |
whole vector. Thus, to bind function key @samp{f1} to the command |
whole vector. Thus, to bind function key @samp{f1} to the command |
1541 |
@code{rmail}, write the following: |
@code{rmail}, write the following: |
1583 |
@end example |
@end example |
1584 |
|
|
1585 |
@node Named ASCII Chars |
@node Named ASCII Chars |
1586 |
@subsection Named ASCII Control Characters |
@subsection Named @acronym{ASCII} Control Characters |
1587 |
|
|
1588 |
@key{TAB}, @key{RET}, @key{BS}, @key{LFD}, @key{ESC} and @key{DEL} |
@key{TAB}, @key{RET}, @key{BS}, @key{LFD}, @key{ESC} and @key{DEL} |
1589 |
started out as names for certain ASCII control characters, used so often |
started out as names for certain @acronym{ASCII} control characters, used so often |
1590 |
that they have special keys of their own. Later, users found it |
that they have special keys of their own. Later, users found it |
1591 |
convenient to distinguish in Emacs between these keys and the ``same'' |
convenient to distinguish in Emacs between these keys and the ``same'' |
1592 |
control characters typed with the @key{CTRL} key. |
control characters typed with the @key{CTRL} key. |
1595 |
reports these keys to Emacs. It treats the ``special'' keys as function |
reports these keys to Emacs. It treats the ``special'' keys as function |
1596 |
keys named @code{tab}, @code{return}, @code{backspace}, @code{linefeed}, |
keys named @code{tab}, @code{return}, @code{backspace}, @code{linefeed}, |
1597 |
@code{escape}, and @code{delete}. These function keys translate |
@code{escape}, and @code{delete}. These function keys translate |
1598 |
automatically into the corresponding ASCII characters @emph{if} they |
automatically into the corresponding @acronym{ASCII} characters @emph{if} they |
1599 |
have no bindings of their own. As a result, neither users nor Lisp |
have no bindings of their own. As a result, neither users nor Lisp |
1600 |
programs need to pay attention to the distinction unless they care to. |
programs need to pay attention to the distinction unless they care to. |
1601 |
|
|
1602 |
If you do not want to distinguish between (for example) @key{TAB} and |
If you do not want to distinguish between (for example) @key{TAB} and |
1603 |
@kbd{C-i}, make just one binding, for the ASCII character @key{TAB} |
@kbd{C-i}, make just one binding, for the @acronym{ASCII} character @key{TAB} |
1604 |
(octal code 011). If you do want to distinguish, make one binding for |
(octal code 011). If you do want to distinguish, make one binding for |
1605 |
this ASCII character, and another for the ``function key'' @code{tab}. |
this @acronym{ASCII} character, and another for the ``function key'' @code{tab}. |
1606 |
|
|
1607 |
With an ordinary ASCII terminal, there is no way to distinguish |
With an ordinary @acronym{ASCII} terminal, there is no way to distinguish |
1608 |
between @key{TAB} and @kbd{C-i} (and likewise for other such pairs), |
between @key{TAB} and @kbd{C-i} (and likewise for other such pairs), |
1609 |
because the terminal sends the same character in both cases. |
because the terminal sends the same character in both cases. |
1610 |
|
|
1611 |
@node Non-ASCII Rebinding |
@node Non-ASCII Rebinding |
1612 |
@subsection Non-ASCII Characters on the Keyboard |
@subsection Non-@acronym{ASCII} Characters on the Keyboard |
1613 |
@cindex rebinding non-ASCII keys |
@cindex rebinding non-@acronym{ASCII} keys |
1614 |
@cindex non-ASCII keys, binding |
@cindex non-@acronym{ASCII} keys, binding |
1615 |
|
|
1616 |
If your keyboard has keys that send non-ASCII characters, such as |
If your keyboard has keys that send non-@acronym{ASCII} characters, such as |
1617 |
accented letters, rebinding these keys is a bit tricky. There are two |
accented letters, rebinding these keys is a bit tricky. There are two |
1618 |
solutions you can use. One is to specify a keyboard coding system, |
solutions you can use. One is to specify a keyboard coding system, |
1619 |
using @code{set-keyboard-coding-system} (@pxref{Specify Coding}). |
using @code{set-keyboard-coding-system} (@pxref{Specify Coding}). |
1629 |
@noindent |
@noindent |
1630 |
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}. |
1631 |
|
|
1632 |
Since this puts a non-ASCII character in the @file{.emacs}, you should |
Since this puts a non-@acronym{ASCII} character in the @file{.emacs}, you should |
1633 |
specify the proper coding system for that file. @xref{Init Syntax}. |
specify the proper coding system for that file. @xref{Init Syntax}. |
1634 |
Specify the same coding system for the file that you use for your |
Specify the same coding system for the file that you use for your |
1635 |
keyboard. |
keyboard. |
1868 |
characters that result from keyboard translation. |
characters that result from keyboard translation. |
1869 |
|
|
1870 |
On a window system, the keyboard key named @key{DELETE} is a function |
On a window system, the keyboard key named @key{DELETE} is a function |
1871 |
key and is distinct from the ASCII character named @key{DEL}. |
key and is distinct from the @acronym{ASCII} character named @key{DEL}. |
1872 |
@xref{Named ASCII Chars}. Keyboard translations affect only ASCII |
@xref{Named ASCII Chars}. Keyboard translations affect only @acronym{ASCII} |
1873 |
character input, not function keys; thus, the above example used on a |
character input, not function keys; thus, the above example used on a |
1874 |
window system does not affect the @key{DELETE} key. However, the |
window system does not affect the @key{DELETE} key. However, the |
1875 |
translation above isn't necessary on window systems, because Emacs can |
translation above isn't necessary on window systems, because Emacs can |
2002 |
sequences are mandatory. |
sequences are mandatory. |
2003 |
|
|
2004 |
@samp{\C-} can be used as a prefix for a control character, as in |
@samp{\C-} can be used as a prefix for a control character, as in |
2005 |
@samp{\C-s} for ASCII control-S, and @samp{\M-} can be used as a prefix for |
@samp{\C-s} for @acronym{ASCII} control-S, and @samp{\M-} can be used as a prefix for |
2006 |
a Meta character, as in @samp{\M-a} for @kbd{Meta-A} or @samp{\M-\C-a} for |
a Meta character, as in @samp{\M-a} for @kbd{Meta-A} or @samp{\M-\C-a} for |
2007 |
@kbd{Control-Meta-A}.@refill |
@kbd{Control-Meta-A}.@refill |
2008 |
|
|
2009 |
@cindex international characters in @file{.emacs} |
@cindex international characters in @file{.emacs} |
2010 |
@cindex non-ASCII characters in @file{.emacs} |
@cindex non-@acronym{ASCII} characters in @file{.emacs} |
2011 |
If you want to include non-ASCII characters in strings in your init |
If you want to include non-@acronym{ASCII} characters in strings in your init |
2012 |
file, you should consider putting a @w{@samp{-*-coding: |
file, you should consider putting a @w{@samp{-*-coding: |
2013 |
@var{coding-system}-*-}} tag on the first line which states the coding |
@var{coding-system}-*-}} tag on the first line which states the coding |
2014 |
system used to save your @file{.emacs}, as explained in @ref{Recognize |
system used to save your @file{.emacs}, as explained in @ref{Recognize |
2015 |
Coding}. This is because the defaults for decoding non-ASCII text might |
Coding}. This is because the defaults for decoding non-@acronym{ASCII} text might |
2016 |
not yet be set up by the time Emacs reads those parts of your init file |
not yet be set up by the time Emacs reads those parts of your init file |
2017 |
which use such strings, possibly leading Emacs to decode those strings |
which use such strings, possibly leading Emacs to decode those strings |
2018 |
incorrectly. |
incorrectly. |
2025 |
require one and some contexts require the other. |
require one and some contexts require the other. |
2026 |
|
|
2027 |
@xref{Non-ASCII Rebinding}, for information about binding commands to |
@xref{Non-ASCII Rebinding}, for information about binding commands to |
2028 |
keys which send non-ASCII characters. |
keys which send non-@acronym{ASCII} characters. |
2029 |
|
|
2030 |
@item True: |
@item True: |
2031 |
@code{t} stands for `true'. |
@code{t} stands for `true'. |