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