Subject: bug#9751: 23.3; Alternative Keyboard Feature/Bug

From: Stefan Monnier <[email-masked]>
Date: Mon, 24 Oct 2011 16:18:20 -0400

>> Oh, yes, it wasn't complete.  Here is a more complete one which seems to
>> work to remap 3 to 4 with 3 globally bound to `undefined'.
> It still does nothing.  I guess for testing it, a Greek keyboard layout
> is not necessary.  It's enough to evaluate:
> (define-key function-key-map [?*] [?b])
> and typing `*' is expected to run `beginning-of-buffer' in Info.

Oh, right because * is not bound to `undefined', instead it's bound to
self-insert-command which is remapped to `undefined'.  Damn!
The patch below at least works for this test case,

        Stefan

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2011-10-03 20:50:54 +0000
+++ src/keyboard.c	2011-10-24 20:15:14 +0000
@@ -8902,6 +8902,14 @@
   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 @@
 	    }
 	}
 
-      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 @@
 				  /* 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)