comparison lisp/emacs-lisp/lmenu.el @ 6744:67485a72803d

(popup-dialog-box): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 08 Apr 1994 05:04:07 +0000
parents 19bf0e182eda
children 4fd40bd394fe
comparison
equal deleted inserted replaced
6743:77349221ca81 6744:67485a72803d
144 (setq menu nil) 144 (setq menu nil)
145 (and cmd 145 (and cmd
146 (if (keymapp cmd) 146 (if (keymapp cmd)
147 (setq menu cmd) 147 (setq menu cmd)
148 (call-interactively cmd)))))) 148 (call-interactively cmd))))))
149
150 (defun popup-dialog-box (data)
151 "Pop up a dialog box.
152 A dialog box description is a list.
153
154 - The first element of the list is a string to display in the dialog box.
155 - The rest of the elements are descriptions of the dialog box's buttons.
156 Each one is a vector of three elements:
157 - The first element is the text of the button.
158 - The second element is the `callback'.
159 - The third element is t or nil, whether this button is selectable.
160
161 If the `callback' of a button is a symbol, then it must name a command.
162 It will be invoked with `call-interactively'. If it is a list, then it is
163 evaluated with `eval'.
164
165 One (and only one) of the buttons may be `nil'. This marker means that all
166 following buttons should be flushright instead of flushleft.
167
168 The syntax, more precisely:
169
170 form := <something to pass to `eval'>
171 command := <a symbol or string, to pass to `call-interactively'>
172 callback := command | form
173 active-p := <t, nil, or a form to evaluate to decide whether this
174 button should be selectable>
175 name := <string>
176 partition := 'nil'
177 button := '[' name callback active-p ']'
178 dialog := '(' name [ button ]+ [ partition [ button ]+ ] ')'"
179 (let ((name (car data))
180 (tail (cdr data))
181 converted
182 choice)
183 (while tail
184 (if (null (car tail))
185 (setq converted (cons nil converted))
186 (let ((item (aref (car tail) 0))
187 (callback (aref (car tail) 1))
188 (enable (aref (car tail) 2)))
189 (setq converted
190 (cons (if enable (cons item callback) item)
191 converted))))
192 (setq tail (cdr tail)))
193 (setq choice (x-popup-dialog t (cons name (nreverse converted))))
194 (setq meaning (assq choice converted))
195 (if meaning
196 (if (symbolp (cdr meaning))
197 (call-interactively (cdr meaning))
198 (eval (cdr meaning))))))
149 199
150 ;; This is empty because the usual elements of the menu bar 200 ;; This is empty because the usual elements of the menu bar
151 ;; are provided by menu-bar.el instead. 201 ;; are provided by menu-bar.el instead.
152 ;; It would not make sense to duplicate them here. 202 ;; It would not make sense to duplicate them here.
153 (defconst default-menubar nil) 203 (defconst default-menubar nil)