aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-04-09 03:53:48 +0000
committerStefan Monnier2008-04-09 03:53:48 +0000
commit0b2b62ff6dcaf77d2897a284013af3ff4b8ae268 (patch)
tree67b16be433d61c9e01cec12cc429d55e1a60bd4e
parent6e6c6aafa36e069bc544ceabca6a20315a409375 (diff)
downloademacs-0b2b62ff6dcaf77d2897a284013af3ff4b8ae268.tar.gz
emacs-0b2b62ff6dcaf77d2897a284013af3ff4b8ae268.zip
* mouse.el (mouse-menu-major-mode-map): New fun extracted from
mouse-major-mode-menu. (mouse-menu-bar-map): New fun extracted from mouse-popup-menubar. (mouse-major-mode-menu, mouse-popup-menubar) (mouse-popup-menubar-stuff): Use them. (C-down-mouse-3): Bind to a dynamic map rather than to mouse-popup-menubar-stuff. * bindings.el (mode-line-major-mode-keymap): Bind down-mouse-1 to mouse-menu-major-mode-map rather than to mouse-major-mode-menu.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/bindings.el15
-rw-r--r--lisp/mouse.el66
3 files changed, 62 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 542dbb7e5ab..a2f7f47a4b5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12008-04-09 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * mouse.el (mouse-menu-major-mode-map): New fun extracted from
4 mouse-major-mode-menu.
5 (mouse-menu-bar-map): New fun extracted from mouse-popup-menubar.
6 (mouse-major-mode-menu, mouse-popup-menubar)
7 (mouse-popup-menubar-stuff): Use them.
8 (C-down-mouse-3): Bind to a dynamic map rather than to
9 mouse-popup-menubar-stuff.
10 * bindings.el (mode-line-major-mode-keymap): Bind down-mouse-1
11 to mouse-menu-major-mode-map rather than to mouse-major-mode-menu.
12
12008-04-09 Dan Nicolaescu <dann@ics.uci.edu> 132008-04-09 Dan Nicolaescu <dann@ics.uci.edu>
2 14
3 * vc-svn.el (vc-svn-modify-change-comment): Add support for the 15 * vc-svn.el (vc-svn-modify-change-comment): Add support for the
diff --git a/lisp/bindings.el b/lisp/bindings.el
index d1045002a04..af94fcd9d85 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -287,7 +287,9 @@ Menu of mode operations in the mode line.")
287 287
288(defvar mode-line-major-mode-keymap 288(defvar mode-line-major-mode-keymap
289 (let ((map (make-sparse-keymap))) 289 (let ((map (make-sparse-keymap)))
290 (define-key map [mode-line down-mouse-1] 'mouse-major-mode-menu) 290 (define-key map [mode-line down-mouse-1]
291 '(menu-item "Menu Bar" ignore
292 :filter (lambda (_) (mouse-menu-major-mode-map))))
291 (define-key map [mode-line mouse-2] 'describe-mode) 293 (define-key map [mode-line mouse-2] 'describe-mode)
292 (define-key map [mode-line down-mouse-3] mode-line-mode-menu) 294 (define-key map [mode-line down-mouse-3] mode-line-mode-menu)
293 map) "\ 295 map) "\
@@ -565,12 +567,11 @@ Actually, STRING need not be a string; any possible mode-line element
565is okay. See `mode-line-format'.") 567is okay. See `mode-line-format'.")
566;; Don't use purecopy here--some people want to change these strings. 568;; Don't use purecopy here--some people want to change these strings.
567(setq minor-mode-alist 569(setq minor-mode-alist
568 (list 570 '((abbrev-mode " Abbrev")
569 (list 'abbrev-mode " Abbrev") 571 (overwrite-mode overwrite-mode)
570 '(overwrite-mode overwrite-mode) 572 (auto-fill-function " Fill")
571 (list 'auto-fill-function " Fill") 573 ;; not really a minor mode...
572 ;; not really a minor mode... 574 (defining-kbd-macro " Def")))
573 '(defining-kbd-macro " Def")))
574 575
575;; These variables are used by autoloadable packages. 576;; These variables are used by autoloadable packages.
576;; They are defined here so that they do not get overridden 577;; They are defined here so that they do not get overridden
diff --git a/lisp/mouse.el b/lisp/mouse.el
index eb20a73f43f..dba63ce3084 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -181,14 +181,7 @@ items `Turn Off' and `Help'."
181 (let ((indicator (car (nth 4 (car (cdr event)))))) 181 (let ((indicator (car (nth 4 (car (cdr event))))))
182 (minor-mode-menu-from-indicator indicator))) 182 (minor-mode-menu-from-indicator indicator)))
183 183
184(defun mouse-major-mode-menu (event &optional prefix) 184(defun mouse-menu-major-mode-map ()
185 "Pop up a mode-specific menu of mouse commands.
186Default to the Edit menu if the major mode doesn't define a menu."
187 ;; Switch to the window clicked on, because otherwise
188 ;; the mode's commands may not make sense.
189 (interactive "@e\nP")
190 ;; Let the mode update its menus first.
191 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
192 (let* (;; Keymap from which to inherit; may be null. 185 (let* (;; Keymap from which to inherit; may be null.
193 (ancestor (mouse-menu-non-singleton 186 (ancestor (mouse-menu-non-singleton
194 (and (current-local-map) 187 (and (current-local-map)
@@ -202,8 +195,7 @@ Default to the Edit menu if the major mode doesn't define a menu."
202 uniq) 195 uniq)
203 (if ancestor 196 (if ancestor
204 (set-keymap-parent newmap ancestor)) 197 (set-keymap-parent newmap ancestor))
205 (popup-menu newmap event prefix))) 198 newmap))
206
207 199
208(defun mouse-menu-non-singleton (menubar) 200(defun mouse-menu-non-singleton (menubar)
209 "Given menu keymap, 201 "Given menu keymap,
@@ -218,12 +210,10 @@ Otherwise return the whole menu."
218 menubar 210 menubar
219 (lookup-key menubar (vector (car submap))))))) 211 (lookup-key menubar (vector (car submap)))))))
220 212
221(defun mouse-popup-menubar (event prefix) 213(defun mouse-menu-bar-map ()
222 "Pop up a menu equivalent to the menu bar for keyboard EVENT with PREFIX. 214 "Return a keymap equivalent to the menu bar.
223The contents are the items that would be in the menu bar whether or 215The contents are the items that would be in the menu bar whether or
224not it is actually displayed." 216not it is actually displayed."
225 (interactive "@e \nP")
226 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
227 (let* ((local-menu (and (current-local-map) 217 (let* ((local-menu (and (current-local-map)
228 (lookup-key (current-local-map) [menu-bar]))) 218 (lookup-key (current-local-map) [menu-bar])))
229 (global-menu (lookup-key global-map [menu-bar])) 219 (global-menu (lookup-key global-map [menu-bar]))
@@ -262,19 +252,42 @@ not it is actually displayed."
262 (cons "Global Menu" 252 (cons "Global Menu"
263 (cdr global-menu))))) 253 (cdr global-menu)))))
264 ;; Supplying the list is faster than making a new map. 254 ;; Supplying the list is faster than making a new map.
265 (popup-menu (append (list global-menu) 255 ;; FIXME: We have a problem here: we have to use the global/local/minor
266 (if local-menu 256 ;; so they're displayed in the expected order, but later on in the command
267 (list local-menu)) 257 ;; loop, they're actually looked up in the opposite order.
268 minor-mode-menus) 258 (apply 'append
269 event prefix))) 259 global-menu
260 local-menu
261 minor-mode-menus)))
262
263(defun mouse-major-mode-menu (event &optional prefix)
264 "Pop up a mode-specific menu of mouse commands.
265Default to the Edit menu if the major mode doesn't define a menu."
266 (interactive "@e\nP")
267 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
268 (popup-menu (mouse-menu-major-mode-map) event prefix))
269(make-obsolete 'mouse-major-mode-menu 'mouse-menu-major-mode-map)
270
271(defun mouse-popup-menubar (event prefix)
272 "Pop up a menu equivalent to the menu bar for keyboard EVENT with PREFIX.
273The contents are the items that would be in the menu bar whether or
274not it is actually displayed."
275 (interactive "@e \nP")
276 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
277 (popup-menu (mouse-menu-bar-map) event prefix))
278(make-obsolete 'mouse-popup-menubar 'mouse-menu-bar-map)
270 279
271(defun mouse-popup-menubar-stuff (event prefix) 280(defun mouse-popup-menubar-stuff (event prefix)
272 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'. 281 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'.
273Use the former if the menu bar is showing, otherwise the latter." 282Use the former if the menu bar is showing, otherwise the latter."
274 (interactive "@e \nP") 283 (interactive "@e\nP")
275 (if (zerop (assoc-default 'menu-bar-lines (frame-parameters) 'eq 0)) 284 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
276 (mouse-popup-menubar event prefix) 285 (popup-menu
277 (mouse-major-mode-menu event prefix))) 286 (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0))
287 (mouse-menu-bar-map)
288 (mouse-menu-major-mode-map))
289 event prefix))
290(make-obsolete 'mouse-popup-menubar-stuff nil)
278 291
279;; Commands that operate on windows. 292;; Commands that operate on windows.
280 293
@@ -2466,7 +2479,12 @@ and selects that window."
2466(if (not (eq system-type 'ms-dos)) 2479(if (not (eq system-type 'ms-dos))
2467 (global-set-key [S-down-mouse-1] 'mouse-set-font)) 2480 (global-set-key [S-down-mouse-1] 'mouse-set-font))
2468;; C-down-mouse-2 is bound in facemenu.el. 2481;; C-down-mouse-2 is bound in facemenu.el.
2469(global-set-key [C-down-mouse-3] 'mouse-popup-menubar-stuff) 2482(global-set-key [C-down-mouse-3]
2483 '(menu-item "Menu Bar" ignore
2484 :filter (lambda (_)
2485 (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0))
2486 (mouse-menu-bar-map)
2487 (mouse-menu-major-mode-map)))))
2470 2488
2471 2489
2472;; Replaced with dragging mouse-1 2490;; Replaced with dragging mouse-1