diff lisp/mouse.el @ 91327:606f2d163a64

Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-312
author Miles Bader <miles@gnu.org>
date Wed, 09 Jan 2008 01:21:15 +0000
parents 56a72e2bd635 08663683b8a1
children
line wrap: on
line diff
--- a/lisp/mouse.el	Tue Jan 08 05:34:24 2008 +0000
+++ b/lisp/mouse.el	Wed Jan 09 01:21:15 2008 +0000
@@ -1,7 +1,7 @@
 ;;; mouse.el --- window system-independent mouse support
 
 ;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: hardware, mouse
@@ -192,12 +192,24 @@
 	 ;; Make a keymap in which our last command leads to a menu or
 	 ;; default to the edit menu.
 	 (newmap (if ancestor
-		     (make-sparse-keymap (concat mode-name " Mode"))
-		   menu-bar-edit-menu)))
+		     (make-sparse-keymap (concat (format-mode-line mode-name)
+                                                 " Mode"))
+		   menu-bar-edit-menu))
+	 uniq)
     (if ancestor
 	;; Make our menu inherit from the desired keymap which we want
 	;; to display as the menu now.
-	(set-keymap-parent newmap ancestor))
+	;; Sometimes keymaps contain duplicate menu code, leading to
+	;; duplicates in the popped-up menu. Avoid this by simply
+	;; taking the first of any identically-named menus.
+	;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00469.html
+	(set-keymap-parent newmap
+			   (progn
+			     (dolist (e ancestor)
+			       (unless (and (listp e)
+					    (assoc (car e) uniq))
+				 (setq uniq (append uniq (list e)))))
+			     uniq)))
     (popup-menu newmap event prefix)))
 
 
@@ -272,7 +284,8 @@
     (or (null local-menu)
 	(stringp local-title-or-map)
 	(setq local-menu (cons 'keymap
-			       (cons (concat mode-name " Mode Menu")
+			       (cons (concat (format-mode-line mode-name)
+                                             " Mode Menu")
 				     (cdr local-menu)))))
     (or (stringp global-title-or-map)
 	(setq global-menu (cons 'keymap
@@ -1861,7 +1874,7 @@
             (setq elt (list adjusted-major-mode
                             (if (stringp adjusted-major-mode)
                                 adjusted-major-mode
-                                mode-name))
+                              (format-mode-line mode-name nil nil buf)))
                   split-by-major-mode (cons elt split-by-major-mode)))
           (or (memq buf (cdr (cdr elt)))
               (setcdr (cdr elt) (cons buf (cdr (cdr elt))))))))