Commit 4f4a84ec authored by Stefan Monnier's avatar Stefan Monnier

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.
parent beb9f745
......@@ -2419,7 +2419,8 @@ kept.@refill
The usual purpose of the terminal-specific library is to map the
escape sequences used by the terminal's function keys onto more
meaningful names, using @code{function-key-map}. See the file
meaningful names, using @code{input-decode-map} (or
@code{function-key-map} before it). See the file
@file{term/lk201.el} for an example of how this is done. Many function
keys are mapped automatically according to the information in the
Termcap data base; the terminal-specific library needs to map only the
......
......@@ -1512,17 +1512,18 @@ specifies a list of keymaps to search in. This argument is ignored if
This section describes keymaps that are used during reading a key
sequence, to translate certain event sequences into others.
@code{read-key-sequence} checks every subsequence of the key sequence
being read, as it is read, against @code{function-key-map} and then
against @code{key-translation-map}.
being read, as it is read, against @code{input-decode-map}, then
@code{function-key-map}, and then against @code{key-translation-map}.
@defvar input-decode-map
@defvar function-key-map
This variable holds a keymap that describes the character sequences sent
by function keys on an ordinary character terminal. This keymap has the
same structure as other keymaps, but is used differently: it specifies
translations to make while reading key sequences, rather than bindings
for key sequences.
If @code{function-key-map} ``binds'' a key sequence @var{k} to a vector
If @code{input-decode-map} ``binds'' a key sequence @var{k} to a vector
@var{v}, then when @var{k} appears as a subsequence @emph{anywhere} in a
key sequence, it is replaced with the events in @var{v}.
......@@ -1530,50 +1531,49 @@ For example, VT100 terminals send @kbd{@key{ESC} O P} when the
keypad @key{PF1} key is pressed. Therefore, we want Emacs to translate
that sequence of events into the single event @code{pf1}. We accomplish
this by ``binding'' @kbd{@key{ESC} O P} to @code{[pf1]} in
@code{function-key-map}, when using a VT100.
@code{input-decode-map}, when using a VT100.
Thus, typing @kbd{C-c @key{PF1}} sends the character sequence @kbd{C-c
@key{ESC} O P}; later the function @code{read-key-sequence} translates
this back into @kbd{C-c @key{PF1}}, which it returns as the vector
@code{[?\C-c pf1]}.
Entries in @code{function-key-map} are ignored if they conflict with
bindings made in the minor mode, local, or global keymaps. The intent
is that the character sequences that function keys send should not have
command bindings in their own right---but if they do, the ordinary
bindings take priority.
The value of @code{function-key-map} is usually set up automatically
The value of @code{input-decode-map} is usually set up automatically
according to the terminal's Terminfo or Termcap entry, but sometimes
those need help from terminal-specific Lisp files. Emacs comes with
terminal-specific files for many common terminals; their main purpose is
to make entries in @code{function-key-map} beyond those that can be
to make entries in @code{input-decode-map} beyond those that can be
deduced from Termcap and Terminfo. @xref{Terminal-Specific}.
@end defvar
@defvar key-translation-map
This variable is another keymap used just like @code{function-key-map}
to translate input events into other events. It differs from
@code{function-key-map} in two ways:
@defvar function-key-map
@itemize @bullet
@item
@code{key-translation-map} goes to work after @code{function-key-map} is
finished; it receives the results of translation by
@code{function-key-map}.
This variable holds a keymap similar to @code{input-decode-map} except
that it describes key sequences which should be translated to
alternative interpretations that are usually preferred. It applies
after @code{input-decode-map} and before @code{key-translation-map}.
@item
Non-prefix bindings in @code{key-translation-map} override actual key
bindings. For example, if @kbd{C-x f} has a non-prefix binding in
@code{key-translation-map}, that translation takes effect even though
@kbd{C-x f} also has a key binding in the global map.
@end itemize
Entries in @code{function-key-map} are ignored if they conflict with
bindings made in the minor mode, local, or global keymaps. I.e.
the remapping only applies if the original key sequence would
otherwise not have any binding.
@end defvar
Note however that actual key bindings can have an effect on
@code{key-translation-map}, even though they are overridden by it.
Indeed, actual key bindings override @code{function-key-map} and thus
may alter the key sequence that @code{key-translation-map} receives.
Clearly, it is better to avoid this type of situation.
@defvar key-translation-map
This variable is another keymap used just like @code{input-decode-map}
to translate input events into other events. It differs from
@code{input-decode-map} in that it goes to work after
@code{function-key-map} is finished rather than before; it receives
the results of translation by @code{function-key-map}.
Just like @code{input-decode-map}, but unlike @code{function-key-map},
this keymap is applied regardless of whether the input key-sequence
has a normal binding. Note however that actual key bindings can have
an effect on @code{key-translation-map}, even though they are
overridden by it. Indeed, actual key bindings override
@code{function-key-map} and thus may alter the key sequence that
@code{key-translation-map} receives. Clearly, it is better to avoid
this type of situation.
The intent of @code{key-translation-map} is for users to map one
character set to another, including ordinary characters normally bound
......@@ -1581,7 +1581,8 @@ to @code{self-insert-command}.
@end defvar
@cindex key translation function
You can use @code{function-key-map} or @code{key-translation-map} for
You can use @code{input-decode-map}, @code{function-key-map}, or
@code{key-translation-map} for
more than simple aliases, by using a function, instead of a key
sequence, as the ``translation'' of a key. Then this function is called
to compute the translation of that key.
......
......@@ -113,7 +113,7 @@ The sparse keymap that displays the Special Props submenu of the Text
Properties menu.
@item function-key-map
The keymap for translating keypad and function keys.@*
The keymap for translating key sequences to preferred alternatives.@*
If there are none, then it contains an empty sparse keymap.
@xref{Translation Keymaps}.
......@@ -151,6 +151,11 @@ A sparse keymap used by the @kbd{e} command of Info.
@vindex Info-mode-map
A sparse keymap containing Info commands.
@item input-decode-map
The keymap for translating keypad and function keys.@*
If there are none, then it contains an empty sparse keymap.
@xref{Translation Keymaps}.
@item isearch-mode-map
@vindex isearch-mode-map
A keymap that defines the characters you can type within incremental
......
......@@ -279,7 +279,7 @@ trying the @samp{.elc} and @samp{.el} suffixes.
@cindex Termcap
The usual function of a terminal-specific library is to enable
special keys to send sequences that Emacs can recognize. It may also
need to set or add to @code{function-key-map} if the Termcap or
need to set or add to @code{input-decode-map} if the Termcap or
Terminfo entry does not specify all the terminal's function keys.
@xref{Terminal Input}.
......
......@@ -1745,7 +1745,8 @@ Setting this variable too high may slow down your typing. Setting it too
low may make it hard to type macros quickly enough.
@item viper-translate-all-ESC-keysequences @code{t} on tty, @code{nil} on windowing display
Normally, Viper lets Emacs translate only those ESC key sequences that are
defined in the low-level key-translation-map or function-key-map, such as those
defined in the low-level @code{input-decode-map}, @code{key-translation-map}
or @code{function-key-map}, such as those
emitted by the arrow and function keys. Other sequences, e.g., @kbd{\\e/}, are
treated as @kbd{ESC} command followed by a @kbd{/}. This is good for people
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
those keys, you will have to find out which key sequences they emit
by typing @kbd{C-q} and then the key (you should switch to Emacs state
first). Then you can bind those sequences to their preferred forms using
@code{function-key-map} as follows:
@code{input-decode-map} as follows:
@lisp
(cond ((string= (getenv "TERM") "xterm")
(define-key function-key-map "\e[192z" [f11]) ; L1
(define-key function-key-map "\e[195z" [f14]) ; L4, Undo
(define-key input-decode-map "\e[192z" [f11]) ; L1
(define-key input-decode-map "\e[195z" [f14]) ; L4, Undo
@end lisp
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.
Manual}, and the Emacs quick reference card for the general info on key
bindings in Emacs.
@vindex @code{input-decode-map}
@vindex @code{function-key-map}
@vindex @code{viper-vi-global-user-map}
@vindex @code{viper-insert-global-user-map}
......
......@@ -257,6 +257,11 @@ supported on other platforms, but not on Windows due to using the winsock
* Lisp Changes in Emacs 23.1
** New keymap `input-decode-map' overrides like key-translation-map, but
applies before function-key-map. Also it is terminal-local contrary to
key-translation-map. Terminal-specific key-sequences are generally added to
this map rather than to function-key-map now.
** Changes related to multiple tty support.
*** $TERM is now set to `dumb' for subprocesses. If you want to know the
......@@ -289,11 +294,8 @@ being suspended/resumed as a parameter.
*** New functions: `environment', `let-environment'.
*** New variables: `local-key-translation-map', `local-function-key-map'.
These are in addition to the global key-translation-map and
function-key-map variables that already existed.
??? How do the new variables relate to the old ones?
*** New variable: `local-function-key-map'.
This in addition to the global function-key-map variable that already existed.
*** `initial-environment' holds the environment inherited from Emacs's parent.
......
2007-10-09 Stefan Monnier <monnier@iro.umontreal.ca>
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.
* lisp.h (XSETPSEUDOVECTOR): Don't set the tag anymore.
This was made redundant by the previous introduction of XSETPVECTYPE.
......
......@@ -445,7 +445,7 @@ Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal;
/* Parent keymap of terminal-local function-key-map instances. */
Lisp_Object Vfunction_key_map;
/* Parent keymap of terminal-local key-translation-map instances. */
/* Keymap of key translations that can override keymaps. */
Lisp_Object Vkey_translation_map;
/* List of deferred actions to be performed at a later time.
......@@ -9131,8 +9131,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
key's again in Vfunction_key_map. */
volatile keyremap fkey;
/* Likewise, for key_translation_map. */
volatile keyremap keytran;
/* Likewise, for key_translation_map and input-decode-map. */
volatile keyremap keytran, indec;
/* If we receive a `switch-frame' or `select-window' event in the middle of
a key sequence, we put it off for later.
......@@ -9209,8 +9209,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
/* We may switch keyboards between rescans, so we need to
reinitialize fkey and keytran before each replay. */
indec.map = indec.parent = current_kboard->Vinput_decode_map;
fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map;
keytran.map = keytran.parent = current_kboard->Vlocal_key_translation_map;
keytran.map = keytran.parent = Vkey_translation_map;
indec.start = indec.end = 0;
fkey.start = fkey.end = 0;
keytran.start = keytran.end = 0;
......@@ -9299,7 +9301,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
Thus, if ESC O a has a function-key-map translation
and ESC o has a binding, don't return after ESC O,
so that we can translate ESC O plus the next character. */
: (fkey.start < t || keytran.start < t))
: (/* indec.start < t || fkey.start < t || */ keytran.start < t))
{
Lisp_Object key;
int used_mouse_menu = 0;
......@@ -9317,13 +9319,17 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
just one key. */
volatile int echo_local_start, keys_local_start, local_first_binding;
eassert (fkey.end == t || (fkey.end > t && fkey.end <= mock_input));
eassert (indec.end == t || (indec.end > t && indec.end <= mock_input));
eassert (indec.start <= indec.end);
eassert (fkey.start <= fkey.end);
eassert (keytran.start <= keytran.end);
/* key-translation-map is applied *after* function-key-map. */
/* key-translation-map is applied *after* function-key-map
which is itself applied *after* input-decode-map. */
eassert (fkey.end <= indec.start);
eassert (keytran.end <= fkey.start);
if (first_unbound < fkey.start && first_unbound < keytran.start)
if (/* first_unbound < indec.start && first_unbound < fkey.start && */
first_unbound < keytran.start)
{ /* The prefix upto first_unbound has no binding and has
no translation left to do either, so we know it's unbound.
If we don't stop now, we risk staying here indefinitely
......@@ -9333,6 +9339,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
for (i = first_unbound + 1; i < t; i++)
keybuf[i - first_unbound - 1] = keybuf[i];
mock_input = t - first_unbound - 1;
indec.end = indec.start -= first_unbound + 1;
indec.map = indec.parent;
fkey.end = fkey.start -= first_unbound + 1;
fkey.map = fkey.parent;
keytran.end = keytran.start -= first_unbound + 1;
......@@ -9758,15 +9766,15 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
/* This is needed for the following scenario:
event 0: a down-event that gets dropped by calling replay_key.
event 1: some normal prefix like C-h.
After event 0, first_unbound is 0, after event 1 fkey.start
and keytran.start are both 1, so when we see that C-h is bound,
we need to update first_unbound. */
After event 0, first_unbound is 0, after event 1 indec.start,
fkey.start, and keytran.start are all 1, so when we see that
C-h is bound, we need to update first_unbound. */
first_unbound = max (t + 1, first_unbound);
else
{
Lisp_Object head;
/* Remember the position to put an upper bound on fkey.start. */
/* Remember the position to put an upper bound on indec.start. */
first_unbound = min (t, first_unbound);
head = EVENT_HEAD (key);
......@@ -9851,21 +9859,27 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
/* If mock_input > t + 1, the above simplification
will actually end up dropping keys on the floor.
This is probably OK for now, but even
if mock_input <= t + 1, we need to adjust fkey
and keytran.
if mock_input <= t + 1, we need to adjust indec,
fkey, and keytran.
Typical case [header-line down-mouse-N]:
mock_input = 2, t = 1, fkey.end = 1,
last_real_key_start = 0. */
if (fkey.end > last_real_key_start)
if (indec.end > last_real_key_start)
{
fkey.end = fkey.start
= min (last_real_key_start, fkey.start);
fkey.map = fkey.parent;
if (keytran.end > last_real_key_start)
indec.end = indec.start
= min (last_real_key_start, indec.start);
indec.map = indec.parent;
if (fkey.end > last_real_key_start)
{
keytran.end = keytran.start
= min (last_real_key_start, keytran.start);
keytran.map = keytran.parent;
fkey.end = fkey.start
= min (last_real_key_start, fkey.start);
fkey.map = fkey.parent;
if (keytran.end > last_real_key_start)
{
keytran.end = keytran.start
= min (last_real_key_start, keytran.start);
keytran.map = keytran.parent;
}
}
}
if (t == last_real_key_start)
......@@ -9919,8 +9933,28 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
/* Record what part of this_command_keys is the current key sequence. */
this_single_command_key_start = this_command_key_count - t;
if (first_binding < nmaps && NILP (submaps[first_binding]))
/* Look for this sequence in input-decode-map.
Scan from indec.end until we find a bound suffix. */
while (indec.end < t)
{
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int done, diff;
GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input),
1, &diff, prompt);
UNGCPRO;
if (done)
{
mock_input = diff + max (t, mock_input);
goto replay_sequence;
}
}
if (first_binding < nmaps && NILP (submaps[first_binding])
&& indec.start >= t)
/* There is a binding and it's not a prefix.
(and it doesn't have any input-decode-map translation pending).
There is thus no function-key in this sequence.
Moving fkey.start is important in this case to allow keytran.start
to go over the sequence before we return (since we keep the
......@@ -9933,12 +9967,12 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
/* If the sequence is unbound, see if we can hang a function key
off the end of it. */
/* Continue scan from fkey.end until we find a bound suffix. */
while (fkey.end < t)
while (fkey.end < indec.start)
{
struct gcpro gcpro1, gcpro2, gcpro3;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int done, diff;
GCPRO3 (fkey.map, keytran.map, delayed_switch_frame);
GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
done = keyremap_step (keybuf, bufsize, &fkey,
max (t, mock_input),
/* If there's a binding (i.e.
......@@ -9950,6 +9984,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
if (done)
{
mock_input = diff + max (t, mock_input);
/* Adjust the input-decode-map counters. */
indec.end += diff;
indec.start += diff;
goto replay_sequence;
}
}
......@@ -9958,17 +9996,19 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
Scan from keytran.end until we find a bound suffix. */
while (keytran.end < fkey.start)
{
struct gcpro gcpro1, gcpro2, gcpro3;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int done, diff;
GCPRO3 (fkey.map, keytran.map, delayed_switch_frame);
GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame);
done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input),
1, &diff, prompt);
UNGCPRO;
if (done)
{
mock_input = diff + max (t, mock_input);
/* Adjust the function-key-map counters. */
/* Adjust the function-key-map and input-decode-map counters. */
indec.end += diff;
indec.start += diff;
fkey.end += diff;
fkey.start += diff;
......@@ -9981,7 +10021,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
and is an upper case letter
use the corresponding lower-case letter instead. */
if (first_binding >= nmaps
&& fkey.start >= t && keytran.start >= t
&& /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
&& INTEGERP (key)
&& ((((XINT (key) & 0x3ffff)
< XCHAR_TABLE (current_buffer->downcase_table)->size)
......@@ -10012,7 +10052,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
and is a shifted function key,
use the corresponding unshifted function key instead. */
if (first_binding >= nmaps
&& fkey.start >= t && keytran.start >= t
&& /* indec.start >= t && fkey.start >= t && */ keytran.start >= t
&& SYMBOLP (key))
{
Lisp_Object breakdown;
......@@ -10033,9 +10073,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
keybuf[t - 1] = new_key;
mock_input = max (t, mock_input);
fkey.start = fkey.end = 0;
keytran.start = keytran.end = 0;
goto replay_sequence;
}
}
......@@ -11460,10 +11497,9 @@ init_kboard (kb)
kb->reference_count = 0;
kb->Vsystem_key_alist = Qnil;
kb->system_key_syms = Qnil;
kb->Vinput_decode_map = Fmake_sparse_keymap (Qnil);
kb->Vlocal_function_key_map = Fmake_sparse_keymap (Qnil);
Fset_keymap_parent (kb->Vlocal_function_key_map, Vfunction_key_map);
kb->Vlocal_key_translation_map = Fmake_sparse_keymap (Qnil);
Fset_keymap_parent (kb->Vlocal_key_translation_map, Vkey_translation_map);
kb->Vdefault_minibuffer_frame = Qnil;
}
......@@ -12196,8 +12232,8 @@ See Info node `(elisp)Multiple displays'. */);
DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map,
doc: /* Keymap that translates key sequences to key sequences during input.
This is used mainly for mapping ASCII function key sequences into
real Emacs function key events (symbols).
This is used mainly for mapping key sequences into some preferred
key events (symbols).
The `read-key-sequence' function replaces any subsequence bound by
`local-function-key-map' with its binding. More precisely, when the
......@@ -12223,6 +12259,25 @@ define a binding on all terminals, change `function-key-map'
instead. Initially, `local-function-key-map' is an empty keymap that
has `function-key-map' as its parent on all terminal devices. */);
DEFVAR_KBOARD ("input-decode-map", Vinput_decode_map,
doc: /* Keymap that decodes input escape sequences.
This is used mainly for mapping ASCII function key sequences into
real Emacs function key events (symbols).
The `read-key-sequence' function replaces any subsequence bound by
`local-function-key-map' with its binding. Contrary to `function-key-map',
this map applies its rebinding regardless of the presence of an ordinary
binding. So it is more like `key-translation-map' except that it applies
before `function-key-map' rather than after.
If the binding is a function, it is called with one argument (the prompt)
and its return value (a key sequence) is used.
The events that come from bindings in `input-decode-map' are not
themselves looked up in `input-decode-map'.
This variable is keyboard-local. */);
DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
doc: /* The parent keymap of all `local-function-key-map' instances.
Function key definitions that apply to all terminal devices should go
......@@ -12231,18 +12286,11 @@ here. If a mapping is defined in both the current
definition will take precendence. */);
Vfunction_key_map = Fmake_sparse_keymap (Qnil);
DEFVAR_KBOARD ("local-key-translation-map", Vlocal_key_translation_map,
doc: /* Keymap of key translations that can override keymaps.
DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
doc: /* Keymap of key translations that can override keymaps.
This keymap works like `function-key-map', but comes after that,
and its non-prefix bindings override ordinary bindings.
`key-translation-map' has a separate binding for each terminal device.
(See Info node `(elisp)Multiple displays'.) If you need to set a key
translation on all terminals, change `global-key-translation-map' instead. */);
DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
doc: /* The parent keymap of all `local-key-translation-map' instances.
Key translations that apply to all terminal devices should go here. */);
Another difference is that it is global rather than keyboard-local. */);
Vkey_translation_map = Fmake_sparse_keymap (Qnil);
DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list,
......@@ -12420,8 +12468,8 @@ mark_kboards ()
mark_object (kb->Vlast_kbd_macro);
mark_object (kb->Vsystem_key_alist);
mark_object (kb->system_key_syms);
mark_object (kb->Vinput_decode_map);
mark_object (kb->Vlocal_function_key_map);
mark_object (kb->Vlocal_key_translation_map);
mark_object (kb->Vdefault_minibuffer_frame);
mark_object (kb->echo_string);
}
......
......@@ -127,14 +127,15 @@ struct kboard
/* Cache for modify_event_symbol. */
Lisp_Object system_key_syms;
/* Keymap mapping ASCII function key sequences onto their
preferred forms. Initialized by the terminal-specific lisp
files. See the DEFVAR for more documentation. */
/* Keymap mapping keys to alternative preferred forms.
See the DEFVAR for more documentation. */
Lisp_Object Vlocal_function_key_map;
/* Keymap of key translations that can override keymaps. */
Lisp_Object Vlocal_key_translation_map;
/* Keymap mapping ASCII function key sequences onto their preferred
forms. Initialized by the terminal-specific lisp files. See the
DEFVAR for more documentation. */
Lisp_Object Vinput_decode_map;
/* Minibufferless frames on this display use this frame's minibuffer. */
Lisp_Object Vdefault_minibuffer_frame;
......@@ -314,7 +315,7 @@ extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object,
/* Parent keymap of terminal-local function-key-map instances. */
extern Lisp_Object Vfunction_key_map;
/* Parent keymap of terminal-local key-translation-map instances. */
/* Keymap of key translations that can override keymaps. */
extern Lisp_Object Vkey_translation_map;
extern int parse_menu_item P_ ((Lisp_Object, int, int));
......
......@@ -3027,8 +3027,8 @@ You type Translation\n\
insert ("\n", 1);
}
if (!NILP (current_kboard->Vlocal_key_translation_map))
describe_map_tree (current_kboard->Vlocal_key_translation_map, 0, Qnil, prefix,
if (!NILP (Vkey_translation_map))
describe_map_tree (Vkey_translation_map, 0, Qnil, prefix,
"Key translations", nomenu, 1, 0, 0);
......@@ -3121,6 +3121,11 @@ You type Translation\n\
describe_map_tree (current_kboard->Vlocal_function_key_map, 0, Qnil, prefix,
"\f\nFunction key map translations", nomenu, 1, 0, 0);
/* Print the input-decode-map translations under this prefix. */
if (!NILP (current_kboard->Vinput_decode_map))
describe_map_tree (current_kboard->Vinput_decode_map, 0, Qnil, prefix,
"\f\nInput decoding map translations", nomenu, 1, 0, 0);
UNGCPRO;
return Qnil;
}
......
......@@ -1274,9 +1274,9 @@ static char **term_get_fkeys_address;
static KBOARD *term_get_fkeys_kboard;
static Lisp_Object term_get_fkeys_1 ();
/* Find the escape codes sent by the function keys for Vfunction_key_map.
/* Find the escape codes sent by the function keys for Vinput_decode_map.
This function scans the termcap function key sequence entries, and
adds entries to Vfunction_key_map for each function key it finds. */
adds entries to Vinput_decode_map for each function key it finds. */
static void
term_get_fkeys (address, kboard)
......@@ -1306,14 +1306,14 @@ term_get_fkeys_1 ()
KBOARD *kboard = term_get_fkeys_kboard;
/* This can happen if CANNOT_DUMP or with strange options. */
if (!initialized)
kboard->Vlocal_function_key_map = Fmake_sparse_keymap (Qnil);
if (!KEYMAPP (kboard->Vinput_decode_map))
kboard->Vinput_decode_map = Fmake_sparse_keymap (Qnil);
for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++)
{
char *sequence = tgetstr (keys[i].cap, address);
if (sequence)
Fdefine_key (kboard->Vlocal_function_key_map, build_string (sequence),
Fdefine_key (kboard->Vinput_decode_map, build_string (sequence),
Fmake_vector (make_number (1),
intern (keys[i].name)));
}
......@@ -1333,13 +1333,13 @@ term_get_fkeys_1 ()
if (k0)
/* Define f0 first, so that f10 takes precedence in case the
key sequences happens to be the same. */
Fdefine_key (kboard->Vlocal_function_key_map, build_string (k0),
Fdefine_key (kboard->Vinput_decode_map, build_string (k0),
Fmake_vector (make_number (1), intern ("f0")));
Fdefine_key (kboard->Vlocal_function_key_map, build_string (k_semi),
Fdefine_key (kboard->Vinput_decode_map, build_string (k_semi),
Fmake_vector (make_number (1), intern ("f10")));
}
else if (k0)
Fdefine_key (kboard->Vlocal_function_key_map, build_string (k0),
Fdefine_key (kboard->Vinput_decode_map, build_string (k0),
Fmake_vector (make_number (1), intern (k0_name)));
}
......@@ -1362,7 +1362,7 @@ term_get_fkeys_1 ()
if (sequence)