aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-06-23 02:56:03 +0000
committerRichard M. Stallman1997-06-23 02:56:03 +0000
commit4d06d2bed24520985e0c6153ddffb539e0c17aef (patch)
treec681cc2d7cd42cc16e2ecf7f87dd2477c4286f8e
parentf2f4aae9afc2c18b7e8d8f7f367a02a712d40729 (diff)
downloademacs-4d06d2bed24520985e0c6153ddffb539e0c17aef.tar.gz
emacs-4d06d2bed24520985e0c6153ddffb539e0c17aef.zip
(popup-menu): Redefine as macro.
(popup-menu-popup, popup-menu-internal): New function.
-rw-r--r--lisp/emacs-lisp/lmenu.el45
1 files changed, 37 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/lmenu.el b/lisp/emacs-lisp/lmenu.el
index a878f6ca206..dcd95a54006 100644
--- a/lisp/emacs-lisp/lmenu.el
+++ b/lisp/emacs-lisp/lmenu.el
@@ -1,6 +1,6 @@
1;;; lmenu.el --- emulate Lucid's menubar support 1;;; lmenu.el --- emulate Lucid's menubar support
2 2
3;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. 3;; Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
4 4
5;; Keywords: emulations 5;; Keywords: emulations
6 6
@@ -124,7 +124,14 @@
124 (setq menu-items (cdr menu-items))) 124 (setq menu-items (cdr menu-items)))
125 menu)) 125 menu))
126 126
127(defun popup-menu (menu-desc) 127;; The value of the cache-symbol for a menu
128;; is
129;; unbound -- nothing computed
130;; (ORIG . TRANSL)
131;; ORIG is the original menu spec list
132;; and TRANSL is its translation.
133
134(defmacro popup-menu (arg)
128 "Pop up the given menu. 135 "Pop up the given menu.
129A menu is a list of menu items, strings, and submenus. 136A menu is a list of menu items, strings, and submenus.
130 137
@@ -189,19 +196,41 @@ The syntax, more precisely:
189 menu-item := '[' name callback active-p [ suffix ] ']' 196 menu-item := '[' name callback active-p [ suffix ] ']'
190 | '[' name callback [ keyword ]+ ']' 197 | '[' name callback [ keyword ]+ ']'
191 menu := '(' name [ menu-item | menu | text ]+ ')'" 198 menu := '(' name [ menu-item | menu | text ]+ ')'"
192 (let ((menu (make-lucid-menu-keymap (car menu-desc) (cdr menu-desc))) 199 (if (not (symbolp arg))
193 (pos (mouse-pixel-position)) 200 `(popup-menu-internal ,arg nil)
201 `(popup-menu-internal ,arg
202 ',(intern (concat "popup-menu-" (symbol-name arg))))))
203
204(defun popup-menu-internal (menu cache-symbol)
205 (if (null cache-symbol)
206 ;; If no cache symbol, translate the menu afresh each time.
207 (popup-menu-popup (make-lucid-menu-keymap (car menu) (cdr menu)))
208 ;; We have a cache symbol. See if the cache is valid
209 ;; for the same menu we have now.
210 (or (and (boundp cache-symbol)
211 (consp (symbol-value cache-symbol))
212 (equal (car (symbol-value cache-symbol))
213 menu))
214 ;; If not, update it.
215 (set cache-symbol
216 (cons menu (make-lucid-menu-keymap (car menu) (cdr menu)))))
217 ;; Use the menu in the cache.
218 (popup-menu-popup (cdr (symbol-value cache-symbol)))))
219
220;; Pop up MENU-KEYMAP which was made by make-lucid-menu-keymap.
221(defun popup-menu-popup (menu-keymap)
222 (let ((pos (mouse-pixel-position))
194 answer cmd) 223 answer cmd)
195 (while (and menu 224 (while (and menu-keymap
196 (setq answer (x-popup-menu (list (list (nth 1 pos) 225 (setq answer (x-popup-menu (list (list (nth 1 pos)
197 (nthcdr 2 pos)) 226 (nthcdr 2 pos))
198 (car pos)) 227 (car pos))
199 menu))) 228 menu-keymap)))
200 (setq cmd (lookup-key menu (apply 'vector answer))) 229 (setq cmd (lookup-key menu-keymap (apply 'vector answer)))
201 (setq menu nil) 230 (setq menu nil)
202 (and cmd 231 (and cmd
203 (if (keymapp cmd) 232 (if (keymapp cmd)
204 (setq menu cmd) 233 (setq menu-keymap cmd)
205 (call-interactively cmd)))))) 234 (call-interactively cmd))))))
206 235
207(defun popup-dialog-box (data) 236(defun popup-dialog-box (data)