changeset 87636:08663683b8a1

(mouse-major-mode-menu): Suppress duplicate menus.
author Glenn Morris <rgm@gnu.org>
date Tue, 08 Jan 2008 05:12:50 +0000
parents 5cb1a5e7e3a6
children 454ba5d2d3ac
files lisp/mouse.el
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mouse.el	Tue Jan 08 05:07:59 2008 +0000
+++ b/lisp/mouse.el	Tue Jan 08 05:12:50 2008 +0000
@@ -194,11 +194,22 @@
 	 (newmap (if ancestor
 		     (make-sparse-keymap (concat (format-mode-line mode-name)
                                                  " Mode"))
-		   menu-bar-edit-menu)))
+		   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)))