diff options
| author | Stefan Monnier | 2002-06-11 19:51:53 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2002-06-11 19:51:53 +0000 |
| commit | 2cf4b7b27fb29677f50697c22f3efed4df832e98 (patch) | |
| tree | 04e29333d264b834f258eab45fc55e5a216545ae /src | |
| parent | 0672b5a0b94147687925017256456762b428ef9b (diff) | |
| download | emacs-2cf4b7b27fb29677f50697c22f3efed4df832e98.tar.gz emacs-2cf4b7b27fb29677f50697c22f3efed4df832e98.zip | |
(read_key_sequence):
Remove prev_(fkey|keytran}_(map|start|end) since we don't want to pass
things through those maps after downcasing events.
Enforce that keytran_end <= fkey_start, i.e. that key-translation-map
applies after function-key-map.
Make sure that keytran can be done in the middle in the sequence.
Be careful not to throw away events past the one we downcase.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 41 | ||||
| -rw-r--r-- | src/keyboard.c | 100 |
2 files changed, 65 insertions, 76 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 169f4dbba62..ec5ac1f784c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2002-06-11 Stefan Monnier <monnier@cs.yale.edu> | ||
| 2 | |||
| 3 | * keyboard.c (read_key_sequence): | ||
| 4 | Remove prev_(fkey|keytran}_(map|start|end) since we don't want to pass | ||
| 5 | things through those maps after downcasing events. | ||
| 6 | Enforce that keytran_end <= fkey_start, i.e. that key-translation-map | ||
| 7 | applies after function-key-map. | ||
| 8 | Make sure that keytran can be done in the middle in the sequence. | ||
| 9 | Be careful not to throw away events past the one we downcase. | ||
| 10 | |||
| 11 | * lread.c (read_integer): Remove unused var `tem'. | ||
| 12 | (read1): Fix int/Lisp_Object mixup. | ||
| 13 | |||
| 14 | * xfaces.c (tty_lookup_color): Type bool/Lisp_Object mismatch fixed. | ||
| 15 | |||
| 1 | 2002-06-11 Richard M. Stallman <rms@gnu.org> | 16 | 2002-06-11 Richard M. Stallman <rms@gnu.org> |
| 2 | 17 | ||
| 3 | * keyboard.c (readable_events): Ignore any number of | 18 | * keyboard.c (readable_events): Ignore any number of |
| @@ -16,12 +31,12 @@ | |||
| 16 | 2002-06-08 Colin Walters <walters@verbum.org> | 31 | 2002-06-08 Colin Walters <walters@verbum.org> |
| 17 | 32 | ||
| 18 | * textprop.c (Vchar_property_alias_alist): New variable. | 33 | * textprop.c (Vchar_property_alias_alist): New variable. |
| 19 | (syms_of_textprop) <Vchar_property_alias_alist>: DEFVAR_LISP. | 34 | (syms_of_textprop) <Vchar_property_alias_alist>: DEFVAR_LISP. |
| 20 | 35 | ||
| 21 | * intervals.c (lookup_char_property): New function for looking up | 36 | * intervals.c (lookup_char_property): New function for looking up |
| 22 | overlay and text properties, created from textget. | 37 | overlay and text properties, created from textget. |
| 23 | (textget): Use it. | 38 | (textget): Use it. |
| 24 | 39 | ||
| 25 | * intervals.h (lookup_char_property): Declare. | 40 | * intervals.h (lookup_char_property): Declare. |
| 26 | (Vchar_property_alias_alist): Declare. | 41 | (Vchar_property_alias_alist): Declare. |
| 27 | 42 | ||
| @@ -34,8 +49,8 @@ | |||
| 34 | 49 | ||
| 35 | 2002-06-07 Eli Zaretskii <eliz@is.elta.co.il> | 50 | 2002-06-07 Eli Zaretskii <eliz@is.elta.co.il> |
| 36 | 51 | ||
| 37 | * xselect.c (lisp_data_to_selection_data): Fix last change: set | 52 | * xselect.c (lisp_data_to_selection_data): Fix last change: |
| 38 | size_ret. | 53 | set size_ret. |
| 39 | 54 | ||
| 40 | 2002-06-07 Andreas Schwab <schwab@suse.de> | 55 | 2002-06-07 Andreas Schwab <schwab@suse.de> |
| 41 | 56 | ||
| @@ -53,8 +68,8 @@ | |||
| 53 | 68 | ||
| 54 | 2002-06-05 Pavel Jan,Bm(Bk <Pavel@Janik.cz> | 69 | 2002-06-05 Pavel Jan,Bm(Bk <Pavel@Janik.cz> |
| 55 | 70 | ||
| 56 | * fileio.c (choose_write_coding_system): Call | 71 | * fileio.c (choose_write_coding_system): |
| 57 | select-safe-coding-system properly. | 72 | Call select-safe-coding-system properly. |
| 58 | 73 | ||
| 59 | 2002-06-03 Richard M. Stallman <rms@gnu.org> | 74 | 2002-06-03 Richard M. Stallman <rms@gnu.org> |
| 60 | 75 | ||
| @@ -67,8 +82,7 @@ | |||
| 67 | 82 | ||
| 68 | 2002-06-03 Ken Raeburn <raeburn@gnu.org> | 83 | 2002-06-03 Ken Raeburn <raeburn@gnu.org> |
| 69 | 84 | ||
| 70 | * buffer.c (fix_overlays_before): Fix list-walking bug in 05-19 | 85 | * buffer.c (fix_overlays_before): Fix list-walking bug in 05-19 change. |
| 71 | change. | ||
| 72 | 86 | ||
| 73 | 2002-06-02 Thien-Thi Nguyen <ttn@gnu.org> | 87 | 2002-06-02 Thien-Thi Nguyen <ttn@gnu.org> |
| 74 | 88 | ||
| @@ -79,13 +93,13 @@ | |||
| 79 | 93 | ||
| 80 | * xdisp.c (redisplay_internal, redisplay_window, decode_mode_spec): | 94 | * xdisp.c (redisplay_internal, redisplay_window, decode_mode_spec): |
| 81 | Cast `current_column' return value to int. | 95 | Cast `current_column' return value to int. |
| 82 | (back_to_previous_visible_line_start, | 96 | (back_to_previous_visible_line_start) |
| 83 | reseat_at_next_visible_line_start, next_element_from_buffer): | 97 | (reseat_at_next_visible_line_start, next_element_from_buffer): |
| 84 | Cast `indented_beyond_p' 3rd arg to float. | 98 | Cast `indented_beyond_p' 3rd arg to float. |
| 85 | 99 | ||
| 86 | * indent.c (last_known_column): Now a float. | 100 | * indent.c (last_known_column): Now a float. |
| 87 | (current_column_1, position_indentation, current_column, | 101 | (current_column_1, position_indentation, current_column) |
| 88 | string_display_width): Return float. | 102 | (string_display_width): Return float. |
| 89 | (Fcurrent_column): Cast `current_column' return value to int. | 103 | (Fcurrent_column): Cast `current_column' return value to int. |
| 90 | (Fcurrent_indentation): Cast `position_indentation' retval to int. | 104 | (Fcurrent_indentation): Cast `position_indentation' retval to int. |
| 91 | (indented_beyond_p): Third arg now a float. | 105 | (indented_beyond_p): Third arg now a float. |
| @@ -145,8 +159,7 @@ | |||
| 145 | Vread_with_symbol_positions. | 159 | Vread_with_symbol_positions. |
| 146 | (readevalloop, Fread, Fread_from_string): Use it. | 160 | (readevalloop, Fread, Fread_from_string): Use it. |
| 147 | (read1): Use readchar_count to add symbol positions to | 161 | (read1): Use readchar_count to add symbol positions to |
| 148 | Vread_symbol_positions_list if Vread_with_symbol_positions is | 162 | Vread_symbol_positions_list if Vread_with_symbol_positions is non-nil. |
| 149 | non-nil. | ||
| 150 | (syms_of_lread): DEFVAR_LISP and initialize them. | 163 | (syms_of_lread): DEFVAR_LISP and initialize them. |
| 151 | 164 | ||
| 152 | * lread.c (read0, read1, read_list, read_vector, read_multibyte) | 165 | * lread.c (read0, read1, read_list, read_vector, read_multibyte) |
diff --git a/src/keyboard.c b/src/keyboard.c index 6b02c399bf2..c680473c79d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -8059,16 +8059,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8059 | /* List of events for which a fake prefix key has been generated. */ | 8059 | /* List of events for which a fake prefix key has been generated. */ |
| 8060 | volatile Lisp_Object fake_prefixed_keys = Qnil; | 8060 | volatile Lisp_Object fake_prefixed_keys = Qnil; |
| 8061 | 8061 | ||
| 8062 | /* Save the status of key translation before each step, | ||
| 8063 | so that we can restore this after downcasing. */ | ||
| 8064 | Lisp_Object prev_fkey_map; | ||
| 8065 | int prev_fkey_start; | ||
| 8066 | int prev_fkey_end; | ||
| 8067 | |||
| 8068 | Lisp_Object prev_keytran_map; | ||
| 8069 | int prev_keytran_start; | ||
| 8070 | int prev_keytran_end; | ||
| 8071 | |||
| 8072 | #if defined (GOBBLE_FIRST_EVENT) | 8062 | #if defined (GOBBLE_FIRST_EVENT) |
| 8073 | int junk; | 8063 | int junk; |
| 8074 | #endif | 8064 | #endif |
| @@ -8230,6 +8220,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8230 | just one key. */ | 8220 | just one key. */ |
| 8231 | volatile int echo_local_start, keys_local_start, local_first_binding; | 8221 | volatile int echo_local_start, keys_local_start, local_first_binding; |
| 8232 | 8222 | ||
| 8223 | /* key-translation-map is applied *after* function-key-map. */ | ||
| 8224 | eassert (keytran_end <= fkey_start); | ||
| 8233 | 8225 | ||
| 8234 | if (first_unbound < fkey_start && first_unbound < keytran_start) | 8226 | if (first_unbound < fkey_start && first_unbound < keytran_start) |
| 8235 | { /* The prefix upto first_unbound has no binding and has | 8227 | { /* The prefix upto first_unbound has no binding and has |
| @@ -8766,14 +8758,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8766 | /* Record what part of this_command_keys is the current key sequence. */ | 8758 | /* Record what part of this_command_keys is the current key sequence. */ |
| 8767 | this_single_command_key_start = this_command_key_count - t; | 8759 | this_single_command_key_start = this_command_key_count - t; |
| 8768 | 8760 | ||
| 8769 | prev_fkey_map = fkey_map; | ||
| 8770 | prev_fkey_start = fkey_start; | ||
| 8771 | prev_fkey_end = fkey_end; | ||
| 8772 | |||
| 8773 | prev_keytran_map = keytran_map; | ||
| 8774 | prev_keytran_start = keytran_start; | ||
| 8775 | prev_keytran_end = keytran_end; | ||
| 8776 | |||
| 8777 | /* If the sequence is unbound, see if we can hang a function key | 8761 | /* If the sequence is unbound, see if we can hang a function key |
| 8778 | off the end of it. We only want to scan real keyboard input | 8762 | off the end of it. We only want to scan real keyboard input |
| 8779 | for function key sequences, so if mock_input says that we're | 8763 | for function key sequences, so if mock_input says that we're |
| @@ -8890,13 +8874,23 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8890 | } | 8874 | } |
| 8891 | } | 8875 | } |
| 8892 | } | 8876 | } |
| 8877 | else if (NILP (submaps[first_binding])) | ||
| 8878 | /* There is a global binding and it's not a prefix. | ||
| 8879 | There is thus no function-key in this sequence. | ||
| 8880 | We can probably show that there can't be any afterwards either | ||
| 8881 | but I can't seem to find a clear reason why not, so I'll | ||
| 8882 | be conservative. | ||
| 8883 | Moving fkey.start is important in this case to allow keytran.start | ||
| 8884 | to go over the sequence before we return (since we keep the | ||
| 8885 | invariant that keytran.end <= fkey.start). */ | ||
| 8886 | (fkey_start = max (fkey_start, t), fkey_end = max (fkey_end, t)); | ||
| 8893 | 8887 | ||
| 8894 | /* Look for this sequence in key-translation-map. */ | 8888 | /* Look for this sequence in key-translation-map. */ |
| 8895 | { | 8889 | { |
| 8896 | Lisp_Object keytran_next; | 8890 | Lisp_Object keytran_next; |
| 8897 | 8891 | ||
| 8898 | /* Scan from keytran_end until we find a bound suffix. */ | 8892 | /* Scan from keytran_end until we find a bound suffix. */ |
| 8899 | while (keytran_end < t) | 8893 | while (keytran_end < fkey_start) |
| 8900 | { | 8894 | { |
| 8901 | Lisp_Object key; | 8895 | Lisp_Object key; |
| 8902 | 8896 | ||
| @@ -8921,8 +8915,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8921 | /* If the key translation map gives a function, not an | 8915 | /* If the key translation map gives a function, not an |
| 8922 | array, then call the function with one arg and use | 8916 | array, then call the function with one arg and use |
| 8923 | its value instead. */ | 8917 | its value instead. */ |
| 8924 | if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next)) | 8918 | if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next))) |
| 8925 | && keytran_end == t) | ||
| 8926 | { | 8919 | { |
| 8927 | struct gcpro gcpro1, gcpro2, gcpro3; | 8920 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 8928 | Lisp_Object tem; | 8921 | Lisp_Object tem; |
| @@ -8945,36 +8938,35 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8945 | key translation map and it's a suffix of the current | 8938 | key translation map and it's a suffix of the current |
| 8946 | sequence (i.e. keytran_end == t), replace it with | 8939 | sequence (i.e. keytran_end == t), replace it with |
| 8947 | the binding and restart with keytran_start at the end. */ | 8940 | the binding and restart with keytran_start at the end. */ |
| 8948 | if ((VECTORP (keytran_next) || STRINGP (keytran_next)) | 8941 | if ((VECTORP (keytran_next) || STRINGP (keytran_next))) |
| 8949 | && keytran_end == t) | ||
| 8950 | { | 8942 | { |
| 8951 | int len = XFASTINT (Flength (keytran_next)); | 8943 | int len = XFASTINT (Flength (keytran_next)); |
| 8944 | int i, diff = len - (keytran_end - keytran_start); | ||
| 8952 | 8945 | ||
| 8953 | t = keytran_start + len; | 8946 | mock_input = max (t, mock_input); |
| 8954 | if (t >= bufsize) | 8947 | if (mock_input + diff >= bufsize) |
| 8955 | error ("Key sequence too long"); | 8948 | error ("Key sequence too long"); |
| 8956 | 8949 | ||
| 8957 | if (VECTORP (keytran_next)) | 8950 | /* Shift the keys that are after keytran_end. */ |
| 8958 | bcopy (XVECTOR (keytran_next)->contents, | 8951 | if (diff < 0) |
| 8959 | keybuf + keytran_start, | 8952 | for (i = keytran_end; i < mock_input; i++) |
| 8960 | (t - keytran_start) * sizeof (keybuf[0])); | 8953 | keybuf[i + diff] = keybuf[i]; |
| 8961 | else if (STRINGP (keytran_next)) | 8954 | else if (diff > 0) |
| 8962 | { | 8955 | for (i = mock_input - 1; i >= keytran_end; i--) |
| 8963 | int i; | 8956 | keybuf[i + diff] = keybuf[i]; |
| 8964 | 8957 | /* Replace the keys between keytran_start and keytran_end | |
| 8965 | for (i = 0; i < len; i++) | 8958 | with those from keytran_next. */ |
| 8966 | XSETFASTINT (keybuf[keytran_start + i], | 8959 | for (i = 0; i < len; i++) |
| 8967 | XSTRING (keytran_next)->data[i]); | 8960 | keybuf[keytran_start + i] |
| 8968 | } | 8961 | = Faref (keytran_next, make_number (i)); |
| 8969 | 8962 | ||
| 8970 | mock_input = t; | 8963 | mock_input += diff; |
| 8971 | keytran_start = keytran_end = t; | 8964 | keytran_start = keytran_end += diff; |
| 8972 | keytran_map = Vkey_translation_map; | 8965 | keytran_map = Vkey_translation_map; |
| 8973 | 8966 | ||
| 8974 | /* Don't pass the results of key-translation-map | 8967 | /* Adjust the function-key-map counters. */ |
| 8975 | through function-key-map. */ | 8968 | fkey_start += diff; |
| 8976 | fkey_start = fkey_end = t; | 8969 | fkey_end += diff; |
| 8977 | fkey_map = Vfunction_key_map; | ||
| 8978 | 8970 | ||
| 8979 | goto replay_sequence; | 8971 | goto replay_sequence; |
| 8980 | } | 8972 | } |
| @@ -9019,15 +9011,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9019 | the lower-case char is defined in the keymaps, because they | 9011 | the lower-case char is defined in the keymaps, because they |
| 9020 | might get translated through function-key-map. */ | 9012 | might get translated through function-key-map. */ |
| 9021 | keybuf[t - 1] = new_key; | 9013 | keybuf[t - 1] = new_key; |
| 9022 | mock_input = t; | 9014 | mock_input = max (t, mock_input); |
| 9023 | |||
| 9024 | fkey_map = prev_fkey_map; | ||
| 9025 | fkey_start = prev_fkey_start; | ||
| 9026 | fkey_end = prev_fkey_end; | ||
| 9027 | |||
| 9028 | keytran_map = prev_keytran_map; | ||
| 9029 | keytran_start = prev_keytran_start; | ||
| 9030 | keytran_end = prev_keytran_end; | ||
| 9031 | 9015 | ||
| 9032 | goto replay_sequence; | 9016 | goto replay_sequence; |
| 9033 | } | 9017 | } |
| @@ -9056,15 +9040,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 9056 | XCAR (breakdown)); | 9040 | XCAR (breakdown)); |
| 9057 | 9041 | ||
| 9058 | keybuf[t - 1] = new_key; | 9042 | keybuf[t - 1] = new_key; |
| 9059 | mock_input = t; | 9043 | mock_input = max (t, mock_input); |
| 9060 | |||
| 9061 | fkey_map = prev_fkey_map; | ||
| 9062 | fkey_start = prev_fkey_start; | ||
| 9063 | fkey_end = prev_fkey_end; | ||
| 9064 | |||
| 9065 | keytran_map = prev_keytran_map; | ||
| 9066 | keytran_start = prev_keytran_start; | ||
| 9067 | keytran_end = prev_keytran_end; | ||
| 9068 | 9044 | ||
| 9069 | goto replay_sequence; | 9045 | goto replay_sequence; |
| 9070 | } | 9046 | } |