Subject: bug#12744: closed (Re: bug#12744: 24.1; key-binding and local-key-binding return invalid keymap)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 28 Oct 2012 15:01:02 +0000

Your bug report

#12744: 24.1; key-binding and local-key-binding return invalid keymap

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
12744: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12744
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#12744: 24.1; key-binding and local-key-binding return invalid keymap
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Sun, 28 Oct 2012 10:58:23 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> It seems to me. That (key-binding [menu-bar]) returns a wrong keymap.
> It starts with a nested keymap:
> (keymap (keymap (keymap (show . undefined) (hide . undefined) (headings
> .. undefined) (Org menu-item "Org" ...) (Tbl menu-item "Tbl" ...)) keymap
> (headings...
> But there's nothing about that nesting in the docs.

Indeed, it's missing from the docs.  This is a new format added in
Emacs-24 (used in `make-composed-keymap').

Any keymap that appears as above within a keymap is treated as a kind of
additional parent, as if it were "inlined" where it appears.

> When the buffer is in org-mode and i trigger tmm-menubar neither the Org
> nor the Tbl menu are in the list.

Indeed, it looks like the tmm-menubar needs some updating as well,
thanks for spotting this.

I've installed the patch below which should fix those problems.

        Stefan

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-10-27 09:54:04 +0000
+++ lisp/ChangeLog	2012-10-28 14:54:26 +0000
@@ -1,3 +1,7 @@
+2012-10-28  Stefan Monnier  <[email-masked]>
+
+	* tmm.el (tmm-prompt): Use map-keymap (bug#12744).
+
 2012-10-27  Eli Zaretskii  <[email-masked]>
 
 	* profiler.el (profiler-report-make-entry-part): Fix help-echo

=== modified file 'lisp/tmm.el'
--- lisp/tmm.el	2012-06-07 16:35:00 +0000
+++ lisp/tmm.el	2012-10-28 14:38:38 +0000
@@ -165,13 +165,15 @@
     ;; tmm-km-list is an alist of (STRING . MEANING).
     ;; It has no other elements.
     ;; The order of elements in tmm-km-list is the order of the menu bar.
+    (if (not not-menu)
+        (map-keymap (lambda (k v) (tmm-get-keymap (cons k v))) menu)
     (dolist (elt menu)
       (cond
        ((stringp elt) (setq gl-str elt))
        ((listp elt) (tmm-get-keymap elt not-menu))
        ((vectorp elt)
         (dotimes (i (length elt))
-          (tmm-get-keymap (cons i (aref elt i)) not-menu)))))
+            (tmm-get-keymap (cons i (aref elt i)) not-menu))))))
     ;; Choose an element of tmm-km-list; put it in choice.
     (if (and not-menu (= 1 (length tmm-km-list)))
 	;; If this is the top-level of an x-popup-menu menu,
@@ -463,9 +465,10 @@
 	       (and (stringp (car elt)) (setq str (car elt))))
 
 	      ((stringp event)		; x-popup or x-popup element
-	       (if (or in-x-menu (stringp (car-safe elt)))
-		   (setq str event event nil km elt)
-		 (setq str event event nil km (cons 'keymap elt)))))
+               (setq str event)
+               (setq event nil)
+	       (setq km (if (or in-x-menu (stringp (car-safe elt)))
+                            elt (cons 'keymap elt)))))
         (unless (or (eq km 'ignore) (null str))
           (let ((binding (where-is-internal km nil t)))
             (when binding

=== modified file 'doc/lispref/ChangeLog'
--- doc/lispref/ChangeLog	2012-10-28 12:56:15 +0000
+++ doc/lispref/ChangeLog	2012-10-28 14:54:03 +0000
@@ -1,3 +1,8 @@
+2012-10-28  Stefan Monnier  <[email-masked]>
+
+	* keymaps.texi (Format of Keymaps): Document the multiple
+	inheritance format.
+
 2012-10-28  Martin Rudalics  <[email-masked]>
 
 	* windows.texi (Basic Windows): Reformulate description of live,

=== modified file 'doc/lispref/keymaps.texi'
--- doc/lispref/keymaps.texi	2012-10-24 03:48:50 +0000
+++ doc/lispref/keymaps.texi	2012-10-28 14:55:42 +0000
@@ -210,6 +210,11 @@
 have a string as an element.  This is called the @dfn{overall prompt
 string} and makes it possible to use the keymap as a menu.
 @xref{Defining Menus}.
+
+@item (keymap @dots{})
+If an element of a keymap is itself a keymap, it counts as if this inner keymap
+were inlined in the outer keymap.  This is used for multiple-inheritance, such
+as in @code{make-composed-keymap}.
 @end table
 
 When the binding is @code{nil}, it doesn't constitute a definition

Subject: 24.1; key-binding and local-key-binding return invalid keymap
From: [email-masked]
To: [email-masked]
Date: Sat, 27 Oct 2012 18:52:32 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

TWhen the buffer is in org-mode and i trigger tmm-menubar neither the Org
nor the Tbl menu are in the list.

It seems to me. That (key-binding [menu-bar]) returns a wrong keymap. It
starts with a nested keymap:

(keymap (keymap (keymap (show . undefined) (hide . undefined) (headings
.. undefined) (Org menu-item "Org" ...) (Tbl menu-item "Tbl" ...)) keymap
(headings...

But there's nothing about that nesting in the docs.

In 23.4.1 on Windows there are no nested keymaps:
(keymap (show . undefined) (hide . undefined) (headings . undefined)
(Org menu-item "Org" ...) (Tbl menu-item "Tbl"...) keymap (headings ...

But the org-mode-map is similar and has the following as part of a keymap:
 (menu-bar keymap
	   (show . undefined)
	   (hide . undefined)
	   (headings . undefined)
	   (Org menu-item "Org"
		(keymap "Org"...

Best regards
Lennart Fricke

In GNU Emacs 24.1.1 (i686-redhat-linux-gnu, GTK+ Version 2.24.11)
 of 2012-08-13 on buildvm-23.phx2.fedoraproject.org
Windowing system distributor `Fedora Project', version 11.0.11203000
Configured using:
 `configure '--build=i686-redhat-linux-gnu'
 '--host=i686-redhat-linux-gnu' '--program-prefix='
 '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr'
 '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
 '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib'
 '--libexecdir=/usr/libexec' '--localstatedir=/var'
 '--sharedstatedir=/var/lib' '--mandir=/usr/share/man'
 '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg'
 '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm'
 '--with-x-toolkit=gtk' '--with-gpm=no' '--with-wide-int'
 'build_alias=i686-redhat-linux-gnu' 'host_alias=i686-redhat-linux-gnu'
 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32
 -march=i686 -mtune=atom -fasynchronous-unwind-tables'
 'LDFLAGS=-Wl,-z,relro ''

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: de_DE.utf8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Org

Minor modes in effect:
  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-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x <escape> <escape> <escape> C-x C-f o r <backspace> 
<backspace> t e s t / t e s t . o r g <return> M-x 
t m m - m <tab> <return> <escape> <escape> <escape> 
<escape> <help-echo> <down-mouse-1> <mouse-1> <down-mouse-1> 
<mouse-1> <help-echo> M-x o r g - v e r <tab> <return> 
<escape> <escape> <help-echo> <down-mouse-1> <mouse-1> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <menu-bar> <help-menu> <se
nd-emacs-bug-report>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit
test.org has auto save data; consider M-x recover-this-file
Quit
Org-mode version 7.8.11
goto-history-element: Beginning of history; no preceding item
goto-history-element: End of history; no default available

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils help-mode view tmm electric org-wl org-w3m org-vm org-rmail
org-mhe org-mew org-irc org-jsinfo org-infojs org-html org-exp ob-exp
org-exp-blocks find-func org-agenda org-info org-gnus org-docview
org-bibtex bibtex org-bbdb org byte-opt warnings bytecomp byte-compile
cconv macroexp advice help-fns advice-preload ob-emacs-lisp ob-tangle
ob-ref ob-lob ob-table org-footnote org-src ob-comint ob-keys ob ob-eval
org-pcomplete pcomplete comint ansi-color ring org-list org-faces
org-compat org-entities org-macs noutline outline easy-mmode format-spec
regexp-opt cal-menu easymenu calendar cal-loaddefs time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar 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 minibuffer loaddefs button faces cus-face files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)