-(defun popup-menu (menu-desc)
- "Pop up the given menu.
-A menu is a list of menu items, strings, and submenus.
-
-The first element of a menu must be a string, which is the name of the
-menu. This is the string that will be displayed in the parent menu, if
-any. For toplevel menus, it is ignored. This string is not displayed
-in the menu itself.
-
-A menu item is a vector of three or four elements:
-
- - the name of the menu item (a string);
- - the `callback' of that item;
- - whether this item is active (selectable);
- - and an optional string to append to the name.
-
-If the `callback' of a menu item is a symbol, then it must name a command.
-It will be invoked with `call-interactively'. If it is a list, then it is
-evaluated with `eval'.
-
-The fourth element of a menu item is a convenient way of adding the name
-of a command's ``argument'' to the menu, like ``Kill Buffer NAME''.
-
-If an element of a menu is a string, then that string will be presented in
-the menu as unselectable text.
-
-If an element of a menu is a string consisting solely of hyphens, then that
-item will be presented as a solid horizontal line.
-
-If an element of a menu is a list, it is treated as a submenu. The name of
-that submenu (the first element in the list) will be used as the name of the
-item representing this menu on the parent.
-
-The syntax, more precisely:
-
- form := <something to pass to `eval'>
- command := <a symbol or string, to pass to `call-interactively'>
- callback := command | form
- active-p := <t or nil, whether this thing is selectable>
- text := <string, non selectable>
- name := <string>
- argument := <string>
- menu-item := '[' name callback active-p [ argument ] ']'
- menu := '(' name [ menu-item | menu | text ]+ ')'
-"
- (let ((menu (make-lucid-menu-keymap (car menu-desc) (cdr menu-desc)))
- (pos (mouse-pixel-position))
- answer cmd)
- (while menu
- (setq answer (x-popup-menu (list (list (nth 1 pos) (nthcdr 2 pos))
- (car pos))
- menu))
- (setq cmd (lookup-key menu (apply 'vector answer)))
- (setq menu nil)
- (and cmd
- (if (keymapp cmd)
- (setq menu cmd)
- (call-interactively cmd))))))
-