8051 |
|
|
8052 |
struct buffer *starting_buffer; |
struct buffer *starting_buffer; |
8053 |
|
|
|
/* Nonzero if we seem to have got the beginning of a binding |
|
|
in function_key_map. */ |
|
|
volatile int function_key_possible = 0; |
|
|
volatile int key_translation_possible = 0; |
|
|
|
|
8054 |
/* List of events for which a fake prefix key has been generated. */ |
/* List of events for which a fake prefix key has been generated. */ |
8055 |
volatile Lisp_Object fake_prefixed_keys = Qnil; |
volatile Lisp_Object fake_prefixed_keys = Qnil; |
8056 |
|
|
8117 |
replay_sequence: |
replay_sequence: |
8118 |
|
|
8119 |
starting_buffer = current_buffer; |
starting_buffer = current_buffer; |
|
function_key_possible = 0; |
|
|
key_translation_possible = 0; |
|
8120 |
first_unbound = bufsize + 1; |
first_unbound = bufsize + 1; |
8121 |
|
|
8122 |
/* Build our list of keymaps. |
/* Build our list of keymaps. |
8186 |
we may be looking at a function key's escape sequence, keep on |
we may be looking at a function key's escape sequence, keep on |
8187 |
reading. */ |
reading. */ |
8188 |
while ((first_binding < nmaps && ! NILP (submaps[first_binding])) |
while ((first_binding < nmaps && ! NILP (submaps[first_binding])) |
8189 |
|| (first_binding >= nmaps |
|| (first_binding >= nmaps && fkey_start < t) |
8190 |
&& fkey_start < t) |
|| (first_binding >= nmaps && keytran_start < t) |
|
|| (first_binding >= nmaps |
|
|
&& keytran_start < t && key_translation_possible) |
|
8191 |
/* Don't return in the middle of a possible function key sequence, |
/* Don't return in the middle of a possible function key sequence, |
8192 |
if the only bindings we found were via case conversion. |
if the only bindings we found were via case conversion. |
8193 |
Thus, if ESC O a has a function-key-map translation |
Thus, if ESC O a has a function-key-map translation |
8617 |
+ first_binding); |
+ first_binding); |
8618 |
|
|
8619 |
/* If KEY wasn't bound, we'll try some fallbacks. */ |
/* If KEY wasn't bound, we'll try some fallbacks. */ |
8620 |
if (first_binding >= nmaps) |
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 |
8629 |
{ |
{ |
8630 |
Lisp_Object head; |
Lisp_Object head; |
8631 |
|
|
8705 |
generate mouse events, so it's okay to zero |
generate mouse events, so it's okay to zero |
8706 |
mock_input in that case too. |
mock_input in that case too. |
8707 |
|
|
8708 |
|
FIXME: The above paragraph seems just plain |
8709 |
|
wrong, if you consider things like |
8710 |
|
xterm-mouse-mode. -stef |
8711 |
|
|
8712 |
Isn't this just the most wonderful code ever? */ |
Isn't this just the most wonderful code ever? */ |
8713 |
if (t == last_real_key_start) |
if (t == last_real_key_start) |
8714 |
{ |
{ |
8761 |
/* Record what part of this_command_keys is the current key sequence. */ |
/* Record what part of this_command_keys is the current key sequence. */ |
8762 |
this_single_command_key_start = this_command_key_count - t; |
this_single_command_key_start = this_command_key_count - t; |
8763 |
|
|
8764 |
/* If the sequence is unbound, see if we can hang a function key |
if (first_binding < nmaps && NILP (submaps[first_binding])) |
8765 |
off the end of it. We only want to scan real keyboard input |
/* There is a binding and it's not a prefix. |
8766 |
for function key sequences, so if mock_input says that we're |
There is thus no function-key in this sequence. |
8767 |
re-reading old events, don't examine it. */ |
Moving fkey.start is important in this case to allow keytran.start |
8768 |
if (first_binding >= nmaps |
to go over the sequence before we return (since we keep the |
8769 |
&& t >= mock_input) |
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. */ |
8777 |
{ |
{ |
8778 |
Lisp_Object fkey_next; |
Lisp_Object fkey_next; |
8779 |
|
|
8780 |
/* Continue scan from fkey_end until we find a bound suffix. |
/* Continue scan from fkey_end until we find a bound suffix. |
8781 |
If we fail, increment fkey_start |
If we fail, increment fkey_start and start over from there. */ |
|
and start fkey_end from there. */ |
|
8782 |
while (fkey_end < t) |
while (fkey_end < t) |
8783 |
{ |
{ |
8784 |
Lisp_Object key; |
Lisp_Object key; |
8785 |
|
|
8786 |
key = keybuf[fkey_end++]; |
key = keybuf[fkey_end++]; |
8787 |
fkey_next |
fkey_next = access_keymap (fkey_map, key, 1, 0, 1); |
|
= access_keymap (fkey_map, key, 1, 0, 1); |
|
8788 |
|
|
8789 |
/* Handle symbol with autoload definition. */ |
/* Handle symbol with autoload definition. */ |
8790 |
if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) |
if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) |
8812 |
array, then call the function with no args and use |
array, then call the function with no args and use |
8813 |
its value instead. */ |
its value instead. */ |
8814 |
if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) |
if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) |
8815 |
&& fkey_end == t) |
/* 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) |
8818 |
{ |
{ |
8819 |
struct gcpro gcpro1, gcpro2, gcpro3; |
struct gcpro gcpro1, gcpro2, gcpro3; |
8820 |
Lisp_Object tem; |
Lisp_Object tem; |
8831 |
error ("Function in key-translation-map returns invalid key sequence"); |
error ("Function in key-translation-map returns invalid key sequence"); |
8832 |
} |
} |
8833 |
|
|
|
function_key_possible = ! NILP (fkey_next); |
|
|
|
|
8834 |
/* If keybuf[fkey_start..fkey_end] is bound in the |
/* If keybuf[fkey_start..fkey_end] is bound in the |
8835 |
function key map and it's a suffix of the current |
function key map and it's a suffix of the current |
8836 |
sequence (i.e. fkey_end == t), replace it with |
sequence (i.e. fkey_end == t), replace it with |
8837 |
the binding and restart with fkey_start at the end. */ |
the binding and restart with fkey_start at the end. */ |
8838 |
if ((VECTORP (fkey_next) || STRINGP (fkey_next)) |
if ((VECTORP (fkey_next) || STRINGP (fkey_next)) |
8839 |
&& fkey_end == t) |
/* 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) |
8842 |
{ |
{ |
8843 |
int len = XFASTINT (Flength (fkey_next)); |
int len = XFASTINT (Flength (fkey_next)); |
8844 |
|
|
8880 |
{ |
{ |
8881 |
fkey_end = ++fkey_start; |
fkey_end = ++fkey_start; |
8882 |
fkey_map = Vfunction_key_map; |
fkey_map = Vfunction_key_map; |
|
function_key_possible = 0; |
|
8883 |
} |
} |
8884 |
} |
} |
8885 |
} |
} |
|
else if (NILP (submaps[first_binding])) |
|
|
/* There is a global binding and it's not a prefix. |
|
|
There is thus no function-key in this sequence. |
|
|
We can probably show that there can't be any afterwards either |
|
|
but I can't seem to find a clear reason why not, so I'll |
|
|
be conservative. |
|
|
Moving fkey.start is important in this case to allow keytran.start |
|
|
to go over the sequence before we return (since we keep the |
|
|
invariant that keytran.end <= fkey.start). */ |
|
|
(fkey_start = max (fkey_start, t), fkey_end = max (fkey_end, t)); |
|
8886 |
|
|
8887 |
/* Look for this sequence in key-translation-map. */ |
/* Look for this sequence in key-translation-map. */ |
8888 |
{ |
{ |
8931 |
error ("Function in key-translation-map returns invalid key sequence"); |
error ("Function in key-translation-map returns invalid key sequence"); |
8932 |
} |
} |
8933 |
|
|
|
key_translation_possible = ! NILP (keytran_next); |
|
|
|
|
8934 |
/* If keybuf[keytran_start..keytran_end] is bound in the |
/* If keybuf[keytran_start..keytran_end] is bound in the |
8935 |
key translation map and it's a suffix of the current |
key translation map and it's a suffix of the current |
8936 |
sequence (i.e. keytran_end == t), replace it with |
sequence (i.e. keytran_end == t), replace it with |
8976 |
{ |
{ |
8977 |
keytran_end = ++keytran_start; |
keytran_end = ++keytran_start; |
8978 |
keytran_map = Vkey_translation_map; |
keytran_map = Vkey_translation_map; |
|
key_translation_possible = 0; |
|
8979 |
} |
} |
8980 |
} |
} |
8981 |
} |
} |
8984 |
and cannot be part of a function key or translation, |
and cannot be part of a function key or translation, |
8985 |
and is an upper case letter |
and is an upper case letter |
8986 |
use the corresponding lower-case letter instead. */ |
use the corresponding lower-case letter instead. */ |
8987 |
if (first_binding == nmaps && ! function_key_possible |
if (first_binding >= nmaps |
8988 |
&& ! key_translation_possible |
&& fkey_start >= t && keytran_start >= t |
8989 |
&& INTEGERP (key) |
&& INTEGERP (key) |
8990 |
&& ((((XINT (key) & 0x3ffff) |
&& ((((XINT (key) & 0x3ffff) |
8991 |
< XCHAR_TABLE (current_buffer->downcase_table)->size) |
< XCHAR_TABLE (current_buffer->downcase_table)->size) |
9015 |
and cannot be part of a function key or translation, |
and cannot be part of a function key or translation, |
9016 |
and is a shifted function key, |
and is a shifted function key, |
9017 |
use the corresponding unshifted function key instead. */ |
use the corresponding unshifted function key instead. */ |
9018 |
if (first_binding == nmaps && ! function_key_possible |
if (first_binding >= nmaps |
9019 |
&& ! key_translation_possible |
&& fkey_start >= t && keytran_start >= t |
9020 |
&& SYMBOLP (key)) |
&& SYMBOLP (key)) |
9021 |
{ |
{ |
9022 |
Lisp_Object breakdown; |
Lisp_Object breakdown; |