aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/keyboard.c84
2 files changed, 48 insertions, 44 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0b9817c8435..f8a4818d8d2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
12002-06-17 Stefan Monnier <monnier@cs.yale.edu> 12002-06-17 Stefan Monnier <monnier@cs.yale.edu>
2 2
3 * window.c (Fset_window_configuration): Lisp_Object/int mixup.
4
5 * keyboard.c (read_key_sequence): Be more careful with first_unbound.
6 Lookup keys in function-key-map immediately so that key-translation-map
7 can be applied earlier.
8 Remove function_key_possible and key_translation_possible, replaced
9 by checking `keytran_start < t'.
10
3 * .gdbinit (xsymbol): Use the name `xname' field. 11 * .gdbinit (xsymbol): Use the name `xname' field.
4 12
52002-06-17 Andrew Choi <akochoi@shaw.ca> 132002-06-17 Andrew Choi <akochoi@shaw.ca>
diff --git a/src/keyboard.c b/src/keyboard.c
index 94588983024..ef4a5028ae3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8051,11 +8051,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8051 8051
8052 struct buffer *starting_buffer; 8052 struct buffer *starting_buffer;
8053 8053
8054 /* Nonzero if we seem to have got the beginning of a binding
8055 in function_key_map. */
8056 volatile int function_key_possible = 0;
8057 volatile int key_translation_possible = 0;
8058
8059 /* List of events for which a fake prefix key has been generated. */ 8054 /* List of events for which a fake prefix key has been generated. */
8060 volatile Lisp_Object fake_prefixed_keys = Qnil; 8055 volatile Lisp_Object fake_prefixed_keys = Qnil;
8061 8056
@@ -8122,8 +8117,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8122 replay_sequence: 8117 replay_sequence:
8123 8118
8124 starting_buffer = current_buffer; 8119 starting_buffer = current_buffer;
8125 function_key_possible = 0;
8126 key_translation_possible = 0;
8127 first_unbound = bufsize + 1; 8120 first_unbound = bufsize + 1;
8128 8121
8129 /* Build our list of keymaps. 8122 /* Build our list of keymaps.
@@ -8193,10 +8186,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8193 we may be looking at a function key's escape sequence, keep on 8186 we may be looking at a function key's escape sequence, keep on
8194 reading. */ 8187 reading. */
8195 while ((first_binding < nmaps && ! NILP (submaps[first_binding])) 8188 while ((first_binding < nmaps && ! NILP (submaps[first_binding]))
8196 || (first_binding >= nmaps 8189 || (first_binding >= nmaps && fkey_start < t)
8197 && fkey_start < t) 8190 || (first_binding >= nmaps && keytran_start < t)
8198 || (first_binding >= nmaps
8199 && keytran_start < t && key_translation_possible)
8200 /* Don't return in the middle of a possible function key sequence, 8191 /* Don't return in the middle of a possible function key sequence,
8201 if the only bindings we found were via case conversion. 8192 if the only bindings we found were via case conversion.
8202 Thus, if ESC O a has a function-key-map translation 8193 Thus, if ESC O a has a function-key-map translation
@@ -8626,7 +8617,15 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8626 + first_binding); 8617 + first_binding);
8627 8618
8628 /* If KEY wasn't bound, we'll try some fallbacks. */ 8619 /* If KEY wasn't bound, we'll try some fallbacks. */
8629 if (first_binding >= nmaps) 8620 if (first_binding < nmaps)
8621 /* This is needed for the following scenario:
8622 event 0: a down-event that gets dropped by calling replay_key.
8623 event 1: some normal prefix like C-h.
8624 After event 0, first_unbound is 0, after event 1 fkey_start
8625 and keytran_start are both 1, so when we see that C-h is bound,
8626 we need to update first_unbound. */
8627 first_unbound = max (t + 1, first_unbound);
8628 else
8630 { 8629 {
8631 Lisp_Object head; 8630 Lisp_Object head;
8632 8631
@@ -8706,6 +8705,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8706 generate mouse events, so it's okay to zero 8705 generate mouse events, so it's okay to zero
8707 mock_input in that case too. 8706 mock_input in that case too.
8708 8707
8708 FIXME: The above paragraph seems just plain
8709 wrong, if you consider things like
8710 xterm-mouse-mode. -stef
8711
8709 Isn't this just the most wonderful code ever? */ 8712 Isn't this just the most wonderful code ever? */
8710 if (t == last_real_key_start) 8713 if (t == last_real_key_start)
8711 { 8714 {
@@ -8758,25 +8761,30 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8758 /* Record what part of this_command_keys is the current key sequence. */ 8761 /* Record what part of this_command_keys is the current key sequence. */
8759 this_single_command_key_start = this_command_key_count - t; 8762 this_single_command_key_start = this_command_key_count - t;
8760 8763
8761 /* If the sequence is unbound, see if we can hang a function key 8764 if (first_binding < nmaps && NILP (submaps[first_binding]))
8762 off the end of it. We only want to scan real keyboard input 8765 /* There is a binding and it's not a prefix.
8763 for function key sequences, so if mock_input says that we're 8766 There is thus no function-key in this sequence.
8764 re-reading old events, don't examine it. */ 8767 Moving fkey.start is important in this case to allow keytran.start
8765 if (first_binding >= nmaps 8768 to go over the sequence before we return (since we keep the
8766 && t >= mock_input) 8769 invariant that keytran.end <= fkey.start). */
8770 {
8771 if (fkey_start < t)
8772 (fkey_start = fkey_end = t, fkey_map = Vfunction_key_map);
8773 }
8774 else
8775 /* If the sequence is unbound, see if we can hang a function key
8776 off the end of it. */
8767 { 8777 {
8768 Lisp_Object fkey_next; 8778 Lisp_Object fkey_next;
8769 8779
8770 /* Continue scan from fkey_end until we find a bound suffix. 8780 /* Continue scan from fkey_end until we find a bound suffix.
8771 If we fail, increment fkey_start 8781 If we fail, increment fkey_start and start over from there. */
8772 and start fkey_end from there. */
8773 while (fkey_end < t) 8782 while (fkey_end < t)
8774 { 8783 {
8775 Lisp_Object key; 8784 Lisp_Object key;
8776 8785
8777 key = keybuf[fkey_end++]; 8786 key = keybuf[fkey_end++];
8778 fkey_next 8787 fkey_next = access_keymap (fkey_map, key, 1, 0, 1);
8779 = access_keymap (fkey_map, key, 1, 0, 1);
8780 8788
8781 /* Handle symbol with autoload definition. */ 8789 /* Handle symbol with autoload definition. */
8782 if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) 8790 if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next))
@@ -8804,7 +8812,9 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8804 array, then call the function with no args and use 8812 array, then call the function with no args and use
8805 its value instead. */ 8813 its value instead. */
8806 if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) 8814 if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next))
8807 && fkey_end == t) 8815 /* If there's a binding (i.e. first_binding >= nmaps)
8816 we don't want to apply this function-key-mapping. */
8817 && fkey_end == t && first_binding >= nmaps)
8808 { 8818 {
8809 struct gcpro gcpro1, gcpro2, gcpro3; 8819 struct gcpro gcpro1, gcpro2, gcpro3;
8810 Lisp_Object tem; 8820 Lisp_Object tem;
@@ -8821,14 +8831,14 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8821 error ("Function in key-translation-map returns invalid key sequence"); 8831 error ("Function in key-translation-map returns invalid key sequence");
8822 } 8832 }
8823 8833
8824 function_key_possible = ! NILP (fkey_next);
8825
8826 /* If keybuf[fkey_start..fkey_end] is bound in the 8834 /* If keybuf[fkey_start..fkey_end] is bound in the
8827 function key map and it's a suffix of the current 8835 function key map and it's a suffix of the current
8828 sequence (i.e. fkey_end == t), replace it with 8836 sequence (i.e. fkey_end == t), replace it with
8829 the binding and restart with fkey_start at the end. */ 8837 the binding and restart with fkey_start at the end. */
8830 if ((VECTORP (fkey_next) || STRINGP (fkey_next)) 8838 if ((VECTORP (fkey_next) || STRINGP (fkey_next))
8831 && fkey_end == t) 8839 /* If there's a binding (i.e. first_binding >= nmaps)
8840 we don't want to apply this function-key-mapping. */
8841 && fkey_end == t && first_binding >= nmaps)
8832 { 8842 {
8833 int len = XFASTINT (Flength (fkey_next)); 8843 int len = XFASTINT (Flength (fkey_next));
8834 8844
@@ -8870,20 +8880,9 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8870 { 8880 {
8871 fkey_end = ++fkey_start; 8881 fkey_end = ++fkey_start;
8872 fkey_map = Vfunction_key_map; 8882 fkey_map = Vfunction_key_map;
8873 function_key_possible = 0;
8874 } 8883 }
8875 } 8884 }
8876 } 8885 }
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));
8887 8886
8888 /* Look for this sequence in key-translation-map. */ 8887 /* Look for this sequence in key-translation-map. */
8889 { 8888 {
@@ -8932,8 +8931,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8932 error ("Function in key-translation-map returns invalid key sequence"); 8931 error ("Function in key-translation-map returns invalid key sequence");
8933 } 8932 }
8934 8933
8935 key_translation_possible = ! NILP (keytran_next);
8936
8937 /* If keybuf[keytran_start..keytran_end] is bound in the 8934 /* If keybuf[keytran_start..keytran_end] is bound in the
8938 key translation map and it's a suffix of the current 8935 key translation map and it's a suffix of the current
8939 sequence (i.e. keytran_end == t), replace it with 8936 sequence (i.e. keytran_end == t), replace it with
@@ -8979,7 +8976,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8979 { 8976 {
8980 keytran_end = ++keytran_start; 8977 keytran_end = ++keytran_start;
8981 keytran_map = Vkey_translation_map; 8978 keytran_map = Vkey_translation_map;
8982 key_translation_possible = 0;
8983 } 8979 }
8984 } 8980 }
8985 } 8981 }
@@ -8988,8 +8984,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8988 and cannot be part of a function key or translation, 8984 and cannot be part of a function key or translation,
8989 and is an upper case letter 8985 and is an upper case letter
8990 use the corresponding lower-case letter instead. */ 8986 use the corresponding lower-case letter instead. */
8991 if (first_binding == nmaps && ! function_key_possible 8987 if (first_binding >= nmaps
8992 && ! key_translation_possible 8988 && fkey_start >= t && keytran_start >= t
8993 && INTEGERP (key) 8989 && INTEGERP (key)
8994 && ((((XINT (key) & 0x3ffff) 8990 && ((((XINT (key) & 0x3ffff)
8995 < XCHAR_TABLE (current_buffer->downcase_table)->size) 8991 < XCHAR_TABLE (current_buffer->downcase_table)->size)
@@ -9019,8 +9015,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
9019 and cannot be part of a function key or translation, 9015 and cannot be part of a function key or translation,
9020 and is a shifted function key, 9016 and is a shifted function key,
9021 use the corresponding unshifted function key instead. */ 9017 use the corresponding unshifted function key instead. */
9022 if (first_binding == nmaps && ! function_key_possible 9018 if (first_binding >= nmaps
9023 && ! key_translation_possible 9019 && fkey_start >= t && keytran_start >= t
9024 && SYMBOLP (key)) 9020 && SYMBOLP (key))
9025 { 9021 {
9026 Lisp_Object breakdown; 9022 Lisp_Object breakdown;