diff options
| author | Richard M. Stallman | 1995-08-08 05:12:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-08-08 05:12:31 +0000 |
| commit | 3fe8e9a22e3e6dd1b8591fe38cbba73fa1d4e630 (patch) | |
| tree | 803aee5d2f01a3a43bf2a9198a3af44af6d35bbb | |
| parent | ae3338006e014475f10cdad7a10812c48620270a (diff) | |
| download | emacs-3fe8e9a22e3e6dd1b8591fe38cbba73fa1d4e630.tar.gz emacs-3fe8e9a22e3e6dd1b8591fe38cbba73fa1d4e630.zip | |
(read_key_sequence): Undo previous change.
Instead, put back the orig_uppercase event if key is not defined.
When downcasing, back up one step in key-translation processing.
| -rw-r--r-- | src/keyboard.c | 108 |
1 files changed, 63 insertions, 45 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index fa0f4bdce37..aed154bd3bb 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2425,6 +2425,12 @@ kbd_buffer_store_event (event) | |||
| 2425 | return; | 2425 | return; |
| 2426 | } | 2426 | } |
| 2427 | } | 2427 | } |
| 2428 | /* Don't insert two buffer_switch_event's in a row. | ||
| 2429 | Just ignore the second one. */ | ||
| 2430 | else if (event->kind == buffer_switch_event | ||
| 2431 | && kbd_fetch_ptr != kbd_store_ptr | ||
| 2432 | && kbd_store_ptr->kind == buffer_switch_event) | ||
| 2433 | return; | ||
| 2428 | 2434 | ||
| 2429 | if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE) | 2435 | if (kbd_store_ptr - kbd_buffer == KBD_BUFFER_SIZE) |
| 2430 | kbd_store_ptr = kbd_buffer; | 2436 | kbd_store_ptr = kbd_buffer; |
| @@ -5191,6 +5197,16 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5191 | int function_key_possible = 0; | 5197 | int function_key_possible = 0; |
| 5192 | int key_translation_possible = 0; | 5198 | int key_translation_possible = 0; |
| 5193 | 5199 | ||
| 5200 | /* Save the status of key translation before each step, | ||
| 5201 | so that we can restore this after downcasing. */ | ||
| 5202 | Lisp_Object prev_fkey_map; | ||
| 5203 | Lisp_Object prev_fkey_start; | ||
| 5204 | Lisp_Object prev_fkey_end; | ||
| 5205 | |||
| 5206 | Lisp_Object prev_keytran_map; | ||
| 5207 | Lisp_Object prev_keytran_start; | ||
| 5208 | Lisp_Object prev_keytran_end; | ||
| 5209 | |||
| 5194 | int junk; | 5210 | int junk; |
| 5195 | 5211 | ||
| 5196 | last_nonmenu_event = Qnil; | 5212 | last_nonmenu_event = Qnil; |
| @@ -5335,7 +5351,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5335 | int echo_local_start, keys_local_start, local_first_binding; | 5351 | int echo_local_start, keys_local_start, local_first_binding; |
| 5336 | 5352 | ||
| 5337 | if (t >= bufsize) | 5353 | if (t >= bufsize) |
| 5338 | error ("key sequence too long"); | 5354 | error ("Key sequence too long"); |
| 5339 | 5355 | ||
| 5340 | if (INTERACTIVE) | 5356 | if (INTERACTIVE) |
| 5341 | echo_local_start = echo_length (); | 5357 | echo_local_start = echo_length (); |
| @@ -5544,7 +5560,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5544 | if (SYMBOLP (posn)) | 5560 | if (SYMBOLP (posn)) |
| 5545 | { | 5561 | { |
| 5546 | if (t + 1 >= bufsize) | 5562 | if (t + 1 >= bufsize) |
| 5547 | error ("key sequence too long"); | 5563 | error ("Key sequence too long"); |
| 5548 | keybuf[t] = posn; | 5564 | keybuf[t] = posn; |
| 5549 | keybuf[t+1] = key; | 5565 | keybuf[t+1] = key; |
| 5550 | mock_input = t + 2; | 5566 | mock_input = t + 2; |
| @@ -5579,7 +5595,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5579 | if (EQ (posn, Qmenu_bar)) | 5595 | if (EQ (posn, Qmenu_bar)) |
| 5580 | { | 5596 | { |
| 5581 | if (t + 1 >= bufsize) | 5597 | if (t + 1 >= bufsize) |
| 5582 | error ("key sequence too long"); | 5598 | error ("Key sequence too long"); |
| 5583 | keybuf[t] = posn; | 5599 | keybuf[t] = posn; |
| 5584 | keybuf[t+1] = key; | 5600 | keybuf[t+1] = key; |
| 5585 | 5601 | ||
| @@ -5738,6 +5754,14 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5738 | if (!used_mouse_menu) | 5754 | if (!used_mouse_menu) |
| 5739 | last_nonmenu_event = key; | 5755 | last_nonmenu_event = key; |
| 5740 | 5756 | ||
| 5757 | prev_fkey_map = fkey_map; | ||
| 5758 | prev_fkey_start = fkey_start; | ||
| 5759 | prev_fkey_end = fkey_end; | ||
| 5760 | |||
| 5761 | prev_keytran_map = keytran_map; | ||
| 5762 | prev_keytran_start = keytran_start; | ||
| 5763 | prev_keytran_end = keytran_end; | ||
| 5764 | |||
| 5741 | /* If the sequence is unbound, see if we can hang a function key | 5765 | /* If the sequence is unbound, see if we can hang a function key |
| 5742 | off the end of it. We only want to scan real keyboard input | 5766 | off the end of it. We only want to scan real keyboard input |
| 5743 | for function key sequences, so if mock_input says that we're | 5767 | for function key sequences, so if mock_input says that we're |
| @@ -5814,7 +5838,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5814 | 5838 | ||
| 5815 | t = fkey_start + len; | 5839 | t = fkey_start + len; |
| 5816 | if (t >= bufsize) | 5840 | if (t >= bufsize) |
| 5817 | error ("key sequence too long"); | 5841 | error ("Key sequence too long"); |
| 5818 | 5842 | ||
| 5819 | if (VECTORP (fkey_next)) | 5843 | if (VECTORP (fkey_next)) |
| 5820 | bcopy (XVECTOR (fkey_next)->contents, | 5844 | bcopy (XVECTOR (fkey_next)->contents, |
| @@ -5914,7 +5938,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5914 | 5938 | ||
| 5915 | t = keytran_start + len; | 5939 | t = keytran_start + len; |
| 5916 | if (t >= bufsize) | 5940 | if (t >= bufsize) |
| 5917 | error ("key sequence too long"); | 5941 | error ("Key sequence too long"); |
| 5918 | 5942 | ||
| 5919 | if (VECTORP (keytran_next)) | 5943 | if (VECTORP (keytran_next)) |
| 5920 | bcopy (XVECTOR (keytran_next)->contents, | 5944 | bcopy (XVECTOR (keytran_next)->contents, |
| @@ -5967,7 +5991,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5967 | || (XINT (key) & shift_modifier))) | 5991 | || (XINT (key) & shift_modifier))) |
| 5968 | { | 5992 | { |
| 5969 | Lisp_Object new_key; | 5993 | Lisp_Object new_key; |
| 5970 | int new_first_binding; | ||
| 5971 | 5994 | ||
| 5972 | original_uppercase = key; | 5995 | original_uppercase = key; |
| 5973 | original_uppercase_position = t - 1; | 5996 | original_uppercase_position = t - 1; |
| @@ -5978,23 +6001,21 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 5978 | XSETINT (new_key, (DOWNCASE (XINT (key) & 0x3ffff) | 6001 | XSETINT (new_key, (DOWNCASE (XINT (key) & 0x3ffff) |
| 5979 | | (XINT (key) & ~0x3ffff))); | 6002 | | (XINT (key) & ~0x3ffff))); |
| 5980 | 6003 | ||
| 5981 | /* See if new_key has a binding. | 6004 | /* We have to do this unconditionally, regardless of whether |
| 5982 | If it does not have one, this does not alter SUBMAPS. */ | 6005 | the lower-case char is defined in the keymaps, because they |
| 5983 | new_first_binding | 6006 | might get translated through function-key-map. */ |
| 5984 | = (follow_key (new_key, | 6007 | keybuf[t - 1] = new_key; |
| 5985 | nmaps - local_first_binding, | 6008 | mock_input = t; |
| 5986 | submaps + local_first_binding, | 6009 | |
| 5987 | defs + local_first_binding, | 6010 | fkey_map = prev_fkey_map; |
| 5988 | submaps + local_first_binding) | 6011 | fkey_start = prev_fkey_start; |
| 5989 | + local_first_binding); | 6012 | fkey_end = prev_fkey_end; |
| 5990 | 6013 | ||
| 5991 | /* If that lower-case char is bound, use it instead. */ | 6014 | keytran_map = prev_keytran_map; |
| 5992 | if (new_first_binding < nmaps) | 6015 | keytran_start = prev_keytran_start; |
| 5993 | { | 6016 | keytran_end = prev_keytran_end; |
| 5994 | keybuf[t - 1] = new_key; | 6017 | |
| 5995 | mock_input = t; | 6018 | goto replay_sequence; |
| 5996 | goto replay_sequence; | ||
| 5997 | } | ||
| 5998 | } | 6019 | } |
| 5999 | /* If KEY is not defined in any of the keymaps, | 6020 | /* If KEY is not defined in any of the keymaps, |
| 6000 | and cannot be part of a function key or translation, | 6021 | and cannot be part of a function key or translation, |
| @@ -6007,37 +6028,31 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6007 | Lisp_Object breakdown; | 6028 | Lisp_Object breakdown; |
| 6008 | int modifiers; | 6029 | int modifiers; |
| 6009 | 6030 | ||
| 6010 | original_uppercase = key; | ||
| 6011 | original_uppercase_position = t - 1; | ||
| 6012 | |||
| 6013 | breakdown = parse_modifiers (key); | 6031 | breakdown = parse_modifiers (key); |
| 6014 | modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car); | 6032 | modifiers = XINT (XCONS (XCONS (breakdown)->cdr)->car); |
| 6015 | if (modifiers & shift_modifier) | 6033 | if (modifiers & shift_modifier) |
| 6016 | { | 6034 | { |
| 6017 | Lisp_Object new_key; | 6035 | Lisp_Object new_key; |
| 6018 | int new_first_binding; | 6036 | |
| 6037 | original_uppercase = key; | ||
| 6038 | original_uppercase_position = t - 1; | ||
| 6019 | 6039 | ||
| 6020 | modifiers &= ~shift_modifier; | 6040 | modifiers &= ~shift_modifier; |
| 6021 | new_key = apply_modifiers (modifiers, | 6041 | new_key = apply_modifiers (modifiers, |
| 6022 | XCONS (breakdown)->car); | 6042 | XCONS (breakdown)->car); |
| 6023 | 6043 | ||
| 6024 | /* See if new_key has a binding. | 6044 | keybuf[t - 1] = new_key; |
| 6025 | If it does not have one, this does not alter SUBMAPS. */ | 6045 | mock_input = t; |
| 6026 | new_first_binding | 6046 | |
| 6027 | = (follow_key (new_key, | 6047 | fkey_map = prev_fkey_map; |
| 6028 | nmaps - local_first_binding, | 6048 | fkey_start = prev_fkey_start; |
| 6029 | submaps + local_first_binding, | 6049 | fkey_end = prev_fkey_end; |
| 6030 | defs + local_first_binding, | 6050 | |
| 6031 | submaps + local_first_binding) | 6051 | keytran_map = prev_keytran_map; |
| 6032 | + local_first_binding); | 6052 | keytran_start = prev_keytran_start; |
| 6033 | 6053 | keytran_end = prev_keytran_end; | |
| 6034 | /* If that unshifted key is bound, use it instead. */ | 6054 | |
| 6035 | if (new_first_binding < nmaps) | 6055 | goto replay_sequence; |
| 6036 | { | ||
| 6037 | keybuf[t - 1] = new_key; | ||
| 6038 | mock_input = t; | ||
| 6039 | goto replay_sequence; | ||
| 6040 | } | ||
| 6041 | } | 6056 | } |
| 6042 | } | 6057 | } |
| 6043 | } | 6058 | } |
| @@ -6050,7 +6065,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6050 | unread_switch_frame = delayed_switch_frame; | 6065 | unread_switch_frame = delayed_switch_frame; |
| 6051 | unbind_to (count, Qnil); | 6066 | unbind_to (count, Qnil); |
| 6052 | 6067 | ||
| 6053 | if (dont_downcase_last && t - 1 == original_uppercase_position) | 6068 | /* Don't downcase the last character if the caller says don't. |
| 6069 | Don't downcase it if the result is undefined, either. */ | ||
| 6070 | if ((dont_downcase_last || first_binding >= nmaps) | ||
| 6071 | && t - 1 == original_uppercase_position) | ||
| 6054 | keybuf[t - 1] = original_uppercase; | 6072 | keybuf[t - 1] = original_uppercase; |
| 6055 | 6073 | ||
| 6056 | /* Occasionally we fabricate events, perhaps by expanding something | 6074 | /* Occasionally we fabricate events, perhaps by expanding something |