98
|
1 \input texinfo.tex
|
|
2
|
|
3 @c %**start of header
|
|
4 @setfilename widget
|
|
5 @settitle The Emacs Widget Library
|
|
6 @iftex
|
|
7 @afourpaper
|
|
8 @headings double
|
|
9 @end iftex
|
|
10 @c %**end of header
|
|
11
|
|
12 @node Top, Introduction, (dir), (dir)
|
|
13 @comment node-name, next, previous, up
|
|
14 @top The Emacs Widget Library
|
|
15
|
153
|
16 Version: 1.98
|
98
|
17
|
|
18 @menu
|
|
19 * Introduction::
|
|
20 * User Interface::
|
|
21 * Programming Example::
|
|
22 * Setting Up the Buffer::
|
|
23 * Basic Types::
|
|
24 * Sexp Types::
|
|
25 * Widget Properties::
|
|
26 * Defining New Widgets::
|
149
|
27 * Widget Browser::
|
|
28 * Widget Minor Mode::
|
|
29 * Utilities::
|
|
30 * Widget Wishlist::
|
98
|
31 @end menu
|
|
32
|
|
33 @node Introduction, User Interface, Top, Top
|
|
34 @comment node-name, next, previous, up
|
|
35 @section Introduction
|
|
36
|
|
37 Most graphical user interface toolkits, such as Motif and XView, provide
|
|
38 a number of standard user interface controls (sometimes known as
|
|
39 `widgets' or `gadgets'). Emacs doesn't really support anything like
|
|
40 this, except for an incredible powerful text ``widget''. On the other
|
|
41 hand, Emacs does provide the necessary primitives to implement many
|
|
42 other widgets within a text buffer. The @code{widget} package
|
|
43 simplifies this task.
|
|
44
|
|
45 The basic widgets are:
|
|
46
|
|
47 @table @code
|
|
48 @item link
|
|
49 Areas of text with an associated action. Intended for hypertext links
|
|
50 embedded in text.
|
|
51 @item push-button
|
|
52 Like link, but intended for stand-alone buttons.
|
|
53 @item editable-field
|
|
54 An editable text field. It can be either variable or fixed length.
|
|
55 @item menu-choice
|
|
56 Allows the user to choose one of multiple options from a menu, each
|
|
57 option is itself a widget. Only the selected option will be visible in
|
|
58 the buffer.
|
|
59 @item radio-button-choice
|
153
|
60 Allows the user to choose one of multiple options by activating radio
|
98
|
61 buttons. The options are implemented as widgets. All options will be
|
|
62 visible in the buffer.
|
|
63 @item item
|
|
64 A simple constant widget intended to be used in the @code{menu-choice} and
|
|
65 @code{radio-button-choice} widgets.
|
|
66 @item choice-item
|
153
|
67 An button item only intended for use in choices. When activated, the user
|
98
|
68 will be asked to select another option from the choice widget.
|
|
69 @item toggle
|
|
70 A simple @samp{on}/@samp{off} switch.
|
|
71 @item checkbox
|
|
72 A checkbox (@samp{[ ]}/@samp{[X]}).
|
|
73 @item editable-list
|
|
74 Create an editable list. The user can insert or delete items in the
|
|
75 list. Each list item is itself a widget.
|
|
76 @end table
|
|
77
|
|
78 Now of what possible use can support for widgets be in a text editor?
|
|
79 I'm glad you asked. The answer is that widgets are useful for
|
|
80 implementing forms. A @dfn{form} in emacs is a buffer where the user is
|
|
81 supposed to fill out a number of fields, each of which has a specific
|
|
82 meaning. The user is not supposed to change or delete any of the text
|
|
83 between the fields. Examples of forms in Emacs are the @file{forms}
|
|
84 package (of course), the customize buffers, the mail and news compose
|
|
85 modes, and the @sc{html} form support in the @file{w3} browser.
|
|
86
|
|
87 The advantages for a programmer of using the @code{widget} package to
|
|
88 implement forms are:
|
|
89
|
|
90 @enumerate
|
|
91 @item
|
|
92 More complex field than just editable text are supported.
|
|
93 @item
|
|
94 You can give the user immediate feedback if he enters invalid data in a
|
|
95 text field, and sometimes prevent entering invalid data.
|
|
96 @item
|
|
97 You can have fixed sized fields, thus allowing multiple field to be
|
|
98 lined up in columns.
|
|
99 @item
|
|
100 It is simple to query or set the value of a field.
|
|
101 @item
|
|
102 Editing happens in buffer, not in the mini-buffer.
|
|
103 @item
|
|
104 Packages using the library get a uniform look, making them easier for
|
|
105 the user to learn.
|
|
106 @item
|
|
107 As support for embedded graphics improve, the widget library will
|
|
108 extended to support it. This means that your code using the widget
|
|
109 library will also use the new graphic features by automatic.
|
|
110 @end enumerate
|
|
111
|
|
112 In order to minimize the code that is loaded by users who does not
|
|
113 create any widgets, the code has been split in two files:
|
|
114
|
|
115 @table @file
|
|
116 @item widget.el
|
|
117 This will declare the user variables, define the function
|
|
118 @code{widget-define}, and autoload the function @code{widget-create}.
|
106
|
119 @item wid-edit.el
|
98
|
120 Everything else is here, there is no reason to load it explicitly, as
|
|
121 it will be autoloaded when needed.
|
|
122 @end table
|
|
123
|
|
124 @node User Interface, Programming Example, Introduction, Top
|
|
125 @comment node-name, next, previous, up
|
|
126 @section User Interface
|
|
127
|
|
128 A form consist of read only text for documentation and some fields,
|
|
129 where each the fields contain two parts, as tag and a value. The tags
|
|
130 are used to identify the fields, so the documentation can refer to the
|
|
131 foo field, meaning the field tagged with @samp{Foo}. Here is an example
|
|
132 form:
|
|
133
|
|
134 @example
|
|
135 Here is some documentation.
|
|
136
|
|
137 Name: @i{My Name} @strong{Choose}: This option
|
|
138 Address: @i{Some Place
|
|
139 In some City
|
|
140 Some country.}
|
|
141
|
|
142 See also @b{_other work_} for more information.
|
|
143
|
|
144 Numbers: count to three below
|
|
145 @b{[INS]} @b{[DEL]} @i{One}
|
|
146 @b{[INS]} @b{[DEL]} @i{Eh, two?}
|
|
147 @b{[INS]} @b{[DEL]} @i{Five!}
|
|
148 @b{[INS]}
|
|
149
|
|
150 Select multiple:
|
|
151
|
|
152 @b{[X]} This
|
|
153 @b{[ ]} That
|
|
154 @b{[X]} Thus
|
|
155
|
|
156 Select one:
|
|
157
|
|
158 @b{(*)} One
|
|
159 @b{( )} Another One.
|
|
160 @b{( )} A Final One.
|
|
161
|
|
162 @b{[Apply Form]} @b{[Reset Form]}
|
|
163 @end example
|
|
164
|
|
165 The top level widgets in is example are tagged @samp{Name},
|
|
166 @samp{Choose}, @samp{Address}, @samp{_other work_}, @samp{Numbers},
|
|
167 @samp{Select multiple}, @samp{Select one}, @samp{[Apply Form]}, and
|
|
168 @samp{[Reset Form]}. There are basically two thing the user can do within
|
|
169 a form, namely editing the editable text fields and activating the
|
|
170 buttons.
|
|
171
|
|
172 @subsection Editable Text Fields
|
|
173
|
|
174 In the example, the value for the @samp{Name} is most likely displayed
|
|
175 in an editable text field, and so are values for each of the members of
|
|
176 the @samp{Numbers} list. All the normal Emacs editing operations are
|
|
177 available for editing these fields. The only restriction is that each
|
|
178 change you make must be contained within a single editable text field.
|
|
179 For example, capitalizing all text from the middle of one field to the
|
|
180 middle of another field is prohibited.
|
|
181
|
|
182 Editing text fields are created by the @code{editable-field} widget.
|
|
183
|
|
184 The editing text fields are highlighted with the
|
|
185 @code{widget-field-face} face, making them easy to find.
|
|
186
|
|
187 @deffn Face widget-field-face
|
|
188 Face used for other editing fields.
|
|
189 @end deffn
|
|
190
|
|
191 @subsection Buttons
|
|
192
|
|
193 Some portions of the buffer have an associated @dfn{action}, which can
|
|
194 be @dfn{activated} by a standard key or mouse command. These portions
|
|
195 are called @dfn{buttons}. The default commands for activating a button
|
|
196 are:
|
|
197
|
|
198 @table @kbd
|
|
199 @item @key{RET}
|
|
200 @deffn Command widget-button-press @var{pos} &optional @var{event}
|
|
201 Activate the button at @var{pos}, defaulting to point.
|
|
202 If point is not located on a button, activate the binding in
|
|
203 @code{widget-global-map} (by default the global map).
|
|
204 @end deffn
|
|
205
|
|
206 @item mouse-2
|
|
207 @deffn Command widget-button-click @var{event}
|
|
208 Activate the button at the location of the mouse pointer. If the mouse
|
|
209 pointer is located in an editable text field, activate the binding in
|
|
210 @code{widget-global-map} (by default the global map).
|
|
211 @end deffn
|
|
212 @end table
|
|
213
|
|
214 There are several different kind of buttons, all of which are present in
|
|
215 the example:
|
|
216
|
|
217 @table @emph
|
|
218 @item The Option Field Tags.
|
|
219 When you activate one of these buttons, you will be asked to choose
|
|
220 between a number of different options. This is how you edit an option
|
|
221 field. Option fields are created by the @code{menu-choice} widget. In
|
|
222 the example, @samp{@b{Choose}} is an option field tag.
|
|
223 @item The @samp{@b{[INS]}} and @samp{@b{[DEL]}} buttons.
|
|
224 Activating these will insert or delete elements from a editable list.
|
|
225 The list is created by the @code{editable-list} widget.
|
|
226 @item Embedded Buttons.
|
|
227 The @samp{@b{_other work_}} is an example of an embedded
|
|
228 button. Embedded buttons are not associated with a fields, but can serve
|
|
229 any purpose, such as implementing hypertext references. They are
|
|
230 usually created by the @code{link} widget.
|
|
231 @item The @samp{@b{[ ]}} and @samp{@b{[X]}} buttons.
|
|
232 Activating one of these will convert it to the other. This is useful
|
|
233 for implementing multiple-choice fields. You can create it wit
|
|
234 @item The @samp{@b{( )}} and @samp{@b{(*)}} buttons.
|
149
|
235 Only one radio button in a @code{radio-button-choice} widget can be
|
153
|
236 selected at any time. When you activate one of the unselected radio
|
149
|
237 buttons, it will be selected and the previous selected radio button will
|
|
238 become unselected.
|
98
|
239 @item The @samp{@b{[Apply Form]}} @samp{@b{[Reset Form]}} buttons.
|
|
240 These are explicit buttons made with the @code{push-button} widget. The main
|
|
241 difference from the @code{link} widget is that the buttons are will be
|
|
242 displayed as GUI buttons when possible.
|
|
243 enough.
|
|
244 @end table
|
|
245
|
|
246 To make them easier to locate, buttons are emphasized in the buffer.
|
|
247
|
|
248 @deffn Face widget-button-face
|
|
249 Face used for buttons.
|
|
250 @end deffn
|
|
251
|
|
252 @defopt widget-mouse-face
|
|
253 Face used for buttons when the mouse pointer is above it.
|
|
254 @end defopt
|
|
255
|
|
256 @subsection Navigation
|
|
257
|
|
258 You can use all the normal Emacs commands to move around in a form
|
|
259 buffer, plus you will have these additional commands:
|
|
260
|
|
261 @table @kbd
|
|
262 @item @key{TAB}
|
|
263 @deffn Command widget-forward &optional count
|
|
264 Move point @var{count} buttons or editing fields forward.
|
|
265 @end deffn
|
|
266 @item @key{M-TAB}
|
|
267 @deffn Command widget-backward &optional count
|
|
268 Move point @var{count} buttons or editing fields backward.
|
|
269 @end deffn
|
|
270 @end table
|
|
271
|
|
272 @node Programming Example, Setting Up the Buffer, User Interface, Top
|
|
273 @comment node-name, next, previous, up
|
|
274 @section Programming Example
|
|
275
|
|
276 Here is the code to implement the user interface example (see @ref{User
|
|
277 Interface}).
|
|
278
|
|
279 @lisp
|
|
280 (require 'widget)
|
|
281
|
|
282 (eval-when-compile
|
106
|
283 (require 'wid-edit))
|
98
|
284
|
|
285 (defvar widget-example-repeat)
|
|
286
|
|
287 (defun widget-example ()
|
|
288 "Create the widgets from the Widget manual."
|
|
289 (interactive)
|
|
290 (switch-to-buffer "*Widget Example*")
|
|
291 (kill-all-local-variables)
|
|
292 (make-local-variable 'widget-example-repeat)
|
|
293 (let ((inhibit-read-only t))
|
|
294 (erase-buffer))
|
|
295 (widget-insert "Here is some documentation.\n\nName: ")
|
|
296 (widget-create 'editable-field
|
|
297 :size 13
|
|
298 "My Name")
|
|
299 (widget-create 'menu-choice
|
|
300 :tag "Choose"
|
|
301 :value "This"
|
|
302 :help-echo "Choose me, please!"
|
|
303 :notify (lambda (widget &rest ignore)
|
|
304 (message "%s is a good choice!"
|
|
305 (widget-value widget)))
|
|
306 '(item :tag "This option" :value "This")
|
|
307 '(choice-item "That option")
|
|
308 '(editable-field :menu-tag "No option" "Thus option"))
|
|
309 (widget-insert "Address: ")
|
|
310 (widget-create 'editable-field
|
|
311 "Some Place\nIn some City\nSome country.")
|
|
312 (widget-insert "\nSee also ")
|
|
313 (widget-create 'link
|
|
314 :notify (lambda (&rest ignore)
|
|
315 (widget-value-set widget-example-repeat
|
|
316 '("En" "To" "Tre"))
|
|
317 (widget-setup))
|
|
318 "other work")
|
|
319 (widget-insert " for more information.\n\nNumbers: count to three below\n")
|
|
320 (setq widget-example-repeat
|
|
321 (widget-create 'editable-list
|
|
322 :entry-format "%i %d %v"
|
|
323 :notify (lambda (widget &rest ignore)
|
|
324 (let ((old (widget-get widget
|
|
325 ':example-length))
|
|
326 (new (length (widget-value widget))))
|
|
327 (unless (eq old new)
|
|
328 (widget-put widget ':example-length new)
|
|
329 (message "You can count to %d." new))))
|
|
330 :value '("One" "Eh, two?" "Five!")
|
|
331 '(editable-field :value "three")))
|
|
332 (widget-insert "\n\nSelect multiple:\n\n")
|
|
333 (widget-create 'checkbox t)
|
|
334 (widget-insert " This\n")
|
|
335 (widget-create 'checkbox nil)
|
|
336 (widget-insert " That\n")
|
|
337 (widget-create 'checkbox
|
|
338 :notify (lambda (&rest ignore) (message "Tickle"))
|
|
339 t)
|
|
340 (widget-insert " Thus\n\nSelect one:\n\n")
|
|
341 (widget-create 'radio-button-choice
|
|
342 :value "One"
|
|
343 :notify (lambda (widget &rest ignore)
|
|
344 (message "You selected %s"
|
|
345 (widget-value widget)))
|
|
346 '(item "One") '(item "Anthor One.") '(item "A Final One."))
|
|
347 (widget-insert "\n")
|
|
348 (widget-create 'push-button
|
|
349 :notify (lambda (&rest ignore)
|
|
350 (if (= (length (widget-value widget-example-repeat))
|
|
351 3)
|
|
352 (message "Congratulation!")
|
|
353 (error "Three was the count!")))
|
|
354 "Apply Form")
|
|
355 (widget-insert " ")
|
|
356 (widget-create 'push-button
|
|
357 :notify (lambda (&rest ignore)
|
|
358 (widget-example))
|
|
359 "Reset Form")
|
|
360 (widget-insert "\n")
|
|
361 (use-local-map widget-keymap)
|
|
362 (widget-setup))
|
|
363 @end lisp
|
|
364
|
|
365 @node Setting Up the Buffer, Basic Types, Programming Example, Top
|
|
366 @comment node-name, next, previous, up
|
|
367 @section Setting Up the Buffer
|
|
368
|
|
369 Widgets are created with @code{widget-create}, which returns a
|
|
370 @dfn{widget} object. This object can be queried and manipulated by
|
|
371 other widget functions, until it is deleted with @code{widget-delete}.
|
|
372 After the widgets have been created, @code{widget-setup} must be called
|
|
373 to enable them.
|
|
374
|
|
375 @defun widget-create type [ keyword argument ]@dots{}
|
|
376 Create and return a widget of type @var{type}.
|
|
377 The syntax for the @var{type} argument is described in @ref{Basic Types}.
|
|
378
|
|
379 The keyword arguments can be used to overwrite the keyword arguments
|
|
380 that are part of @var{type}.
|
|
381 @end defun
|
|
382
|
|
383 @defun widget-delete widget
|
|
384 Delete @var{widget} and remove it from the buffer.
|
|
385 @end defun
|
|
386
|
|
387 @defun widget-setup
|
|
388 Setup a buffer to support widgets.
|
|
389
|
|
390 This should be called after creating all the widgets and before allowing
|
|
391 the user to edit them.
|
|
392 @refill
|
|
393 @end defun
|
|
394
|
|
395 If you want to insert text outside the widgets in the form, the
|
|
396 recommended way to do that is with @code{widget-insert}.
|
|
397
|
|
398 @defun widget-insert
|
|
399 Insert the arguments, either strings or characters, at point.
|
|
400 The inserted text will be read only.
|
|
401 @end defun
|
|
402
|
|
403 There is a standard widget keymap which you might find useful.
|
|
404
|
|
405 @defvr Const widget-keymap
|
108
|
406 A keymap with the global keymap as its parent.@*
|
98
|
407 @key{TAB} and @kbd{C-@key{TAB}} are bound to @code{widget-forward} and
|
|
408 @code{widget-backward}, respectively. @kbd{@key{RET}} and @kbd{mouse-2}
|
|
409 are bound to @code{widget-button-press} and
|
|
410 @code{widget-button-}.@refill
|
|
411 @end defvr
|
|
412
|
|
413 @defvar widget-global-map
|
|
414 Keymap used by @code{widget-button-press} and @code{widget-button-click}
|
|
415 when not on a button. By default this is @code{global-map}.
|
|
416 @end defvar
|
|
417
|
|
418 @node Basic Types, Sexp Types, Setting Up the Buffer, Top
|
|
419 @comment node-name, next, previous, up
|
|
420 @section Basic Types
|
|
421
|
|
422 The syntax of a type specification is given below:
|
|
423
|
|
424 @example
|
|
425 NAME ::= (NAME [KEYWORD ARGUMENT]... ARGS)
|
|
426 | NAME
|
|
427 @end example
|
|
428
|
|
429 Where, @var{name} is a widget name, @var{keyword} is the name of a
|
|
430 property, @var{argument} is the value of the property, and @var{args}
|
|
431 are interpreted in a widget specific way.
|
|
432
|
|
433 There following keyword arguments that apply to all widgets:
|
|
434
|
|
435 @table @code
|
|
436 @item :value
|
|
437 The initial value for widgets of this type.
|
|
438
|
|
439 @item :format
|
|
440 This string will be inserted in the buffer when you create a widget.
|
|
441 The following @samp{%} escapes are available:
|
|
442
|
|
443 @table @samp
|
|
444 @item %[
|
|
445 @itemx %]
|
|
446 The text inside will be marked as a button.
|
|
447
|
153
|
448 By default, the text will be shown in @code{widget-button-face}, and
|
|
449 surrounded by brackets.
|
|
450
|
|
451 @defopt widget-button-prefix
|
|
452 String to prefix buttons.
|
|
453 @end defopt
|
|
454
|
|
455 @defopt widget-button-suffix
|
|
456 String to suffix buttons.
|
|
457 @end defopt
|
|
458
|
98
|
459 @item %@{
|
|
460 @itemx %@}
|
|
461 The text inside will be displayed with the face specified by
|
|
462 @code{:sample-face}.
|
|
463
|
|
464 @item %v
|
|
465 This will be replaces with the buffer representation of the widgets
|
|
466 value. What this is depends on the widget type.
|
|
467
|
|
468 @item %d
|
|
469 Insert the string specified by @code{:doc} here.
|
|
470
|
|
471 @item %h
|
|
472 Like @samp{%d}, with the following modifications: If the documentation
|
|
473 string is more than one line, it will add a button which will toggle
|
|
474 between showing only the first line, and showing the full text.
|
|
475 Furthermore, if there is no @code{:doc} property in the widget, it will
|
|
476 instead examine the @code{:documentation-property} property. If it is a
|
|
477 lambda expression, it will be called with the widget's value as an
|
|
478 argument, and the result will be used as the documentation text.
|
|
479
|
|
480 @item %t
|
|
481 Insert the string specified by @code{:tag} here, or the @code{princ}
|
|
482 representation of the value if there is no tag.
|
|
483
|
|
484 @item %%
|
|
485 Insert a literal @samp{%}.
|
|
486 @end table
|
|
487
|
|
488 @item :button-face
|
|
489 Face used to highlight text inside %[ %] in the format.
|
|
490
|
153
|
491 @item :button-prefix
|
|
492 @itemx :button-suffix
|
|
493
|
|
494 Text around %[ %] in the format.
|
|
495
|
|
496 These can be
|
|
497 @table @emph
|
|
498 @item nil
|
|
499 No text is inserted.
|
|
500
|
|
501 @item a string
|
|
502 The string is inserted literally.
|
|
503
|
|
504 @item a symbol
|
|
505 The value of the symbol is expanded according to this table.
|
|
506 @end table
|
|
507
|
98
|
508 @item :doc
|
|
509 The string inserted by the @samp{%d} escape in the format
|
|
510 string.
|
|
511
|
|
512 @item :tag
|
|
513 The string inserted by the @samp{%t} escape in the format
|
|
514 string.
|
|
515
|
|
516 @item :tag-glyph
|
|
517 Name of image to use instead of the string specified by `:tag' on
|
|
518 Emacsen that supports it.
|
|
519
|
|
520 @item :help-echo
|
|
521 Message displayed whenever you move to the widget with either
|
|
522 @code{widget-forward} or @code{widget-backward}.
|
|
523
|
|
524 @item :indent
|
|
525 An integer indicating the absolute number of spaces to indent children
|
|
526 of this widget.
|
|
527
|
|
528 @item :offset
|
|
529 An integer indicating how many extra spaces to add to the widget's
|
|
530 grandchildren compared to this widget.
|
|
531
|
|
532 @item :extra-offset
|
|
533 An integer indicating how many extra spaces to add to the widget's
|
|
534 children compared to this widget.
|
|
535
|
|
536 @item :notify
|
|
537 A function called each time the widget or a nested widget is changed.
|
|
538 The function is called with two or three arguments. The first argument
|
|
539 is the widget itself, the second argument is the widget that was
|
|
540 changed, and the third argument is the event leading to the change, if
|
|
541 any.
|
|
542
|
|
543 @item :menu-tag
|
|
544 Tag used in the menu when the widget is used as an option in a
|
|
545 @code{menu-choice} widget.
|
|
546
|
|
547 @item :menu-tag-get
|
|
548 Function used for finding the tag when the widget is used as an option
|
|
549 in a @code{menu-choice} widget. By default, the tag used will be either the
|
|
550 @code{:menu-tag} or @code{:tag} property if present, or the @code{princ}
|
|
551 representation of the @code{:value} property if not.
|
|
552
|
|
553 @item :match
|
|
554 Should be a function called with two arguments, the widget and a value,
|
|
555 and returning non-nil if the widget can represent the specified value.
|
|
556
|
|
557 @item :validate
|
|
558 A function which takes a widget as an argument, and return nil if the
|
|
559 widgets current value is valid for the widget. Otherwise, it should
|
|
560 return the widget containing the invalid data, and set that widgets
|
|
561 @code{:error} property to a string explaining the error.
|
|
562
|
149
|
563 The following predefined function can be used:
|
|
564
|
|
565 @defun widget-children-validate widget
|
|
566 All the @code{:children} of @var{widget} must be valid.
|
|
567 @end defun
|
|
568
|
110
|
569 @item :tab-order
|
|
570 Specify the order in which widgets are traversed with
|
|
571 @code{widget-forward} or @code{widget-backward}. This is only partially
|
|
572 implemented.
|
|
573
|
|
574 @enumerate a
|
|
575 @item
|
|
576 Widgets with tabbing order @code{-1} are ignored.
|
|
577
|
|
578 @item
|
|
579 (Unimplemented) When on a widget with tabbing order @var{n}, go to the
|
|
580 next widget in the buffer with tabbing order @var{n+1} or @code{nil},
|
|
581 whichever comes first.
|
|
582
|
|
583 @item
|
|
584 When on a widget with no tabbing order specified, go to the next widget
|
|
585 in the buffer with a positive tabbing order, or @code{nil}
|
|
586 @end enumerate
|
|
587
|
98
|
588 @item :parent
|
110
|
589 The parent of a nested widget (e.g. a @code{menu-choice} item or an
|
|
590 element of a @code{editable-list} widget).
|
108
|
591
|
|
592 @item :sibling-args
|
|
593 This keyword is only used for members of a @code{radio-button-choice} or
|
|
594 @code{checklist}. The value should be a list of extra keyword
|
|
595 arguments, which will be used when creating the @code{radio-button} or
|
|
596 @code{checkbox} associated with this item.
|
|
597
|
98
|
598 @end table
|
|
599
|
|
600 @deffn {User Option} widget-glyph-directory
|
|
601 Directory where glyphs are found.
|
|
602 Widget will look here for a file with the same name as specified for the
|
|
603 image, with either a @samp{.xpm} (if supported) or @samp{.xbm} extension.
|
|
604 @end deffn
|
|
605
|
|
606 @deffn{User Option} widget-glyph-enable
|
|
607 If non-nil, allow glyphs to appear on displayes where they are supported.
|
|
608 @end deffn
|
|
609
|
|
610
|
|
611 @menu
|
|
612 * link::
|
|
613 * url-link::
|
|
614 * info-link::
|
|
615 * push-button::
|
|
616 * editable-field::
|
|
617 * text::
|
|
618 * menu-choice::
|
|
619 * radio-button-choice::
|
|
620 * item::
|
|
621 * choice-item::
|
|
622 * toggle::
|
|
623 * checkbox::
|
|
624 * checklist::
|
|
625 * editable-list::
|
149
|
626 * group::
|
98
|
627 @end menu
|
|
628
|
|
629 @node link, url-link, Basic Types, Basic Types
|
|
630 @comment node-name, next, previous, up
|
|
631 @subsection The @code{link} Widget
|
|
632
|
|
633 Syntax:
|
|
634
|
|
635 @example
|
|
636 TYPE ::= (link [KEYWORD ARGUMENT]... [ VALUE ])
|
|
637 @end example
|
|
638
|
|
639 The @var{value}, if present, is used to initialize the @code{:value}
|
|
640 property. The value should be a string, which will be inserted in the
|
|
641 buffer.
|
|
642
|
153
|
643 By default the link will be shown in brackets.
|
|
644
|
|
645 @defopt widget-link-prefix
|
|
646 String to prefix links.
|
|
647 @end defopt
|
|
648
|
|
649 @defopt widget-link-suffix
|
|
650 String to suffix links.
|
|
651 @end defopt
|
|
652
|
98
|
653 @node url-link, info-link, link, Basic Types
|
|
654 @comment node-name, next, previous, up
|
|
655 @subsection The @code{url-link} Widget
|
|
656
|
|
657 Syntax:
|
|
658
|
|
659 @example
|
|
660 TYPE ::= (url-link [KEYWORD ARGUMENT]... URL)
|
|
661 @end example
|
|
662
|
|
663 When this link is activated, the @sc{www} browser specified by
|
|
664 @code{browse-url-browser-function} will be called with @var{url}.
|
|
665
|
|
666 @node info-link, push-button, url-link, Basic Types
|
|
667 @comment node-name, next, previous, up
|
|
668 @subsection The @code{info-link} Widget
|
|
669
|
|
670 Syntax:
|
|
671
|
|
672 @example
|
|
673 TYPE ::= (info-link [KEYWORD ARGUMENT]... ADDRESS)
|
|
674 @end example
|
|
675
|
|
676 When this link is activated, the build-in info browser is started on
|
|
677 @var{address}.
|
|
678
|
|
679 @node push-button, editable-field, info-link, Basic Types
|
|
680 @comment node-name, next, previous, up
|
|
681 @subsection The @code{push-button} Widget
|
|
682
|
|
683 Syntax:
|
|
684
|
|
685 @example
|
|
686 TYPE ::= (push-button [KEYWORD ARGUMENT]... [ VALUE ])
|
|
687 @end example
|
|
688
|
|
689 The @var{value}, if present, is used to initialize the @code{:value}
|
|
690 property. The value should be a string, which will be inserted in the
|
|
691 buffer.
|
|
692
|
153
|
693 By default the tag will be shown in brackets.
|
120
|
694
|
153
|
695 @defopt widget-push-button-prefix
|
|
696 String to prefix push buttons.
|
|
697 @end defopt
|
120
|
698
|
153
|
699 @defopt widget-push-button-suffix
|
|
700 String to suffix push buttons.
|
|
701 @end defopt
|
120
|
702
|
98
|
703 @node editable-field, text, push-button, Basic Types
|
|
704 @comment node-name, next, previous, up
|
|
705 @subsection The @code{editable-field} Widget
|
|
706
|
|
707 Syntax:
|
|
708
|
|
709 @example
|
|
710 TYPE ::= (editable-field [KEYWORD ARGUMENT]... [ VALUE ])
|
|
711 @end example
|
|
712
|
|
713 The @var{value}, if present, is used to initialize the @code{:value}
|
|
714 property. The value should be a string, which will be inserted in
|
|
715 field. This widget will match all string values.
|
|
716
|
|
717 The following extra properties are recognized.
|
|
718
|
|
719 @table @code
|
|
720 @item :size
|
108
|
721 The width of the editable field.@*
|
98
|
722 By default the field will reach to the end of the line.
|
|
723
|
|
724 @item :value-face
|
|
725 Face used for highlighting the editable field. Default is
|
|
726 @code{widget-field-face}.
|
|
727
|
|
728 @item :secret
|
|
729 Character used to display the value. You can set this to e.g. @code{?*}
|
|
730 if the field contains a password or other secret information. By
|
|
731 default, the value is not secret.
|
|
732
|
|
733 @item :valid-regexp
|
|
734 By default the @code{:validate} function will match the content of the
|
|
735 field with the value of this attribute. The default value is @code{""}
|
|
736 which matches everything.
|
|
737
|
|
738 @item :keymap
|
|
739 Keymap used in the editable field. The default value is
|
|
740 @code{widget-field-keymap}, which allows you to use all the normal
|
|
741 editing commands, even if the buffers major mode supress some of them.
|
|
742 Pressing return activates the function specified by @code{:activate}.
|
|
743
|
|
744 @item :hide-front-space
|
|
745 @itemx :hide-rear-space
|
|
746 In order to keep track of the editable field, emacs places an invisible
|
|
747 space character in front of the field, and for fixed sized fields also
|
|
748 in the rear end of the field. For fields that extent to the end of the
|
|
749 line, the terminating linefeed serves that purpose instead.
|
|
750
|
|
751 Emacs will try to make the spaces intangible when it is safe to do so.
|
|
752 Intangible means that the cursor motion commands will skip over the
|
|
753 character as if it didn't exist. This is safe to do when the text
|
|
754 preceding or following the widget cannot possible change during the
|
|
755 lifetime of the @code{editable-field} widget. The preferred way to tell
|
|
756 Emacs this, is to add text to the @code{:format} property around the
|
|
757 value. For example @code{:format "Tag: %v "}.
|
|
758
|
|
759 You can overwrite the internal safety check by setting the
|
|
760 @code{:hide-front-space} or @code{:hide-rear-space} properties to
|
|
761 non-nil. This is not recommended. For example, @emph{all} text that
|
|
762 belongs to a widget (i.e. is created from its @code{:format} string) will
|
|
763 change whenever the widget changes its value.
|
|
764
|
|
765 @end table
|
|
766
|
|
767 @node text, menu-choice, editable-field, Basic Types
|
|
768 @comment node-name, next, previous, up
|
|
769 @subsection The @code{text} Widget
|
|
770
|
|
771 This is just like @code{editable-field}, but intended for multiline text
|
|
772 fields. The default @code{:keymap} is @code{widget-text-keymap}, which
|
|
773 does not rebind the return key.
|
|
774
|
|
775 @node menu-choice, radio-button-choice, text, Basic Types
|
|
776 @comment node-name, next, previous, up
|
|
777 @subsection The @code{menu-choice} Widget
|
|
778
|
|
779 Syntax:
|
|
780
|
|
781 @example
|
|
782 TYPE ::= (menu-choice [KEYWORD ARGUMENT]... TYPE ... )
|
|
783 @end example
|
|
784
|
|
785 The @var{type} arguments represents each possible choice. The widgets
|
|
786 value of will be the value of the chosen @var{type} argument. This
|
|
787 widget will match any value that matches at least one of the specified
|
|
788 @var{type} arguments.
|
|
789
|
|
790 @table @code
|
|
791 @item :void
|
|
792 Widget type used as a fallback when the value does not match any of the
|
|
793 specified @var{type} arguments.
|
|
794
|
|
795 @item :case-fold
|
|
796 Set this to nil if you don't want to ignore case when prompting for a
|
|
797 choice through the minibuffer.
|
|
798
|
|
799 @item :children
|
|
800 A list whose car is the widget representing the currently chosen type in
|
|
801 the buffer.
|
|
802
|
|
803 @item :choice
|
|
804 The current chosen type
|
|
805
|
|
806 @item :args
|
|
807 The list of types.
|
|
808 @end table
|
|
809
|
|
810 @node radio-button-choice, item, menu-choice, Basic Types
|
|
811 @comment node-name, next, previous, up
|
|
812 @subsection The @code{radio-button-choice} Widget
|
|
813
|
|
814 Syntax:
|
|
815
|
|
816 @example
|
|
817 TYPE ::= (radio-button-choice [KEYWORD ARGUMENT]... TYPE ... )
|
|
818 @end example
|
|
819
|
|
820 The @var{type} arguments represents each possible choice. The widgets
|
|
821 value of will be the value of the chosen @var{type} argument. This
|
|
822 widget will match any value that matches at least one of the specified
|
|
823 @var{type} arguments.
|
|
824
|
|
825 The following extra properties are recognized.
|
|
826
|
|
827 @table @code
|
|
828 @item :entry-format
|
|
829 This string will be inserted for each entry in the list.
|
|
830 The following @samp{%} escapes are available:
|
|
831 @table @samp
|
|
832 @item %v
|
|
833 Replaced with the buffer representation of the @var{type} widget.
|
|
834 @item %b
|
|
835 Replace with the radio button.
|
|
836 @item %%
|
|
837 Insert a literal @samp{%}.
|
|
838 @end table
|
|
839
|
108
|
840 @item button-args
|
|
841 A list of keywords to pass to the radio buttons. Useful for setting
|
|
842 e.g. the @samp{:help-echo} for each button.
|
|
843
|
98
|
844 @item :buttons
|
|
845 The widgets representing the radio buttons.
|
|
846
|
|
847 @item :children
|
|
848 The widgets representing each type.
|
|
849
|
|
850 @item :choice
|
|
851 The current chosen type
|
|
852
|
|
853 @item :args
|
|
854 The list of types.
|
|
855 @end table
|
|
856
|
|
857 You can add extra radio button items to a @code{radio-button-choice}
|
|
858 widget after it has been created with the function
|
|
859 @code{widget-radio-add-item}.
|
|
860
|
|
861 @defun widget-radio-add-item widget type
|
|
862 Add to @code{radio-button-choice} widget @var{widget} a new radio button item of type
|
|
863 @var{type}.
|
|
864 @end defun
|
|
865
|
|
866 Please note that such items added after the @code{radio-button-choice}
|
|
867 widget has been created will @strong{not} be properly destructed when
|
|
868 you call @code{widget-delete}.
|
|
869
|
|
870 @node item, choice-item, radio-button-choice, Basic Types
|
|
871 @comment node-name, next, previous, up
|
|
872 @subsection The @code{item} Widget
|
|
873
|
|
874 Syntax:
|
|
875
|
|
876 @example
|
|
877 ITEM ::= (item [KEYWORD ARGUMENT]... VALUE)
|
|
878 @end example
|
|
879
|
|
880 The @var{value}, if present, is used to initialize the @code{:value}
|
|
881 property. The value should be a string, which will be inserted in the
|
|
882 buffer. This widget will only match the specified value.
|
|
883
|
|
884 @node choice-item, toggle, item, Basic Types
|
|
885 @comment node-name, next, previous, up
|
|
886 @subsection The @code{choice-item} Widget
|
|
887
|
|
888 Syntax:
|
|
889
|
|
890 @example
|
|
891 ITEM ::= (choice-item [KEYWORD ARGUMENT]... VALUE)
|
|
892 @end example
|
|
893
|
|
894 The @var{value}, if present, is used to initialize the @code{:value}
|
|
895 property. The value should be a string, which will be inserted in the
|
|
896 buffer as a button. Activating the button of a @code{choice-item} is
|
|
897 equivalent to activating the parent widget. This widget will only match
|
|
898 the specified value.
|
|
899
|
|
900 @node toggle, checkbox, choice-item, Basic Types
|
|
901 @comment node-name, next, previous, up
|
|
902 @subsection The @code{toggle} Widget
|
|
903
|
|
904 Syntax:
|
|
905
|
|
906 @example
|
|
907 TYPE ::= (toggle [KEYWORD ARGUMENT]...)
|
|
908 @end example
|
|
909
|
|
910 The widget has two possible states, `on' and `off', which corresponds to
|
|
911 a @code{t} or @code{nil} value.
|
|
912
|
|
913 The following extra properties are recognized.
|
|
914
|
|
915 @table @code
|
|
916 @item :on
|
|
917 String representing the `on' state. By default the string @samp{on}.
|
|
918 @item :off
|
|
919 String representing the `off' state. By default the string @samp{off}.
|
|
920 @item :on-glyph
|
|
921 Name of a glyph to be used instead of the `:on' text string, on emacsen
|
|
922 that supports it.
|
|
923 @item :off-glyph
|
|
924 Name of a glyph to be used instead of the `:off' text string, on emacsen
|
|
925 that supports it.
|
|
926 @end table
|
|
927
|
|
928 @node checkbox, checklist, toggle, Basic Types
|
|
929 @comment node-name, next, previous, up
|
|
930 @subsection The @code{checkbox} Widget
|
|
931
|
|
932 The widget has two possible states, `selected' and `unselected', which
|
|
933 corresponds to a @code{t} or @code{nil} value.
|
|
934
|
|
935 Syntax:
|
|
936
|
|
937 @example
|
|
938 TYPE ::= (checkbox [KEYWORD ARGUMENT]...)
|
|
939 @end example
|
|
940
|
|
941 @node checklist, editable-list, checkbox, Basic Types
|
|
942 @comment node-name, next, previous, up
|
|
943 @subsection The @code{checklist} Widget
|
|
944
|
|
945 Syntax:
|
|
946
|
|
947 @example
|
|
948 TYPE ::= (checklist [KEYWORD ARGUMENT]... TYPE ... )
|
|
949 @end example
|
|
950
|
|
951 The @var{type} arguments represents each checklist item. The widgets
|
|
952 value of will be a list containing the value of each ticked @var{type}
|
|
953 argument. The checklist widget will match a list whose elements all
|
|
954 matches at least one of the specified @var{type} arguments.
|
|
955
|
|
956 The following extra properties are recognized.
|
|
957
|
|
958 @table @code
|
|
959 @item :entry-format
|
|
960 This string will be inserted for each entry in the list.
|
|
961 The following @samp{%} escapes are available:
|
|
962 @table @samp
|
|
963 @item %v
|
|
964 Replaced with the buffer representation of the @var{type} widget.
|
|
965 @item %b
|
|
966 Replace with the checkbox.
|
|
967 @item %%
|
|
968 Insert a literal @samp{%}.
|
|
969 @end table
|
|
970
|
149
|
971 @item :greedy
|
|
972 Usually, a checklist will only match if the items are in the exact
|
|
973 sequence given in the specification. By setting @code{:greedy} to
|
|
974 non-nil, it will allow the items to come in any sequence. However, if
|
|
975 you extract the value they will be in the sequence given in the
|
|
976 checklist. I.e. the original sequence is forgotten.
|
|
977
|
108
|
978 @item button-args
|
|
979 A list of keywords to pass to the checkboxes. Useful for setting
|
|
980 e.g. the @samp{:help-echo} for each checkbox.
|
|
981
|
98
|
982 @item :buttons
|
|
983 The widgets representing the checkboxes.
|
|
984
|
|
985 @item :children
|
|
986 The widgets representing each type.
|
|
987
|
|
988 @item :args
|
|
989 The list of types.
|
|
990 @end table
|
|
991
|
149
|
992 @node editable-list, group, checklist, Basic Types
|
98
|
993 @comment node-name, next, previous, up
|
|
994 @subsection The @code{editable-list} Widget
|
|
995
|
|
996 Syntax:
|
|
997
|
|
998 @example
|
|
999 TYPE ::= (editable-list [KEYWORD ARGUMENT]... TYPE)
|
|
1000 @end example
|
|
1001
|
149
|
1002 The value is a list, where each member represents one widget of type
|
98
|
1003 @var{type}.
|
|
1004
|
|
1005 The following extra properties are recognized.
|
|
1006
|
|
1007 @table @code
|
|
1008 @item :entry-format
|
|
1009 This string will be inserted for each entry in the list.
|
|
1010 The following @samp{%} escapes are available:
|
|
1011 @table @samp
|
|
1012 @item %v
|
|
1013 This will be replaced with the buffer representation of the @var{type}
|
|
1014 widget.
|
|
1015 @item %i
|
|
1016 Insert the @b{[INS]} button.
|
|
1017 @item %d
|
|
1018 Insert the @b{[DEL]} button.
|
|
1019 @item %%
|
|
1020 Insert a literal @samp{%}.
|
|
1021 @end table
|
|
1022
|
108
|
1023 @item :insert-button-args
|
|
1024 A list of keyword arguments to pass to the insert buttons.
|
|
1025
|
|
1026 @item :delete-button-args
|
|
1027 A list of keyword arguments to pass to the delete buttons.
|
|
1028
|
|
1029 @item :append-button-args
|
|
1030 A list of keyword arguments to pass to the trailing insert button.
|
|
1031
|
|
1032
|
98
|
1033 @item :buttons
|
|
1034 The widgets representing the insert and delete buttons.
|
|
1035
|
|
1036 @item :children
|
|
1037 The widgets representing the elements of the list.
|
|
1038
|
|
1039 @item :args
|
|
1040 List whose car is the type of the list elements.
|
|
1041
|
|
1042 @end table
|
|
1043
|
149
|
1044 @node group, , editable-list, Basic Types
|
|
1045 @comment node-name, next, previous, up
|
|
1046 @subsection The @code{group} Widget
|
|
1047
|
|
1048 This widget simply group other widget together.
|
|
1049
|
|
1050 Syntax:
|
|
1051
|
|
1052 @example
|
|
1053 TYPE ::= (group [KEYWORD ARGUMENT]... TYPE...)
|
|
1054 @end example
|
|
1055
|
|
1056 The value is a list, with one member for each @var{type}.
|
|
1057
|
98
|
1058 @node Sexp Types, Widget Properties, Basic Types, Top
|
|
1059 @comment
|
|
1060 @section Sexp Types
|
|
1061
|
|
1062 A number of widgets for editing s-expressions (lisp types) are also
|
149
|
1063 available. These basically fall in the following categories.
|
98
|
1064
|
|
1065 @menu
|
149
|
1066 * constants::
|
98
|
1067 * generic::
|
|
1068 * atoms::
|
|
1069 * composite::
|
|
1070 @end menu
|
|
1071
|
149
|
1072 @node constants, generic, Sexp Types, Sexp Types
|
98
|
1073 @comment node-name, next, previous, up
|
149
|
1074 @subsection The Constant Widgets.
|
98
|
1075
|
149
|
1076 The @code{const} widget can contain any lisp expression, but the user is
|
98
|
1077 prohibited from editing edit it, which is mainly useful as a component
|
|
1078 of one of the composite widgets.
|
|
1079
|
149
|
1080 The syntax for the @code{const} widget is
|
98
|
1081
|
|
1082 @example
|
|
1083 TYPE ::= (const [KEYWORD ARGUMENT]... [ VALUE ])
|
|
1084 @end example
|
|
1085
|
|
1086 The @var{value}, if present, is used to initialize the @code{:value}
|
|
1087 property and can be any s-expression.
|
|
1088
|
|
1089 @deffn Widget const
|
|
1090 This will display any valid s-expression in an immutable part of the
|
|
1091 buffer.
|
|
1092 @end deffn
|
|
1093
|
149
|
1094 There are two variations of the @code{const} widget, namely
|
|
1095 @code{variable-item} and @code{function-item}. These should contain a
|
|
1096 symbol with a variable or function binding. The major difference from
|
|
1097 the @code{const} widget is that they will allow the user to see the
|
|
1098 variable or function documentation for the symbol.
|
|
1099
|
|
1100 @deffn Widget variable-item
|
|
1101 An immutable symbol that is bound as a variable.
|
|
1102 @end deffn
|
|
1103
|
|
1104 @deffn Widget function-item
|
|
1105 An immutable symbol that is bound as a function.
|
|
1106 @end deffn
|
|
1107
|
|
1108 @node generic, atoms, constants, Sexp Types
|
|
1109 @comment node-name, next, previous, up
|
|
1110 @subsection Generic Sexp Widget.
|
|
1111
|
|
1112 The @code{sexp} widget can contain any lisp expression, and allows the
|
|
1113 user to edit it inline in the buffer.
|
|
1114
|
|
1115 The syntax for the @code{sexp} widget is
|
|
1116
|
|
1117 @example
|
|
1118 TYPE ::= (sexp [KEYWORD ARGUMENT]... [ VALUE ])
|
|
1119 @end example
|
|
1120
|
98
|
1121 @deffn Widget sexp
|
|
1122 This will allow you to edit any valid s-expression in an editable buffer
|
|
1123 field.
|
|
1124
|
|
1125 The @code{sexp} widget takes the same keyword arguments as the
|
|
1126 @code{editable-field} widget.
|
|
1127 @end deffn
|
|
1128
|
|
1129 @node atoms, composite, generic, Sexp Types
|
|
1130 @comment node-name, next, previous, up
|
|
1131 @subsection Atomic Sexp Widgets.
|
|
1132
|
|
1133 The atoms are s-expressions that does not consist of other
|
|
1134 s-expressions. A string is an atom, while a list is a composite type.
|
|
1135 You can edit the value of an atom with the following widgets.
|
|
1136
|
|
1137 The syntax for all the atoms are
|
|
1138
|
|
1139 @example
|
|
1140 TYPE ::= (NAME [KEYWORD ARGUMENT]... [ VALUE ])
|
|
1141 @end example
|
|
1142
|
|
1143 The @var{value}, if present, is used to initialize the @code{:value}
|
|
1144 property and must be an expression of the same type as the widget.
|
|
1145 I.e. the string widget can only be initialized with a string.
|
|
1146
|
124
|
1147 All the atom widgets take the same keyword arguments as the
|
|
1148 @code{editable-field} widget.
|
98
|
1149
|
|
1150 @deffn Widget string
|
|
1151 Allows you to edit a string in an editable field.
|
|
1152 @end deffn
|
|
1153
|
149
|
1154 @deffn Widget regexp
|
|
1155 Allows you to edit a regular expression in an editable field.
|
|
1156 @end deffn
|
|
1157
|
124
|
1158 @deffn Widget character
|
|
1159 Allows you to enter a character in an editable field.
|
|
1160 @end deffn
|
|
1161
|
98
|
1162 @deffn Widget file
|
|
1163 Allows you to edit a file name in an editable field. You you activate
|
|
1164 the tag button, you can edit the file name in the mini-buffer with
|
|
1165 completion.
|
|
1166
|
|
1167 Keywords:
|
|
1168 @table @code
|
|
1169 @item :must-match
|
|
1170 If this is set to non-nil, only existing file names will be allowed in
|
|
1171 the minibuffer.
|
|
1172 @end table
|
|
1173 @end deffn
|
|
1174
|
|
1175 @deffn Widget directory
|
|
1176 Allows you to edit a directory name in an editable field.
|
|
1177 Similar to the @code{file} widget.
|
|
1178 @end deffn
|
|
1179
|
|
1180 @deffn Widget symbol
|
|
1181 Allows you to edit a lisp symbol in an editable field.
|
|
1182 @end deffn
|
|
1183
|
149
|
1184 @deffn Widget function
|
|
1185 Allows you to edit a lambda expression, or a function name with completion.
|
|
1186 @end deffn
|
|
1187
|
|
1188 @deffn Widget variable
|
|
1189 Allows you to edit a variable name, with completion.
|
|
1190 @end deffn
|
|
1191
|
98
|
1192 @deffn Widget integer
|
|
1193 Allows you to edit an integer in an editable field.
|
|
1194 @end deffn
|
|
1195
|
|
1196 @deffn Widget number
|
|
1197 Allows you to edit a number in an editable field.
|
|
1198 @end deffn
|
|
1199
|
|
1200 @deffn Widget boolean
|
|
1201 Allows you to edit a boolean. In lisp this means a variable which is
|
|
1202 either nil meaning false, or non-nil meaning true.
|
|
1203 @end deffn
|
|
1204
|
|
1205
|
|
1206 @node composite, , atoms, Sexp Types
|
|
1207 @comment node-name, next, previous, up
|
|
1208 @subsection Composite Sexp Widgets.
|
|
1209
|
|
1210 The syntax for the composite are
|
|
1211
|
|
1212 @example
|
|
1213 TYPE ::= (NAME [KEYWORD ARGUMENT]... COMPONENT...)
|
|
1214 @end example
|
|
1215
|
|
1216 Where each @var{component} must be a widget type. Each component widget
|
|
1217 will be displayed in the buffer, and be editable to the user.
|
|
1218
|
|
1219 @deffn Widget cons
|
|
1220 The value of a @code{cons} widget is a cons-cell where the car is the
|
|
1221 value of the first component and the cdr is the value of the second
|
|
1222 component. There must be exactly two components.
|
|
1223 @end deffn
|
|
1224
|
149
|
1225 @deffn Widget list
|
|
1226 The value of a @code{list} widget is a list containing the value of
|
98
|
1227 each of its component.
|
|
1228 @end deffn
|
|
1229
|
|
1230 @deffn Widget vector
|
|
1231 The value of a @code{vector} widget is a vector containing the value of
|
|
1232 each of its component.
|
|
1233 @end deffn
|
|
1234
|
|
1235 The above suffice for specifying fixed size lists and vectors. To get
|
|
1236 variable length lists and vectors, you can use a @code{choice},
|
|
1237 @code{set} or @code{repeat} widgets together with the @code{:inline}
|
|
1238 keywords. If any component of a composite widget has the @code{:inline}
|
|
1239 keyword set, its value must be a list which will then be spliced into
|
|
1240 the composite. For example, to specify a list whose first element must
|
|
1241 be a file name, and whose remaining arguments should either by the
|
|
1242 symbol @code{t} or two files, you can use the following widget
|
|
1243 specification:
|
|
1244
|
|
1245 @example
|
|
1246 (list file
|
|
1247 (choice (const t)
|
|
1248 (list :inline t
|
|
1249 :value ("foo" "bar")
|
|
1250 string string)))
|
|
1251 @end example
|
|
1252
|
|
1253 The value of a widget of this type will either have the form
|
|
1254 @samp{(file t)} or @code{(file string string)}.
|
|
1255
|
|
1256 This concept of inline is probably hard to understand. It was certainly
|
|
1257 hard to implement so instead of confuse you more by trying to explain it
|
|
1258 here, I'll just suggest you meditate over it for a while.
|
|
1259
|
|
1260 @deffn Widget choice
|
|
1261 Allows you to edit a sexp which may have one of fixed set of types. It
|
|
1262 is currently implemented with the @code{choice-menu} basic widget, and
|
|
1263 has a similar syntax.
|
|
1264 @end deffn
|
|
1265
|
|
1266 @deffn Widget set
|
|
1267 Allows you to specify a type which must be a list whose elements all
|
|
1268 belong to given set. The elements of the list is not significant. This
|
|
1269 is implemented on top of the @code{checklist} basic widget, and has a
|
|
1270 similar syntax.
|
|
1271 @end deffn
|
|
1272
|
|
1273 @deffn Widget repeat
|
|
1274 Allows you to specify a variable length list whose members are all of
|
|
1275 the same type. Implemented on top of the `editable-list' basic widget,
|
|
1276 and has a similar syntax.
|
|
1277 @end deffn
|
|
1278
|
|
1279 @node Widget Properties, Defining New Widgets, Sexp Types, Top
|
|
1280 @comment node-name, next, previous, up
|
|
1281 @section Properties
|
|
1282
|
|
1283 You can examine or set the value of a widget by using the widget object
|
|
1284 that was returned by @code{widget-create}.
|
|
1285
|
|
1286 @defun widget-value widget
|
|
1287 Return the current value contained in @var{widget}.
|
|
1288 It is an error to call this function on an uninitialized widget.
|
|
1289 @end defun
|
|
1290
|
|
1291 @defun widget-value-set widget value
|
|
1292 Set the value contained in @var{widget} to @var{value}.
|
|
1293 It is an error to call this function with an invalid @var{value}.
|
|
1294 @end defun
|
|
1295
|
|
1296 @strong{Important:} You @emph{must} call @code{widget-setup} after
|
|
1297 modifying the value of a widget before the user is allowed to edit the
|
|
1298 widget again. It is enough to call @code{widget-setup} once if you
|
|
1299 modify multiple widgets. This is currently only necessary if the widget
|
|
1300 contains an editing field, but may be necessary for other widgets in the
|
|
1301 future.
|
|
1302
|
|
1303 If your application needs to associate some information with the widget
|
|
1304 objects, for example a reference to the item being edited, it can be
|
|
1305 done with @code{widget-put} and @code{widget-get}. The property names
|
|
1306 must begin with a @samp{:}.
|
|
1307
|
|
1308 @defun widget-put widget property value
|
|
1309 In @var{widget} set @var{property} to @var{value}.
|
|
1310 @var{property} should be a symbol, while @var{value} can be anything.
|
|
1311 @end defun
|
|
1312
|
|
1313 @defun widget-get widget property
|
|
1314 In @var{widget} return the value for @var{property}.
|
|
1315 @var{property} should be a symbol, the value is what was last set by
|
|
1316 @code{widget-put} for @var{property}.
|
|
1317 @end defun
|
|
1318
|
|
1319 @defun widget-member widget property
|
|
1320 Non-nil if @var{widget} has a value (even nil) for property @var{property}.
|
|
1321 @end defun
|
|
1322
|
|
1323 Occasionally it can be useful to know which kind of widget you have,
|
|
1324 i.e. the name of the widget type you gave when the widget was created.
|
|
1325
|
|
1326 @defun widget-type widget
|
|
1327 Return the name of @var{widget}, a symbol.
|
|
1328 @end defun
|
|
1329
|
116
|
1330 Widgets can be in two states: active, which means they are modifiable by
|
|
1331 the user, or inactive, which means they cannot be modified by the user.
|
|
1332 You can query or set the state with the following code:
|
|
1333
|
|
1334 @lisp
|
|
1335 ;; Examine if @var{widget} is active or not.
|
|
1336 (if (widget-apply @var{widget} :active)
|
|
1337 (message "Widget is active.")
|
|
1338 (message "Widget is inactive.")
|
|
1339
|
|
1340 ;; Make @var{widget} inactive.
|
|
1341 (widget-apply @var{widget} :deactivate)
|
|
1342
|
|
1343 ;; Make @var{widget} active.
|
|
1344 (widget-apply @var{widget} :activate)
|
|
1345 @end lisp
|
|
1346
|
|
1347 A widget is inactive if itself, or any of its ancestors (found by
|
|
1348 following the @code{:parent} link) have been deactivated. To make sure
|
|
1349 a widget is really active, you must therefore activate both itself, and
|
|
1350 all its ancestors.
|
|
1351
|
|
1352 @lisp
|
|
1353 (while widget
|
|
1354 (widget-apply widget :activate)
|
|
1355 (setq widget (widget-get widget :parent)))
|
|
1356 @end lisp
|
|
1357
|
|
1358 You can check if a widget has been made inactive by examining the value
|
|
1359 of @code{:inactive} keyword. If this is non-nil, the widget itself has
|
|
1360 been deactivated. This is different from using the @code{:active}
|
|
1361 keyword, in that the later tell you if the widget @strong{or} any of its
|
|
1362 ancestors have been deactivated. Do not attempt to set the
|
|
1363 @code{:inactive} keyword directly. Use the @code{:activate}
|
|
1364 @code{:deactivated} keywords instead.
|
|
1365
|
|
1366
|
149
|
1367 @node Defining New Widgets, Widget Browser, Widget Properties, Top
|
98
|
1368 @comment node-name, next, previous, up
|
|
1369 @section Defining New Widgets
|
|
1370
|
|
1371 You can define specialized widgets with @code{define-widget}. It allows
|
|
1372 you to create a shorthand for more complex widgets, including specifying
|
|
1373 component widgets and default new default values for the keyword
|
|
1374 arguments.
|
|
1375
|
|
1376 @defun widget-define name class doc &rest args
|
|
1377 Define a new widget type named @var{name} from @code{class}.
|
|
1378
|
|
1379 @var{name} and class should both be symbols, @code{class} should be one
|
|
1380 of the existing widget types.
|
|
1381
|
|
1382 The third argument @var{DOC} is a documentation string for the widget.
|
|
1383
|
|
1384 After the new widget has been defined, the following two calls will
|
|
1385 create identical widgets:
|
|
1386
|
|
1387 @itemize @bullet
|
|
1388 @item
|
|
1389 @lisp
|
|
1390 (widget-create @var{name})
|
|
1391 @end lisp
|
|
1392
|
|
1393 @item
|
|
1394 @lisp
|
|
1395 (apply widget-create @var{class} @var{args})
|
|
1396 @end lisp
|
|
1397 @end itemize
|
|
1398
|
|
1399 @end defun
|
|
1400
|
|
1401 Using @code{widget-define} does just store the definition of the widget
|
|
1402 type in the @code{widget-type} property of @var{name}, which is what
|
|
1403 @code{widget-create} uses.
|
|
1404
|
|
1405 If you just want to specify defaults for keywords with no complex
|
|
1406 conversions, you can use @code{identity} as your conversion function.
|
|
1407
|
|
1408 The following additional keyword arguments are useful when defining new
|
|
1409 widgets:
|
|
1410 @table @code
|
|
1411 @item :convert-widget
|
|
1412 Function to convert a widget type before creating a widget of that
|
|
1413 type. It takes a widget type as an argument, and returns the converted
|
|
1414 widget type. When a widget is created, this function is called for the
|
|
1415 widget type and all the widgets parent types, most derived first.
|
|
1416
|
149
|
1417 The following predefined functions can be used here:
|
|
1418
|
|
1419 @defun widget-types-convert-widget widget
|
|
1420 Convert @code{:args} as widget types in @var{widget}.
|
|
1421 @end defun
|
|
1422
|
|
1423 @defun widget-value-convert-widget widget
|
|
1424 Initialize @code{:value} from @code{:args} in @var{widget}.
|
|
1425 @end defun
|
|
1426
|
98
|
1427 @item :value-to-internal
|
|
1428 Function to convert the value to the internal format. The function
|
|
1429 takes two arguments, a widget and an external value, and returns the
|
|
1430 internal value. The function is called on the present @code{:value}
|
|
1431 when the widget is created, and on any value set later with
|
|
1432 @code{widget-value-set}.
|
|
1433
|
|
1434 @item :value-to-external
|
|
1435 Function to convert the value to the external format. The function
|
|
1436 takes two arguments, a widget and an internal value, and returns the
|
|
1437 internal value. The function is called on the present @code{:value}
|
|
1438 when the widget is created, and on any value set later with
|
|
1439 @code{widget-value-set}.
|
|
1440
|
|
1441 @item :create
|
|
1442 Function to create a widget from scratch. The function takes one
|
|
1443 argument, a widget type, and create a widget of that type, insert it in
|
|
1444 the buffer, and return a widget object.
|
|
1445
|
|
1446 @item :delete
|
|
1447 Function to delete a widget. The function takes one argument, a widget,
|
|
1448 and should remove all traces of the widget from the buffer.
|
|
1449
|
|
1450 @item :value-create
|
|
1451 Function to expand the @samp{%v} escape in the format string. It will
|
|
1452 be called with the widget as its argument. Should
|
|
1453 insert a representation of the widgets value in the buffer.
|
|
1454
|
|
1455 @item :value-delete
|
|
1456 Should remove the representation of the widgets value from the buffer.
|
|
1457 It will be called with the widget as its argument. It doesn't have to
|
|
1458 remove the text, but it should release markers and delete nested widgets
|
|
1459 if such has been used.
|
|
1460
|
149
|
1461 The following predefined function can be used here:
|
|
1462
|
|
1463 @defun widget-children-value-delete widget
|
|
1464 Delete all @code{:children} and @code{:buttons} in @var{widget}.
|
|
1465 @end defun
|
|
1466
|
|
1467 @item :value-get
|
|
1468 Function to extract the value of a widget, as it is displayed in the
|
|
1469 buffer.
|
|
1470
|
|
1471 The following predefined function can be used here:
|
|
1472
|
|
1473 @defun widget-value-value-get widget
|
|
1474 Return the @code{:value} property of @var{widget}.
|
|
1475 @end defun
|
|
1476
|
98
|
1477 @item :format-handler
|
|
1478 Function to handle unknown @samp{%} escapes in the format string. It
|
|
1479 will be called with the widget and the escape character as arguments.
|
|
1480 You can set this to allow your widget to handle non-standard escapes.
|
|
1481
|
|
1482 You should end up calling @code{widget-default-format-handler} to handle
|
|
1483 unknown escape sequences, which will handle the @samp{%h} and any future
|
|
1484 escape sequences, as well as give an error for unknown escapes.
|
149
|
1485
|
|
1486 @item :action
|
|
1487 Function to handle user initiated events. By default, @code{:notify}
|
|
1488 the parent.
|
|
1489
|
|
1490 The following predefined function can be used here:
|
|
1491
|
|
1492 @defun widget-parent-action widget &optional event
|
|
1493 Tell @code{:parent} of @var{widget} to handle the @code{:action}.@br
|
|
1494 Optional @var{event} is the event that triggered the action.
|
|
1495 @end defun
|
|
1496
|
|
1497 @item :prompt-value
|
|
1498 Function to prompt for a value in the minibuffer. The function should
|
|
1499 take four arguments, @var{widget}, @var{prompt}, @var{value}, and
|
|
1500 @var{unbound} and should return a value for widget entered by the user.
|
|
1501 @var{prompt} is the prompt to use. @var{value} is the default value to
|
|
1502 use, unless @var{unbound} is non-nil in which case there are no default
|
|
1503 value. The function should read the value using the method most natural
|
|
1504 for this widget, and does not have to check that it matches.
|
98
|
1505 @end table
|
|
1506
|
|
1507 If you want to define a new widget from scratch, use the @code{default}
|
|
1508 widget as its base.
|
|
1509
|
149
|
1510 @deffn Widget default
|
98
|
1511 Widget used as a base for other widgets.
|
|
1512
|
|
1513 It provides most of the functionality that is referred to as ``by
|
|
1514 default'' in this text.
|
|
1515 @end deffn
|
|
1516
|
149
|
1517 @node Widget Browser, Widget Minor Mode, Defining New Widgets, Top
|
|
1518 @comment node-name, next, previous, up
|
|
1519 @section Widget Browser
|
|
1520
|
|
1521 There is a separate package to browse widgets. This is intended to help
|
|
1522 programmers who want to examine the content of a widget. The browser
|
|
1523 shows the value of each keyword, but uses links for certain keywords
|
|
1524 such as `:parent', which avoids printing cyclic structures.
|
|
1525
|
|
1526 @deffn Command widget-browse WIDGET
|
|
1527 Create a widget browser for WIDGET.
|
|
1528 When called interactively, prompt for WIDGET.
|
|
1529 @end deffn
|
|
1530
|
|
1531 @deffn Command widget-browse-other-window WIDGET
|
|
1532 Create a widget browser for WIDGET and show it in another window.
|
|
1533 When called interactively, prompt for WIDGET.
|
|
1534 @end deffn
|
|
1535
|
|
1536 @deffn Command widget-browse-at POS
|
|
1537 Create a widget browser for the widget at POS.
|
|
1538 When called interactively, use the position of point.
|
|
1539 @end deffn
|
|
1540
|
|
1541 @node Widget Minor Mode, Utilities, Widget Browser, Top
|
98
|
1542 @comment node-name, next, previous, up
|
149
|
1543 @section Widget Minor Mode
|
|
1544
|
|
1545 There is a minor mode for manipulating widgets in major modes that
|
|
1546 doesn't provide any support for widgets themselves. This is mostly
|
|
1547 intended to be useful for programmers doing experiments.
|
|
1548
|
|
1549 @deffn Command widget-minor-mode
|
|
1550 Togle minor mode for traversing widgets.
|
|
1551 With arg, turn widget mode on if and only if arg is positive.
|
|
1552 @end deffn
|
|
1553
|
|
1554 @defvar widget-minor-mode-keymap
|
|
1555 Keymap used in @code{widget-minor-mode}.
|
|
1556 @end defvar
|
|
1557
|
|
1558 @node Utilities, Widget Wishlist, Widget Minor Mode, Top
|
|
1559 @comment node-name, next, previous, up
|
|
1560 @section Utilities.
|
|
1561
|
|
1562 @defun widget-prompt-value widget prompt [ value unbound ]
|
|
1563 Prompt for a value matching @var{widget}, using @var{prompt}.@br
|
|
1564 The current value is assumed to be @var{value}, unless @var{unbound} is
|
|
1565 non-nil.@refill
|
|
1566 @end defun
|
|
1567
|
|
1568 @defun widget-get-sibling widget
|
|
1569 Get the item @var{widget} is assumed to toggle.@br
|
|
1570 This is only meaningful for radio buttons or checkboxes in a list.
|
|
1571 @end defun
|
|
1572
|
|
1573 @node Widget Wishlist, , Utilities, Top
|
|
1574 @comment node-name, next, previous, up
|
|
1575 @section Wishlist
|
98
|
1576
|
|
1577 @itemize @bullet
|
|
1578 @item
|
|
1579 It should be possible to add or remove items from a list with @kbd{C-k}
|
|
1580 and @kbd{C-o} (suggested by @sc{rms}).
|
|
1581
|
|
1582 @item
|
|
1583 The @samp{[INS]} and @samp{[DEL]} buttons should be replaced by a single
|
|
1584 dash (@samp{-}). The dash should be a button that, when activated, ask
|
|
1585 whether you want to add or delete an item (@sc{rms} wanted to git rid of
|
|
1586 the ugly buttons, the dash is my idea).
|
|
1587
|
|
1588 @item
|
|
1589 The @code{menu-choice} tag should be prettier, something like the abbreviated
|
|
1590 menus in Open Look.
|
|
1591
|
|
1592 @item
|
149
|
1593 Finish @code{:tab-order}.
|
136
|
1594
|
|
1595 @item
|
98
|
1596 Make indentation work with glyphs and propertional fonts.
|
|
1597
|
|
1598 @item
|
149
|
1599 Add commands to show overview of object and class hierarchies to the
|
|
1600 browser.
|
|
1601
|
|
1602 @item
|
|
1603 Find a way to disable mouse highlight for inactive widgets.
|
|
1604
|
|
1605 @item
|
|
1606 Find a way to make glyphs look inactive.
|
|
1607
|
|
1608 @item
|
|
1609 Add @code{property-list} widget.
|
|
1610
|
|
1611 @item
|
|
1612 Add @code{association-list} widget.
|
|
1613
|
|
1614 @item
|
|
1615 Add @code{key-binding} widget.
|
|
1616
|
|
1617 @item
|
|
1618 Add @code{widget} widget for editing widget specifications.
|
|
1619
|
|
1620 @item
|
|
1621 Find clean way to implement variable length list.
|
|
1622 See @code{TeX-printer-list} for an explanation.
|
|
1623
|
|
1624 @item
|
|
1625 @kbd{C-h} in @code{widget-prompt-value} should give type specific help.
|
98
|
1626
|
|
1627 @end itemize
|
|
1628
|
|
1629 @contents
|
|
1630 @bye
|