Subject: bug#6212: 23.2; ^S^Q^@ --error--> Wrong type argument: characterp, 67108896

From: Stefan Monnier <[email-masked]>
Date: Tue, 18 May 2010 16:32:13 -0400

>> Attempting to insert a literal ^@ control character worked in 23.1.
>> In 23.2, it results in an error: Wrong type argument: characterp,
>> 67108896
>> I am typing C-q C-SPC, in Emacs in Screen in linux's fbcon.  Since ^@ is
>> the zeroth character, perhaps this is an off-by-one or overflow error
>> somewhere.  The same error occurs when typing C-q C-@.
>     * bindings.el (function-key-map): Map C-@ to C-SPC if C-@ is unbound.
[...]
> Stefan, could you take a look?  I don't know your original motivation
> for this change, so I don't know how to fix it.

Indeed, that's part of the culprit.  The reason for the remapping is
that as the comment tries to explain many terminals send C-@ when the
user hits C-SPC, so rather than bind commands to both <prefix> C-SPC and
<prefix> C-@, it's much better to let key remapping handling it once and
for all.  The "canonical" binding is for C-SPC, so we want to remap C-@
to C-SPC rather than the other way around.

But note that C-q C-SPC works just fine, so the remapping from
C-@ to C-SPC is not really the core problem.

I think the patch I just installed (appended) will fix things.
Can you confirm?

        Stefan

=== modified file 'lisp/subr.el'
--- lisp/subr.el	2010-05-15 13:23:48 +0000
+++ lisp/subr.el	2010-05-18 20:25:28 +0000
@@ -1868,16 +1868,14 @@
 	(if inhibit-quit (setq quit-flag nil)))
       ;; Translate TAB key into control-I ASCII character, and so on.
       ;; Note: `read-char' does it using the `ascii-character' property.
-      ;; We could try and use read-key-sequence instead, but then C-q ESC
-      ;; or C-q C-x might not return immediately since ESC or C-x might be
-      ;; bound to some prefix in function-key-map or key-translation-map.
+      ;; We could try and use read-key instead.
+      (let ((translation (lookup-key local-function-key-map (vector char))))
+	(if (arrayp translation)
+	    (setq translated (aref translation 0))))
       (setq translated
 	    (if (integerp char)
 		(char-resolve-modifiers char)
 	      char))
-      (let ((translation (lookup-key local-function-key-map (vector char))))
-	(if (arrayp translation)
-	    (setq translated (aref translation 0))))
       (cond ((null translated))
 	    ((not (integerp translated))
 	     (setq unread-command-events (list char)