aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-07-19 15:52:02 +0000
committerDave Love2000-07-19 15:52:02 +0000
commitde420e82008b3389ec879e462caec0475c161220 (patch)
tree26ead34c651cac2747cc681fcf78376d627632e8
parent482bb01b8bede433ea0cc47ad476a50d323ea440 (diff)
downloademacs-de420e82008b3389ec879e462caec0475c161220.tar.gz
emacs-de420e82008b3389ec879e462caec0475c161220.zip
(popup-menu): Allow a list of keymaps for menu arg.
(mouse-popup-menubar, mouse-popup-menubar-stuff): New functions. (global-map): Bind c-down-mouse-3 to mouse-popup-menubar-stuff.
-rw-r--r--lisp/mouse.el36
1 files changed, 29 insertions, 7 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index ad86868f13c..b5d3a9dcb9d 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1,9 +1,9 @@
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 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1995, 1999, 2000 Free Software Foundation, Inc.
4 4
5;; Maintainer: FSF 5;; Maintainer: FSF
6;; Keywords: hardware 6;; Keywords: hardware, mouse
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
9 9
@@ -46,15 +46,18 @@
46 46
47(defun popup-menu (menu &optional position prefix) 47(defun popup-menu (menu &optional position prefix)
48 "Popup the given menu and call the selected option. 48 "Popup the given menu and call the selected option.
49MENU can be a keymap or an easymenu-style menu. 49MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
50`x-popup-menu'.
50POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to 51POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to
51 the current mouse position. 52 the current mouse position.
52PREFIX is the prefix argument (if any) to pass to the command." 53PREFIX is the prefix argument (if any) to pass to the command."
53 (let* ((map (if (keymapp menu) menu 54 (let* ((map (cond
54 (let* ((map (easy-menu-create-menu (car menu) (cdr menu))) 55 ((keymapp menu) menu)
56 ((and (listp menu) (keymapp (car menu))) menu)
57 (t (let* ((map (easy-menu-create-menu (car menu) (cdr menu)))
55 (filter (when (symbolp map) 58 (filter (when (symbolp map)
56 (plist-get (get map 'menu-pro) :filter)))) 59 (plist-get (get map 'menu-pro) :filter))))
57 (if filter (funcall filter (symbol-function map)) map)))) 60 (if filter (funcall filter (symbol-function map)) map)))))
58 event) 61 event)
59 ;; The looping behavior was taken from lmenu's popup-menu-popup 62 ;; The looping behavior was taken from lmenu's popup-menu-popup
60 (while (and map (setq event (x-popup-menu position map))) 63 (while (and map (setq event (x-popup-menu position map)))
@@ -135,6 +138,25 @@ Default to the Edit menu if the major mode doesn't define a menu."
135 menubar 138 menubar
136 (setq mouse-major-mode-menu-prefix (list (car submap))) 139 (setq mouse-major-mode-menu-prefix (list (car submap)))
137 (lookup-key menubar (vector (car submap))))))) 140 (lookup-key menubar (vector (car submap)))))))
141
142(defun mouse-popup-menubar (event prefix)
143 "Pops up a menu equiavlent to the menu bar a keyboard EVENT with PREFIX.
144The contents are the items that would be in the menu bar whether or
145not it is actually displayed."
146 (interactive "@e \nP")
147 (run-hooks 'activate-menubar-hook)
148 (let* ((local-menu (lookup-key (current-local-map) [menu-bar]))
149 (global-menu (lookup-key global-map [menu-bar])))
150 ;; Supplying the list is faster than making a new map.
151 (popup-menu (list global-menu local-menu) event prefix)))
152
153(defun mouse-popup-menubar-stuff (event prefix)
154 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'.
155Use the former if the menu bar is showing, otherwise the latter."
156 (interactive "@e \nP")
157 (if (zerop (assoc-default 'menu-bar-lines (frame-parameters) 'eq 0))
158 (mouse-popup-menubar event prefix)
159 (mouse-major-mode-menu event prefix)))
138 160
139;; Commands that operate on windows. 161;; Commands that operate on windows.
140 162
@@ -2047,7 +2069,7 @@ and selects that window."
2047(if (not (eq system-type 'ms-dos)) 2069(if (not (eq system-type 'ms-dos))
2048 (global-set-key [S-down-mouse-1] 'mouse-set-font)) 2070 (global-set-key [S-down-mouse-1] 'mouse-set-font))
2049;; C-down-mouse-2 is bound in facemenu.el. 2071;; C-down-mouse-2 is bound in facemenu.el.
2050(global-set-key [C-down-mouse-3] 'mouse-major-mode-menu) 2072(global-set-key [C-down-mouse-3] 'mouse-popup-menubar-stuff)
2051 2073
2052 2074
2053;; Replaced with dragging mouse-1 2075;; Replaced with dragging mouse-1