Subject: RE: 23.0.60; substitute-command-keys incorrect for self-insert-command

From: "Drew Adams" <[email-masked]>
Date: Tue, 19 Aug 2008 14:43:09 -0700

> > emacs -Q
> > In *scratch* buffer, type this, then use C-x C-e after it:
> > (princ (substitute-command-keys "\\{global-map}") (current-buffer))
> > 
> > You will see this:
> > 
> > key             binding
> > ---             -------
> > 
> > \200 .. \377 self-insert-command
> > 
> > The bug is that the \200 and the \377 are treated 
> differently. The \200
> > is a single octal character; the \377 is four characters, 
> \, 3, 7, 7.
> 
>
> I believe this is simply how the Lisp printer behaves.  Note that
> string_count_byte8 is zero for \200, but one for \377; hence \200 is
> printed literally, while \377 is converted into an escaped string.
> 
> Using `insert' rather than `princ' probably gives the result you want.
> 
> I'm no expert on this area, though, so maybe someone else 
> could comment more authoritatively.

1. Yes, thanks. This treats the \200 and \377 the same way - both are single
octal characters:

(with-current-buffer "foo"
  (insert (substitute-command-keys
            (concat "\\{" "global-map" "}"))))

2. I'm using this in the *Help* buffer. The behavior of using octal chars here
is new with Emacs 23, BTW. In Emacs 22, I see instead "  .. y", where the first
char looks like a space char and the y is really a y with an
umlaut/diaresis/trema (two dots, at least). Dunno if the new behavior is
intended or not.

[I'm not sure those represent the same two character ranges, BTW, but in any
case in Emacs 22 there are no octal chars from `substitute-command-keys'.]