aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2000-07-24 15:19:02 +0000
committerEli Zaretskii2000-07-24 15:19:02 +0000
commit7636d2a3699d10e87d794d5beb5081712e151bb9 (patch)
treebba431c436dc695ee3c2189f130b0f2f4994c823
parent488205c001093dd6f240951917e9cd2c6fda345e (diff)
downloademacs-7636d2a3699d10e87d794d5beb5081712e151bb9.tar.gz
emacs-7636d2a3699d10e87d794d5beb5081712e151bb9.zip
(popup-menu): Run the keymap through indirect-function,
in case it was defined with define-prefix-key. If the menu is a list of keymaps, look up the binding of user's choice in each one of the keymaps. (mouse-popup-menubar): If the global and local menu-bar keymaps don't have a prompt string, create one and insert it into the keymap. Don't barf if current-local-map returns nil.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/mouse.el44
2 files changed, 49 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bf3159647dc..e97205960ea 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12000-07-24 Eli Zaretskii <eliz@is.elta.co.il>
2
3 * mouse.el (popup-menu): Run the keymap through indirect-function,
4 in case it was defined with define-prefix-key. If the menu is a
5 list of keymaps, look up the binding of user's choice in each one
6 of the keymaps.
7 (mouse-popup-menubar): If the global and local menu-bar keymaps
8 don't have a prompt string, create one and insert it into the
9 keymap. Don't barf if current-local-map returns nil.
10
12000-07-24 Francis Wright <fjw@maths.qmw.ac.uk> 112000-07-24 Francis Wright <fjw@maths.qmw.ac.uk>
2 12
3 * dired.el (dired-sort-R-check): Added to allow recursive listing 13 * dired.el (dired-sort-R-check): Added to allow recursive listing
diff --git a/lisp/mouse.el b/lisp/mouse.el
index b5d3a9dcb9d..ef78aff5a7c 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -60,11 +60,26 @@ PREFIX is the prefix argument (if any) to pass to the command."
60 (if filter (funcall filter (symbol-function map)) map))))) 60 (if filter (funcall filter (symbol-function map)) map)))))
61 event) 61 event)
62 ;; The looping behavior was taken from lmenu's popup-menu-popup 62 ;; The looping behavior was taken from lmenu's popup-menu-popup
63 (while (and map (setq event (x-popup-menu position map))) 63 (while (and map (setq event
64 ;; map could be a prefix key, in which case
65 ;; we need to get its function cell
66 ;; definition.
67 (x-popup-menu position (indirect-function map))))
64 ;; Strangely x-popup-menu returns a list. 68 ;; Strangely x-popup-menu returns a list.
65 ;; mouse-major-mode-menu was using a weird: 69 ;; mouse-major-mode-menu was using a weird:
66 ;; (key-binding (apply 'vector (append '(menu-bar) menu-prefix events))) 70 ;; (key-binding (apply 'vector (append '(menu-bar) menu-prefix events)))
67 (let ((cmd (lookup-key map (apply 'vector event)))) 71 (let ((cmd
72 (if (and (not (keymapp map)) (listp map))
73 ;; We were given a list of keymaps. Search them all
74 ;; in sequence until a first binding is found.
75 (let ((mouse-click (apply 'vector event))
76 binding)
77 (while (and map (null binding))
78 (setq binding (lookup-key (car map) mouse-click))
79 (setq map (cdr map)))
80 binding)
81 ;; We were given a single keymap.
82 (lookup-key map (apply 'vector event)))))
68 (setq map nil) 83 (setq map nil)
69 ;; Clear out echoing, which perhaps shows a prefix arg. 84 ;; Clear out echoing, which perhaps shows a prefix arg.
70 (message "") 85 (message "")
@@ -145,10 +160,29 @@ The contents are the items that would be in the menu bar whether or
145not it is actually displayed." 160not it is actually displayed."
146 (interactive "@e \nP") 161 (interactive "@e \nP")
147 (run-hooks 'activate-menubar-hook) 162 (run-hooks 'activate-menubar-hook)
148 (let* ((local-menu (lookup-key (current-local-map) [menu-bar])) 163 (let* ((local-menu (and (current-local-map)
149 (global-menu (lookup-key global-map [menu-bar]))) 164 (lookup-key (current-local-map) [menu-bar])))
165 (global-menu (lookup-key global-map [menu-bar]))
166 (local-title-or-map (and local-menu (cadr local-menu)))
167 (global-title-or-map (cadr global-menu)))
168 ;; If the keymaps don't have prompt string (a lazy programmer
169 ;; didn't bother to provide one), create it and insert it into the
170 ;; keymaps; each keymap gets its own prompt. This is required for
171 ;; non-toolkit versions to display non-empty menu pane names.
172 (or (null local-menu)
173 (stringp local-title-or-map)
174 (setq local-menu (cons 'keymap
175 (cons (concat mode-name " Mode Menu")
176 (cdr local-menu)))))
177 (or (stringp global-title-or-map)
178 (setq global-menu (cons 'keymap
179 (cons "Global Menu"
180 (cdr global-menu)))))
150 ;; Supplying the list is faster than making a new map. 181 ;; Supplying the list is faster than making a new map.
151 (popup-menu (list global-menu local-menu) event prefix))) 182 (popup-menu (if local-menu
183 (list global-menu local-menu)
184 (list global-menu))
185 event prefix)))
152 186
153(defun mouse-popup-menubar-stuff (event prefix) 187(defun mouse-popup-menubar-stuff (event prefix)
154 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'. 188 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'.