From: Richard M. Stallman Date: Tue, 2 Jul 2002 18:49:03 +0000 (+0000) Subject: (easy-menu-popup-menu): New function. X-Git-Tag: ttn-vms-21-2-B4~14343 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=89fd3098d88e6e2f41bd56a0629f609f02b6c42f;p=emacs.git (easy-menu-popup-menu): New function. --- diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el index bf2e190e489..045a5590699 100644 --- a/lisp/emacs-lisp/easymenu.el +++ b/lisp/emacs-lisp/easymenu.el @@ -616,6 +616,20 @@ In some cases we use that to select between the local and global maps." (or (keymapp map) (error "Malformed menu in easy-menu: (%s)" map)) map) +(defun easy-menu-popup-menu (menu &optional event) + "Pop up a menu and run a command according to user's selection. +MENU is a menu description as in `easy-menu-define'. +EVENT is a mouse button event and determines where to pop up the menu. +If EVENT is nil, pop up menu at the current mouse position." + (let ((map (easy-menu-create-menu (car menu) (cdr menu)))) + (if (symbolp map) + (let ((f (memq :filter (get map 'menu-prop)))) + (setq map (symbol-function map)) + (if f (setq map (funcall (cadr f) map))))) + (let* ((sel (x-popup-menu (or event t) map)) + (f (if (consp sel) (lookup-key map (apply 'vector sel))))) + (if (commandp f) (call-interactively f))))) + (provide 'easymenu) ;;; easymenu.el ends here