Mercurial > emacs
comparison lisp/mouse.el @ 31258:12f2e341ee9c
(mouse-major-mode-menu): Use local-key-binding.
(mouse-popup-menubar): Add minor mode menus.
(popup-menu): Check for lookup-key returning number.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 29 Aug 2000 11:10:48 +0000 |
parents | ad577e2e48d3 |
children | f329cce08485 |
comparison
equal
deleted
inserted
replaced
31257:790050caa073 | 31258:12f2e341ee9c |
---|---|
74 ;; in sequence until a first binding is found. | 74 ;; in sequence until a first binding is found. |
75 (let ((mouse-click (apply 'vector event)) | 75 (let ((mouse-click (apply 'vector event)) |
76 binding) | 76 binding) |
77 (while (and map (null binding)) | 77 (while (and map (null binding)) |
78 (setq binding (lookup-key (car map) mouse-click)) | 78 (setq binding (lookup-key (car map) mouse-click)) |
79 (if (numberp binding) ; `too long' | |
80 (setq binding nil)) | |
79 (setq map (cdr map))) | 81 (setq map (cdr map))) |
80 binding) | 82 binding) |
81 ;; We were given a single keymap. | 83 ;; We were given a single keymap. |
82 (lookup-key map (apply 'vector event))))) | 84 (lookup-key map (apply 'vector event))))) |
83 (setq map nil) | 85 (setq map nil) |
109 ;; It is either nil or (SOME-SYMBOL). | 111 ;; It is either nil or (SOME-SYMBOL). |
110 (mouse-major-mode-menu-prefix nil) | 112 (mouse-major-mode-menu-prefix nil) |
111 ;; Keymap from which to inherit; may be null. | 113 ;; Keymap from which to inherit; may be null. |
112 (ancestor (mouse-major-mode-menu-1 | 114 (ancestor (mouse-major-mode-menu-1 |
113 (and (current-local-map) | 115 (and (current-local-map) |
114 (lookup-key (current-local-map) [menu-bar])))) | 116 (local-key-binding [menu-bar])))) |
115 ;; Make a keymap in which our last command leads to a menu or | 117 ;; Make a keymap in which our last command leads to a menu or |
116 ;; default to the edit menu. | 118 ;; default to the edit menu. |
117 (newmap (if ancestor | 119 (newmap (if ancestor |
118 (make-sparse-keymap (concat mode-name " Mode")) | 120 (make-sparse-keymap (concat mode-name " Mode")) |
119 menu-bar-edit-menu)) | 121 menu-bar-edit-menu)) |
167 (run-hooks 'activate-menubar-hook) | 169 (run-hooks 'activate-menubar-hook) |
168 (let* ((local-menu (and (current-local-map) | 170 (let* ((local-menu (and (current-local-map) |
169 (lookup-key (current-local-map) [menu-bar]))) | 171 (lookup-key (current-local-map) [menu-bar]))) |
170 (global-menu (lookup-key global-map [menu-bar])) | 172 (global-menu (lookup-key global-map [menu-bar])) |
171 (local-title-or-map (and local-menu (cadr local-menu))) | 173 (local-title-or-map (and local-menu (cadr local-menu))) |
174 (minor-mode-menus (mapcar #'cdr (minor-mode-key-binding [menu-bar]))) | |
172 (global-title-or-map (cadr global-menu))) | 175 (global-title-or-map (cadr global-menu))) |
173 ;; If the keymaps don't have prompt string (a lazy programmer | 176 ;; If the keymaps don't have prompt string (a lazy programmer |
174 ;; didn't bother to provide one), create it and insert it into the | 177 ;; didn't bother to provide one), create it and insert it into the |
175 ;; keymaps; each keymap gets its own prompt. This is required for | 178 ;; keymaps; each keymap gets its own prompt. This is required for |
176 ;; non-toolkit versions to display non-empty menu pane names. | 179 ;; non-toolkit versions to display non-empty menu pane names. |
182 (or (stringp global-title-or-map) | 185 (or (stringp global-title-or-map) |
183 (setq global-menu (cons 'keymap | 186 (setq global-menu (cons 'keymap |
184 (cons "Global Menu" | 187 (cons "Global Menu" |
185 (cdr global-menu))))) | 188 (cdr global-menu))))) |
186 ;; Supplying the list is faster than making a new map. | 189 ;; Supplying the list is faster than making a new map. |
187 (popup-menu (if local-menu | 190 (popup-menu (append (list global-menu) |
188 (list global-menu local-menu) | 191 (if local-menu |
189 (list global-menu)) | 192 (list local-menu)) |
193 minor-mode-menus) | |
190 event prefix))) | 194 event prefix))) |
191 | 195 |
192 (defun mouse-popup-menubar-stuff (event prefix) | 196 (defun mouse-popup-menubar-stuff (event prefix) |
193 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'. | 197 "Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'. |
194 Use the former if the menu bar is showing, otherwise the latter." | 198 Use the former if the menu bar is showing, otherwise the latter." |