From e6346438e26069017f0eb5e1b15c53c30587462e Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 25 Oct 2011 08:54:04 -0400 Subject: [PATCH] Make function-key-map apply when key is bound to `undefined'. * src/keyboard.c (test_undefined): New function. (read_key_sequence): Use it to detect when a key is bound to `undefined'. Fixes: debbugs:9751 --- src/ChangeLog | 5 +++++ src/keyboard.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index cee48bd1731..52581be2863 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2011-10-25 Stefan Monnier + + * keyboard.c (test_undefined): New function (bug#9751). + (read_key_sequence): Use it to detect when a key is bound to `undefined'. + 2011-10-25 Enami Tsugutomo * sysdep.c (init_sys_modes): Fix the check for the controlling diff --git a/src/keyboard.c b/src/keyboard.c index 6f3bfd8c1e7..eb316947dcb 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -8902,6 +8902,14 @@ keyremap_step (Lisp_Object *keybuf, int bufsize, volatile keyremap *fkey, return 0; } +static int +test_undefined (Lisp_Object binding) +{ + return (EQ (binding, Qundefined) + || (!NILP (binding) && SYMBOLP (binding) + && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined))); +} + /* Read a sequence of keys that ends with a non prefix character, storing it in KEYBUF, a buffer of size BUFSIZE. Prompt with PROMPT. @@ -9852,7 +9860,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, } } - if (first_binding < nmaps && NILP (submaps[first_binding]) + if (first_binding < nmaps + && NILP (submaps[first_binding]) + && !test_undefined (defs[first_binding]) && indec.start >= t) /* There is a binding and it's not a prefix. (and it doesn't have any input-decode-map translation pending). @@ -9879,7 +9889,9 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt, /* If there's a binding (i.e. first_binding >= nmaps) we don't want to apply this function-key-mapping. */ - fkey.end + 1 == t && first_binding >= nmaps, + fkey.end + 1 == t + && (first_binding >= nmaps + || test_undefined (defs[first_binding])), &diff, prompt); UNGCPRO; if (done) -- 2.39.5