comparison 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
comparison
equal deleted inserted replaced
91326:b1a63d7fa09c 91327:606f2d163a64
1 ;;; mouse.el --- window system-independent mouse support 1 ;;; mouse.el --- window system-independent mouse support
2 2
3 ;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003, 3 ;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 5
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Keywords: hardware, mouse 7 ;; Keywords: hardware, mouse
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
190 (and (current-local-map) 190 (and (current-local-map)
191 (local-key-binding [menu-bar])))) 191 (local-key-binding [menu-bar]))))
192 ;; Make a keymap in which our last command leads to a menu or 192 ;; Make a keymap in which our last command leads to a menu or
193 ;; default to the edit menu. 193 ;; default to the edit menu.
194 (newmap (if ancestor 194 (newmap (if ancestor
195 (make-sparse-keymap (concat mode-name " Mode")) 195 (make-sparse-keymap (concat (format-mode-line mode-name)
196 menu-bar-edit-menu))) 196 " Mode"))
197 menu-bar-edit-menu))
198 uniq)
197 (if ancestor 199 (if ancestor
198 ;; Make our menu inherit from the desired keymap which we want 200 ;; Make our menu inherit from the desired keymap which we want
199 ;; to display as the menu now. 201 ;; to display as the menu now.
200 (set-keymap-parent newmap ancestor)) 202 ;; Sometimes keymaps contain duplicate menu code, leading to
203 ;; duplicates in the popped-up menu. Avoid this by simply
204 ;; taking the first of any identically-named menus.
205 ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00469.html
206 (set-keymap-parent newmap
207 (progn
208 (dolist (e ancestor)
209 (unless (and (listp e)
210 (assoc (car e) uniq))
211 (setq uniq (append uniq (list e)))))
212 uniq)))
201 (popup-menu newmap event prefix))) 213 (popup-menu newmap event prefix)))
202 214
203 215
204 ;; Compute and cache the equivalent keys in MENU and all its submenus. 216 ;; Compute and cache the equivalent keys in MENU and all its submenus.
205 ;;;(defun mouse-major-mode-menu-compute-equiv-keys (menu) 217 ;;;(defun mouse-major-mode-menu-compute-equiv-keys (menu)
270 (local-title-or-map (and local-menu (cadr local-menu))) 282 (local-title-or-map (and local-menu (cadr local-menu)))
271 (global-title-or-map (cadr global-menu))) 283 (global-title-or-map (cadr global-menu)))
272 (or (null local-menu) 284 (or (null local-menu)
273 (stringp local-title-or-map) 285 (stringp local-title-or-map)
274 (setq local-menu (cons 'keymap 286 (setq local-menu (cons 'keymap
275 (cons (concat mode-name " Mode Menu") 287 (cons (concat (format-mode-line mode-name)
288 " Mode Menu")
276 (cdr local-menu))))) 289 (cdr local-menu)))))
277 (or (stringp global-title-or-map) 290 (or (stringp global-title-or-map)
278 (setq global-menu (cons 'keymap 291 (setq global-menu (cons 'keymap
279 (cons "Global Menu" 292 (cons "Global Menu"
280 (cdr global-menu))))) 293 (cdr global-menu)))))
1859 (setq elt (assoc adjusted-major-mode split-by-major-mode)) 1872 (setq elt (assoc adjusted-major-mode split-by-major-mode))
1860 (unless elt 1873 (unless elt
1861 (setq elt (list adjusted-major-mode 1874 (setq elt (list adjusted-major-mode
1862 (if (stringp adjusted-major-mode) 1875 (if (stringp adjusted-major-mode)
1863 adjusted-major-mode 1876 adjusted-major-mode
1864 mode-name)) 1877 (format-mode-line mode-name nil nil buf)))
1865 split-by-major-mode (cons elt split-by-major-mode))) 1878 split-by-major-mode (cons elt split-by-major-mode)))
1866 (or (memq buf (cdr (cdr elt))) 1879 (or (memq buf (cdr (cdr elt)))
1867 (setcdr (cdr elt) (cons buf (cdr (cdr elt)))))))) 1880 (setcdr (cdr elt) (cons buf (cdr (cdr elt))))))))
1868 ;; Compute the sum of squares of sizes of the major-mode buckets. 1881 ;; Compute the sum of squares of sizes of the major-mode buckets.
1869 (let ((tail split-by-major-mode)) 1882 (let ((tail split-by-major-mode))