aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-10-13 06:01:49 +0000
committerRichard M. Stallman1993-10-13 06:01:49 +0000
commit1abe6abe4fd1a545c3397151ce42b69064270f8d (patch)
tree9d9941cf9559f3d38e83d45045a1e899d4e4cf69
parentd22d6453de00a5fb2628f16c56777e2af2e31cd4 (diff)
downloademacs-1abe6abe4fd1a545c3397151ce42b69064270f8d.tar.gz
emacs-1abe6abe4fd1a545c3397151ce42b69064270f8d.zip
(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.
-rw-r--r--src/keyboard.c48
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)
4241 fkey_next 4241 fkey_next
4242 = get_keyelt (access_keymap (fkey_next, key, 1, 0)); 4242 = get_keyelt (access_keymap (fkey_next, key, 1, 0));
4243 4243
4244 /* If the function key map gives a function, not an
4245 array, then call the function with no args and use
4246 its value instead. */
4247 if (SYMBOLP (fkey_next) && ! NILP (Ffboundp (fkey_next))
4248 && fkey_end == t)
4249 {
4250 struct gcpro gcpro1, gcpro2, gcpro3;
4251 Lisp_Object tem;
4252 tem = fkey_next;
4253
4254 GCPRO3 (fkey_map, keytran_map, delayed_switch_frame);
4255 fkey_next = call0 (fkey_next);
4256 UNGCPRO;
4257 /* If the function returned something invalid,
4258 barf--don't ignore it.
4259 (To ignore it safely, we would need to gcpro a bunch of
4260 other variables.) */
4261 if (! (VECTORP (fkey_next) || STRINGP (fkey_next)))
4262 error ("Function in function-key-map returns invalid key sequence");
4263 }
4264
4244 /* If keybuf[fkey_start..fkey_end] is bound in the 4265 /* If keybuf[fkey_start..fkey_end] is bound in the
4245 function key map and it's a suffix of the current 4266 function key map and it's a suffix of the current
4246 sequence (i.e. fkey_end == t), replace it with 4267 sequence (i.e. fkey_end == t), replace it with
@@ -4263,8 +4284,8 @@ read_key_sequence (keybuf, bufsize, prompt)
4263 int i; 4284 int i;
4264 4285
4265 for (i = 0; i < len; i++) 4286 for (i = 0; i < len; i++)
4266 XFASTINT (keybuf[fkey_start + i]) = 4287 XFASTINT (keybuf[fkey_start + i])
4267 XSTRING (fkey_next)->data[i]; 4288 = XSTRING (fkey_next)->data[i];
4268 } 4289 }
4269 4290
4270 mock_input = t; 4291 mock_input = t;
@@ -4313,8 +4334,29 @@ read_key_sequence (keybuf, bufsize, prompt)
4313 keytran_next 4334 keytran_next
4314 = get_keyelt (access_keymap (keytran_next, key, 1, 0)); 4335 = get_keyelt (access_keymap (keytran_next, key, 1, 0));
4315 4336
4337 /* If the key translation map gives a function, not an
4338 array, then call the function with no args and use
4339 its value instead. */
4340 if (SYMBOLP (keytran_next) && ! NILP (Ffboundp (keytran_next))
4341 && keytran_end == t)
4342 {
4343 struct gcpro gcpro1, gcpro2, gcpro3;
4344 Lisp_Object tem;
4345 tem = keytran_next;
4346
4347 GCPRO3 (keytran_map, keytran_map, delayed_switch_frame);
4348 keytran_next = call0 (keytran_next);
4349 UNGCPRO;
4350 /* If the function returned something invalid,
4351 barf--don't ignore it.
4352 (To ignore it safely, we would need to gcpro a bunch of
4353 other variables.) */
4354 if (! (VECTORP (keytran_next) || STRINGP (keytran_next)))
4355 error ("Function in function-key-map returns invalid key sequence");
4356 }
4357
4316 /* If keybuf[keytran_start..keytran_end] is bound in the 4358 /* If keybuf[keytran_start..keytran_end] is bound in the
4317 function key map and it's a suffix of the current 4359 key translation map and it's a suffix of the current
4318 sequence (i.e. keytran_end == t), replace it with 4360 sequence (i.e. keytran_end == t), replace it with
4319 the binding and restart with keytran_start at the end. */ 4361 the binding and restart with keytran_start at the end. */
4320 if ((VECTORP (keytran_next) || STRINGP (keytran_next)) 4362 if ((VECTORP (keytran_next) || STRINGP (keytran_next))