(file-remote-p): Docstring fix.
[bpt/emacs.git] / lisp / mouse.el
index 8802aa9..40debbd 100644 (file)
@@ -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 @@ Default to the Edit menu if the major mode doesn't define a menu."
         ;; 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 @@ not it is actually displayed."
     (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 @@ and selects that window."
             (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))))))))