# HG changeset patch # User Dave Love # Date 964021922 0 # Node ID 7ce202715b72c584049d978a24f41da0ee2f69c9 # Parent 09b01c9914a6b0bec49be1cf4d961d41cb77393d (popup-menu): Allow a list of keymaps for menu arg. (mouse-popup-menubar, mouse-popup-menubar-stuff): New functions. (global-map): Bind c-down-mouse-3 to mouse-popup-menubar-stuff. diff -r 09b01c9914a6 -r 7ce202715b72 lisp/mouse.el --- a/lisp/mouse.el Wed Jul 19 15:51:05 2000 +0000 +++ b/lisp/mouse.el Wed Jul 19 15:52:02 2000 +0000 @@ -1,9 +1,9 @@ ;;; mouse.el --- window system-independent mouse support -;; Copyright (C) 1993, 1994, 1995, 1999 Free Software Foundation, Inc. +;; Copyright (C) 1993, 1994, 1995, 1999, 2000 Free Software Foundation, Inc. ;; Maintainer: FSF -;; Keywords: hardware +;; Keywords: hardware, mouse ;; This file is part of GNU Emacs. @@ -46,15 +46,18 @@ (defun popup-menu (menu &optional position prefix) "Popup the given menu and call the selected option. -MENU can be a keymap or an easymenu-style menu. +MENU can be a keymap, an easymenu-style menu or a list of keymaps as for +`x-popup-menu'. POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to the current mouse position. PREFIX is the prefix argument (if any) to pass to the command." - (let* ((map (if (keymapp menu) menu - (let* ((map (easy-menu-create-menu (car menu) (cdr menu))) + (let* ((map (cond + ((keymapp menu) menu) + ((and (listp menu) (keymapp (car menu))) menu) + (t (let* ((map (easy-menu-create-menu (car menu) (cdr menu))) (filter (when (symbolp map) (plist-get (get map 'menu-pro) :filter)))) - (if filter (funcall filter (symbol-function map)) map)))) + (if filter (funcall filter (symbol-function map)) map))))) event) ;; The looping behavior was taken from lmenu's popup-menu-popup (while (and map (setq event (x-popup-menu position map))) @@ -135,6 +138,25 @@ menubar (setq mouse-major-mode-menu-prefix (list (car submap))) (lookup-key menubar (vector (car submap))))))) + +(defun mouse-popup-menubar (event prefix) + "Pops up a menu equiavlent to the menu bar a 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) + (let* ((local-menu (lookup-key (current-local-map) [menu-bar])) + (global-menu (lookup-key global-map [menu-bar]))) + ;; Supplying the list is faster than making a new map. + (popup-menu (list global-menu local-menu) event prefix))) + +(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))) ;; Commands that operate on windows. @@ -2047,7 +2069,7 @@ (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-major-mode-menu) +(global-set-key [C-down-mouse-3] 'mouse-popup-menubar-stuff) ;; Replaced with dragging mouse-1