diff options
| author | Stefan Monnier | 2007-10-09 05:05:39 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-10-09 05:05:39 +0000 |
| commit | 4f4a84ec801ea0d62d32a1b5679def1e16d3f813 (patch) | |
| tree | 86e671367bcef6d2b42e0a3ae0e1a83c32659f50 /doc | |
| parent | beb9f7453ae9a4473cf43a16c186a090d77c4b3b (diff) | |
| download | emacs-4f4a84ec801ea0d62d32a1b5679def1e16d3f813.tar.gz emacs-4f4a84ec801ea0d62d32a1b5679def1e16d3f813.zip | |
Add new `input-decode-map' keymap and use it for temrinal
escape sequences.
* keyboard.h (struct kboard): Add Vinput_decode_map.
Remove Vlocal_key_translation_map.
* keyboard.c (read_key_sequence): Add support for input-decode-map.
(init_kboard): Init input-decode-map.
Replace local-key-translation-map back with key-translation-map.
(syms_of_keyboard): Declare input-decode-map.
Remove local-key-translation-map. Update docstrings.
(mark_kboards): Mark Vinput_decode_map.
Don't mark Vlocal_key_translation_map.
* keymap.c (Fdescribe_buffer_bindings): Describe input-decode-map.
Replace local-key-translation-map back with key-translation-map.
* term.c (term_get_fkeys_1, CONDITIONAL_REASSIGN):
Bind in input-decode-map rather than function-key-map.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/emacs/custom.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/keymaps.texi | 69 | ||||
| -rw-r--r-- | doc/lispref/maps.texi | 7 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 2 | ||||
| -rw-r--r-- | doc/misc/viper.texi | 10 |
5 files changed, 50 insertions, 41 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index d496ab84b19..1276c45af70 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -2419,7 +2419,8 @@ kept.@refill | |||
| 2419 | 2419 | ||
| 2420 | The usual purpose of the terminal-specific library is to map the | 2420 | The usual purpose of the terminal-specific library is to map the |
| 2421 | escape sequences used by the terminal's function keys onto more | 2421 | escape sequences used by the terminal's function keys onto more |
| 2422 | meaningful names, using @code{function-key-map}. See the file | 2422 | meaningful names, using @code{input-decode-map} (or |
| 2423 | @code{function-key-map} before it). See the file | ||
| 2423 | @file{term/lk201.el} for an example of how this is done. Many function | 2424 | @file{term/lk201.el} for an example of how this is done. Many function |
| 2424 | keys are mapped automatically according to the information in the | 2425 | keys are mapped automatically according to the information in the |
| 2425 | Termcap data base; the terminal-specific library needs to map only the | 2426 | Termcap data base; the terminal-specific library needs to map only the |
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index eb10dfcbce3..2bd0de60f58 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi | |||
| @@ -1512,17 +1512,18 @@ specifies a list of keymaps to search in. This argument is ignored if | |||
| 1512 | This section describes keymaps that are used during reading a key | 1512 | This section describes keymaps that are used during reading a key |
| 1513 | sequence, to translate certain event sequences into others. | 1513 | sequence, to translate certain event sequences into others. |
| 1514 | @code{read-key-sequence} checks every subsequence of the key sequence | 1514 | @code{read-key-sequence} checks every subsequence of the key sequence |
| 1515 | being read, as it is read, against @code{function-key-map} and then | 1515 | being read, as it is read, against @code{input-decode-map}, then |
| 1516 | against @code{key-translation-map}. | 1516 | @code{function-key-map}, and then against @code{key-translation-map}. |
| 1517 | |||
| 1518 | @defvar input-decode-map | ||
| 1517 | 1519 | ||
| 1518 | @defvar function-key-map | ||
| 1519 | This variable holds a keymap that describes the character sequences sent | 1520 | This variable holds a keymap that describes the character sequences sent |
| 1520 | by function keys on an ordinary character terminal. This keymap has the | 1521 | by function keys on an ordinary character terminal. This keymap has the |
| 1521 | same structure as other keymaps, but is used differently: it specifies | 1522 | same structure as other keymaps, but is used differently: it specifies |
| 1522 | translations to make while reading key sequences, rather than bindings | 1523 | translations to make while reading key sequences, rather than bindings |
| 1523 | for key sequences. | 1524 | for key sequences. |
| 1524 | 1525 | ||
| 1525 | If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector | 1526 | If @code{input-decode-map} ``binds'' a key sequence @var{k} to a vector |
| 1526 | @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a | 1527 | @var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a |
| 1527 | key sequence, it is replaced with the events in @var{v}. | 1528 | key sequence, it is replaced with the events in @var{v}. |
| 1528 | 1529 | ||
| @@ -1530,50 +1531,49 @@ For example, VT100 terminals send @kbd{@key{ESC} O P} when the | |||
| 1530 | keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate | 1531 | keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate |
| 1531 | that sequence of events into the single event @code{pf1}. We accomplish | 1532 | that sequence of events into the single event @code{pf1}. We accomplish |
| 1532 | this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in | 1533 | this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in |
| 1533 | @code{function-key-map}, when using a VT100. | 1534 | @code{input-decode-map}, when using a VT100. |
| 1534 | 1535 | ||
| 1535 | Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c | 1536 | Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c |
| 1536 | @key{ESC} O P}; later the function @code{read-key-sequence} translates | 1537 | @key{ESC} O P}; later the function @code{read-key-sequence} translates |
| 1537 | this back into @kbd{C-c @key{PF1}}, which it returns as the vector | 1538 | this back into @kbd{C-c @key{PF1}}, which it returns as the vector |
| 1538 | @code{[?\C-c pf1]}. | 1539 | @code{[?\C-c pf1]}. |
| 1539 | 1540 | ||
| 1540 | Entries in @code{function-key-map} are ignored if they conflict with | 1541 | The value of @code{input-decode-map} is usually set up automatically |
| 1541 | bindings made in the minor mode, local, or global keymaps. The intent | ||
| 1542 | is that the character sequences that function keys send should not have | ||
| 1543 | command bindings in their own right---but if they do, the ordinary | ||
| 1544 | bindings take priority. | ||
| 1545 | |||
| 1546 | The value of @code{function-key-map} is usually set up automatically | ||
| 1547 | according to the terminal's Terminfo or Termcap entry, but sometimes | 1542 | according to the terminal's Terminfo or Termcap entry, but sometimes |
| 1548 | those need help from terminal-specific Lisp files. Emacs comes with | 1543 | those need help from terminal-specific Lisp files. Emacs comes with |
| 1549 | terminal-specific files for many common terminals; their main purpose is | 1544 | terminal-specific files for many common terminals; their main purpose is |
| 1550 | to make entries in @code{function-key-map} beyond those that can be | 1545 | to make entries in @code{input-decode-map} beyond those that can be |
| 1551 | deduced from Termcap and Terminfo. @xref{Terminal-Specific}. | 1546 | deduced from Termcap and Terminfo. @xref{Terminal-Specific}. |
| 1552 | @end defvar | 1547 | @end defvar |
| 1553 | 1548 | ||
| 1554 | @defvar key-translation-map | 1549 | @defvar function-key-map |
| 1555 | This variable is another keymap used just like @code{function-key-map} | ||
| 1556 | to translate input events into other events. It differs from | ||
| 1557 | @code{function-key-map} in two ways: | ||
| 1558 | 1550 | ||
| 1559 | @itemize @bullet | 1551 | This variable holds a keymap similar to @code{input-decode-map} except |
| 1560 | @item | 1552 | that it describes key sequences which should be translated to |
| 1561 | @code{key-translation-map} goes to work after @code{function-key-map} is | 1553 | alternative interpretations that are usually preferred. It applies |
| 1562 | finished; it receives the results of translation by | 1554 | after @code{input-decode-map} and before @code{key-translation-map}. |
| 1563 | @code{function-key-map}. | ||
| 1564 | 1555 | ||
| 1565 | @item | 1556 | Entries in @code{function-key-map} are ignored if they conflict with |
| 1566 | Non-prefix bindings in @code{key-translation-map} override actual key | 1557 | bindings made in the minor mode, local, or global keymaps. I.e. |
| 1567 | bindings. For example, if @kbd{C-x f} has a non-prefix binding in | 1558 | the remapping only applies if the original key sequence would |
| 1568 | @code{key-translation-map}, that translation takes effect even though | 1559 | otherwise not have any binding. |
| 1569 | @kbd{C-x f} also has a key binding in the global map. | 1560 | @end defvar |
| 1570 | @end itemize | ||
| 1571 | 1561 | ||
| 1572 | Note however that actual key bindings can have an effect on | 1562 | @defvar key-translation-map |
| 1573 | @code{key-translation-map}, even though they are overridden by it. | 1563 | This variable is another keymap used just like @code{input-decode-map} |
| 1574 | Indeed, actual key bindings override @code{function-key-map} and thus | 1564 | to translate input events into other events. It differs from |
| 1575 | may alter the key sequence that @code{key-translation-map} receives. | 1565 | @code{input-decode-map} in that it goes to work after |
| 1576 | Clearly, it is better to avoid this type of situation. | 1566 | @code{function-key-map} is finished rather than before; it receives |
| 1567 | the results of translation by @code{function-key-map}. | ||
| 1568 | |||
| 1569 | Just like @code{input-decode-map}, but unlike @code{function-key-map}, | ||
| 1570 | this keymap is applied regardless of whether the input key-sequence | ||
| 1571 | has a normal binding. Note however that actual key bindings can have | ||
| 1572 | an effect on @code{key-translation-map}, even though they are | ||
| 1573 | overridden by it. Indeed, actual key bindings override | ||
| 1574 | @code{function-key-map} and thus may alter the key sequence that | ||
| 1575 | @code{key-translation-map} receives. Clearly, it is better to avoid | ||
| 1576 | this type of situation. | ||
| 1577 | 1577 | ||
| 1578 | The intent of @code{key-translation-map} is for users to map one | 1578 | The intent of @code{key-translation-map} is for users to map one |
| 1579 | character set to another, including ordinary characters normally bound | 1579 | character set to another, including ordinary characters normally bound |
| @@ -1581,7 +1581,8 @@ to @code{self-insert-command}. | |||
| 1581 | @end defvar | 1581 | @end defvar |
| 1582 | 1582 | ||
| 1583 | @cindex key translation function | 1583 | @cindex key translation function |
| 1584 | You can use @code{function-key-map} or @code{key-translation-map} for | 1584 | You can use @code{input-decode-map}, @code{function-key-map}, or |
| 1585 | @code{key-translation-map} for | ||
| 1585 | more than simple aliases, by using a function, instead of a key | 1586 | more than simple aliases, by using a function, instead of a key |
| 1586 | sequence, as the ``translation'' of a key. Then this function is called | 1587 | sequence, as the ``translation'' of a key. Then this function is called |
| 1587 | to compute the translation of that key. | 1588 | to compute the translation of that key. |
diff --git a/doc/lispref/maps.texi b/doc/lispref/maps.texi index 5a5745b1b51..2e370f91238 100644 --- a/doc/lispref/maps.texi +++ b/doc/lispref/maps.texi | |||
| @@ -113,7 +113,7 @@ The sparse keymap that displays the Special Props submenu of the Text | |||
| 113 | Properties menu. | 113 | Properties menu. |
| 114 | 114 | ||
| 115 | @item function-key-map | 115 | @item function-key-map |
| 116 | The keymap for translating keypad and function keys.@* | 116 | The keymap for translating key sequences to preferred alternatives.@* |
| 117 | If there are none, then it contains an empty sparse keymap. | 117 | If there are none, then it contains an empty sparse keymap. |
| 118 | @xref{Translation Keymaps}. | 118 | @xref{Translation Keymaps}. |
| 119 | 119 | ||
| @@ -151,6 +151,11 @@ A sparse keymap used by the @kbd{e} command of Info. | |||
| 151 | @vindex Info-mode-map | 151 | @vindex Info-mode-map |
| 152 | A sparse keymap containing Info commands. | 152 | A sparse keymap containing Info commands. |
| 153 | 153 | ||
| 154 | @item input-decode-map | ||
| 155 | The keymap for translating keypad and function keys.@* | ||
| 156 | If there are none, then it contains an empty sparse keymap. | ||
| 157 | @xref{Translation Keymaps}. | ||
| 158 | |||
| 154 | @item isearch-mode-map | 159 | @item isearch-mode-map |
| 155 | @vindex isearch-mode-map | 160 | @vindex isearch-mode-map |
| 156 | A keymap that defines the characters you can type within incremental | 161 | A keymap that defines the characters you can type within incremental |
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 89b44a99353..68fba8d9774 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -279,7 +279,7 @@ trying the @samp{.elc} and @samp{.el} suffixes. | |||
| 279 | @cindex Termcap | 279 | @cindex Termcap |
| 280 | The usual function of a terminal-specific library is to enable | 280 | The usual function of a terminal-specific library is to enable |
| 281 | special keys to send sequences that Emacs can recognize. It may also | 281 | special keys to send sequences that Emacs can recognize. It may also |
| 282 | need to set or add to @code{function-key-map} if the Termcap or | 282 | need to set or add to @code{input-decode-map} if the Termcap or |
| 283 | Terminfo entry does not specify all the terminal's function keys. | 283 | Terminfo entry does not specify all the terminal's function keys. |
| 284 | @xref{Terminal Input}. | 284 | @xref{Terminal Input}. |
| 285 | 285 | ||
diff --git a/doc/misc/viper.texi b/doc/misc/viper.texi index 4e9eaaff40e..c86b2383168 100644 --- a/doc/misc/viper.texi +++ b/doc/misc/viper.texi | |||
| @@ -1745,7 +1745,8 @@ Setting this variable too high may slow down your typing. Setting it too | |||
| 1745 | low may make it hard to type macros quickly enough. | 1745 | low may make it hard to type macros quickly enough. |
| 1746 | @item viper-translate-all-ESC-keysequences @code{t} on tty, @code{nil} on windowing display | 1746 | @item viper-translate-all-ESC-keysequences @code{t} on tty, @code{nil} on windowing display |
| 1747 | Normally, Viper lets Emacs translate only those ESC key sequences that are | 1747 | Normally, Viper lets Emacs translate only those ESC key sequences that are |
| 1748 | defined in the low-level key-translation-map or function-key-map, such as those | 1748 | defined in the low-level @code{input-decode-map}, @code{key-translation-map} |
| 1749 | or @code{function-key-map}, such as those | ||
| 1749 | emitted by the arrow and function keys. Other sequences, e.g., @kbd{\\e/}, are | 1750 | emitted by the arrow and function keys. Other sequences, e.g., @kbd{\\e/}, are |
| 1750 | treated as @kbd{ESC} command followed by a @kbd{/}. This is good for people | 1751 | treated as @kbd{ESC} command followed by a @kbd{/}. This is good for people |
| 1751 | who type fast and tend to hit other characters right after they hit | 1752 | who type fast and tend to hit other characters right after they hit |
| @@ -2009,12 +2010,12 @@ not emit the right signals for Emacs to understand. To let Emacs know about | |||
| 2009 | those keys, you will have to find out which key sequences they emit | 2010 | those keys, you will have to find out which key sequences they emit |
| 2010 | by typing @kbd{C-q} and then the key (you should switch to Emacs state | 2011 | by typing @kbd{C-q} and then the key (you should switch to Emacs state |
| 2011 | first). Then you can bind those sequences to their preferred forms using | 2012 | first). Then you can bind those sequences to their preferred forms using |
| 2012 | @code{function-key-map} as follows: | 2013 | @code{input-decode-map} as follows: |
| 2013 | 2014 | ||
| 2014 | @lisp | 2015 | @lisp |
| 2015 | (cond ((string= (getenv "TERM") "xterm") | 2016 | (cond ((string= (getenv "TERM") "xterm") |
| 2016 | (define-key function-key-map "\e[192z" [f11]) ; L1 | 2017 | (define-key input-decode-map "\e[192z" [f11]) ; L1 |
| 2017 | (define-key function-key-map "\e[195z" [f14]) ; L4, Undo | 2018 | (define-key input-decode-map "\e[195z" [f14]) ; L4, Undo |
| 2018 | @end lisp | 2019 | @end lisp |
| 2019 | 2020 | ||
| 2020 | The above illustrates how to do this for Xterm. On VT100, you would have to | 2021 | The above illustrates how to do this for Xterm. On VT100, you would have to |
| @@ -2206,6 +2207,7 @@ So much about Viper-specific bindings. | |||
| 2206 | Manual}, and the Emacs quick reference card for the general info on key | 2207 | Manual}, and the Emacs quick reference card for the general info on key |
| 2207 | bindings in Emacs. | 2208 | bindings in Emacs. |
| 2208 | 2209 | ||
| 2210 | @vindex @code{input-decode-map} | ||
| 2209 | @vindex @code{function-key-map} | 2211 | @vindex @code{function-key-map} |
| 2210 | @vindex @code{viper-vi-global-user-map} | 2212 | @vindex @code{viper-vi-global-user-map} |
| 2211 | @vindex @code{viper-insert-global-user-map} | 2213 | @vindex @code{viper-insert-global-user-map} |