diff options
| author | Richard M. Stallman <rms@gnu.org> | 1993-10-13 06:01:49 +0000 |
|---|---|---|
| committer | Richard M. Stallman <rms@gnu.org> | 1993-10-13 06:01:49 +0000 |
| commit | 1abe6abe4fd1a545c3397151ce42b69064270f8d (patch) | |
| tree | 9d9941cf9559f3d38e83d45045a1e899d4e4cf69 /src | |
| parent | d22d6453de00a5fb2628f16c56777e2af2e31cd4 (diff) | |
| download | emacs-1abe6abe4fd1a545c3397151ce42b69064270f8d.tar.gz | |
(read_key_sequence): Allow function in key-translation-map
just as in function-key-map.
(read_key_sequence): Allow function-key-map to have a
function as the binding; call the function and use its value.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 388555b52fb..db0307b1a6e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -4241,6 +4241,27 @@ read_key_sequence (keybuf, bufsize, prompt) fkey_next = get_keyelt (access_keymap (fkey_next, key, 1, 0)); + /* If the function key map gives a function, not an + array, then call the function with no args and use + its value instead. */ + if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next)) + && fkey_end == t) + { + struct gcpro gcpro1, gcpro2, gcpro3; + Lisp_Object tem; + tem = fkey_next; + + GCPRO3 (fkey_map, keytran_map, delayed_switch_frame); + fkey_next = call0 (fkey_next); + UNGCPRO; + /* If the function returned something invalid, + barf--don't ignore it. + (To ignore it safely, we would need to gcpro a bunch of + other variables.) */ + if (! (VECTORP (fkey_next) || STRINGP (fkey_next))) + error ("Function in function-key-map returns invalid key sequence"); + } + /* If keybuf[fkey_start..fkey_end] is bound in the function key map and it's a suffix of the current sequence (i.e. fkey_end == t), replace it with @@ -4263,8 +4284,8 @@ read_key_sequence (keybuf, bufsize, prompt) int i; for (i = 0; i < len; i++) - XFASTINT (keybuf[fkey_start + i]) = - XSTRING (fkey_next)->data[i]; + XFASTINT (keybuf[fkey_start + i]) + = XSTRING (fkey_next)->data[i]; } mock_input = t; @@ -4313,8 +4334,29 @@ read_key_sequence (keybuf, bufsize, prompt) keytran_next = get_keyelt (access_keymap (keytran_next, key, 1, 0)); + /* If the key translation map gives a function, not an + array, then call the function with no args and use + its value instead. */ + if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next)) + && keytran_end == t) + { + struct gcpro gcpro1, gcpro2, gcpro3; + Lisp_Object tem; + tem = keytran_next; + + GCPRO3 (keytran_map, keytran_map, delayed_switch_frame); + keytran_next = call0 (keytran_next); + UNGCPRO; + /* If the function returned something invalid, + barf--don't ignore it. + (To ignore it safely, we would need to gcpro a bunch of + other variables.) */ + if (! (VECTORP (keytran_next) || STRINGP (keytran_next))) + error ("Function in function-key-map returns invalid key sequence"); + } + /* If keybuf[keytran_start..keytran_end] is bound in the - function key map and it's a suffix of the current + key translation map and it's a suffix of the current sequence (i.e. keytran_end == t), replace it with the binding and restart with keytran_start at the end. */ if ((VECTORP (keytran_next) || STRINGP (keytran_next)) |
