Subject: bug#6527: C-h b alters key-translation-map (in a bad way)

From: David Reitter <[email-masked]>
Date: Mon, 28 Jun 2010 10:41:36 -0400

X-debbugs-cc: [email-masked]

C-h b alters the key translation map.

Emacs
(setq ns-command-modifier 'alt)  ;; On NS, we need to assign the modifier key
Press Command-C -> A-c is undefined (correct)
C-h b
Press Command-C -> ¢ is inserted

The value of `key-translation-map' is indeed changed by C-h b, and resetting it fixes the problem.

Some debugging suggests that something odd is happening in describe_map(). Commenting out

  map = call1 (Qkeymap_canonicalize, map);

makes the error go away.  A direct call to `keymap-canonicalize' does not, however, reproduce it, so there is something else going on.

Full credit for the original report of a reproducible bug goes to Larry Denenberg - his report is quoted below.

In GNU Emacs 23.2.50.1 (x86_64-apple-darwin10.3.1, NS apple-appkit-1038.29)
 of 2010-05-10 on elin.psy.cmu.edu
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  which-function-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> C-x k <return> ) s e <backspace> <backspace> 
<backspace> ( s e t q SPC n s - a <backspace> c o m 
m a n d - m o d i f i e r SPC ' a l t ) C-x C-e <return> 
A-c A-c <down> <down> C-h b <help-echo> <down-mouse-1> 
<mouse-1> A-c A-c <help-echo> <menu-bar> <help-menu> 
<send-emacs-bug-report>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Unable to load color "darkblue"
alt
Type C-x 1 to delete the help window, C-M-v to scroll help.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug kmacro two-column iso-transl
help-mode view ghostedit ghostedit-stopwords-en easy-mmode which-func
imenu tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)

===

Begin forwarded message:

> From: Larry Denenberg <[email-masked]>
> Date: June 25, 2010 7:02:32 AM EDT
> To: [email-masked]
> Cc: [email-masked]
> Subject: [Aquamacs-bugs] 23.2; ^H B doesn't just describe bindings, it changes them
> Reply-To: Bug reports for Aquamacs Emacs <[email-masked]>
> 
> 
> Starting from scratch, type ^H C ⌘. [that's C-h A-.) to get
>        ⌘. runs the command keyboard-quit
> 
> Then type ^H B to see a help buffer describing key bindings, after
> which ^H C ⌘. again (in any buffer) yields
>        · (translated from ⌘.) runs the command self-insert-command
> 
> Note that the first character here is not a period but a centered dot, #xb7.
> 
> BTW, after you've done this, you get "Options have changed - save them?"
> upon exit.
> 
> I get this behavior in Aquamacs as described below, whether starting
> "-q" or "-Q", and also in 24.0.50.1.  I do not get it in 22.3.1, nor in
> plain GNU Emacs 24.0.50.2.
> 
> /Larry Denenberg
> [email-masked]
> http://larry.denenberg.com/
> 
> 
> In GNU Emacs 23.2.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)
> of 2010-05-09 on braeburn.aquamacs.org - Aquamacs Distribution 2.0
> Windowing system distributor `Apple', version 10.3.1038
> configured using `configure  '--with-ns' '--without-x' 'CFLAGS=-arch i386 -arch ppc' 'LDFLAGS=-arch i386 -arch ppc''
> 
> Important settings:
>  value of $LC_ALL: nil
>  value of $LC_COLLATE: nil
>  value of $LC_CTYPE: nil
>  value of $LC_MESSAGES: nil
>  value of $LC_MONETARY: nil
>  value of $LC_NUMERIC: nil
>  value of $LC_TIME: nil
>  value of $LANG: en_US.UTF-8
>  value of $XMODIFIERS: nil
>  locale-coding-system: utf-8-unix
>  default enable-multibyte-characters: t
> 
> Major mode: Text
> 
> Minor modes in effect:
>  savehist-mode: t
>  smart-frame-positioning-mode: t
>  aquamacs-autoface-mode: t
>  recentf-mode: t
>  osx-key-mode: t
>  tabbar-mwheel-mode: t
>  tabbar-mode: t
>  show-paren-mode: t
>  delete-selection-mode: t
>  pc-selection-mode: t
>  cua-mode: t
>  tooltip-mode: t
>  mouse-wheel-mode: t
>  tool-bar-mode: t
>  menu-bar-mode: t
>  file-name-shadow-mode: t
>  global-font-lock-mode: t
>  font-lock-mode: t
>  blink-cursor-mode: t
>  auto-encryption-mode: t
>  auto-compression-mode: t
>  smart-spacing-mode: t
>  column-number-mode: t
>  line-number-mode: t
>  visual-line-mode: t
>  transient-mark-mode: t
> 
> Recent input:
> <ns-application-activated> ^H C ⌘. ^H B ^H C ⌘. ^X 
> O ^H O <help-echo> <help-echo> <help-echo> <help-echo> 
> <help-echo> <switch-frame> ^H C ⌘. <menu-bar> <help-menu> 
> <bug-diagnosis> <start-vanilla-aquamacs> <menu-bar> 
> <help-menu> <bug-diagnosis> <send-emacs-bug-report
>> 
> 
> Recent messages:
> Cleaning up the recentf list...done (0 removed)
> 29 environment variables imported from login shell (/bin/bash).
> Loading /Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/auctex.el (source)...done
> Loading /Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/haskell-mode/haskell-site-file.el (source)...done
> one-buffer-one-frame-mode disabled.
> Mark set [32 times]
> Aquamacs is based on GNU Emacs, a part of the GNU/Linux system. It is Free Software: you can improve and redistribute it under the GNU General Public License, version 3 or later. Copyright (C) 2010 Free Software Foundation, Inc. (C) 2010 D. Reitter. No Warranty.
> ⌘. runs the command keyboard-quit
> Type "q" to quit, M-x scroll-up to scroll help.
> · (translated from ⌘.) runs the command self-insert-command [2 times]
> start-vanilla-aquamacs: Searching for program: no such file or directory, Aquamacs.app/Contents/MacOS/Aquamacs
> 
> Load-path shadows:
> None found.
> 
> Features:
> (shadow sort mail-extr message ecomplete rfc822 mml mml-sec
> password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
> rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
> mm-util mail-prsvr gmm-utils mailheader canlock sha1 hex-util hashcash
> mail-utils emacsbug kmacro two-column iso-transl aquamacs-mode-defaults
> auctex-config server tex-site smart-dnd aquamacs-aux savehist mouse-sel
> one-buffer-one-frame smart-frame-positioning drews_init
> color-theme-autoloads saveplace visual-line aquamacs-bug
> aquamacs-autoface-mode aquamacs-editing sendmail recentf tree-widget
> cus-edit osxkeys emulate-mac-keyboard-mode frame-cmds strings misc-fns
> thingatpt+ thingatpt frame-fns avoid aquamacs-mac-fontsets fit-frame
> aquamacs-frame-setup aquamacs-tabbar tabbar-window cl cl-19 tabbar
> easy-mmode cus-start cus-load aquamacs-site-start cocoa-compatibility
> filladapt aquamacs-redo check-for-updates aquamacs-menu osx_defaults
> aquamacs-tool-bar aquamacs mac-extra-functions aquamacs-tools
> aquamacs-macros parse-time timezone time-date paren delsel pc-select
> cua-base wid-edit regexp-opt advice advice-preload byte-opt bytecomp
> byte-compile debug help-fns help-mode view image-file disp-table tooltip
> ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd
> fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
> select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu
> font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
> thai tai-viet lao korean japanese hebrew greek romanian slovak czech
> european ethiopic indian cyrillic chinese case-table epa-hook
> jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces
> cus-face files text-properties overlay md5 base64 format env code-pages
> mule custom widget hashtable-print-readable backquote
> make-network-process ns multi-tty emacs)
> 
> Command line: (Aquamacs.app/Contents/MacOS/Aquamacs)
> 
> PATH: /Users/larry/Bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/nmh/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/texbin:/opt/subversion/bin:/usr/lib:/Users/larry/Bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/nmh/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/texbin:/opt/subversion/bin:/usr/lib:/usr/texbin:/usr/local/texlive/2008/bin
> 
> exec-path: (/Users/larry/Bin /bin /sbin /usr/bin /usr/sbin /usr/local/nmh/bin /usr/local/bin /usr/local/mysql/bin /usr/texbin /opt/subversion/bin /usr/lib /Users/larry/Bin /bin /sbin /usr/bin /usr/sbin /usr/local/nmh/bin /usr/local/bin /usr/local/mysql/bin /usr/texbin /opt/subversion/bin /usr/lib /Applications/Aquamacs.app/Contents/MacOS/bin /usr/local/texlive/2008/bin)
> _______________________________________________
> Aquamacs-bugs mailing list
> [email-masked]
> http://lists.aquamacs.org/mailman/listinfo.cgi/aquamacs-bugs