616 |
(or (keymapp map) (error "Malformed menu in easy-menu: (%s)" map)) |
(or (keymapp map) (error "Malformed menu in easy-menu: (%s)" map)) |
617 |
map) |
map) |
618 |
|
|
619 |
|
(defun easy-menu-popup-menu (menu &optional event) |
620 |
|
"Pop up a menu and run a command according to user's selection. |
621 |
|
MENU is a menu description as in `easy-menu-define'. |
622 |
|
EVENT is a mouse button event and determines where to pop up the menu. |
623 |
|
If EVENT is nil, pop up menu at the current mouse position." |
624 |
|
(let ((map (easy-menu-create-menu (car menu) (cdr menu)))) |
625 |
|
(if (symbolp map) |
626 |
|
(let ((f (memq :filter (get map 'menu-prop)))) |
627 |
|
(setq map (symbol-function map)) |
628 |
|
(if f (setq map (funcall (cadr f) map))))) |
629 |
|
(let* ((sel (x-popup-menu (or event t) map)) |
630 |
|
(f (if (consp sel) (lookup-key map (apply 'vector sel))))) |
631 |
|
(if (commandp f) (call-interactively f))))) |
632 |
|
|
633 |
(provide 'easymenu) |
(provide 'easymenu) |
634 |
|
|
635 |
;;; easymenu.el ends here |
;;; easymenu.el ends here |