Mercurial > emacs
comparison lisp/mouse.el @ 24960:00d2eba70774
(mouse-major-mode-menu): Default to menu-bar-edit-menu
for modes which don't define menus.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 19 Jul 1999 21:49:13 +0000 |
parents | cb2244476b40 |
children | a6428fea28fd |
comparison
equal
deleted
inserted
replaced
24959:1e276451494f | 24960:00d2eba70774 |
---|---|
43 :group 'mouse) | 43 :group 'mouse) |
44 | 44 |
45 ;; Provide a mode-specific menu on a mouse button. | 45 ;; Provide a mode-specific menu on a mouse button. |
46 | 46 |
47 (defun mouse-major-mode-menu (event prefix) | 47 (defun mouse-major-mode-menu (event prefix) |
48 "Pop up a mode-specific menu of mouse commands." | 48 "Pop up a mode-specific menu of mouse commands. |
49 Default to the Edit menu if the major mode doesn't define a menu." | |
49 ;; Switch to the window clicked on, because otherwise | 50 ;; Switch to the window clicked on, because otherwise |
50 ;; the mode's commands may not make sense. | 51 ;; the mode's commands may not make sense. |
51 (interactive "@e\nP") | 52 (interactive "@e\nP") |
52 ;; Let the mode update its menus first. | 53 ;; Let the mode update its menus first. |
53 (run-hooks 'activate-menubar-hook) | 54 (run-hooks 'activate-menubar-hook) |
54 (let (;; This is where mouse-major-mode-menu-prefix | 55 (let* (;; This is where mouse-major-mode-menu-prefix |
55 ;; returns the prefix we should use (after menu-bar). | 56 ;; returns the prefix we should use (after menu-bar). |
56 ;; It is either nil or (SOME-SYMBOL). | 57 ;; It is either nil or (SOME-SYMBOL). |
57 (mouse-major-mode-menu-prefix nil) | 58 (mouse-major-mode-menu-prefix nil) |
58 ;; Make a keymap in which our last command leads to a menu | 59 ;; Keymap from which to inherit; may be null. |
59 (newmap (make-sparse-keymap (concat mode-name " Mode"))) | 60 (ancestor (mouse-major-mode-menu-1 |
60 result) | 61 (and (current-local-map) |
61 ;; Make our menu inherit from the desired keymap | 62 (lookup-key (current-local-map) [menu-bar])))) |
62 ;; which we want to display as the menu now. | 63 ;; Make a keymap in which our last command leads to a menu or |
63 (set-keymap-parent newmap | 64 ;; default to the edit menu. |
64 (mouse-major-mode-menu-1 | 65 (newmap (if ancestor |
65 (and (current-local-map) | 66 (make-sparse-keymap (concat mode-name " Mode")) |
66 (lookup-key (current-local-map) [menu-bar])))) | 67 menu-bar-edit-menu)) |
68 result) | |
69 (if ancestor | |
70 ;; Make our menu inherit from the desired keymap which we want | |
71 ;; to display as the menu now. | |
72 (set-keymap-parent newmap ancestor)) | |
67 (setq result (x-popup-menu t (list newmap))) | 73 (setq result (x-popup-menu t (list newmap))) |
68 (if result | 74 (if result |
69 (let ((command (key-binding | 75 (let ((command (key-binding |
70 (apply 'vector (append '(menu-bar) | 76 (apply 'vector (append '(menu-bar) |
71 mouse-major-mode-menu-prefix | 77 mouse-major-mode-menu-prefix |