aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorStefan Monnier2007-10-09 05:05:39 +0000
committerStefan Monnier2007-10-09 05:05:39 +0000
commit4f4a84ec801ea0d62d32a1b5679def1e16d3f813 (patch)
tree86e671367bcef6d2b42e0a3ae0e1a83c32659f50 /doc
parentbeb9f7453ae9a4473cf43a16c186a090d77c4b3b (diff)
downloademacs-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.texi3
-rw-r--r--doc/lispref/keymaps.texi69
-rw-r--r--doc/lispref/maps.texi7
-rw-r--r--doc/lispref/os.texi2
-rw-r--r--doc/misc/viper.texi10
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
2421escape sequences used by the terminal's function keys onto more 2421escape sequences used by the terminal's function keys onto more
2422meaningful names, using @code{function-key-map}. See the file 2422meaningful 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
2424keys are mapped automatically according to the information in the 2425keys are mapped automatically according to the information in the
2425Termcap data base; the terminal-specific library needs to map only the 2426Termcap 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
1513sequence, to translate certain event sequences into others. 1513sequence, 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
1515being read, as it is read, against @code{function-key-map} and then 1515being read, as it is read, against @code{input-decode-map}, then
1516against @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
1519This variable holds a keymap that describes the character sequences sent 1520This variable holds a keymap that describes the character sequences sent
1520by function keys on an ordinary character terminal. This keymap has the 1521by function keys on an ordinary character terminal. This keymap has the
1521same structure as other keymaps, but is used differently: it specifies 1522same structure as other keymaps, but is used differently: it specifies
1522translations to make while reading key sequences, rather than bindings 1523translations to make while reading key sequences, rather than bindings
1523for key sequences. 1524for key sequences.
1524 1525
1525If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector 1526If @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
1527key sequence, it is replaced with the events in @var{v}. 1528key 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
1530keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate 1531keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate
1531that sequence of events into the single event @code{pf1}. We accomplish 1532that sequence of events into the single event @code{pf1}. We accomplish
1532this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in 1533this 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
1535Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c 1536Thus, 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
1537this back into @kbd{C-c @key{PF1}}, which it returns as the vector 1538this 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
1540Entries in @code{function-key-map} are ignored if they conflict with 1541The value of @code{input-decode-map} is usually set up automatically
1541bindings made in the minor mode, local, or global keymaps. The intent
1542is that the character sequences that function keys send should not have
1543command bindings in their own right---but if they do, the ordinary
1544bindings take priority.
1545
1546The value of @code{function-key-map} is usually set up automatically
1547according to the terminal's Terminfo or Termcap entry, but sometimes 1542according to the terminal's Terminfo or Termcap entry, but sometimes
1548those need help from terminal-specific Lisp files. Emacs comes with 1543those need help from terminal-specific Lisp files. Emacs comes with
1549terminal-specific files for many common terminals; their main purpose is 1544terminal-specific files for many common terminals; their main purpose is
1550to make entries in @code{function-key-map} beyond those that can be 1545to make entries in @code{input-decode-map} beyond those that can be
1551deduced from Termcap and Terminfo. @xref{Terminal-Specific}. 1546deduced 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
1555This variable is another keymap used just like @code{function-key-map}
1556to translate input events into other events. It differs from
1557@code{function-key-map} in two ways:
1558 1550
1559@itemize @bullet 1551This variable holds a keymap similar to @code{input-decode-map} except
1560@item 1552that it describes key sequences which should be translated to
1561@code{key-translation-map} goes to work after @code{function-key-map} is 1553alternative interpretations that are usually preferred. It applies
1562finished; it receives the results of translation by 1554after @code{input-decode-map} and before @code{key-translation-map}.
1563@code{function-key-map}.
1564 1555
1565@item 1556Entries in @code{function-key-map} are ignored if they conflict with
1566Non-prefix bindings in @code{key-translation-map} override actual key 1557bindings made in the minor mode, local, or global keymaps. I.e.
1567bindings. For example, if @kbd{C-x f} has a non-prefix binding in 1558the remapping only applies if the original key sequence would
1568@code{key-translation-map}, that translation takes effect even though 1559otherwise 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
1572Note 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. 1563This variable is another keymap used just like @code{input-decode-map}
1574Indeed, actual key bindings override @code{function-key-map} and thus 1564to translate input events into other events. It differs from
1575may alter the key sequence that @code{key-translation-map} receives. 1565@code{input-decode-map} in that it goes to work after
1576Clearly, it is better to avoid this type of situation. 1566@code{function-key-map} is finished rather than before; it receives
1567the results of translation by @code{function-key-map}.
1568
1569Just like @code{input-decode-map}, but unlike @code{function-key-map},
1570this keymap is applied regardless of whether the input key-sequence
1571has a normal binding. Note however that actual key bindings can have
1572an effect on @code{key-translation-map}, even though they are
1573overridden 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
1576this type of situation.
1577 1577
1578The intent of @code{key-translation-map} is for users to map one 1578The intent of @code{key-translation-map} is for users to map one
1579character set to another, including ordinary characters normally bound 1579character 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
1584You can use @code{function-key-map} or @code{key-translation-map} for 1584You can use @code{input-decode-map}, @code{function-key-map}, or
1585@code{key-translation-map} for
1585more than simple aliases, by using a function, instead of a key 1586more than simple aliases, by using a function, instead of a key
1586sequence, as the ``translation'' of a key. Then this function is called 1587sequence, as the ``translation'' of a key. Then this function is called
1587to compute the translation of that key. 1588to 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
113Properties menu. 113Properties menu.
114 114
115@item function-key-map 115@item function-key-map
116The keymap for translating keypad and function keys.@* 116The keymap for translating key sequences to preferred alternatives.@*
117If there are none, then it contains an empty sparse keymap. 117If 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
152A sparse keymap containing Info commands. 152A sparse keymap containing Info commands.
153 153
154@item input-decode-map
155The keymap for translating keypad and function keys.@*
156If 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
156A keymap that defines the characters you can type within incremental 161A 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
281special keys to send sequences that Emacs can recognize. It may also 281special keys to send sequences that Emacs can recognize. It may also
282need to set or add to @code{function-key-map} if the Termcap or 282need to set or add to @code{input-decode-map} if the Termcap or
283Terminfo entry does not specify all the terminal's function keys. 283Terminfo 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
1745low may make it hard to type macros quickly enough. 1745low 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
1747Normally, Viper lets Emacs translate only those ESC key sequences that are 1747Normally, Viper lets Emacs translate only those ESC key sequences that are
1748defined in the low-level key-translation-map or function-key-map, such as those 1748defined in the low-level @code{input-decode-map}, @code{key-translation-map}
1749or @code{function-key-map}, such as those
1749emitted by the arrow and function keys. Other sequences, e.g., @kbd{\\e/}, are 1750emitted by the arrow and function keys. Other sequences, e.g., @kbd{\\e/}, are
1750treated as @kbd{ESC} command followed by a @kbd{/}. This is good for people 1751treated as @kbd{ESC} command followed by a @kbd{/}. This is good for people
1751who type fast and tend to hit other characters right after they hit 1752who 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
2009those keys, you will have to find out which key sequences they emit 2010those keys, you will have to find out which key sequences they emit
2010by typing @kbd{C-q} and then the key (you should switch to Emacs state 2011by typing @kbd{C-q} and then the key (you should switch to Emacs state
2011first). Then you can bind those sequences to their preferred forms using 2012first). 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
2020The above illustrates how to do this for Xterm. On VT100, you would have to 2021The above illustrates how to do this for Xterm. On VT100, you would have to
@@ -2206,6 +2207,7 @@ So much about Viper-specific bindings.
2206Manual}, and the Emacs quick reference card for the general info on key 2207Manual}, and the Emacs quick reference card for the general info on key
2207bindings in Emacs. 2208bindings 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}