(let ((indicator (car (nth 4 (car (cdr event))))))
(minor-mode-menu-from-indicator indicator)))
-(defun mouse-major-mode-menu (event &optional prefix)
- "Pop up a mode-specific menu of mouse commands.
-Default to the Edit menu if the major mode doesn't define a menu."
- ;; Switch to the window clicked on, because otherwise
- ;; the mode's commands may not make sense.
- (interactive "@e\nP")
- ;; Let the mode update its menus first.
- (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
+(defun mouse-menu-major-mode-map ()
(let* (;; Keymap from which to inherit; may be null.
(ancestor (mouse-menu-non-singleton
(and (current-local-map)
menu-bar-edit-menu))
uniq)
(if ancestor
- ;; Make our menu inherit from the desired keymap which we want
- ;; to display as the menu now.
- ;; Sometimes keymaps contain duplicate menu code, leading to
- ;; duplicates in the popped-up menu. Avoid this by simply
- ;; taking the first of any identically-named menus.
- ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg00469.html
- (set-keymap-parent newmap
- (progn
- (dolist (e ancestor)
- (unless (and (listp e)
- (assoc (car e) uniq))
- (setq uniq (append uniq (list e)))))
- uniq)))
- (popup-menu newmap event prefix)))
-
+ (set-keymap-parent newmap ancestor))
+ newmap))
(defun mouse-menu-non-singleton (menubar)
"Given menu keymap,
(let (submap)
(map-keymap
(lambda (k v) (setq submap (if submap t (cons k v))))
- menubar)
+ (keymap-canonicalize menubar))
(if (eq submap t)
menubar
(lookup-key menubar (vector (car submap)))))))
-(defun mouse-popup-menubar (event prefix)
- "Pop up a menu equivalent to the menu bar for keyboard EVENT with PREFIX.
+(defun mouse-menu-bar-map ()
+ "Return a keymap equivalent to the menu bar.
The contents are the items that would be in the menu bar whether or
not it is actually displayed."
- (interactive "@e \nP")
- (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
(let* ((local-menu (and (current-local-map)
(lookup-key (current-local-map) [menu-bar])))
(global-menu (lookup-key global-map [menu-bar]))
;; display non-empty menu pane names.
(minor-mode-menus
(mapcar
- (function
- (lambda (menu)
- (let* ((minor-mode (car menu))
- (menu (cdr menu))
- (title-or-map (cadr menu)))
- (or (stringp title-or-map)
- (setq menu
- (cons 'keymap
- (cons (concat
- (capitalize (subst-char-in-string
- ?- ?\s (symbol-name
- minor-mode)))
- " Menu")
- (cdr menu)))))
- menu)))
+ (lambda (menu)
+ (let* ((minor-mode (car menu))
+ (menu (cdr menu))
+ (title-or-map (cadr menu)))
+ (or (stringp title-or-map)
+ (setq menu
+ (cons 'keymap
+ (cons (concat
+ (capitalize (subst-char-in-string
+ ?- ?\s (symbol-name
+ minor-mode)))
+ " Menu")
+ (cdr menu)))))
+ menu))
(minor-mode-key-binding [menu-bar])))
(local-title-or-map (and local-menu (cadr local-menu)))
(global-title-or-map (cadr global-menu)))
(cons "Global Menu"
(cdr global-menu)))))
;; Supplying the list is faster than making a new map.
- (popup-menu (append (list global-menu)
- (if local-menu
- (list local-menu))
- minor-mode-menus)
- event prefix)))
+ ;; FIXME: We have a problem here: we have to use the global/local/minor
+ ;; so they're displayed in the expected order, but later on in the command
+ ;; loop, they're actually looked up in the opposite order.
+ (apply 'append
+ global-menu
+ local-menu
+ minor-mode-menus)))
+
+(defun mouse-major-mode-menu (event &optional prefix)
+ "Pop up a mode-specific menu of mouse commands.
+Default to the Edit menu if the major mode doesn't define a menu."
+ (interactive "@e\nP")
+ (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
+ (popup-menu (mouse-menu-major-mode-map) event prefix))
+(make-obsolete 'mouse-major-mode-menu 'mouse-menu-major-mode-map)
+
+(defun mouse-popup-menubar (event prefix)
+ "Pop up a menu equivalent to the menu bar for keyboard EVENT with PREFIX.
+The contents are the items that would be in the menu bar whether or
+not it is actually displayed."
+ (interactive "@e \nP")
+ (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
+ (popup-menu (mouse-menu-bar-map) event prefix))
+(make-obsolete 'mouse-popup-menubar 'mouse-menu-bar-map)
(defun mouse-popup-menubar-stuff (event prefix)
"Popup a menu like either `mouse-major-mode-menu' or `mouse-popup-menubar'.
Use the former if the menu bar is showing, otherwise the latter."
- (interactive "@e \nP")
- (if (zerop (assoc-default 'menu-bar-lines (frame-parameters) 'eq 0))
- (mouse-popup-menubar event prefix)
- (mouse-major-mode-menu event prefix)))
+ (interactive "@e\nP")
+ (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
+ (popup-menu
+ (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0))
+ (mouse-menu-bar-map)
+ (mouse-menu-major-mode-map))
+ event prefix))
+(make-obsolete 'mouse-popup-menubar-stuff nil)
\f
;; Commands that operate on windows.
(defun mouse-set-region-1 ()
;; Set transient-mark-mode for a little while.
- (if (memq transient-mark-mode '(nil identity))
- (setq transient-mark-mode 'only))
+ (unless (eq (car-safe transient-mark-mode) 'only)
+ (setq transient-mark-mode
+ (cons 'only
+ (unless (eq transient-mark-mode 'lambda)
+ transient-mark-mode))))
(setq mouse-last-region-beg (region-beginning))
(setq mouse-last-region-end (region-end))
(setq mouse-last-region-tick (buffer-modified-tick)))
(overlay-start mouse-drag-overlay))
region-termination))
last-command this-command)
- (when (eq transient-mark-mode 'identity)
- ;; Reset `transient-mark-mode' to avoid expanding the region
- ;; while scrolling (compare thread on "Erroneous selection
- ;; extension ..." on bug-gnu-emacs from 2007-06-10).
- (setq transient-mark-mode nil))
(push-mark region-commencement t t)
(goto-char region-termination)
(if (not do-mouse-drag-region-post-process)
(if (not (eq system-type 'ms-dos))
(global-set-key [S-down-mouse-1] 'mouse-set-font))
;; C-down-mouse-2 is bound in facemenu.el.
-(global-set-key [C-down-mouse-3] 'mouse-popup-menubar-stuff)
+(global-set-key [C-down-mouse-3]
+ '(menu-item "Menu Bar" ignore
+ :filter (lambda (_)
+ (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0))
+ (mouse-menu-bar-map)
+ (mouse-menu-major-mode-map)))))
;; Replaced with dragging mouse-1