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 /src | |
| 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 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/keyboard.c | 146 | ||||
| -rw-r--r-- | src/keyboard.h | 15 | ||||
| -rw-r--r-- | src/keymap.c | 9 | ||||
| -rw-r--r-- | src/term.c | 20 |
5 files changed, 138 insertions, 68 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9e1ef4b06f8..6374b29aedc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,21 @@ | |||
| 1 | 2007-10-09 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2007-10-09 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | Add new `input-decode-map' keymap and use it for temrinal | ||
| 4 | escape sequences. | ||
| 5 | * keyboard.h (struct kboard): Add Vinput_decode_map. | ||
| 6 | Remove Vlocal_key_translation_map. | ||
| 7 | * keyboard.c (read_key_sequence): Add support for input-decode-map. | ||
| 8 | (init_kboard): Init input-decode-map. | ||
| 9 | Replace local-key-translation-map back with key-translation-map. | ||
| 10 | (syms_of_keyboard): Declare input-decode-map. | ||
| 11 | Remove local-key-translation-map. Update docstrings. | ||
| 12 | (mark_kboards): Mark Vinput_decode_map. | ||
| 13 | Don't mark Vlocal_key_translation_map. | ||
| 14 | * keymap.c (Fdescribe_buffer_bindings): Describe input-decode-map. | ||
| 15 | Replace local-key-translation-map back with key-translation-map. | ||
| 16 | * term.c (term_get_fkeys_1, CONDITIONAL_REASSIGN): | ||
| 17 | Bind in input-decode-map rather than function-key-map. | ||
| 18 | |||
| 3 | * lisp.h (XSETPSEUDOVECTOR): Don't set the tag anymore. | 19 | * lisp.h (XSETPSEUDOVECTOR): Don't set the tag anymore. |
| 4 | This was made redundant by the previous introduction of XSETPVECTYPE. | 20 | This was made redundant by the previous introduction of XSETPVECTYPE. |
| 5 | 21 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 0e9dfee877f..9068f944664 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -445,7 +445,7 @@ Lisp_Object Qcommand_hook_internal, Vcommand_hook_internal; | |||
| 445 | /* Parent keymap of terminal-local function-key-map instances. */ | 445 | /* Parent keymap of terminal-local function-key-map instances. */ |
| 446 | Lisp_Object Vfunction_key_map; | 446 | Lisp_Object Vfunction_key_map; |
| 447 | 447 | ||
| 448 | /* Parent keymap of terminal-local key-translation-map instances. */ | 448 | /* Keymap of key translations that can override keymaps. */ |
| 449 | Lisp_Object Vkey_translation_map; | 449 | Lisp_Object Vkey_translation_map; |
| 450 | 450 | ||
| 451 | /* List of deferred actions to be performed at a later time. | 451 | /* List of deferred actions to be performed at a later time. |
| @@ -9131,8 +9131,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9131 | key's again in Vfunction_key_map. */ | 9131 | key's again in Vfunction_key_map. */ |
| 9132 | volatile keyremap fkey; | 9132 | volatile keyremap fkey; |
| 9133 | 9133 | ||
| 9134 | /* Likewise, for key_translation_map. */ | 9134 | /* Likewise, for key_translation_map and input-decode-map. */ |
| 9135 | volatile keyremap keytran; | 9135 | volatile keyremap keytran, indec; |
| 9136 | 9136 | ||
| 9137 | /* If we receive a `switch-frame' or `select-window' event in the middle of | 9137 | /* If we receive a `switch-frame' or `select-window' event in the middle of |
| 9138 | a key sequence, we put it off for later. | 9138 | a key sequence, we put it off for later. |
| @@ -9209,8 +9209,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9209 | 9209 | ||
| 9210 | /* We may switch keyboards between rescans, so we need to | 9210 | /* We may switch keyboards between rescans, so we need to |
| 9211 | reinitialize fkey and keytran before each replay. */ | 9211 | reinitialize fkey and keytran before each replay. */ |
| 9212 | indec.map = indec.parent = current_kboard->Vinput_decode_map; | ||
| 9212 | fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map; | 9213 | fkey.map = fkey.parent = current_kboard->Vlocal_function_key_map; |
| 9213 | keytran.map = keytran.parent = current_kboard->Vlocal_key_translation_map; | 9214 | keytran.map = keytran.parent = Vkey_translation_map; |
| 9215 | indec.start = indec.end = 0; | ||
| 9214 | fkey.start = fkey.end = 0; | 9216 | fkey.start = fkey.end = 0; |
| 9215 | keytran.start = keytran.end = 0; | 9217 | keytran.start = keytran.end = 0; |
| 9216 | 9218 | ||
| @@ -9299,7 +9301,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9299 | Thus, if ESC O a has a function-key-map translation | 9301 | Thus, if ESC O a has a function-key-map translation |
| 9300 | and ESC o has a binding, don't return after ESC O, | 9302 | and ESC o has a binding, don't return after ESC O, |
| 9301 | so that we can translate ESC O plus the next character. */ | 9303 | so that we can translate ESC O plus the next character. */ |
| 9302 | : (fkey.start < t || keytran.start < t)) | 9304 | : (/* indec.start < t || fkey.start < t || */ keytran.start < t)) |
| 9303 | { | 9305 | { |
| 9304 | Lisp_Object key; | 9306 | Lisp_Object key; |
| 9305 | int used_mouse_menu = 0; | 9307 | int used_mouse_menu = 0; |
| @@ -9317,13 +9319,17 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9317 | just one key. */ | 9319 | just one key. */ |
| 9318 | volatile int echo_local_start, keys_local_start, local_first_binding; | 9320 | volatile int echo_local_start, keys_local_start, local_first_binding; |
| 9319 | 9321 | ||
| 9320 | eassert (fkey.end == t || (fkey.end > t && fkey.end <= mock_input)); | 9322 | eassert (indec.end == t || (indec.end > t && indec.end <= mock_input)); |
| 9323 | eassert (indec.start <= indec.end); | ||
| 9321 | eassert (fkey.start <= fkey.end); | 9324 | eassert (fkey.start <= fkey.end); |
| 9322 | eassert (keytran.start <= keytran.end); | 9325 | eassert (keytran.start <= keytran.end); |
| 9323 | /* key-translation-map is applied *after* function-key-map. */ | 9326 | /* key-translation-map is applied *after* function-key-map |
| 9327 | which is itself applied *after* input-decode-map. */ | ||
| 9328 | eassert (fkey.end <= indec.start); | ||
| 9324 | eassert (keytran.end <= fkey.start); | 9329 | eassert (keytran.end <= fkey.start); |
| 9325 | 9330 | ||
| 9326 | if (first_unbound < fkey.start && first_unbound < keytran.start) | 9331 | if (/* first_unbound < indec.start && first_unbound < fkey.start && */ |
| 9332 | first_unbound < keytran.start) | ||
| 9327 | { /* The prefix upto first_unbound has no binding and has | 9333 | { /* The prefix upto first_unbound has no binding and has |
| 9328 | no translation left to do either, so we know it's unbound. | 9334 | no translation left to do either, so we know it's unbound. |
| 9329 | If we don't stop now, we risk staying here indefinitely | 9335 | If we don't stop now, we risk staying here indefinitely |
| @@ -9333,6 +9339,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9333 | for (i = first_unbound + 1; i < t; i++) | 9339 | for (i = first_unbound + 1; i < t; i++) |
| 9334 | keybuf[i - first_unbound - 1] = keybuf[i]; | 9340 | keybuf[i - first_unbound - 1] = keybuf[i]; |
| 9335 | mock_input = t - first_unbound - 1; | 9341 | mock_input = t - first_unbound - 1; |
| 9342 | indec.end = indec.start -= first_unbound + 1; | ||
| 9343 | indec.map = indec.parent; | ||
| 9336 | fkey.end = fkey.start -= first_unbound + 1; | 9344 | fkey.end = fkey.start -= first_unbound + 1; |
| 9337 | fkey.map = fkey.parent; | 9345 | fkey.map = fkey.parent; |
| 9338 | keytran.end = keytran.start -= first_unbound + 1; | 9346 | keytran.end = keytran.start -= first_unbound + 1; |
| @@ -9758,15 +9766,15 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9758 | /* This is needed for the following scenario: | 9766 | /* This is needed for the following scenario: |
| 9759 | event 0: a down-event that gets dropped by calling replay_key. | 9767 | event 0: a down-event that gets dropped by calling replay_key. |
| 9760 | event 1: some normal prefix like C-h. | 9768 | event 1: some normal prefix like C-h. |
| 9761 | After event 0, first_unbound is 0, after event 1 fkey.start | 9769 | After event 0, first_unbound is 0, after event 1 indec.start, |
| 9762 | and keytran.start are both 1, so when we see that C-h is bound, | 9770 | fkey.start, and keytran.start are all 1, so when we see that |
| 9763 | we need to update first_unbound. */ | 9771 | C-h is bound, we need to update first_unbound. */ |
| 9764 | first_unbound = max (t + 1, first_unbound); | 9772 | first_unbound = max (t + 1, first_unbound); |
| 9765 | else | 9773 | else |
| 9766 | { | 9774 | { |
| 9767 | Lisp_Object head; | 9775 | Lisp_Object head; |
| 9768 | 9776 | ||
| 9769 | /* Remember the position to put an upper bound on fkey.start. */ | 9777 | /* Remember the position to put an upper bound on indec.start. */ |
| 9770 | first_unbound = min (t, first_unbound); | 9778 | first_unbound = min (t, first_unbound); |
| 9771 | 9779 | ||
| 9772 | head = EVENT_HEAD (key); | 9780 | head = EVENT_HEAD (key); |
| @@ -9851,21 +9859,27 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9851 | /* If mock_input > t + 1, the above simplification | 9859 | /* If mock_input > t + 1, the above simplification |
| 9852 | will actually end up dropping keys on the floor. | 9860 | will actually end up dropping keys on the floor. |
| 9853 | This is probably OK for now, but even | 9861 | This is probably OK for now, but even |
| 9854 | if mock_input <= t + 1, we need to adjust fkey | 9862 | if mock_input <= t + 1, we need to adjust indec, |
| 9855 | and keytran. | 9863 | fkey, and keytran. |
| 9856 | Typical case [header-line down-mouse-N]: | 9864 | Typical case [header-line down-mouse-N]: |
| 9857 | mock_input = 2, t = 1, fkey.end = 1, | 9865 | mock_input = 2, t = 1, fkey.end = 1, |
| 9858 | last_real_key_start = 0. */ | 9866 | last_real_key_start = 0. */ |
| 9859 | if (fkey.end > last_real_key_start) | 9867 | if (indec.end > last_real_key_start) |
| 9860 | { | 9868 | { |
| 9861 | fkey.end = fkey.start | 9869 | indec.end = indec.start |
| 9862 | = min (last_real_key_start, fkey.start); | 9870 | = min (last_real_key_start, indec.start); |
| 9863 | fkey.map = fkey.parent; | 9871 | indec.map = indec.parent; |
| 9864 | if (keytran.end > last_real_key_start) | 9872 | if (fkey.end > last_real_key_start) |
| 9865 | { | 9873 | { |
| 9866 | keytran.end = keytran.start | 9874 | fkey.end = fkey.start |
| 9867 | = min (last_real_key_start, keytran.start); | 9875 | = min (last_real_key_start, fkey.start); |
| 9868 | keytran.map = keytran.parent; | 9876 | fkey.map = fkey.parent; |
| 9877 | if (keytran.end > last_real_key_start) | ||
| 9878 | { | ||
| 9879 | keytran.end = keytran.start | ||
| 9880 | = min (last_real_key_start, keytran.start); | ||
| 9881 | keytran.map = keytran.parent; | ||
| 9882 | } | ||
| 9869 | } | 9883 | } |
| 9870 | } | 9884 | } |
| 9871 | if (t == last_real_key_start) | 9885 | if (t == last_real_key_start) |
| @@ -9919,8 +9933,28 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9919 | /* Record what part of this_command_keys is the current key sequence. */ | 9933 | /* Record what part of this_command_keys is the current key sequence. */ |
| 9920 | this_single_command_key_start = this_command_key_count - t; | 9934 | this_single_command_key_start = this_command_key_count - t; |
| 9921 | 9935 | ||
| 9922 | if (first_binding < nmaps && NILP (submaps[first_binding])) | 9936 | /* Look for this sequence in input-decode-map. |
| 9937 | Scan from indec.end until we find a bound suffix. */ | ||
| 9938 | while (indec.end < t) | ||
| 9939 | { | ||
| 9940 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | ||
| 9941 | int done, diff; | ||
| 9942 | |||
| 9943 | GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); | ||
| 9944 | done = keyremap_step (keybuf, bufsize, &indec, max (t, mock_input), | ||
| 9945 | 1, &diff, prompt); | ||
| 9946 | UNGCPRO; | ||
| 9947 | if (done) | ||
| 9948 | { | ||
| 9949 | mock_input = diff + max (t, mock_input); | ||
| 9950 | goto replay_sequence; | ||
| 9951 | } | ||
| 9952 | } | ||
| 9953 | |||
| 9954 | if (first_binding < nmaps && NILP (submaps[first_binding]) | ||
| 9955 | && indec.start >= t) | ||
| 9923 | /* There is a binding and it's not a prefix. | 9956 | /* There is a binding and it's not a prefix. |
| 9957 | (and it doesn't have any input-decode-map translation pending). | ||
| 9924 | There is thus no function-key in this sequence. | 9958 | There is thus no function-key in this sequence. |
| 9925 | Moving fkey.start is important in this case to allow keytran.start | 9959 | Moving fkey.start is important in this case to allow keytran.start |
| 9926 | to go over the sequence before we return (since we keep the | 9960 | 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, | |||
| 9933 | /* If the sequence is unbound, see if we can hang a function key | 9967 | /* If the sequence is unbound, see if we can hang a function key |
| 9934 | off the end of it. */ | 9968 | off the end of it. */ |
| 9935 | /* Continue scan from fkey.end until we find a bound suffix. */ | 9969 | /* Continue scan from fkey.end until we find a bound suffix. */ |
| 9936 | while (fkey.end < t) | 9970 | while (fkey.end < indec.start) |
| 9937 | { | 9971 | { |
| 9938 | struct gcpro gcpro1, gcpro2, gcpro3; | 9972 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 9939 | int done, diff; | 9973 | int done, diff; |
| 9940 | 9974 | ||
| 9941 | GCPRO3 (fkey.map, keytran.map, delayed_switch_frame); | 9975 | GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); |
| 9942 | done = keyremap_step (keybuf, bufsize, &fkey, | 9976 | done = keyremap_step (keybuf, bufsize, &fkey, |
| 9943 | max (t, mock_input), | 9977 | max (t, mock_input), |
| 9944 | /* If there's a binding (i.e. | 9978 | /* If there's a binding (i.e. |
| @@ -9950,6 +9984,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9950 | if (done) | 9984 | if (done) |
| 9951 | { | 9985 | { |
| 9952 | mock_input = diff + max (t, mock_input); | 9986 | mock_input = diff + max (t, mock_input); |
| 9987 | /* Adjust the input-decode-map counters. */ | ||
| 9988 | indec.end += diff; | ||
| 9989 | indec.start += diff; | ||
| 9990 | |||
| 9953 | goto replay_sequence; | 9991 | goto replay_sequence; |
| 9954 | } | 9992 | } |
| 9955 | } | 9993 | } |
| @@ -9958,17 +9996,19 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9958 | Scan from keytran.end until we find a bound suffix. */ | 9996 | Scan from keytran.end until we find a bound suffix. */ |
| 9959 | while (keytran.end < fkey.start) | 9997 | while (keytran.end < fkey.start) |
| 9960 | { | 9998 | { |
| 9961 | struct gcpro gcpro1, gcpro2, gcpro3; | 9999 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 9962 | int done, diff; | 10000 | int done, diff; |
| 9963 | 10001 | ||
| 9964 | GCPRO3 (fkey.map, keytran.map, delayed_switch_frame); | 10002 | GCPRO4 (indec.map, fkey.map, keytran.map, delayed_switch_frame); |
| 9965 | done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input), | 10003 | done = keyremap_step (keybuf, bufsize, &keytran, max (t, mock_input), |
| 9966 | 1, &diff, prompt); | 10004 | 1, &diff, prompt); |
| 9967 | UNGCPRO; | 10005 | UNGCPRO; |
| 9968 | if (done) | 10006 | if (done) |
| 9969 | { | 10007 | { |
| 9970 | mock_input = diff + max (t, mock_input); | 10008 | mock_input = diff + max (t, mock_input); |
| 9971 | /* Adjust the function-key-map counters. */ | 10009 | /* Adjust the function-key-map and input-decode-map counters. */ |
| 10010 | indec.end += diff; | ||
| 10011 | indec.start += diff; | ||
| 9972 | fkey.end += diff; | 10012 | fkey.end += diff; |
| 9973 | fkey.start += diff; | 10013 | fkey.start += diff; |
| 9974 | 10014 | ||
| @@ -9981,7 +10021,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9981 | and is an upper case letter | 10021 | and is an upper case letter |
| 9982 | use the corresponding lower-case letter instead. */ | 10022 | use the corresponding lower-case letter instead. */ |
| 9983 | if (first_binding >= nmaps | 10023 | if (first_binding >= nmaps |
| 9984 | && fkey.start >= t && keytran.start >= t | 10024 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t |
| 9985 | && INTEGERP (key) | 10025 | && INTEGERP (key) |
| 9986 | && ((((XINT (key) & 0x3ffff) | 10026 | && ((((XINT (key) & 0x3ffff) |
| 9987 | < XCHAR_TABLE (current_buffer->downcase_table)->size) | 10027 | < XCHAR_TABLE (current_buffer->downcase_table)->size) |
| @@ -10012,7 +10052,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 10012 | and is a shifted function key, | 10052 | and is a shifted function key, |
| 10013 | use the corresponding unshifted function key instead. */ | 10053 | use the corresponding unshifted function key instead. */ |
| 10014 | if (first_binding >= nmaps | 10054 | if (first_binding >= nmaps |
| 10015 | && fkey.start >= t && keytran.start >= t | 10055 | && /* indec.start >= t && fkey.start >= t && */ keytran.start >= t |
| 10016 | && SYMBOLP (key)) | 10056 | && SYMBOLP (key)) |
| 10017 | { | 10057 | { |
| 10018 | Lisp_Object breakdown; | 10058 | Lisp_Object breakdown; |
| @@ -10033,9 +10073,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 10033 | 10073 | ||
| 10034 | keybuf[t - 1] = new_key; | 10074 | keybuf[t - 1] = new_key; |
| 10035 | mock_input = max (t, mock_input); | 10075 | mock_input = max (t, mock_input); |
| 10036 | fkey.start = fkey.end = 0; | ||
| 10037 | keytran.start = keytran.end = 0; | ||
| 10038 | |||
| 10039 | goto replay_sequence; | 10076 | goto replay_sequence; |
| 10040 | } | 10077 | } |
| 10041 | } | 10078 | } |
| @@ -11460,10 +11497,9 @@ init_kboard (kb) | |||
| 11460 | kb->reference_count = 0; | 11497 | kb->reference_count = 0; |
| 11461 | kb->Vsystem_key_alist = Qnil; | 11498 | kb->Vsystem_key_alist = Qnil; |
| 11462 | kb->system_key_syms = Qnil; | 11499 | kb->system_key_syms = Qnil; |
| 11500 | kb->Vinput_decode_map = Fmake_sparse_keymap (Qnil); | ||
| 11463 | kb->Vlocal_function_key_map = Fmake_sparse_keymap (Qnil); | 11501 | kb->Vlocal_function_key_map = Fmake_sparse_keymap (Qnil); |
| 11464 | Fset_keymap_parent (kb->Vlocal_function_key_map, Vfunction_key_map); | 11502 | Fset_keymap_parent (kb->Vlocal_function_key_map, Vfunction_key_map); |
| 11465 | kb->Vlocal_key_translation_map = Fmake_sparse_keymap (Qnil); | ||
| 11466 | Fset_keymap_parent (kb->Vlocal_key_translation_map, Vkey_translation_map); | ||
| 11467 | kb->Vdefault_minibuffer_frame = Qnil; | 11503 | kb->Vdefault_minibuffer_frame = Qnil; |
| 11468 | } | 11504 | } |
| 11469 | 11505 | ||
| @@ -12196,8 +12232,8 @@ See Info node `(elisp)Multiple displays'. */); | |||
| 12196 | 12232 | ||
| 12197 | DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map, | 12233 | DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map, |
| 12198 | doc: /* Keymap that translates key sequences to key sequences during input. | 12234 | doc: /* Keymap that translates key sequences to key sequences during input. |
| 12199 | This is used mainly for mapping ASCII function key sequences into | 12235 | This is used mainly for mapping key sequences into some preferred |
| 12200 | real Emacs function key events (symbols). | 12236 | key events (symbols). |
| 12201 | 12237 | ||
| 12202 | The `read-key-sequence' function replaces any subsequence bound by | 12238 | The `read-key-sequence' function replaces any subsequence bound by |
| 12203 | `local-function-key-map' with its binding. More precisely, when the | 12239 | `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' | |||
| 12223 | instead. Initially, `local-function-key-map' is an empty keymap that | 12259 | instead. Initially, `local-function-key-map' is an empty keymap that |
| 12224 | has `function-key-map' as its parent on all terminal devices. */); | 12260 | has `function-key-map' as its parent on all terminal devices. */); |
| 12225 | 12261 | ||
| 12262 | DEFVAR_KBOARD ("input-decode-map", Vinput_decode_map, | ||
| 12263 | doc: /* Keymap that decodes input escape sequences. | ||
| 12264 | This is used mainly for mapping ASCII function key sequences into | ||
| 12265 | real Emacs function key events (symbols). | ||
| 12266 | |||
| 12267 | The `read-key-sequence' function replaces any subsequence bound by | ||
| 12268 | `local-function-key-map' with its binding. Contrary to `function-key-map', | ||
| 12269 | this map applies its rebinding regardless of the presence of an ordinary | ||
| 12270 | binding. So it is more like `key-translation-map' except that it applies | ||
| 12271 | before `function-key-map' rather than after. | ||
| 12272 | |||
| 12273 | If the binding is a function, it is called with one argument (the prompt) | ||
| 12274 | and its return value (a key sequence) is used. | ||
| 12275 | |||
| 12276 | The events that come from bindings in `input-decode-map' are not | ||
| 12277 | themselves looked up in `input-decode-map'. | ||
| 12278 | |||
| 12279 | This variable is keyboard-local. */); | ||
| 12280 | |||
| 12226 | DEFVAR_LISP ("function-key-map", &Vfunction_key_map, | 12281 | DEFVAR_LISP ("function-key-map", &Vfunction_key_map, |
| 12227 | doc: /* The parent keymap of all `local-function-key-map' instances. | 12282 | doc: /* The parent keymap of all `local-function-key-map' instances. |
| 12228 | Function key definitions that apply to all terminal devices should go | 12283 | 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 | |||
| 12231 | definition will take precendence. */); | 12286 | definition will take precendence. */); |
| 12232 | Vfunction_key_map = Fmake_sparse_keymap (Qnil); | 12287 | Vfunction_key_map = Fmake_sparse_keymap (Qnil); |
| 12233 | 12288 | ||
| 12234 | DEFVAR_KBOARD ("local-key-translation-map", Vlocal_key_translation_map, | 12289 | DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, |
| 12235 | doc: /* Keymap of key translations that can override keymaps. | 12290 | doc: /* Keymap of key translations that can override keymaps. |
| 12236 | This keymap works like `function-key-map', but comes after that, | 12291 | This keymap works like `function-key-map', but comes after that, |
| 12237 | and its non-prefix bindings override ordinary bindings. | 12292 | and its non-prefix bindings override ordinary bindings. |
| 12238 | 12293 | Another difference is that it is global rather than keyboard-local. */); | |
| 12239 | `key-translation-map' has a separate binding for each terminal device. | ||
| 12240 | (See Info node `(elisp)Multiple displays'.) If you need to set a key | ||
| 12241 | translation on all terminals, change `global-key-translation-map' instead. */); | ||
| 12242 | |||
| 12243 | DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, | ||
| 12244 | doc: /* The parent keymap of all `local-key-translation-map' instances. | ||
| 12245 | Key translations that apply to all terminal devices should go here. */); | ||
| 12246 | Vkey_translation_map = Fmake_sparse_keymap (Qnil); | 12294 | Vkey_translation_map = Fmake_sparse_keymap (Qnil); |
| 12247 | 12295 | ||
| 12248 | DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list, | 12296 | DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list, |
| @@ -12420,8 +12468,8 @@ mark_kboards () | |||
| 12420 | mark_object (kb->Vlast_kbd_macro); | 12468 | mark_object (kb->Vlast_kbd_macro); |
| 12421 | mark_object (kb->Vsystem_key_alist); | 12469 | mark_object (kb->Vsystem_key_alist); |
| 12422 | mark_object (kb->system_key_syms); | 12470 | mark_object (kb->system_key_syms); |
| 12471 | mark_object (kb->Vinput_decode_map); | ||
| 12423 | mark_object (kb->Vlocal_function_key_map); | 12472 | mark_object (kb->Vlocal_function_key_map); |
| 12424 | mark_object (kb->Vlocal_key_translation_map); | ||
| 12425 | mark_object (kb->Vdefault_minibuffer_frame); | 12473 | mark_object (kb->Vdefault_minibuffer_frame); |
| 12426 | mark_object (kb->echo_string); | 12474 | mark_object (kb->echo_string); |
| 12427 | } | 12475 | } |
diff --git a/src/keyboard.h b/src/keyboard.h index a65bf8cfa02..2e50c4c5f1f 100644 --- a/src/keyboard.h +++ b/src/keyboard.h | |||
| @@ -127,14 +127,15 @@ struct kboard | |||
| 127 | /* Cache for modify_event_symbol. */ | 127 | /* Cache for modify_event_symbol. */ |
| 128 | Lisp_Object system_key_syms; | 128 | Lisp_Object system_key_syms; |
| 129 | 129 | ||
| 130 | /* Keymap mapping ASCII function key sequences onto their | 130 | /* Keymap mapping keys to alternative preferred forms. |
| 131 | preferred forms. Initialized by the terminal-specific lisp | 131 | See the DEFVAR for more documentation. */ |
| 132 | files. See the DEFVAR for more documentation. */ | ||
| 133 | Lisp_Object Vlocal_function_key_map; | 132 | Lisp_Object Vlocal_function_key_map; |
| 134 | 133 | ||
| 135 | /* Keymap of key translations that can override keymaps. */ | 134 | /* Keymap mapping ASCII function key sequences onto their preferred |
| 136 | Lisp_Object Vlocal_key_translation_map; | 135 | forms. Initialized by the terminal-specific lisp files. See the |
| 137 | 136 | DEFVAR for more documentation. */ | |
| 137 | Lisp_Object Vinput_decode_map; | ||
| 138 | |||
| 138 | /* Minibufferless frames on this display use this frame's minibuffer. */ | 139 | /* Minibufferless frames on this display use this frame's minibuffer. */ |
| 139 | Lisp_Object Vdefault_minibuffer_frame; | 140 | Lisp_Object Vdefault_minibuffer_frame; |
| 140 | 141 | ||
| @@ -314,7 +315,7 @@ extern Lisp_Object read_char P_ ((int, int, Lisp_Object *, Lisp_Object, | |||
| 314 | /* Parent keymap of terminal-local function-key-map instances. */ | 315 | /* Parent keymap of terminal-local function-key-map instances. */ |
| 315 | extern Lisp_Object Vfunction_key_map; | 316 | extern Lisp_Object Vfunction_key_map; |
| 316 | 317 | ||
| 317 | /* Parent keymap of terminal-local key-translation-map instances. */ | 318 | /* Keymap of key translations that can override keymaps. */ |
| 318 | extern Lisp_Object Vkey_translation_map; | 319 | extern Lisp_Object Vkey_translation_map; |
| 319 | 320 | ||
| 320 | extern int parse_menu_item P_ ((Lisp_Object, int, int)); | 321 | extern int parse_menu_item P_ ((Lisp_Object, int, int)); |
diff --git a/src/keymap.c b/src/keymap.c index 181d43a4f48..be23c20a3aa 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -3027,8 +3027,8 @@ You type Translation\n\ | |||
| 3027 | insert ("\n", 1); | 3027 | insert ("\n", 1); |
| 3028 | } | 3028 | } |
| 3029 | 3029 | ||
| 3030 | if (!NILP (current_kboard->Vlocal_key_translation_map)) | 3030 | if (!NILP (Vkey_translation_map)) |
| 3031 | describe_map_tree (current_kboard->Vlocal_key_translation_map, 0, Qnil, prefix, | 3031 | describe_map_tree (Vkey_translation_map, 0, Qnil, prefix, |
| 3032 | "Key translations", nomenu, 1, 0, 0); | 3032 | "Key translations", nomenu, 1, 0, 0); |
| 3033 | 3033 | ||
| 3034 | 3034 | ||
| @@ -3121,6 +3121,11 @@ You type Translation\n\ | |||
| 3121 | describe_map_tree (current_kboard->Vlocal_function_key_map, 0, Qnil, prefix, | 3121 | describe_map_tree (current_kboard->Vlocal_function_key_map, 0, Qnil, prefix, |
| 3122 | "\f\nFunction key map translations", nomenu, 1, 0, 0); | 3122 | "\f\nFunction key map translations", nomenu, 1, 0, 0); |
| 3123 | 3123 | ||
| 3124 | /* Print the input-decode-map translations under this prefix. */ | ||
| 3125 | if (!NILP (current_kboard->Vinput_decode_map)) | ||
| 3126 | describe_map_tree (current_kboard->Vinput_decode_map, 0, Qnil, prefix, | ||
| 3127 | "\f\nInput decoding map translations", nomenu, 1, 0, 0); | ||
| 3128 | |||
| 3124 | UNGCPRO; | 3129 | UNGCPRO; |
| 3125 | return Qnil; | 3130 | return Qnil; |
| 3126 | } | 3131 | } |
diff --git a/src/term.c b/src/term.c index a6c69c71bef..b97e77b2320 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -1274,9 +1274,9 @@ static char **term_get_fkeys_address; | |||
| 1274 | static KBOARD *term_get_fkeys_kboard; | 1274 | static KBOARD *term_get_fkeys_kboard; |
| 1275 | static Lisp_Object term_get_fkeys_1 (); | 1275 | static Lisp_Object term_get_fkeys_1 (); |
| 1276 | 1276 | ||
| 1277 | /* Find the escape codes sent by the function keys for Vfunction_key_map. | 1277 | /* Find the escape codes sent by the function keys for Vinput_decode_map. |
| 1278 | This function scans the termcap function key sequence entries, and | 1278 | This function scans the termcap function key sequence entries, and |
| 1279 | adds entries to Vfunction_key_map for each function key it finds. */ | 1279 | adds entries to Vinput_decode_map for each function key it finds. */ |
| 1280 | 1280 | ||
| 1281 | static void | 1281 | static void |
| 1282 | term_get_fkeys (address, kboard) | 1282 | term_get_fkeys (address, kboard) |
| @@ -1306,14 +1306,14 @@ term_get_fkeys_1 () | |||
| 1306 | KBOARD *kboard = term_get_fkeys_kboard; | 1306 | KBOARD *kboard = term_get_fkeys_kboard; |
| 1307 | 1307 | ||
| 1308 | /* This can happen if CANNOT_DUMP or with strange options. */ | 1308 | /* This can happen if CANNOT_DUMP or with strange options. */ |
| 1309 | if (!initialized) | 1309 | if (!KEYMAPP (kboard->Vinput_decode_map)) |
| 1310 | kboard->Vlocal_function_key_map = Fmake_sparse_keymap (Qnil); | 1310 | kboard->Vinput_decode_map = Fmake_sparse_keymap (Qnil); |
| 1311 | 1311 | ||
| 1312 | for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) | 1312 | for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) |
| 1313 | { | 1313 | { |
| 1314 | char *sequence = tgetstr (keys[i].cap, address); | 1314 | char *sequence = tgetstr (keys[i].cap, address); |
| 1315 | if (sequence) | 1315 | if (sequence) |
| 1316 | Fdefine_key (kboard->Vlocal_function_key_map, build_string (sequence), | 1316 | Fdefine_key (kboard->Vinput_decode_map, build_string (sequence), |
| 1317 | Fmake_vector (make_number (1), | 1317 | Fmake_vector (make_number (1), |
| 1318 | intern (keys[i].name))); | 1318 | intern (keys[i].name))); |
| 1319 | } | 1319 | } |
| @@ -1333,13 +1333,13 @@ term_get_fkeys_1 () | |||
| 1333 | if (k0) | 1333 | if (k0) |
| 1334 | /* Define f0 first, so that f10 takes precedence in case the | 1334 | /* Define f0 first, so that f10 takes precedence in case the |
| 1335 | key sequences happens to be the same. */ | 1335 | key sequences happens to be the same. */ |
| 1336 | Fdefine_key (kboard->Vlocal_function_key_map, build_string (k0), | 1336 | Fdefine_key (kboard->Vinput_decode_map, build_string (k0), |
| 1337 | Fmake_vector (make_number (1), intern ("f0"))); | 1337 | Fmake_vector (make_number (1), intern ("f0"))); |
| 1338 | Fdefine_key (kboard->Vlocal_function_key_map, build_string (k_semi), | 1338 | Fdefine_key (kboard->Vinput_decode_map, build_string (k_semi), |
| 1339 | Fmake_vector (make_number (1), intern ("f10"))); | 1339 | Fmake_vector (make_number (1), intern ("f10"))); |
| 1340 | } | 1340 | } |
| 1341 | else if (k0) | 1341 | else if (k0) |
| 1342 | Fdefine_key (kboard->Vlocal_function_key_map, build_string (k0), | 1342 | Fdefine_key (kboard->Vinput_decode_map, build_string (k0), |
| 1343 | Fmake_vector (make_number (1), intern (k0_name))); | 1343 | Fmake_vector (make_number (1), intern (k0_name))); |
| 1344 | } | 1344 | } |
| 1345 | 1345 | ||
| @@ -1362,7 +1362,7 @@ term_get_fkeys_1 () | |||
| 1362 | if (sequence) | 1362 | if (sequence) |
| 1363 | { | 1363 | { |
| 1364 | sprintf (fkey, "f%d", i); | 1364 | sprintf (fkey, "f%d", i); |
| 1365 | Fdefine_key (kboard->Vlocal_function_key_map, build_string (sequence), | 1365 | Fdefine_key (kboard->Vinput_decode_map, build_string (sequence), |
| 1366 | Fmake_vector (make_number (1), | 1366 | Fmake_vector (make_number (1), |
| 1367 | intern (fkey))); | 1367 | intern (fkey))); |
| 1368 | } | 1368 | } |
| @@ -1379,7 +1379,7 @@ term_get_fkeys_1 () | |||
| 1379 | { \ | 1379 | { \ |
| 1380 | char *sequence = tgetstr (cap2, address); \ | 1380 | char *sequence = tgetstr (cap2, address); \ |
| 1381 | if (sequence) \ | 1381 | if (sequence) \ |
| 1382 | Fdefine_key (kboard->Vlocal_function_key_map, build_string (sequence), \ | 1382 | Fdefine_key (kboard->Vinput_decode_map, build_string (sequence), \ |
| 1383 | Fmake_vector (make_number (1), \ | 1383 | Fmake_vector (make_number (1), \ |
| 1384 | intern (sym))); \ | 1384 | intern (sym))); \ |
| 1385 | } | 1385 | } |