Mercurial > hg > xemacs-beta
comparison man/widget.texi @ 5496:a7da359711ce
Backed out changeset e82f5b7010fe, incompatible with extant makeinfo.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 02 May 2011 10:35:36 +0100 |
parents | e82f5b7010fe |
children | 64be8a494bdc |
comparison
equal
deleted
inserted
replaced
5492:e82f5b7010fe | 5496:a7da359711ce |
---|---|
1 \input texinfo.tex | 1 \input texinfo.tex |
2 | |
2 @c %**start of header | 3 @c %**start of header |
3 @setfilename ../info/widget.info | 4 @setfilename ../info/widget.info |
4 @settitle The Emacs Widget Library | 5 @settitle The Emacs Widget Library |
5 @syncodeindex fn cp | 6 @iftex |
6 @syncodeindex vr cp | 7 @afourpaper |
7 @syncodeindex ky cp | 8 @headings double |
9 @end iftex | |
8 @c %**end of header | 10 @c %**end of header |
9 @c Synced up with: FSF 23.1.92. | |
10 @c Synced by: Ben Wing, 2-17-10. | |
11 | |
12 @copying | |
13 Copyright @copyright{} 2000, 2001, 2002, 2003, 2004, 2005, | |
14 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | |
15 | |
16 @quotation | |
17 Permission is granted to copy, distribute and/or modify this document | |
18 under the terms of the GNU Free Documentation License, Version 1.3 or | |
19 any later version published by the Free Software Foundation; with no | |
20 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'', | |
21 and with the Back-Cover Texts as in (a) below. A copy of the license | |
22 is included in the section entitled ``GNU Free Documentation License''. | |
23 | |
24 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and | |
25 modify this GNU manual. Buying copies from the FSF supports it in | |
26 developing GNU and promoting software freedom.'' | |
27 @end quotation | |
28 @end copying | |
29 | 11 |
30 @ifinfo | 12 @ifinfo |
31 @dircategory XEmacs Editor | 13 @dircategory XEmacs Editor |
32 @direntry | 14 @direntry |
33 * Widget: (widget). The "widget" package used by the Emacs Customization | 15 * Widgets: (widget). The Emacs Widget Library. |
34 facility. | |
35 @end direntry | 16 @end direntry |
36 @end ifinfo | 17 @end ifinfo |
37 | 18 |
38 @contents | |
39 | |
40 @node Top, Introduction, (dir), (dir) | 19 @node Top, Introduction, (dir), (dir) |
41 @comment node-name, next, previous, up | 20 @comment node-name, next, previous, up |
42 @top The Emacs Widget Library | 21 @top The Emacs Widget Library |
43 | |
44 @insertcopying | |
45 | 22 |
46 @menu | 23 @menu |
47 * Introduction:: | 24 * Introduction:: |
48 * User Interface:: | 25 * User Interface:: |
49 * Programming Example:: | 26 * Programming Example:: |
54 * Defining New Widgets:: | 31 * Defining New Widgets:: |
55 * Widget Browser:: | 32 * Widget Browser:: |
56 * Widget Minor Mode:: | 33 * Widget Minor Mode:: |
57 * Utilities:: | 34 * Utilities:: |
58 * Widget Wishlist:: | 35 * Widget Wishlist:: |
59 * Widget Internals:: | 36 * Widget Internals:: |
60 * GNU Free Documentation License:: | |
61 * Index:: | |
62 @detailmenu | |
63 --- The Detailed Node Listing --- | |
64 | |
65 The Emacs Widget Library | |
66 | |
67 * Introduction:: | |
68 * User Interface:: | |
69 * Programming Example:: | |
70 * Setting Up the Buffer:: | |
71 * Basic Types:: | |
72 * Sexp Types:: | |
73 * Widget Properties:: | |
74 * Defining New Widgets:: | |
75 * Widget Browser:: | |
76 * Widget Minor Mode:: | |
77 * Utilities:: | |
78 * Widget Wishlist:: | |
79 * Widget Internals:: | |
80 * GNU Free Documentation License:: | |
81 * Index:: | |
82 | |
83 Basic Types | |
84 | |
85 * link:: | |
86 * url-link:: | |
87 * info-link:: | |
88 * push-button:: | |
89 * editable-field:: | |
90 * text:: | |
91 * menu-choice:: | |
92 * radio-button-choice:: | |
93 * item:: | |
94 * choice-item:: | |
95 * toggle:: | |
96 * checkbox:: | |
97 * checklist:: | |
98 * editable-list:: | |
99 * group:: | |
100 | |
101 Sexp Types | |
102 | |
103 * constants:: | |
104 * generic:: | |
105 * atoms:: | |
106 * composite:: | |
107 | |
108 @end detailmenu | |
109 @end menu | 37 @end menu |
110 | 38 |
111 | |
112 | |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | |
121 @node Introduction, User Interface, Top, Top | 39 @node Introduction, User Interface, Top, Top |
122 @comment node-name, next, previous, up | 40 @comment node-name, next, previous, up |
123 @section Introduction | 41 @section Introduction |
124 | 42 |
125 @c XEmacs changes to reflect history, native widgets, and GTK | 43 @c XEmacs changes to reflect history, native widgets, and GTK |
126 Most graphical user interface toolkits provide | 44 Most graphical user interface toolkits, since Motif and XView, provide |
127 a number of standard user interface controls (sometimes known as | 45 a number of standard user interface controls (sometimes known as |
128 `widgets' or `gadgets'). Historically, Emacs didn't support anything like | 46 `widgets' or `gadgets'). Historically, Emacs didn't support anything like |
129 this, except for its incredible powerful text ``widget''. However, | 47 this, except for its incredible powerful text ``widget''. However, |
130 since XEmacs 21.4, XEmacs has supported ``native'' widgets (GUI controls | 48 since XEmacs 21.4, XEmacs has supported ``native'' widgets (GUI controls |
131 implemented as Lisp APIs in C for the MS Windows, Motif, Athena, and GTK | 49 implemented as Lisp APIs in C for the MS Windows, Motif, Athena, and GTK |
133 toolkit). On the other hand, Emacs does provide the necessary | 51 toolkit). On the other hand, Emacs does provide the necessary |
134 primitives to implement many other widgets within a text buffer, and of | 52 primitives to implement many other widgets within a text buffer, and of |
135 course this is the only way to implement self-contained controls in a | 53 course this is the only way to implement self-contained controls in a |
136 text terminal. The @code{widget} package simplifies this task. | 54 text terminal. The @code{widget} package simplifies this task. |
137 | 55 |
138 @cindex basic widgets | |
139 @cindex widgets, basic types | |
140 Examples of some basic widgets include: | 56 Examples of some basic widgets include: |
141 | 57 |
142 @table @code | 58 @table @code |
143 @item link | 59 @item link |
144 Areas of text with an associated action. Intended for hypertext links | 60 Areas of text with an associated action. Intended for hypertext links |
145 embedded in text. | 61 embedded in text. |
146 @item push-button | 62 @item push-button |
147 Like link, but intended for stand-alone buttons. | 63 Like link, but intended for stand-alone buttons. |
148 @item editable-field | 64 @item editable-field |
149 An editable text field. It can be either variable or fixed length. | 65 An editable text field. It can be either variable or fixed length. |
150 @item menu-choice | 66 @item menu-choice |
151 Allows the user to choose one of multiple options from a menu, each | 67 Allows the user to choose one of multiple options from a menu, each |
155 Allows the user to choose one of multiple options by activating radio | 71 Allows the user to choose one of multiple options by activating radio |
156 buttons. The options are implemented as widgets. All options will be | 72 buttons. The options are implemented as widgets. All options will be |
157 visible in the buffer. | 73 visible in the buffer. |
158 @item item | 74 @item item |
159 A simple constant widget intended to be used in the @code{menu-choice} and | 75 A simple constant widget intended to be used in the @code{menu-choice} and |
160 @code{radio-button-choice} widgets. | 76 @code{radio-button-choice} widgets. |
161 @item choice-item | 77 @item choice-item |
162 A button item only intended for use in choices. When invoked, the user | 78 A button item only intended for use in choices. When invoked, the user |
163 will be asked to select another option from the choice widget. | 79 will be asked to select another option from the choice widget. |
164 @item toggle | 80 @item toggle |
165 A simple @samp{on}/@samp{off} switch. | 81 A simple @samp{on}/@samp{off} switch. |
166 @item checkbox | 82 @item checkbox |
167 A checkbox (@samp{[ ]}/@samp{[X]}). | 83 A checkbox (@samp{[ ]}/@samp{[X]}). |
168 @item editable-list | 84 @item editable-list |
169 Create an editable list. The user can insert or delete items in the | 85 Create an editable list. The user can insert or delete items in the |
170 list. Each list item is itself a widget. | 86 list. Each list item is itself a widget. |
171 @end table | 87 @end table |
172 | 88 |
173 Now, of what possible use can support for widgets be in a text editor? | 89 Now of what possible use can support for widgets be in a text editor? |
174 I'm glad you asked. The answer is that widgets are useful for | 90 I'm glad you asked. The answer is that widgets are useful for |
175 implementing forms. A @dfn{form} in Emacs is a buffer where the user is | 91 implementing forms. A @dfn{form} in Emacs is a buffer where the user is |
176 supposed to fill out a number of fields, each of which has a specific | 92 supposed to fill out a number of fields, each of which has a specific |
177 meaning. The user is not supposed to change or delete any of the text | 93 meaning. The user is not supposed to change or delete any of the text |
178 between the fields. Examples of forms in Emacs are the @file{forms} | 94 between the fields. Examples of forms in Emacs are the @file{forms} |
179 package (of course), the customize buffers, the mail and news compose | 95 package (of course), the customize buffers, the mail and news compose |
180 modes, and the @acronym{HTML} form support in the @file{w3} browser. | 96 modes, and the @sc{html} form support in the @file{w3} browser. |
181 | 97 |
182 @cindex widget library, why use it | |
183 The advantages for a programmer of using the @code{widget} package to | 98 The advantages for a programmer of using the @code{widget} package to |
184 implement forms are: | 99 implement forms are: |
185 | 100 |
186 @enumerate | 101 @enumerate |
187 @item | 102 @item |
188 More complex fields than just editable text are supported. | 103 More complex fields than just editable text are supported. |
189 @item | 104 @item |
190 You can give the users immediate feedback if they enter invalid data in a | 105 You can give the user immediate feedback if he enters invalid data in a |
191 text field, and sometimes prevent entering invalid data. | 106 text field, and sometimes prevent entering invalid data. |
192 @item | 107 @item |
193 You can have fixed sized fields, thus allowing multiple fields to be | 108 You can have fixed sized fields, thus allowing multiple fields to be |
194 lined up in columns. | 109 lined up in columns. |
195 @item | 110 @item |
196 It is simple to query or set the value of a field. | 111 It is simple to query or set the value of a field. |
197 @item | 112 @item |
198 Editing happens in a normal buffer, not in the mini-buffer. | 113 Editing happens in a normal buffer, not in the mini-buffer. |
199 @item | 114 @item |
200 Packages using the library get a uniform look-and-feel, making them easier for | 115 Packages using the library get a uniform look-and-feel, making them easier for |
201 the user to learn. | 116 the user to learn. |
202 @item | 117 @item |
203 As support for embedded graphics improve, the widget library will be | 118 As support for embedded graphics has improved, the widget library will |
204 extended to use the GUI features. This means that your code using the | 119 extended to support it. This means that your code using the widget |
205 widget library will also use the new graphic features automatically. | 120 library will also use the new graphic features automatically. |
206 @item | 121 @item |
207 A widget specification is implemented as a class, and new subclasses can | 122 A widget specification is implemented as a class, and new subclasses can |
208 be derived from any class, by restricting or extending the behavior. | 123 be derived from any class, by restricting or extending the behavior. |
209 @end enumerate | 124 @end enumerate |
210 | 125 |
218 @item wid-edit.el | 133 @item wid-edit.el |
219 Everything else is here. Do not load it explicitly, as | 134 Everything else is here. Do not load it explicitly, as |
220 it will be autoloaded when needed. | 135 it will be autoloaded when needed. |
221 @end table | 136 @end table |
222 | 137 |
223 In order to minimize the code that is loaded by users who does not | |
224 create any widgets, the code has been split in two files: | |
225 | |
226 @table @file | |
227 @item widget.el | |
228 This will declare the user variables, define the function | |
229 @code{widget-define}, and autoload the function @code{widget-create}. | |
230 @item wid-edit.el | |
231 Everything else is here, there is no reason to load it explicitly, as | |
232 it will be autoloaded when needed. | |
233 @end table | |
234 | |
235 @node User Interface, Programming Example, Introduction, Top | 138 @node User Interface, Programming Example, Introduction, Top |
236 @comment node-name, next, previous, up | 139 @comment node-name, next, previous, up |
237 @section User Interface | 140 @section User Interface |
238 | 141 |
239 A form consists of read only text for documentation and some fields, | 142 A form consists of read only text for documentation and some fields, |
240 where each field contains two parts, a tag and a value. The tags are | 143 where each of the fields contains two parts, a tag and a value. The |
241 used to identify the fields, so the documentation can refer to the | 144 tags are used to identify the fields, so the documentation can refer to |
242 @samp{foo field}, meaning the field tagged with @samp{Foo}. Here is an | 145 the foo field, meaning the field tagged with @samp{Foo}. Here is an |
243 example form: | 146 example form: |
244 | 147 |
245 @example | 148 @example |
246 Here is some documentation. | 149 Here is some documentation. |
247 | 150 |
254 | 157 |
255 Numbers: count to three below | 158 Numbers: count to three below |
256 @b{[INS]} @b{[DEL]} @i{One} | 159 @b{[INS]} @b{[DEL]} @i{One} |
257 @b{[INS]} @b{[DEL]} @i{Eh, two?} | 160 @b{[INS]} @b{[DEL]} @i{Eh, two?} |
258 @b{[INS]} @b{[DEL]} @i{Five!} | 161 @b{[INS]} @b{[DEL]} @i{Five!} |
259 @b{[INS]} | 162 @b{[INS]} |
260 | 163 |
261 Select multiple: | 164 Select multiple: |
262 | 165 |
263 @b{[X]} This | 166 @b{[X]} This |
264 @b{[ ]} That | 167 @b{[ ]} That |
274 @end example | 177 @end example |
275 | 178 |
276 The top level widgets in this example are tagged @samp{Name}, | 179 The top level widgets in this example are tagged @samp{Name}, |
277 @samp{Choose}, @samp{Address}, @samp{_other work_}, @samp{Numbers}, | 180 @samp{Choose}, @samp{Address}, @samp{_other work_}, @samp{Numbers}, |
278 @samp{Select multiple}, @samp{Select one}, @samp{[Apply Form]}, and | 181 @samp{Select multiple}, @samp{Select one}, @samp{[Apply Form]}, and |
279 @samp{[Reset Form]}. There are basically two things the user can do | 182 @samp{[Reset Form]}. There are basically two thing the user can do within |
280 within a form, namely editing the editable text fields and activating | 183 a form, namely editing the editable text fields and activating the |
281 the buttons. | 184 buttons. |
282 | 185 |
283 @subsection Editable Text Fields | 186 @subsection Editable Text Fields |
284 | 187 |
285 In the example, the value for the @samp{Name} is most likely displayed | 188 In the example, the value for the @samp{Name} is most likely displayed |
286 in an editable text field, and so are values for each of the members of | 189 in an editable text field, and so are values for each of the members of |
288 available for editing these fields. The only restriction is that each | 191 available for editing these fields. The only restriction is that each |
289 change you make must be contained within a single editable text field. | 192 change you make must be contained within a single editable text field. |
290 For example, capitalizing all text from the middle of one field to the | 193 For example, capitalizing all text from the middle of one field to the |
291 middle of another field is prohibited. | 194 middle of another field is prohibited. |
292 | 195 |
293 Editable text fields are created by the @code{editable-field} widget. | 196 Editing text fields are created by the @code{editable-field} widget. |
294 | |
295 @strong{Warning:} In an @code{editable-field} widget, the editable | |
296 field must not be adjacent to another widget---that won't work. | |
297 You must put some text in between. Either make this text part of | |
298 the @code{editable-field} widget itself, or insert it with | |
299 @code{widget-insert}. | |
300 | |
301 The @code{:format} keyword is useful for generating the necessary | |
302 text; for instance, if you give it a value of @code{"Name: %v "}, | |
303 the @samp{Name: } part will provide the necessary separating text | |
304 before the field and the trailing space will provide the | |
305 separating text after the field. If you don't include the | |
306 @code{:size} keyword, the field will extend to the end of the | |
307 line, and the terminating newline will provide separation after. | |
308 | |
309 @strong{Warning:} In an @code{editable-field} widget, the @samp{%v} escape | |
310 must be preceded by some other text in the @code{:format} string | |
311 (if specified). | |
312 | 197 |
313 The editing text fields are highlighted with the | 198 The editing text fields are highlighted with the |
314 @code{widget-field-face} face, making them easy to find. | 199 @code{widget-field-face} face, making them easy to find. |
315 | 200 |
316 @deffn Face widget-field-face | 201 @deffn Face widget-field-face |
317 Face used for other editing fields. | 202 Face used for other editing fields. |
318 @end deffn | 203 @end deffn |
319 | 204 |
320 @subsection Buttons | 205 @subsection Buttons |
321 | 206 |
322 @cindex widget buttons | |
323 @cindex button widgets | |
324 Some portions of the buffer have an associated @dfn{action}, which can | 207 Some portions of the buffer have an associated @dfn{action}, which can |
325 be @dfn{invoked} by a standard key or mouse command. These portions | 208 be @dfn{invoked} by a standard key or mouse command. These portions |
326 are called @dfn{buttons}. The default commands for activating a button | 209 are called @dfn{buttons}. The default commands for activating a button |
327 are: | 210 are: |
328 | 211 |
332 Invoke the button at @var{pos}, defaulting to point. | 215 Invoke the button at @var{pos}, defaulting to point. |
333 If point is not located on a button, invoke the binding in | 216 If point is not located on a button, invoke the binding in |
334 @code{widget-global-map} (by default the global map). | 217 @code{widget-global-map} (by default the global map). |
335 @end deffn | 218 @end deffn |
336 | 219 |
337 @kindex Mouse-2 @r{(on button widgets}) | 220 @item mouse-2 |
338 @item Mouse-2 | |
339 @deffn Command widget-button-click @var{event} | 221 @deffn Command widget-button-click @var{event} |
340 Invoke the button at the location of the mouse pointer. If the mouse | 222 Invoke the button at the location of the mouse pointer. If the mouse |
341 pointer is located in an editable text field, invoke the binding in | 223 pointer is located in an editable text field, invoke the binding in |
342 @code{widget-global-map} (by default the global map). | 224 @code{widget-global-map} (by default the global map). |
343 @end deffn | 225 @end deffn |
345 | 227 |
346 There are several different kind of buttons, all of which are present in | 228 There are several different kind of buttons, all of which are present in |
347 the example: | 229 the example: |
348 | 230 |
349 @table @emph | 231 @table @emph |
350 @cindex option field tag | 232 @item The Option Field Tags. |
351 @item The Option Field Tags | |
352 When you invoke one of these buttons, you will be asked to choose | 233 When you invoke one of these buttons, you will be asked to choose |
353 between a number of different options. This is how you edit an option | 234 between a number of different options. This is how you edit an option |
354 field. Option fields are created by the @code{menu-choice} widget. In | 235 field. Option fields are created by the @code{menu-choice} widget. In |
355 the example, @samp{@b{Choose}} is an option field tag. | 236 the example, @samp{@b{Choose}} is an option field tag. |
356 @item The @samp{@b{[INS]}} and @samp{@b{[DEL]}} buttons | 237 @item The @samp{@b{[INS]}} and @samp{@b{[DEL]}} buttons. |
357 Activating these will insert or delete elements from an editable list. | 238 Activating these will insert or delete elements from an editable list. |
358 The list is created by the @code{editable-list} widget. | 239 The list is created by the @code{editable-list} widget. |
359 @cindex embedded buttons | 240 @item Embedded Buttons. |
360 @item Embedded Buttons | |
361 The @samp{@b{_other work_}} is an example of an embedded | 241 The @samp{@b{_other work_}} is an example of an embedded |
362 button. Embedded buttons are not associated with any fields, but can serve | 242 button. Embedded buttons are not associated with a fields, but can serve |
363 any purpose, such as implementing hypertext references. They are | 243 any purpose, such as implementing hypertext references. They are |
364 usually created by the @code{link} widget. | 244 usually created by the @code{link} widget. |
365 @item The @samp{@b{[ ]}} and @samp{@b{[X]}} buttons | 245 @item The @samp{@b{[ ]}} and @samp{@b{[X]}} buttons. |
366 Activating one of these will convert it to the other. This is useful | 246 Activating one of these will convert it to the other. This is useful |
367 for implementing multiple-choice fields. You can create them with the | 247 for implementing multiple-choice fields. You can create it wit |
368 @code{checkbox} widget. | 248 @item The @samp{@b{( )}} and @samp{@b{(*)}} buttons. |
369 @item The @samp{@b{( )}} and @samp{@b{(*)}} buttons | |
370 Only one radio button in a @code{radio-button-choice} widget can be | 249 Only one radio button in a @code{radio-button-choice} widget can be |
371 selected at any time. When you invoke one of the unselected radio | 250 selected at any time. When you invoke one of the unselected radio |
372 buttons, it will be selected and the previous selected radio button will | 251 buttons, it will be selected and the previous selected radio button will |
373 become unselected. | 252 become unselected. |
374 @item The @samp{@b{[Apply Form]}} and @samp{@b{[Reset Form]}} buttons | 253 @item The @samp{@b{[Apply Form]}} @samp{@b{[Reset Form]}} buttons. |
375 These are explicit buttons made with the @code{push-button} widget. The | 254 These are explicit buttons made with the @code{push-button} widget. The main |
376 main difference from the @code{link} widget is that the buttons will be | 255 difference from the @code{link} widget is that the buttons are will be |
377 displayed as GUI buttons when possible. | 256 displayed as GUI buttons when possible. |
378 @end table | 257 enough. |
379 | 258 @end table |
380 To make them easier to locate, buttons are emphasized in the buffer. | 259 |
260 To make them easier to locate, buttons are emphasized in the buffer. | |
381 | 261 |
382 @deffn Face widget-button-face | 262 @deffn Face widget-button-face |
383 Face used for buttons. | 263 Face used for buttons. |
384 @end deffn | 264 @end deffn |
385 | 265 |
386 @defopt widget-mouse-face | 266 @defopt widget-mouse-face |
387 Face used for highlighting a button when the mouse pointer moves across | 267 Face used for buttons when the mouse pointer is above it. |
388 it. | |
389 @end defopt | 268 @end defopt |
390 | 269 |
391 @subsection Navigation | 270 @subsection Navigation |
392 | 271 |
393 You can use all the normal Emacs commands to move around in a form | 272 You can use all the normal Emacs commands to move around in a form |
396 @table @kbd | 275 @table @kbd |
397 @item @key{TAB} | 276 @item @key{TAB} |
398 @deffn Command widget-forward &optional count | 277 @deffn Command widget-forward &optional count |
399 Move point @var{count} buttons or editing fields forward. | 278 Move point @var{count} buttons or editing fields forward. |
400 @end deffn | 279 @end deffn |
401 @item @kbd{M-@key{TAB}} | 280 @item @key{M-TAB} |
402 @itemx @kbd{S-@key{TAB}} | |
403 @deffn Command widget-backward &optional count | 281 @deffn Command widget-backward &optional count |
404 Move point @var{count} buttons or editing fields backward. | 282 Move point @var{count} buttons or editing fields backward. |
405 @end deffn | 283 @end deffn |
406 @end table | 284 @end table |
407 | 285 |
408 @node Programming Example, Setting Up the Buffer, User Interface, Top | 286 @node Programming Example, Setting Up the Buffer, User Interface, Top |
409 @comment node-name, next, previous, up | 287 @comment node-name, next, previous, up |
410 @section Programming Example | 288 @section Programming Example |
411 | 289 |
412 @cindex widgets, programming example | 290 Here is the code to implement the user interface example (see @ref{User |
413 @cindex example of using widgets | |
414 Here is the code to implement the user interface example (@pxref{User | |
415 Interface}). | 291 Interface}). |
416 | 292 |
417 @lisp | 293 @lisp |
418 (require 'widget) | 294 (require 'widget) |
419 | 295 |
427 (interactive) | 303 (interactive) |
428 (kill-buffer (get-buffer-create "*Widget Example*")) | 304 (kill-buffer (get-buffer-create "*Widget Example*")) |
429 (switch-to-buffer (get-buffer-create "*Widget Example*")) | 305 (switch-to-buffer (get-buffer-create "*Widget Example*")) |
430 (kill-all-local-variables) | 306 (kill-all-local-variables) |
431 (make-local-variable 'widget-example-repeat) | 307 (make-local-variable 'widget-example-repeat) |
432 (widget-insert "Here is some documentation.\n\n") | 308 (widget-insert "Here is some documentation.\n\nName: ") |
433 (widget-create 'editable-field | 309 (widget-create 'editable-field |
434 :size 13 | 310 :size 13 |
435 :format "Name: %v " ; Text after the field! | 311 "My Name") |
436 "My Name") | |
437 (widget-create 'menu-choice | 312 (widget-create 'menu-choice |
438 :tag "Choose" | 313 :tag "Choose" |
439 :value "This" | 314 :value "This" |
440 :help-echo "Choose me, please!" | 315 :help-echo "Choose me, please!" |
441 :notify (lambda (widget &rest ignore) | 316 :notify (lambda (widget &rest ignore) |
442 (message "%s is a good choice!" | 317 (message "%s is a good choice!" |
443 (widget-value widget))) | 318 (widget-value widget))) |
444 '(item :tag "This option" :value "This") | 319 '(item :tag "This option" :value "This") |
445 '(choice-item "That option") | 320 '(choice-item "That option") |
446 '(editable-field :menu-tag "No option" "Thus option")) | 321 '(editable-field :menu-tag "No option" "Thus option")) |
322 (widget-insert "Address: ") | |
447 (widget-create 'editable-field | 323 (widget-create 'editable-field |
448 :format "Address: %v" | 324 "Some Place\nIn some City\nSome country.") |
449 "Some Place\nIn some City\nSome country.") | |
450 (widget-insert "\nSee also ") | 325 (widget-insert "\nSee also ") |
451 (widget-create 'link | 326 (widget-create 'link |
452 :notify (lambda (&rest ignore) | 327 :notify (lambda (&rest ignore) |
453 (widget-value-set widget-example-repeat | 328 (widget-value-set widget-example-repeat |
454 '("En" "To" "Tre")) | 329 '("En" "To" "Tre")) |
455 (widget-setup)) | 330 (widget-setup)) |
456 "other work") | 331 "other work") |
457 (widget-insert | 332 (widget-insert " for more information.\n\nNumbers: count to three below\n") |
458 " for more information.\n\nNumbers: count to three below\n") | |
459 (setq widget-example-repeat | 333 (setq widget-example-repeat |
460 (widget-create 'editable-list | 334 (widget-create 'editable-list |
461 :entry-format "%i %d %v" | 335 :entry-format "%i %d %v" |
462 :notify (lambda (widget &rest ignore) | 336 :notify (lambda (widget &rest ignore) |
463 (let ((old (widget-get widget | 337 (let ((old (widget-get widget |
483 (message "You selected %s" | 357 (message "You selected %s" |
484 (widget-value widget))) | 358 (widget-value widget))) |
485 '(item "One") '(item "Another One.") '(item "A Final One.")) | 359 '(item "One") '(item "Another One.") '(item "A Final One.")) |
486 (widget-insert "\n") | 360 (widget-insert "\n") |
487 (widget-create 'push-button | 361 (widget-create 'push-button |
488 :notify (lambda (&rest ignore) | 362 :notify (lambda (&rest ignore) |
489 (if (= (length (widget-value widget-example-repeat)) | 363 (if (= (length (widget-value widget-example-repeat)) |
490 3) | 364 3) |
491 (message "Congratulation!") | 365 (message "Congratulation!") |
492 (error "Three was the count!"))) | 366 (error "Three was the count!"))) |
493 "Apply Form") | 367 "Apply Form") |
494 (widget-insert " ") | 368 (widget-insert " ") |
495 (widget-create 'push-button | 369 (widget-create 'push-button |
496 :notify (lambda (&rest ignore) | 370 :notify (lambda (&rest ignore) |
497 (widget-example)) | 371 (widget-example)) |
498 "Reset Form") | 372 "Reset Form") |
521 | 395 |
522 @defun widget-delete widget | 396 @defun widget-delete widget |
523 Delete @var{widget} and remove it from the buffer. | 397 Delete @var{widget} and remove it from the buffer. |
524 @end defun | 398 @end defun |
525 | 399 |
526 @defun widget-setup | 400 @defun widget-setup |
527 Set up a buffer to support widgets. | 401 Setup a buffer to support widgets. |
528 | 402 |
529 This should be called after creating all the widgets and before allowing | 403 This should be called after creating all the widgets and before allowing |
530 the user to edit them. | 404 the user to edit them. |
531 @refill | 405 @refill |
532 @end defun | 406 @end defun |
533 | 407 |
534 If you want to insert text outside the widgets in the form, the | 408 If you want to insert text outside the widgets in the form, the |
535 recommended way to do that is with @code{widget-insert}. | 409 recommended way to do that is with @code{widget-insert}. |
536 | 410 |
537 @defun widget-insert | 411 @defun widget-insert |
538 Insert the arguments, either strings or characters, at point. | 412 Insert the arguments, either strings or characters, at point. |
539 The inserted text will be read-only. | 413 The inserted text will be read only. |
540 @end defun | 414 @end defun |
541 | 415 |
542 There is a standard widget keymap which you might find useful. | 416 There is a standard widget keymap which you might find useful. |
543 | 417 |
544 @findex widget-button-press | |
545 @findex widget-button-click | |
546 @defvr Const widget-keymap | 418 @defvr Const widget-keymap |
547 A keymap with the global keymap as its parent.@* | 419 A keymap with the global keymap as its parent.@* |
548 @key{TAB} and @kbd{C-@key{TAB}} are bound to @code{widget-forward} and | 420 @key{TAB} and @kbd{C-@key{TAB}} are bound to @code{widget-forward} and |
549 @code{widget-backward}, respectively. @key{RET} and @kbd{Mouse-2} | 421 @code{widget-backward}, respectively. @kbd{@key{RET}} and @kbd{mouse-2} |
550 are bound to @code{widget-button-press} and | 422 are bound to @code{widget-button-press} and |
551 @code{widget-button-click}.@refill | 423 @code{widget-button-}.@refill |
552 @end defvr | 424 @end defvr |
553 | 425 |
554 @defvar widget-global-map | 426 @defvar widget-global-map |
555 Keymap used by @code{widget-button-press} and @code{widget-button-click} | 427 Keymap used by @code{widget-button-press} and @code{widget-button-click} |
556 when not on a button. By default this is @code{global-map}. | 428 when not on a button. By default this is @code{global-map}. |
558 | 430 |
559 @node Basic Types, Sexp Types, Setting Up the Buffer, Top | 431 @node Basic Types, Sexp Types, Setting Up the Buffer, Top |
560 @comment node-name, next, previous, up | 432 @comment node-name, next, previous, up |
561 @section Basic Types | 433 @section Basic Types |
562 | 434 |
563 This is the general syntax of a type specification: | 435 The syntax of a type specification is given below: |
564 | 436 |
565 @example | 437 @example |
566 @var{name} ::= (@var{name} [@var{keyword} @var{argument}]... @var{args}) | 438 NAME ::= (NAME [KEYWORD ARGUMENT]... ARGS) |
567 | @var{name} | 439 | NAME |
568 @end example | 440 @end example |
569 | 441 |
570 where @var{name} is a widget name, @var{keyword} is the name of a | 442 where @var{name} is a widget name, @var{keyword} is the name of a |
571 property, @var{argument} is the value of the property, and @var{args} | 443 property, @var{argument} is the value of the property, and @var{args} |
572 are interpreted in a widget specific way. | 444 are interpreted in a widget specific way. |
573 | 445 |
574 @cindex keyword arguments | 446 There following keyword arguments that apply to all widgets: |
575 The following keyword arguments apply to all widgets: | |
576 | 447 |
577 @table @code | 448 @table @code |
578 @vindex value@r{ keyword} | |
579 @item :value | 449 @item :value |
580 The initial value for widgets of this type. | 450 The initial value for widgets of this type. |
581 | 451 |
582 @vindex format@r{ keyword} | |
583 @item :format | 452 @item :format |
584 This string will be inserted in the buffer when you create a widget. | 453 This string will be inserted in the buffer when you create a widget. |
585 The following @samp{%} escapes are available: | 454 The following @samp{%} escapes are available: |
586 | 455 |
587 @table @samp | 456 @table @samp |
588 @item %[ | 457 @item %[ |
589 @itemx %] | 458 @itemx %] |
590 The text inside will be marked as a button. | 459 The text inside will be marked as a button. |
591 | 460 |
592 By default, the text will be shown in @code{widget-button-face}, and | 461 By default, the text will be shown in @code{widget-button-face}, and |
593 surrounded by brackets. | 462 surrounded by brackets. |
594 | 463 |
595 @defopt widget-button-prefix | 464 @defopt widget-button-prefix |
596 String to prefix buttons. | 465 String to prefix buttons. |
597 @end defopt | 466 @end defopt |
598 | 467 |
606 @code{:sample-face}. | 475 @code{:sample-face}. |
607 | 476 |
608 @item %v | 477 @item %v |
609 This will be replaced with the buffer representation of the widget's | 478 This will be replaced with the buffer representation of the widget's |
610 value. What this is depends on the widget type. | 479 value. What this is depends on the widget type. |
611 | |
612 @strong{Warning:} In an @code{editable-field} widget, the @samp{%v} escape | |
613 must be preceded by some other text in the format string (if specified). | |
614 | 480 |
615 @item %d | 481 @item %d |
616 Insert the string specified by @code{:doc} here. | 482 Insert the string specified by @code{:doc} here. |
617 | 483 |
618 @item %h | 484 @item %h |
627 @item %t | 493 @item %t |
628 Insert the string specified by @code{:tag} here, or the @code{princ} | 494 Insert the string specified by @code{:tag} here, or the @code{princ} |
629 representation of the value if there is no tag. | 495 representation of the value if there is no tag. |
630 | 496 |
631 @item %% | 497 @item %% |
632 Insert a literal @samp{%}. | 498 Insert a literal @samp{%}. |
633 @end table | 499 @end table |
634 | 500 |
635 @vindex button-face@r{ keyword} | |
636 @item :button-face | 501 @item :button-face |
637 Face used to highlight text inside %[ %] in the format. | 502 Face used to highlight text inside %[ %] in the format. |
638 | 503 |
639 @vindex button-prefix@r{ keyword} | |
640 @vindex button-suffix@r{ keyword} | |
641 @item :button-prefix | 504 @item :button-prefix |
642 @itemx :button-suffix | 505 @itemx :button-suffix |
506 | |
643 Text around %[ %] in the format. | 507 Text around %[ %] in the format. |
644 | 508 |
645 These can be | 509 These can be |
646 @table @emph | 510 @table @emph |
647 @item nil | 511 @item nil |
652 | 516 |
653 @item a symbol | 517 @item a symbol |
654 The value of the symbol is expanded according to this table. | 518 The value of the symbol is expanded according to this table. |
655 @end table | 519 @end table |
656 | 520 |
657 @vindex doc@r{ keyword} | |
658 @item :doc | 521 @item :doc |
659 The string inserted by the @samp{%d} or @samp{%h} escape in the format | 522 The string inserted by the @samp{%d} or @samp{%h} escape in the format |
660 string. | 523 string. |
661 | 524 |
662 @vindex tag@r{ keyword} | |
663 @item :tag | 525 @item :tag |
664 The string inserted by the @samp{%t} escape in the format | 526 The string inserted by the @samp{%t} escape in the format |
665 string. | 527 string. |
666 | 528 |
667 @vindex tag-glyph@r{ keyword} | |
668 @item :tag-glyph | 529 @item :tag-glyph |
669 Name of image to use instead of the string specified by @code{:tag} on | 530 Name of image to use instead of the string specified by `:tag' on |
670 Emacsen that supports it. | 531 Emacsen that supports it. |
671 | 532 |
672 @vindex help-echo@r{ keyword} | |
673 @item :help-echo | 533 @item :help-echo |
674 Specifies how to display a message whenever you move to the widget with | 534 Message displayed whenever you move to the widget with either |
675 either @code{widget-forward} or @code{widget-backward} or move the mouse | 535 @code{widget-forward} or @code{widget-backward}. |
676 over it (using the standard @code{help-echo} mechanism). The argument | 536 |
677 is either a string to display, a function of one argument, the widget, | |
678 which should return a string to display, or a form that evaluates to | |
679 such a string. | |
680 | |
681 @vindex follow-link@r{ keyword} | |
682 @item :follow-link | |
683 Specifies how to interpret a @key{mouse-1} click on the widget. | |
684 @xref{Clickable Text,, Defining Clickable Text, elisp, the Emacs Lisp Reference Manual}. | |
685 | |
686 @vindex indent@r{ keyword} | |
687 @item :indent | 537 @item :indent |
688 An integer indicating the absolute number of spaces to indent children | 538 An integer indicating the absolute number of spaces to indent children |
689 of this widget. | 539 of this widget. |
690 | 540 |
691 @vindex offset@r{ keyword} | |
692 @item :offset | 541 @item :offset |
693 An integer indicating how many extra spaces to add to the widget's | 542 An integer indicating how many extra spaces to add to the widget's |
694 grandchildren compared to this widget. | 543 grandchildren compared to this widget. |
695 | 544 |
696 @vindex extra-offset@r{ keyword} | |
697 @item :extra-offset | 545 @item :extra-offset |
698 An integer indicating how many extra spaces to add to the widget's | 546 An integer indicating how many extra spaces to add to the widget's |
699 children compared to this widget. | 547 children compared to this widget. |
700 | 548 |
701 @vindex notify@r{ keyword} | |
702 @item :notify | 549 @item :notify |
703 A function called each time the widget or a nested widget is changed. | 550 A function called each time the widget or a nested widget is changed. |
704 The function is called with two or three arguments. The first argument | 551 The function is called with two or three arguments. The first argument |
705 is the widget itself, the second argument is the widget that was | 552 is the widget itself, the second argument is the widget that was |
706 changed, and the third argument is the event leading to the change, if | 553 changed, and the third argument is the event leading to the change, if |
707 any. In editable fields, this includes all insertions, deletions, | 554 any. In editable fields, this includes all insertions, deletions, |
708 @emph{etc}. To watch only for ``final'' actions, redefine the | 555 @emph{etc}. To watch only for ``final'' actions, redefine the |
709 @code{:action} callback. | 556 @code{:action} callback. |
710 | 557 |
711 @vindex menu-tag@r{ keyword} | |
712 @item :menu-tag | 558 @item :menu-tag |
713 Tag used in the menu when the widget is used as an option in a | 559 Tag used in the menu when the widget is used as an option in a |
714 @code{menu-choice} widget. | 560 @code{menu-choice} widget. |
715 | 561 |
716 @vindex menu-tag-get@r{ keyword} | |
717 @item :menu-tag-get | 562 @item :menu-tag-get |
718 Function used for finding the tag when the widget is used as an option | 563 Function used for finding the tag when the widget is used as an option |
719 in a @code{menu-choice} widget. By default, the tag used will be either the | 564 in a @code{menu-choice} widget. By default, the tag used will be either the |
720 @code{:menu-tag} or @code{:tag} property if present, or the @code{princ} | 565 @code{:menu-tag} or @code{:tag} property if present, or the @code{princ} |
721 representation of the @code{:value} property if not. | 566 representation of the @code{:value} property if not. |
722 | 567 |
723 @vindex match@r{ keyword} | |
724 @item :match | 568 @item :match |
725 Should be a function called with two arguments, the widget and a value, | 569 Should be a function called with two arguments, the widget and a value, |
726 and returning non-@code{nil} if the widget can represent the specified value. | 570 and returning non-nil if the widget can represent the specified value. |
727 | 571 |
728 @vindex validate@r{ keyword} | |
729 @item :validate | 572 @item :validate |
730 A function which takes a widget as an argument, and returns @code{nil} | 573 A function which takes a widget as an argument, and returns nil if the |
731 if the widget's current value is valid for the widget. Otherwise it | 574 widget's current value is valid for the widget. Otherwise it should |
732 should return the widget containing the invalid data, and set that | 575 return the widget containing the invalid data, and set that widget's |
733 widget's @code{:error} property to a string explaining the error. | 576 @code{:error} property to a string explaining the error. |
734 | 577 |
735 The following predefined function can be used: | 578 The following predefined function can be used: |
736 | 579 |
737 @defun widget-children-validate widget | 580 @defun widget-children-validate widget |
738 All the @code{:children} of @var{widget} must be valid. | 581 All the @code{:children} of @var{widget} must be valid. |
739 @end defun | 582 @end defun |
740 | 583 |
741 @vindex tab-order@r{ keyword} | |
742 @item :tab-order | 584 @item :tab-order |
743 Specify the order in which widgets are traversed with | 585 Specify the order in which widgets are traversed with |
744 @code{widget-forward} or @code{widget-backward}. This is only partially | 586 @code{widget-forward} or @code{widget-backward}. This is only partially |
745 implemented. | 587 implemented. |
746 | 588 |
747 @enumerate a | 589 @enumerate a |
748 @item | 590 @item |
749 Widgets with tabbing order @code{-1} are ignored. | 591 Widgets with tabbing order @code{-1} are ignored. |
750 | 592 |
751 @item | 593 @item |
752 (Unimplemented) When on a widget with tabbing order @var{n}, go to the | 594 (Unimplemented) When on a widget with tabbing order @var{n}, go to the |
753 next widget in the buffer with tabbing order @var{n+1} or @code{nil}, | 595 next widget in the buffer with tabbing order @var{n+1} or @code{nil}, |
754 whichever comes first. | 596 whichever comes first. |
755 | 597 |
756 @item | 598 @item |
757 When on a widget with no tabbing order specified, go to the next widget | 599 When on a widget with no tabbing order specified, go to the next widget |
758 in the buffer with a positive tabbing order, or @code{nil} | 600 in the buffer with a positive tabbing order, or @code{nil} |
759 @end enumerate | 601 @end enumerate |
760 | 602 |
761 @vindex parent@r{ keyword} | |
762 @item :parent | 603 @item :parent |
763 The parent of a nested widget (e.g.@: a @code{menu-choice} item or an | 604 The parent of a nested widget (e.g. a @code{menu-choice} item or an |
764 element of an @code{editable-list} widget). | 605 element of an @code{editable-list} widget). |
765 | 606 |
766 @vindex sibling-args@r{ keyword} | |
767 @item :sibling-args | 607 @item :sibling-args |
768 This keyword is only used for members of a @code{radio-button-choice} or | 608 This keyword is only used for members of a @code{radio-button-choice} or |
769 @code{checklist}. The value should be a list of extra keyword | 609 @code{checklist}. The value should be a list of extra keyword |
770 arguments, which will be used when creating the @code{radio-button} or | 610 arguments, which will be used when creating the @code{radio-button} or |
771 @code{checkbox} associated with this item. | 611 @code{checkbox} associated with this item. |
772 | 612 |
773 @end table | 613 @end table |
774 | 614 |
775 @deffn {User Option} widget-glyph-directory | 615 @deffn {User Option} widget-glyph-directory |
776 Directory where glyphs are found. | 616 Directory where glyphs are found. |
777 Widget will look here for a file with the same name as specified for the | 617 Widget will look here for a file with the same name as specified for the |
778 image, with either a @file{.xpm} (if supported) or @file{.xbm} extension. | 618 image, with either a @samp{.xpm} (if supported) or @samp{.xbm} extension. |
779 @end deffn | 619 @end deffn |
780 | 620 |
781 @deffn{User Option} widget-glyph-enable | 621 @deffn{User Option} widget-glyph-enable |
782 If non-@code{nil}, allow glyphs to appear on displays where they are supported. | 622 If non-nil, allow glyphs to appear on displays where they are supported. |
783 @end deffn | 623 @end deffn |
784 | 624 |
785 | 625 |
786 @menu | 626 @menu |
787 * link:: | 627 * link:: |
802 @end menu | 642 @end menu |
803 | 643 |
804 @node link, url-link, Basic Types, Basic Types | 644 @node link, url-link, Basic Types, Basic Types |
805 @comment node-name, next, previous, up | 645 @comment node-name, next, previous, up |
806 @subsection The @code{link} Widget | 646 @subsection The @code{link} Widget |
807 @findex link@r{ widget} | |
808 | 647 |
809 Syntax: | 648 Syntax: |
810 | 649 |
811 @example | 650 @example |
812 @var{type} ::= (link [@var{keyword} @var{argument}]... [ @var{value} ]) | 651 TYPE ::= (link [KEYWORD ARGUMENT]... [ VALUE ]) |
813 @end example | 652 @end example |
814 | 653 |
815 The @var{value}, if present, is used to initialize the @code{:value} | 654 The @var{value}, if present, is used to initialize the @code{:value} |
816 property. The value should be a string, which will be inserted in the | 655 property. The value should be a string, which will be inserted in the |
817 buffer. | 656 buffer. |
818 | 657 |
819 By default the link will be shown in brackets. | 658 By default the link will be shown in brackets. |
820 | 659 |
821 @defopt widget-link-prefix | 660 @defopt widget-link-prefix |
822 String to prefix links. | 661 String to prefix links. |
827 @end defopt | 666 @end defopt |
828 | 667 |
829 @node url-link, info-link, link, Basic Types | 668 @node url-link, info-link, link, Basic Types |
830 @comment node-name, next, previous, up | 669 @comment node-name, next, previous, up |
831 @subsection The @code{url-link} Widget | 670 @subsection The @code{url-link} Widget |
832 @findex url-link@r{ widget} | |
833 | 671 |
834 Syntax: | 672 Syntax: |
835 | 673 |
836 @example | 674 @example |
837 @var{type} ::= (url-link [@var{keyword} @var{argument}]... @var{url}) | 675 TYPE ::= (url-link [KEYWORD ARGUMENT]... URL) |
838 @end example | 676 @end example |
839 | 677 |
840 @findex browse-url-browser-function@r{, and @code{url-link} widget} | 678 When this link is invoked, the @sc{www} browser specified by |
841 When this link is invoked, the @acronym{WWW} browser specified by | 679 @code{browse-url-browser-function} will be called with @var{url}. |
842 @code{browse-url-browser-function} will be called with @var{url}. | |
843 | 680 |
844 @node info-link, push-button, url-link, Basic Types | 681 @node info-link, push-button, url-link, Basic Types |
845 @comment node-name, next, previous, up | 682 @comment node-name, next, previous, up |
846 @subsection The @code{info-link} Widget | 683 @subsection The @code{info-link} Widget |
847 @findex info-link@r{ widget} | |
848 | 684 |
849 Syntax: | 685 Syntax: |
850 | 686 |
851 @example | 687 @example |
852 @var{type} ::= (info-link [@var{keyword} @var{argument}]... @var{address}) | 688 TYPE ::= (info-link [KEYWORD ARGUMENT]... ADDRESS) |
853 @end example | 689 @end example |
854 | 690 |
855 When this link is invoked, the built-in Info reader is started on | 691 When this link is invoked, the built-in info browser is started on |
856 @var{address}. | 692 @var{address}. |
857 | 693 |
858 @node push-button, editable-field, info-link, Basic Types | 694 @node push-button, editable-field, info-link, Basic Types |
859 @comment node-name, next, previous, up | 695 @comment node-name, next, previous, up |
860 @subsection The @code{push-button} Widget | 696 @subsection The @code{push-button} Widget |
861 @findex push-button@r{ widget} | |
862 | 697 |
863 Syntax: | 698 Syntax: |
864 | 699 |
865 @example | 700 @example |
866 @var{type} ::= (push-button [@var{keyword} @var{argument}]... [ @var{value} ]) | 701 TYPE ::= (push-button [KEYWORD ARGUMENT]... [ VALUE ]) |
867 @end example | 702 @end example |
868 | 703 |
869 The @var{value}, if present, is used to initialize the @code{:value} | 704 The @var{value}, if present, is used to initialize the @code{:value} |
870 property. The value should be a string, which will be inserted in the | 705 property. The value should be a string, which will be inserted in the |
871 buffer. | 706 buffer. |
872 | 707 |
873 By default the tag will be shown in brackets. | 708 By default the tag will be shown in brackets. |
874 | 709 |
875 @defopt widget-push-button-prefix | 710 @defopt widget-push-button-prefix |
876 String to prefix push buttons. | 711 String to prefix push buttons. |
881 @end defopt | 716 @end defopt |
882 | 717 |
883 @node editable-field, text, push-button, Basic Types | 718 @node editable-field, text, push-button, Basic Types |
884 @comment node-name, next, previous, up | 719 @comment node-name, next, previous, up |
885 @subsection The @code{editable-field} Widget | 720 @subsection The @code{editable-field} Widget |
886 @findex editable-field@r{ widget} | |
887 | 721 |
888 Syntax: | 722 Syntax: |
889 | 723 |
890 @example | 724 @example |
891 @var{type} ::= (editable-field [@var{keyword} @var{argument}]... [ @var{value} ]) | 725 TYPE ::= (editable-field [KEYWORD ARGUMENT]... [ VALUE ]) |
892 @end example | 726 @end example |
893 | 727 |
894 The @var{value}, if present, is used to initialize the @code{:value} | 728 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 | 729 property. The value should be a string, which will be inserted in |
896 field. This widget will match all string values. | 730 field. This widget will match all string values. |
897 | 731 |
898 The following extra properties are recognized: | 732 The following extra properties are recognized. |
899 | 733 |
900 @table @code | 734 @table @code |
901 @vindex size@r{ keyword} | |
902 @item :size | 735 @item :size |
903 The minimum width of the editable field.@* | 736 The minimum width of the editable field.@* |
904 By default the field will reach to the end of the line. If the | 737 By default the field will reach to the end of the line. If the |
905 content is too large, the displayed representation will expand to | 738 content is too large, the displayed representation will expand to |
906 contain it. The content is not truncated to size. | 739 contain it. The content is not truncated to size. |
907 | 740 |
908 @vindex value-face@r{ keyword} | |
909 @item :value-face | 741 @item :value-face |
910 Face used for highlighting the editable field. Default is | 742 Face used for highlighting the editable field. Default is |
911 @code{widget-field-face}, see @ref{User Interface}. | 743 @code{widget-field-face}. |
912 | 744 |
913 @vindex secret@r{ keyword} | |
914 @item :secret | 745 @item :secret |
915 Character used to display the value. You can set this to e.g.@: @code{?*} | 746 Character used to display the value. You can set this to e.g. @code{?*} |
916 if the field contains a password or other secret information. By | 747 if the field contains a password or other secret information. By |
917 default, this is @code{nil}, and the value is not secret. | 748 default, the value is not secret. |
918 | 749 |
919 @vindex valid-regexp@r{ keyword} | |
920 @item :valid-regexp | 750 @item :valid-regexp |
921 By default the @code{:validate} function will match the content of the | 751 By default the @code{:validate} function will match the content of the |
922 field with the value of this attribute. The default value is @code{""} | 752 field with the value of this attribute. The default value is @code{""} |
923 which matches everything. | 753 which matches everything. |
924 | 754 |
925 @vindex keymap@r{ keyword} | |
926 @vindex widget-field-keymap | |
927 @item :keymap | 755 @item :keymap |
928 Keymap used in the editable field. The default value is | 756 Keymap used in the editable field. The default value is |
929 @code{widget-field-keymap}, which allows you to use all the normal | 757 @code{widget-field-keymap}, which allows you to use all the normal |
930 editing commands, even if the buffer's major mode suppresses some of | 758 editing commands, even if the buffer's major mode suppress some of them. |
931 them. Pressing @key{RET} invokes the function specified by | 759 Pressing return invokes the function specified by @code{:action}. |
932 @code{:action}. | |
933 @end table | 760 @end table |
934 | 761 |
935 @node text, menu-choice, editable-field, Basic Types | 762 @node text, menu-choice, editable-field, Basic Types |
936 @comment node-name, next, previous, up | 763 @comment node-name, next, previous, up |
937 @subsection The @code{text} Widget | 764 @subsection The @code{text} Widget |
938 @findex text@r{ widget} | 765 |
939 | |
940 @vindex widget-text-keymap | |
941 This is just like @code{editable-field}, but intended for multiline text | 766 This is just like @code{editable-field}, but intended for multiline text |
942 fields. The default @code{:keymap} is @code{widget-text-keymap}, which | 767 fields. The default @code{:keymap} is @code{widget-text-keymap}, which |
943 does not rebind the @key{RET} key. | 768 does not rebind the return key. |
944 | 769 |
945 @node menu-choice, radio-button-choice, text, Basic Types | 770 @node menu-choice, radio-button-choice, text, Basic Types |
946 @comment node-name, next, previous, up | 771 @comment node-name, next, previous, up |
947 @subsection The @code{menu-choice} Widget | 772 @subsection The @code{menu-choice} Widget |
948 @findex menu-choice@r{ widget} | |
949 | 773 |
950 Syntax: | 774 Syntax: |
951 | 775 |
952 @example | 776 @example |
953 @var{type} ::= (menu-choice [@var{keyword} @var{argument}]... @var{type} ... ) | 777 TYPE ::= (menu-choice [KEYWORD ARGUMENT]... TYPE ... ) |
954 @end example | 778 @end example |
955 | 779 |
956 The @var{type} argument represents each possible choice. The widget's | 780 The @var{type} argument represents each possible choice. The widget's |
957 value will be that of the chosen @var{type} argument. This widget will | 781 value will be that of the chosen @var{type} argument. This widget will |
958 match any value matching at least one of the specified @var{type} | 782 match any value matching at least one of the specified @var{type} |
959 arguments. | 783 arguments. |
960 | 784 |
961 @table @code | 785 @table @code |
962 @vindex void@r{ keyword} | 786 @item :void |
963 @item :void | |
964 Widget type used as a fallback when the value does not match any of the | 787 Widget type used as a fallback when the value does not match any of the |
965 specified @var{type} arguments. | 788 specified @var{type} arguments. |
966 | 789 |
967 @vindex case-fold@r{ keyword} | |
968 @item :case-fold | 790 @item :case-fold |
969 Set this to @code{nil} if you don't want to ignore case when prompting for a | 791 Set this to nil if you don't want to ignore case when prompting for a |
970 choice through the minibuffer. | 792 choice through the minibuffer. |
971 | 793 |
972 @vindex children@r{ keyword} | |
973 @item :children | 794 @item :children |
974 A list whose @sc{car} is the widget representing the currently chosen | 795 A list whose car is the widget representing the currently chosen type in |
975 type in the buffer. | 796 the buffer. |
976 | 797 |
977 @vindex choice@r{ keyword} | |
978 @item :choice | 798 @item :choice |
979 The current chosen type. | 799 The current chosen type |
980 | 800 |
981 @vindex args@r{ keyword} | 801 @item :args |
982 @item :args | 802 The list of types. |
983 The list of types. | |
984 @end table | 803 @end table |
985 | 804 |
986 @node radio-button-choice, item, menu-choice, Basic Types | 805 @node radio-button-choice, item, menu-choice, Basic Types |
987 @comment node-name, next, previous, up | 806 @comment node-name, next, previous, up |
988 @subsection The @code{radio-button-choice} Widget | 807 @subsection The @code{radio-button-choice} Widget |
989 @findex radio-button-choice@r{ widget} | |
990 | 808 |
991 Syntax: | 809 Syntax: |
992 | 810 |
993 @example | 811 @example |
994 @var{type} ::= (radio-button-choice [@var{keyword} @var{argument}]... @var{type} ... ) | 812 TYPE ::= (radio-button-choice [KEYWORD ARGUMENT]... TYPE ... ) |
995 @end example | 813 @end example |
996 | 814 |
997 The component types specify the choices, with one radio button for | 815 The @var{type} argument represents each possible choice. The widget's |
998 each. The widget's value will be that of the chosen @var{type} | 816 value will be that of the chosen @var{type} argument. This widget will |
999 argument. This widget matches any value that matches at least one of | 817 match any value matching at least one of the specified @var{type} |
1000 the specified @var{type} arguments. | 818 arguments. |
1001 | 819 |
1002 The following extra properties are recognized. | 820 The following extra properties are recognized. |
1003 | 821 |
1004 @table @code | 822 @table @code |
1005 @vindex entry-format@r{ keyword} | |
1006 @item :entry-format | 823 @item :entry-format |
1007 This string will be inserted for each entry in the list. | 824 This string will be inserted for each entry in the list. |
1008 The following @samp{%} escapes are available: | 825 The following @samp{%} escapes are available: |
1009 @table @samp | 826 @table @samp |
1010 @item %v | 827 @item %v |
1011 Replace with the buffer representation of the @var{type} widget. | 828 Replaced with the buffer representation of the @var{type} widget. |
1012 @item %b | 829 @item %b |
1013 Replace with the radio button. | 830 Replace with the radio button. |
1014 @item %% | 831 @item %% |
1015 Insert a literal @samp{%}. | 832 Insert a literal @samp{%}. |
1016 @end table | 833 @end table |
1017 | 834 |
1018 @vindex button-args@r{ keyword} | 835 @item button-args |
1019 @item :button-args | |
1020 A list of keywords to pass to the radio buttons. Useful for setting | 836 A list of keywords to pass to the radio buttons. Useful for setting |
1021 e.g.@: the @samp{:help-echo} for each button. | 837 e.g. the @samp{:help-echo} for each button. |
1022 | 838 |
1023 @vindex buttons@r{ keyword} | |
1024 @item :buttons | 839 @item :buttons |
1025 The widgets representing the radio buttons. | 840 The widgets representing the radio buttons. |
1026 | 841 |
1027 @vindex children@r{ keyword} | |
1028 @item :children | 842 @item :children |
1029 The widgets representing each type. | 843 The widgets representing each type. |
1030 | 844 |
1031 @vindex choice@r{ keyword} | |
1032 @item :choice | 845 @item :choice |
1033 The current chosen type | 846 The current chosen type |
1034 | 847 |
1035 @vindex args@r{ keyword} | 848 @item :args |
1036 @item :args | 849 The list of types. |
1037 The list of types. | |
1038 @end table | 850 @end table |
1039 | 851 |
1040 You can add extra radio button items to a @code{radio-button-choice} | 852 You can add extra radio button items to a @code{radio-button-choice} |
1041 widget after it has been created with the function | 853 widget after it has been created with the function |
1042 @code{widget-radio-add-item}. | 854 @code{widget-radio-add-item}. |
1043 | 855 |
1044 @defun widget-radio-add-item widget type | 856 @defun widget-radio-add-item widget type |
1045 Add to @code{radio-button-choice} widget @var{widget} a new radio button | 857 Add to @code{radio-button-choice} widget @var{widget} a new radio button item of type |
1046 item of type @var{type}. | 858 @var{type}. |
1047 @end defun | 859 @end defun |
1048 | 860 |
1049 Please note that such items added after the @code{radio-button-choice} | 861 Please note that such items added after the @code{radio-button-choice} |
1050 widget has been created will @strong{not} be properly destructed when | 862 widget has been created will @strong{not} be properly destructed when |
1051 you call @code{widget-delete}. | 863 you call @code{widget-delete}. |
1052 | 864 |
1053 @node item, choice-item, radio-button-choice, Basic Types | 865 @node item, choice-item, radio-button-choice, Basic Types |
1054 @comment node-name, next, previous, up | 866 @comment node-name, next, previous, up |
1055 @subsection The @code{item} Widget | 867 @subsection The @code{item} Widget |
1056 @findex item@r{ widget} | |
1057 | 868 |
1058 Syntax: | 869 Syntax: |
1059 | 870 |
1060 @example | 871 @example |
1061 @var{item} ::= (item [@var{keyword} @var{argument}]... @var{value}) | 872 ITEM ::= (item [KEYWORD ARGUMENT]... VALUE) |
1062 @end example | 873 @end example |
1063 | 874 |
1064 The @var{value}, if present, is used to initialize the @code{:value} | 875 The @var{value}, if present, is used to initialize the @code{:value} |
1065 property. The value should be a string, which will be inserted in the | 876 property. The value should be a string, which will be inserted in the |
1066 buffer. This widget will only match the specified value. | 877 buffer. This widget will only match the specified value. |
1067 | 878 |
1068 @node choice-item, toggle, item, Basic Types | 879 @node choice-item, toggle, item, Basic Types |
1069 @comment node-name, next, previous, up | 880 @comment node-name, next, previous, up |
1070 @subsection The @code{choice-item} Widget | 881 @subsection The @code{choice-item} Widget |
1071 @findex choice-item@r{ widget} | |
1072 | 882 |
1073 Syntax: | 883 Syntax: |
1074 | 884 |
1075 @example | 885 @example |
1076 @var{item} ::= (choice-item [@var{keyword} @var{argument}]... @var{value}) | 886 ITEM ::= (choice-item [KEYWORD ARGUMENT]... VALUE) |
1077 @end example | 887 @end example |
1078 | 888 |
1079 The @var{value}, if present, is used to initialize the @code{:value} | 889 The @var{value}, if present, is used to initialize the @code{:value} |
1080 property. The value should be a string, which will be inserted in the | 890 property. The value should be a string, which will be inserted in the |
1081 buffer as a button. Activating the button of a @code{choice-item} is | 891 buffer as a button. Activating the button of a @code{choice-item} is |
1082 equivalent to activating the parent widget. This widget will only match | 892 equivalent to activating the parent widget. This widget will only match |
1083 the specified value. | 893 the specified value. |
1084 | 894 |
1085 @node toggle, checkbox, choice-item, Basic Types | 895 @node toggle, checkbox, choice-item, Basic Types |
1086 @comment node-name, next, previous, up | 896 @comment node-name, next, previous, up |
1087 @subsection The @code{toggle} Widget | 897 @subsection The @code{toggle} Widget |
1088 @findex toggle@r{ widget} | |
1089 | 898 |
1090 Syntax: | 899 Syntax: |
1091 | 900 |
1092 @example | 901 @example |
1093 @var{type} ::= (toggle [@var{keyword} @var{argument}]...) | 902 TYPE ::= (toggle [KEYWORD ARGUMENT]...) |
1094 @end example | 903 @end example |
1095 | 904 |
1096 The widget has two possible states, @samp{on} and @samp{off}, which | 905 The widget has two possible states, `on' and `off', which correspond to |
1097 correspond to a @code{t} or @code{nil} value, respectively. | 906 a @code{t} or @code{nil} value respectively. |
1098 | 907 |
1099 The following extra properties are recognized: | 908 The following extra properties are recognized. |
1100 | 909 |
1101 @table @code | 910 @table @code |
1102 @item :on | 911 @item :on |
1103 A string representing the @samp{on} state. By default the string | 912 String representing the `on' state. By default the string @samp{on}. |
1104 @samp{on}. | 913 @item :off |
1105 @item :off | 914 String representing the `off' state. By default the string @samp{off}. |
1106 A string representing the @samp{off} state. By default the string | |
1107 @samp{off}. | |
1108 @vindex on-glyph@r{ keyword} | |
1109 @item :on-glyph | 915 @item :on-glyph |
1110 Name of a glyph to be used instead of the @samp{:on} text string, on | 916 Name of a glyph to be used instead of the `:on' text string, on emacsen |
1111 emacsen that supports this. | 917 that supports it. |
1112 @vindex off-glyph@r{ keyword} | |
1113 @item :off-glyph | 918 @item :off-glyph |
1114 Name of a glyph to be used instead of the @samp{:off} text string, on | 919 Name of a glyph to be used instead of the `:off' text string, on emacsen |
1115 emacsen that supports this. | 920 that supports it. |
1116 @end table | 921 @end table |
1117 | 922 |
1118 @node checkbox, checklist, toggle, Basic Types | 923 @node checkbox, checklist, toggle, Basic Types |
1119 @comment node-name, next, previous, up | 924 @comment node-name, next, previous, up |
1120 @subsection The @code{checkbox} Widget | 925 @subsection The @code{checkbox} Widget |
1121 @findex checkbox@r{ widget} | 926 |
1122 | 927 The widget has two possible states, `selected' and `unselected', which |
1123 This widget has two possible states, @samp{selected} and | 928 corresponds to a @code{t} or @code{nil} value. |
1124 @samp{unselected}, which corresponds to a @code{t} or @code{nil} value. | |
1125 | 929 |
1126 Syntax: | 930 Syntax: |
1127 | 931 |
1128 @example | 932 @example |
1129 @var{type} ::= (checkbox [@var{keyword} @var{argument}]...) | 933 TYPE ::= (checkbox [KEYWORD ARGUMENT]...) |
1130 @end example | 934 @end example |
1131 | 935 |
1132 @node checklist, editable-list, checkbox, Basic Types | 936 @node checklist, editable-list, checkbox, Basic Types |
1133 @comment node-name, next, previous, up | 937 @comment node-name, next, previous, up |
1134 @subsection The @code{checklist} Widget | 938 @subsection The @code{checklist} Widget |
1135 @findex checklist@r{ widget} | |
1136 | 939 |
1137 Syntax: | 940 Syntax: |
1138 | 941 |
1139 @example | 942 @example |
1140 @var{type} ::= (checklist [@var{keyword} @var{argument}]... @var{type} ... ) | 943 TYPE ::= (checklist [KEYWORD ARGUMENT]... TYPE ... ) |
1141 @end example | 944 @end example |
1142 | 945 |
1143 The @var{type} arguments represent each checklist item. The widget's | 946 The @var{type} arguments represents each checklist item. The widget's |
1144 value will be a list containing the values of all checked @var{type} | 947 value will be a list containing the values of all ticked @var{type} |
1145 arguments. The checklist widget will match a list whose elements all | 948 arguments. The checklist widget will match a list whose elements all |
1146 match at least one of the specified @var{type} arguments. | 949 match at least one of the specified @var{type} arguments. |
1147 | 950 |
1148 The following extra properties are recognized: | 951 The following extra properties are recognized. |
1149 | 952 |
1150 @table @code | 953 @table @code |
1151 @vindex entry-format@r{ keyword} | |
1152 @item :entry-format | 954 @item :entry-format |
1153 This string will be inserted for each entry in the list. | 955 This string will be inserted for each entry in the list. |
1154 The following @samp{%} escapes are available: | 956 The following @samp{%} escapes are available: |
1155 @table @samp | 957 @table @samp |
1156 @item %v | 958 @item %v |
1157 Replaced with the buffer representation of the @var{type} widget. | 959 Replaced with the buffer representation of the @var{type} widget. |
1158 @item %b | 960 @item %b |
1159 Replace with the checkbox. | 961 Replace with the checkbox. |
1160 @item %% | 962 @item %% |
1161 Insert a literal @samp{%}. | 963 Insert a literal @samp{%}. |
1162 @end table | 964 @end table |
1163 | 965 |
1164 @vindex greedy@r{ keyword} | |
1165 @item :greedy | 966 @item :greedy |
1166 Usually a checklist will only match if the items are in the exact | 967 Usually a checklist will only match if the items are in the exact |
1167 sequence given in the specification. By setting @code{:greedy} to | 968 sequence given in the specification. By setting @code{:greedy} to |
1168 non-@code{nil}, it will allow the items to appear in any sequence. | 969 non-nil, it will allow the items to appear in any sequence. However, if |
1169 However, if you extract the value they will be in the sequence given | 970 you extract the values they will be in the sequence given in the |
1170 in the checklist, i.e.@: the original sequence is forgotten. | 971 checklist. I.e. the original sequence is forgotten. |
1171 | 972 |
1172 @vindex button-args@r{ keyword} | 973 @item button-args |
1173 @item :button-args | |
1174 A list of keywords to pass to the checkboxes. Useful for setting | 974 A list of keywords to pass to the checkboxes. Useful for setting |
1175 e.g.@: the @samp{:help-echo} for each checkbox. | 975 e.g. the @samp{:help-echo} for each checkbox. |
1176 | 976 |
1177 @vindex buttons@r{ keyword} | |
1178 @item :buttons | 977 @item :buttons |
1179 The widgets representing the checkboxes. | 978 The widgets representing the checkboxes. |
1180 | 979 |
1181 @vindex children@r{ keyword} | |
1182 @item :children | 980 @item :children |
1183 The widgets representing each type. | 981 The widgets representing each type. |
1184 | 982 |
1185 @vindex args@r{ keyword} | 983 @item :args |
1186 @item :args | 984 The list of types. |
1187 The list of types. | |
1188 @end table | 985 @end table |
1189 | 986 |
1190 @node editable-list, group, checklist, Basic Types | 987 @node editable-list, group, checklist, Basic Types |
1191 @comment node-name, next, previous, up | 988 @comment node-name, next, previous, up |
1192 @subsection The @code{editable-list} Widget | 989 @subsection The @code{editable-list} Widget |
1193 @findex editable-list@r{ widget} | |
1194 | 990 |
1195 Syntax: | 991 Syntax: |
1196 | 992 |
1197 @example | 993 @example |
1198 @var{type} ::= (editable-list [@var{keyword} @var{argument}]... @var{type}) | 994 TYPE ::= (editable-list [KEYWORD ARGUMENT]... TYPE) |
1199 @end example | 995 @end example |
1200 | 996 |
1201 The value is a list, where each member represents one widget of type | 997 The value is a list, where each member represents one widget of type |
1202 @var{type}. | 998 @var{type}. |
1203 | 999 |
1204 The following extra properties are recognized: | 1000 The following extra properties are recognized. |
1205 | 1001 |
1206 @table @code | 1002 @table @code |
1207 @vindex entry-format@r{ keyword} | |
1208 @item :entry-format | 1003 @item :entry-format |
1209 This string will be inserted for each entry in the list. | 1004 This string will be inserted for each entry in the list. |
1210 The following @samp{%} escapes are available: | 1005 The following @samp{%} escapes are available: |
1211 @table @samp | 1006 @table @samp |
1212 @item %v | 1007 @item %v |
1215 @item %i | 1010 @item %i |
1216 Insert the @b{[INS]} button. | 1011 Insert the @b{[INS]} button. |
1217 @item %d | 1012 @item %d |
1218 Insert the @b{[DEL]} button. | 1013 Insert the @b{[DEL]} button. |
1219 @item %% | 1014 @item %% |
1220 Insert a literal @samp{%}. | 1015 Insert a literal @samp{%}. |
1221 @end table | 1016 @end table |
1222 | 1017 |
1223 @vindex insert-button-args@r{ keyword} | |
1224 @item :insert-button-args | 1018 @item :insert-button-args |
1225 A list of keyword arguments to pass to the insert buttons. | 1019 A list of keyword arguments to pass to the insert buttons. |
1226 | 1020 |
1227 @vindex delete-button-args@r{ keyword} | |
1228 @item :delete-button-args | 1021 @item :delete-button-args |
1229 A list of keyword arguments to pass to the delete buttons. | 1022 A list of keyword arguments to pass to the delete buttons. |
1230 | 1023 |
1231 @vindex append-button-args@r{ keyword} | |
1232 @item :append-button-args | 1024 @item :append-button-args |
1233 A list of keyword arguments to pass to the trailing insert button. | 1025 A list of keyword arguments to pass to the trailing insert button. |
1234 | 1026 |
1235 @vindex buttons@r{ keyword} | 1027 |
1236 @item :buttons | 1028 @item :buttons |
1237 The widgets representing the insert and delete buttons. | 1029 The widgets representing the insert and delete buttons. |
1238 | 1030 |
1239 @vindex children@r{ keyword} | |
1240 @item :children | 1031 @item :children |
1241 The widgets representing the elements of the list. | 1032 The widgets representing the elements of the list. |
1242 | 1033 |
1243 @vindex args@r{ keyword} | |
1244 @item :args | 1034 @item :args |
1245 List whose @sc{car} is the type of the list elements. | 1035 List whose car is the type of the list elements. |
1036 | |
1246 @end table | 1037 @end table |
1247 | 1038 |
1248 @node group, , editable-list, Basic Types | 1039 @node group, , editable-list, Basic Types |
1249 @comment node-name, next, previous, up | 1040 @comment node-name, next, previous, up |
1250 @subsection The @code{group} Widget | 1041 @subsection The @code{group} Widget |
1251 @findex group@r{ widget} | |
1252 | 1042 |
1253 This widget simply groups other widgets together. | 1043 This widget simply groups other widgets together. |
1254 | 1044 |
1255 Syntax: | 1045 Syntax: |
1256 | 1046 |
1257 @example | 1047 @example |
1258 @var{type} ::= (group [@var{keyword} @var{argument}]... @var{type}...) | 1048 TYPE ::= (group [KEYWORD ARGUMENT]... TYPE...) |
1259 @end example | 1049 @end example |
1260 | 1050 |
1261 The value is a list, with one member for each @var{type}. | 1051 The value is a list, with one member for each @var{type}. |
1262 | 1052 |
1263 @node Sexp Types, Widget Properties, Basic Types, Top | 1053 @node Sexp Types, Widget Properties, Basic Types, Top |
1264 @comment | 1054 @comment |
1265 @section Sexp Types | 1055 @section Sexp Types |
1266 @cindex sexp types | 1056 |
1267 | 1057 A number of widgets for editing s-expressions (lisp types) are also |
1268 A number of widgets for editing @dfn{s-expressions} (Lisp types), sexp | 1058 available. These basically fall in the following categories. |
1269 for short, are also available. These basically fall in several | |
1270 categories described in this section. | |
1271 | 1059 |
1272 @menu | 1060 @menu |
1273 * constants:: | 1061 * constants:: |
1274 * generic:: | 1062 * generic:: |
1275 * atoms:: | 1063 * atoms:: |
1276 * composite:: | 1064 * composite:: |
1277 @end menu | 1065 @end menu |
1278 | 1066 |
1279 @node constants, generic, Sexp Types, Sexp Types | 1067 @node constants, generic, Sexp Types, Sexp Types |
1280 @comment node-name, next, previous, up | 1068 @comment node-name, next, previous, up |
1281 @subsection The Constant Widgets | 1069 @subsection The Constant Widgets. |
1282 @cindex constant widgets | 1070 |
1283 | 1071 The @code{const} widget can contain any lisp expression, but the user is |
1284 The @code{const} widget can contain any Lisp expression, but the user is | |
1285 prohibited from editing it, which is mainly useful as a component of one | 1072 prohibited from editing it, which is mainly useful as a component of one |
1286 of the composite widgets. | 1073 of the composite widgets. |
1287 | 1074 |
1288 The syntax for the @code{const} widget is: | 1075 The syntax for the @code{const} widget is |
1289 | 1076 |
1290 @example | 1077 @example |
1291 @var{type} ::= (const [@var{keyword} @var{argument}]... [ @var{value} ]) | 1078 TYPE ::= (const [KEYWORD ARGUMENT]... [ VALUE ]) |
1292 @end example | 1079 @end example |
1293 | 1080 |
1294 The @var{value}, if present, is used to initialize the @code{:value} | 1081 The @var{value}, if present, is used to initialize the @code{:value} |
1295 property and can be any s-expression. | 1082 property and can be any s-expression. |
1296 | 1083 |
1297 @deffn Widget const | 1084 @deffn Widget const |
1298 This will display any valid s-expression in an immutable part of the | 1085 This will display any valid s-expression in an immutable part of the |
1299 buffer. | 1086 buffer. |
1300 @end deffn | 1087 @end deffn |
1301 | 1088 |
1302 There are two variations of the @code{const} widget, namely | 1089 There are two variations of the @code{const} widget, namely |
1303 @code{variable-item} and @code{function-item}. These should contain a | 1090 @code{variable-item} and @code{function-item}. These should contain a |
1304 symbol with a variable or function binding. The major difference from | 1091 symbol with a variable or function binding. The major difference from |
1313 An immutable symbol that is bound as a function. | 1100 An immutable symbol that is bound as a function. |
1314 @end deffn | 1101 @end deffn |
1315 | 1102 |
1316 @node generic, atoms, constants, Sexp Types | 1103 @node generic, atoms, constants, Sexp Types |
1317 @comment node-name, next, previous, up | 1104 @comment node-name, next, previous, up |
1318 @subsection Generic Sexp Widget | 1105 @subsection Generic Sexp Widget. |
1319 @cindex generic sexp widget | 1106 |
1320 | 1107 The @code{sexp} widget can contain any lisp expression, and allows the |
1321 The @code{sexp} widget can contain any Lisp expression, and allows the | |
1322 user to edit it inline in the buffer. | 1108 user to edit it inline in the buffer. |
1323 | 1109 |
1324 The syntax for the @code{sexp} widget is: | 1110 The syntax for the @code{sexp} widget is |
1325 | 1111 |
1326 @example | 1112 @example |
1327 @var{type} ::= (sexp [@var{keyword} @var{argument}]... [ @var{value} ]) | 1113 TYPE ::= (sexp [KEYWORD ARGUMENT]... [ VALUE ]) |
1328 @end example | 1114 @end example |
1329 | 1115 |
1330 @deffn Widget sexp | 1116 @deffn Widget sexp |
1331 This will allow you to edit any valid s-expression in an editable buffer | 1117 This will allow you to edit any valid s-expression in an editable buffer |
1332 field. | 1118 field. |
1333 | 1119 |
1334 The @code{sexp} widget takes the same keyword arguments as the | 1120 The @code{sexp} widget takes the same keyword arguments as the |
1335 @code{editable-field} widget. @xref{editable-field}. | 1121 @code{editable-field} widget. |
1336 @end deffn | 1122 @end deffn |
1337 | 1123 |
1338 @node atoms, composite, generic, Sexp Types | 1124 @node atoms, composite, generic, Sexp Types |
1339 @comment node-name, next, previous, up | 1125 @comment node-name, next, previous, up |
1340 @subsection Atomic Sexp Widgets | 1126 @subsection Atomic Sexp Widgets. |
1341 @cindex atomic sexp widget | 1127 |
1342 | 1128 The atoms are s-expressions that does not consist of other |
1343 The atoms are s-expressions that do not consist of other s-expressions. | 1129 s-expressions. A string is an atom, while a list is a composite type. |
1344 For example, a string, a file name, or a symbol are atoms, while a list | 1130 You can edit the value of an atom with the following widgets. |
1345 is a composite type. You can edit the value of an atom with the | 1131 |
1346 following widgets. | 1132 The syntax for all the atoms are |
1347 | 1133 |
1348 The syntax for all the atoms are: | 1134 @example |
1349 | 1135 TYPE ::= (NAME [KEYWORD ARGUMENT]... [ VALUE ]) |
1350 @example | |
1351 @var{type} ::= (@var{construct} [@var{keyword} @var{argument}]... [ @var{value} ]) | |
1352 @end example | 1136 @end example |
1353 | 1137 |
1354 The @var{value}, if present, is used to initialize the @code{:value} | 1138 The @var{value}, if present, is used to initialize the @code{:value} |
1355 property and must be an expression of the same type as the widget. | 1139 property and must be an expression of the same type as the widget. |
1356 That is, the string widget can only be initialized with a string. | 1140 I.e. the string widget can only be initialized with a string. |
1357 | 1141 |
1358 All the atom widgets take the same keyword arguments as the | 1142 All the atom widgets take the same keyword arguments as the |
1359 @code{editable-field} widget. @xref{editable-field}. | 1143 @code{editable-field} widget. |
1360 | 1144 |
1361 @deffn Widget string | 1145 @deffn Widget string |
1362 Allows you to edit a string in an editable field. | 1146 Allows you to edit a string in an editable field. |
1363 @end deffn | 1147 @end deffn |
1364 | 1148 |
1369 @deffn Widget character | 1153 @deffn Widget character |
1370 Allows you to enter a character in an editable field. | 1154 Allows you to enter a character in an editable field. |
1371 @end deffn | 1155 @end deffn |
1372 | 1156 |
1373 @deffn Widget file | 1157 @deffn Widget file |
1374 Allows you to edit a file name in an editable field. | 1158 Allows you to edit a file name in an editable field. If you invoke |
1159 the tag button, you can edit the file name in the mini-buffer with | |
1160 completion. | |
1375 | 1161 |
1376 Keywords: | 1162 Keywords: |
1377 @table @code | 1163 @table @code |
1378 @vindex must-match@r{ keyword} | |
1379 @item :must-match | 1164 @item :must-match |
1380 If this is set to non-@code{nil}, only existing file names will be | 1165 If this is set to non-nil, only existing file names will be allowed in |
1381 allowed in the minibuffer. | 1166 the minibuffer. |
1382 @end table | 1167 @end table |
1383 @end deffn | 1168 @end deffn |
1384 | 1169 |
1385 @deffn Widget directory | 1170 @deffn Widget directory |
1386 Allows you to edit a directory name in an editable field. | 1171 Allows you to edit a directory name in an editable field. |
1387 Similar to the @code{file} widget. | 1172 Similar to the @code{file} widget. |
1388 @end deffn | 1173 @end deffn |
1389 | 1174 |
1390 @deffn Widget symbol | 1175 @deffn Widget symbol |
1391 Allows you to edit a Lisp symbol in an editable field. | 1176 Allows you to edit a lisp symbol in an editable field. |
1392 @end deffn | 1177 @end deffn |
1393 | 1178 |
1394 @deffn Widget function | 1179 @deffn Widget function |
1395 Allows you to edit a lambda expression, or a function name with completion. | 1180 Allows you to edit a lambda expression, or a function name with completion. |
1396 @end deffn | 1181 @end deffn |
1406 @deffn Widget number | 1191 @deffn Widget number |
1407 Allows you to edit a number in an editable field. | 1192 Allows you to edit a number in an editable field. |
1408 @end deffn | 1193 @end deffn |
1409 | 1194 |
1410 @deffn Widget boolean | 1195 @deffn Widget boolean |
1411 Allows you to edit a boolean. In Lisp this means a variable which is | 1196 Allows you to edit a boolean. In lisp this means a variable which is |
1412 either @code{nil} meaning false, or non-@code{nil} meaning true. | 1197 either nil meaning false, or non-nil meaning true. |
1413 @end deffn | 1198 @end deffn |
1414 | 1199 |
1415 | 1200 |
1416 @node composite, , atoms, Sexp Types | 1201 @node composite, , atoms, Sexp Types |
1417 @comment node-name, next, previous, up | 1202 @comment node-name, next, previous, up |
1418 @subsection Composite Sexp Widgets | 1203 @subsection Composite Sexp Widgets. |
1419 @cindex composite sexp widgets | 1204 |
1420 | 1205 The syntax for the composite are |
1421 The syntax for the composite widget construct is: | 1206 |
1422 | 1207 @example |
1423 @example | 1208 TYPE ::= (NAME [KEYWORD ARGUMENT]... COMPONENT...) |
1424 @var{type} ::= (@var{construct} [@var{keyword} @var{argument}]... @var{component}...) | 1209 @end example |
1425 @end example | 1210 |
1426 | 1211 Where each @var{component} must be a widget type. Each component widget |
1427 @noindent | 1212 will be displayed in the buffer, and be editable to the user. |
1428 where each @var{component} must be a widget type. Each component widget | |
1429 will be displayed in the buffer, and will be editable by the user. | |
1430 | 1213 |
1431 @deffn Widget cons | 1214 @deffn Widget cons |
1432 The value of a @code{cons} widget must be a cons-cell whose @sc{car} | 1215 The value of a @code{cons} widget is a cons-cell where the car is the |
1433 and @sc{cdr} have two specified types. It uses this syntax: | 1216 value of the first component and the cdr is the value of the second |
1434 | 1217 component. There must be exactly two components. |
1435 @example | |
1436 @var{type} ::= (cons [@var{keyword} @var{argument}]... @var{car-type} @var{cdr-type}) | |
1437 @end example | |
1438 @end deffn | |
1439 | |
1440 @deffn Widget choice | |
1441 The value matched by a @code{choice} widget must have one of a fixed | |
1442 set of types. The widget's syntax is as follows: | |
1443 | |
1444 @example | |
1445 @var{type} ::= (choice [@var{keyword} @var{argument}]... @var{type} ... ) | |
1446 @end example | |
1447 | |
1448 The value of a @code{choice} widget can be anything that matches any of the | |
1449 @var{types}. | |
1450 @end deffn | 1218 @end deffn |
1451 | 1219 |
1452 @deffn Widget list | 1220 @deffn Widget list |
1453 The value of a @code{list} widget must be a list whose element types | 1221 The value of a @code{list} widget is a list containing the value of |
1454 match the specified component types: | 1222 each of its component. |
1455 | |
1456 @example | |
1457 @var{type} ::= (list [@var{keyword} @var{argument}]... @var{component-type}...) | |
1458 @end example | |
1459 | |
1460 Thus, @code{(list string number)} matches lists of two elements, | |
1461 the first being a string and the second being a number. | |
1462 @end deffn | 1223 @end deffn |
1463 | 1224 |
1464 @deffn Widget vector | 1225 @deffn Widget vector |
1465 The @code{vector} widget is like the @code{list} widget but matches | 1226 The value of a @code{vector} widget is a vector containing the value of |
1466 vectors instead of lists. Thus, @code{(vector string number)} matches | 1227 each of its component. |
1467 vectors of two elements, the first being a string and the second being | |
1468 a number. | |
1469 @end deffn | 1228 @end deffn |
1470 | 1229 |
1471 The above suffice for specifying fixed size lists and vectors. To get | 1230 The above suffice for specifying fixed size lists and vectors. To get |
1472 variable length lists and vectors, you can use a @code{choice}, | 1231 variable length lists and vectors, you can use a @code{choice}, |
1473 @code{set}, or @code{repeat} widget together with the @code{:inline} | 1232 @code{set} or @code{repeat} widgets together with the @code{:inline} |
1474 keyword. If any component of a composite widget has the | 1233 keywords. If any component of a composite widget has the @code{:inline} |
1475 @code{:inline} keyword set, its value must be a list which will then | 1234 keyword set, its value must be a list which will then be spliced into |
1476 be spliced into the composite. For example, to specify a list whose | 1235 the composite. For example, to specify a list whose first element must |
1477 first element must be a file name, and whose remaining elements should | 1236 be a file name, and whose remaining arguments should either by the |
1478 either be the symbol @code{t} or two strings (file names), you can use | 1237 symbol @code{t} or two files, you can use the following widget |
1479 the following widget specification: | 1238 specification: |
1480 | 1239 |
1481 @example | 1240 @example |
1482 (list file | 1241 (list file |
1483 (choice (const t) | 1242 (choice (const t) |
1484 (list :inline t | 1243 (list :inline t |
1485 :value ("foo" "bar") | 1244 :value ("foo" "bar") |
1486 string string))) | 1245 string string))) |
1487 @end example | 1246 @end example |
1488 | 1247 |
1489 The value of a widget of this type will either have the form | 1248 The value of a widget of this type will either have the form |
1490 @code{(file t)} or @code{(file @var{string} @var{string})}. | 1249 @samp{(file t)} or @code{(file string string)}. |
1491 | 1250 |
1492 This concept of @code{:inline} may be hard to understand. It was | 1251 This concept of inline is probably hard to understand. It was certainly |
1493 certainly hard to implement, so instead of confusing you more by | 1252 hard to implement so instead of confusing you more by trying to explain |
1494 trying to explain it here, I'll just suggest you meditate over it for | 1253 it here, I'll just suggest you meditate over it for a while. |
1495 a while. | 1254 |
1255 @deffn Widget choice | |
1256 Allows you to edit a sexp which may have one of a fixed set of types. | |
1257 It is currently implemented with the @code{choice-menu} basic widget, | |
1258 and has a similar syntax. | |
1259 @end deffn | |
1496 | 1260 |
1497 @deffn Widget set | 1261 @deffn Widget set |
1498 Specifies a type whose values are the lists whose elements all belong | 1262 Allows you to specify a type which must be a list whose elements all |
1499 to a given set. The order of elements of the list is not significant. | 1263 belong to given set. The elements of the list is not significant. This |
1500 Here's the syntax: | 1264 is implemented on top of the @code{checklist} basic widget, and has a |
1501 | 1265 similar syntax. |
1502 @example | |
1503 @var{type} ::= (set [@var{keyword} @var{argument}]... @var{permitted-element} ... ) | |
1504 @end example | |
1505 | |
1506 Use @code{const} to specify each permitted element, like this: | |
1507 @code{(set (const a) (const b))}. | |
1508 @end deffn | 1266 @end deffn |
1509 | 1267 |
1510 @deffn Widget repeat | 1268 @deffn Widget repeat |
1511 Specifies a list of any number of elements that fit a certain type. | 1269 Allows you to specify a variable length list whose members are all of |
1512 | 1270 the same type. Implemented on top of the `editable-list' basic widget, |
1513 @example | 1271 and has a similar syntax. |
1514 @var{type} ::= (repeat [@var{keyword} @var{argument}]... @var{type}) | |
1515 @end example | |
1516 @end deffn | 1272 @end deffn |
1517 | 1273 |
1518 @node Widget Properties, Defining New Widgets, Sexp Types, Top | 1274 @node Widget Properties, Defining New Widgets, Sexp Types, Top |
1519 @comment node-name, next, previous, up | 1275 @comment node-name, next, previous, up |
1520 @section Properties | 1276 @section Properties |
1521 @cindex properties of widgets | |
1522 @cindex widget properties | |
1523 | 1277 |
1524 You can examine or set the value of a widget by using the widget object | 1278 You can examine or set the value of a widget by using the widget object |
1525 that was returned by @code{widget-create}. | 1279 that was returned by @code{widget-create}. |
1526 | 1280 |
1527 @defun widget-value widget | 1281 @defun widget-value widget |
1537 @strong{Important:} You @emph{must} call @code{widget-setup} after | 1291 @strong{Important:} You @emph{must} call @code{widget-setup} after |
1538 modifying the value of a widget before the user is allowed to edit the | 1292 modifying the value of a widget before the user is allowed to edit the |
1539 widget again. It is enough to call @code{widget-setup} once if you | 1293 widget again. It is enough to call @code{widget-setup} once if you |
1540 modify multiple widgets. This is currently only necessary if the widget | 1294 modify multiple widgets. This is currently only necessary if the widget |
1541 contains an editing field, but may be necessary for other widgets in the | 1295 contains an editing field, but may be necessary for other widgets in the |
1542 future. | 1296 future. |
1543 | 1297 |
1544 If your application needs to associate some information with the widget | 1298 If your application needs to associate some information with the widget |
1545 objects, for example a reference to the item being edited, it can be | 1299 objects, for example a reference to the item being edited, it can be |
1546 done with @code{widget-put} and @code{widget-get}. The property names | 1300 done with @code{widget-put} and @code{widget-get}. The property names |
1547 must begin with a @samp{:}. | 1301 must begin with a @samp{:}. |
1556 @var{property} should be a symbol, the value is what was last set by | 1310 @var{property} should be a symbol, the value is what was last set by |
1557 @code{widget-put} for @var{property}. | 1311 @code{widget-put} for @var{property}. |
1558 @end defun | 1312 @end defun |
1559 | 1313 |
1560 @defun widget-member widget property | 1314 @defun widget-member widget property |
1561 Non-@code{nil} if @var{widget} has a value (even @code{nil}) for | 1315 Non-nil if @var{widget} has a value (even nil) for property @var{property}. |
1562 property @var{property}. | |
1563 @end defun | 1316 @end defun |
1564 | 1317 |
1565 Occasionally it can be useful to know which kind of widget you have, | 1318 Occasionally it can be useful to know which kind of widget you have, |
1566 i.e.@: the name of the widget type you gave when the widget was created. | 1319 i.e. the name of the widget type you gave when the widget was created. |
1567 | 1320 |
1568 @defun widget-type widget | 1321 @defun widget-type widget |
1569 Return the name of @var{widget}, a symbol. | 1322 Return the name of @var{widget}, a symbol. |
1570 @end defun | 1323 @end defun |
1571 | 1324 |
1572 @cindex active widget | |
1573 @cindex inactive widget | |
1574 @cindex activate a widget | |
1575 @cindex deactivate a widget | |
1576 Widgets can be in two states: active, which means they are modifiable by | 1325 Widgets can be in two states: active, which means they are modifiable by |
1577 the user, or inactive, which means they cannot be modified by the user. | 1326 the user, or inactive, which means they cannot be modified by the user. |
1578 You can query or set the state with the following code: | 1327 You can query or set the state with the following code: |
1579 | 1328 |
1580 @lisp | 1329 @lisp |
1588 | 1337 |
1589 ;; Make @var{widget} active. | 1338 ;; Make @var{widget} active. |
1590 (widget-apply @var{widget} :activate) | 1339 (widget-apply @var{widget} :activate) |
1591 @end lisp | 1340 @end lisp |
1592 | 1341 |
1593 A widget is inactive if it, or any of its ancestors (found by | 1342 A widget is inactive if itself or any of its ancestors (found by |
1594 following the @code{:parent} link), have been deactivated. To make sure | 1343 following the @code{:parent} link) have been deactivated. To make sure |
1595 a widget is really active, you must therefore activate both it and | 1344 a widget is really active, you must therefore activate both itself and |
1596 all its ancestors. | 1345 all its ancestors. |
1597 | 1346 |
1598 @lisp | 1347 @lisp |
1599 (while widget | 1348 (while widget |
1600 (widget-apply widget :activate) | 1349 (widget-apply widget :activate) |
1601 (setq widget (widget-get widget :parent))) | 1350 (setq widget (widget-get widget :parent))) |
1602 @end lisp | 1351 @end lisp |
1603 | 1352 |
1604 You can check if a widget has been made inactive by examining the value | 1353 You can check if a widget has been made inactive by examining the value |
1605 of the @code{:inactive} keyword. If this is non-@code{nil}, the widget itself | 1354 of the @code{:inactive} keyword. If this is non-nil, the widget itself |
1606 has been deactivated. This is different from using the @code{:active} | 1355 has been deactivated. This is different from using the @code{:active} |
1607 keyword, in that the latter tells you if the widget @strong{or} any of | 1356 keyword, in that the latter tells you if the widget @strong{or} any of |
1608 its ancestors have been deactivated. Do not attempt to set the | 1357 its ancestors have been deactivated. Do not attempt to set the |
1609 @code{:inactive} keyword directly. Use the @code{:activate} | 1358 @code{:inactive} keyword directly. Use the @code{:activate} |
1610 @code{:deactivate} keywords instead. | 1359 @code{:deactivate} keywords instead. |
1611 | 1360 |
1612 | 1361 |
1613 @node Defining New Widgets, Widget Browser, Widget Properties, Top | 1362 @node Defining New Widgets, Widget Browser, Widget Properties, Top |
1614 @comment node-name, next, previous, up | 1363 @comment node-name, next, previous, up |
1615 @section Defining New Widgets | 1364 @section Defining New Widgets |
1616 @cindex new widgets | |
1617 @cindex defining new widgets | |
1618 | 1365 |
1619 You can define specialized widgets with @code{define-widget}. It allows | 1366 You can define specialized widgets with @code{define-widget}. It allows |
1620 you to create a shorthand for more complex widgets, including specifying | 1367 you to create a shorthand for more complex widgets. This includes |
1621 component widgets and new default values for the keyword | 1368 specifying component widgets and new default values for the keyword |
1622 arguments. | 1369 arguments. |
1623 | 1370 |
1624 @defun define-widget name class doc &rest args | 1371 @defun define-widget name class doc &rest args |
1625 Define a new widget type named @var{name} from @code{class}. | 1372 Define a new widget type named @var{name} from @code{class}. |
1626 | 1373 |
1627 @var{name} and class should both be symbols, @code{class} should be one | 1374 @var{name} and class should both be symbols, @code{class} should be one |
1628 of the existing widget types. | 1375 of the existing widget types. |
1629 | 1376 |
1630 The third argument @var{doc} is a documentation string for the widget. | 1377 The third argument @var{DOC} is a documentation string for the widget. |
1631 | 1378 |
1632 After the new widget has been defined the following two calls will | 1379 After the new widget has been defined the following two calls will |
1633 create identical widgets: | 1380 create identical widgets: |
1634 | 1381 |
1635 @itemize @bullet | 1382 @itemize @bullet |
1648 | 1395 |
1649 Using @code{define-widget} just stores the definition of the widget type | 1396 Using @code{define-widget} just stores the definition of the widget type |
1650 in the @code{widget-type} property of @var{name}, which is what | 1397 in the @code{widget-type} property of @var{name}, which is what |
1651 @code{widget-create} uses. | 1398 @code{widget-create} uses. |
1652 | 1399 |
1653 If you only want to specify defaults for keywords with no complex | 1400 If you just want to specify defaults for keywords with no complex |
1654 conversions, you can use @code{identity} as your @code{:convert-widget} | 1401 conversions, you can use @code{identity} as your @code{:convert-widget} |
1655 function. | 1402 function. |
1656 | 1403 |
1657 The following additional keyword arguments are useful when defining new | 1404 The following additional keyword arguments are useful when defining new |
1658 widgets: | 1405 widgets: |
1659 @table @code | 1406 @table @code |
1660 @vindex convert-widget@r{ keyword} | |
1661 @item :convert-widget | 1407 @item :convert-widget |
1662 Method to convert type-specific components of a widget type before | 1408 Method to convert type-specific components of a widget type before |
1663 instantiating a widget of that type. Not normally called from user | 1409 instantiating a widget of that type. Not normally called from user |
1664 code, it is invoked by @code{widget-convert}. Typical operations | 1410 code, it is invoked by @code{widget-convert}. Typical operations |
1665 include converting types of child widgets to widget instances and | 1411 include converting types of child widgets to widget instances and |
1681 @defun widget-value-convert-widget widget | 1427 @defun widget-value-convert-widget widget |
1682 Initialize @code{:value} from @code{(car :args)} in @var{widget}, and | 1428 Initialize @code{:value} from @code{(car :args)} in @var{widget}, and |
1683 reset @code{:args}. | 1429 reset @code{:args}. |
1684 @end defun | 1430 @end defun |
1685 | 1431 |
1686 @vindex copy@r{ keyword} | |
1687 @item :copy | 1432 @item :copy |
1688 Function to deep copy a widget type. It takes a shallow copy of the | 1433 A method to implement deep copying of the type. Any member of the |
1689 widget type as an argument (made by @code{copy-sequence}), and returns a | |
1690 deep copy. The purpose of this is to avoid having different instances | |
1691 of combined widgets share nested attributes. Any member of the | |
1692 widget which might be changed in place (rather than replaced) should be | 1434 widget which might be changed in place (rather than replaced) should be |
1693 copied by this method. (@code{widget-copy} uses @code{copy-sequence} to | 1435 copied by this method. (@code{widget-copy} uses @code{copy-sequence} to |
1694 ensure that the top-level list is a copy.) This particularly applies to | 1436 ensure that the top-level list is a copy.) This particularly applies to |
1695 child widgets. | 1437 child widgets. |
1696 | 1438 |
1697 The following predefined functions can be used here: | |
1698 | |
1699 @defun widget-types-copy widget | |
1700 Copy @code{:args} as widget types in @var{widget}. | |
1701 @end defun | |
1702 | |
1703 @vindex value-to-internal@r{ keyword} | |
1704 @item :value-to-internal | 1439 @item :value-to-internal |
1705 Function to convert the value to the internal format. The function | 1440 Function to convert the value to the internal format. The function |
1706 takes two arguments, a widget and an external value. It returns the | 1441 takes two arguments, a widget and an external value. It returns the |
1707 internal value. The function is called on the present @code{:value} | 1442 internal value. The function is called on the present @code{:value} |
1708 when the widget is created, and on any value set later with | 1443 when the widget is created, and on any value set later with |
1709 @code{widget-value-set}. | 1444 @code{widget-value-set}. |
1710 | 1445 |
1711 @vindex value-to-external@r{ keyword} | |
1712 @item :value-to-external | 1446 @item :value-to-external |
1713 Function to convert the value to the external format. The function | 1447 Function to convert the value to the external format. The function |
1714 takes two arguments, a widget and an internal value, and returns the | 1448 takes two arguments, a widget and an internal value, and returns the |
1715 external value. The function is called on the present @code{:value} | 1449 internal value. The function is called on the present @code{:value} |
1716 when the widget is created, and on any value set later with | 1450 when the widget is created, and on any value set later with |
1717 @code{widget-value-set}. | 1451 @code{widget-value-set}. |
1718 | 1452 |
1719 @vindex create@r{ keyword} | |
1720 @item :create | 1453 @item :create |
1721 Function to create a widget from scratch. The function takes one | 1454 Function to create a widget from scratch. The function takes one |
1722 argument, a widget, and inserts it in the buffer. Not normally called | 1455 argument, a widget, and inserts it in the buffer. Not normally called |
1723 from user code. Instead, call @code{widget-create} or related | 1456 from user code. Instead, call @code{widget-create} or related |
1724 functions, which take a type argument, (usually) convert it to a widget, | 1457 functions, which take a type argument, (usually) convert it to a widget, |
1726 return the (possibly converted) widget. | 1459 return the (possibly converted) widget. |
1727 | 1460 |
1728 The default, @code{widget-default-create}, is invariably appropriate. | 1461 The default, @code{widget-default-create}, is invariably appropriate. |
1729 (None of the standard widgets specify @code{:create}.) | 1462 (None of the standard widgets specify @code{:create}.) |
1730 | 1463 |
1731 @vindex delete@r{ keyword} | |
1732 @item :delete | 1464 @item :delete |
1733 Function to delete a widget. The function takes one argument, a widget, | 1465 Function to delete a widget. The function takes one argument, a widget, |
1734 and should remove all traces of the widget from the buffer. | 1466 and should remove all traces of the widget from the buffer. |
1735 | 1467 |
1736 The default value is: | |
1737 | |
1738 @defun widget-default-delete widget | |
1739 Remove @var{widget} from the buffer. | |
1740 Delete all @code{:children} and @code{:buttons} in @var{widget}. | |
1741 @end defun | |
1742 | |
1743 In most cases you should not change this value, but instead use | |
1744 @code{:value-delete} to make any additional cleanup. | |
1745 | |
1746 @vindex value-create@r{ keyword} | |
1747 @item :value-create | 1468 @item :value-create |
1748 Function to expand the @samp{%v} escape in the format string. It will | 1469 Function to expand the @samp{%v} escape in the format string. It will |
1749 be called with the widget as its argument and should insert a | 1470 be called with the widget as its argument and should insert a |
1750 representation of the widget's value in the buffer. | 1471 representation of the widget's value in the buffer. |
1751 | 1472 |
1752 Nested widgets should be listed in @code{:children} or @code{:buttons} | |
1753 to make sure they are automatically deleted. | |
1754 | |
1755 @vindex value-delete@r{ keyword} | |
1756 @item :value-delete | 1473 @item :value-delete |
1757 Should remove the representation of the widget's value from the buffer. | 1474 Should remove the representation of the widget's value from the buffer. |
1758 It will be called with the widget as its argument. It doesn't have to | 1475 It will be called with the widget as its argument. It doesn't have to |
1759 remove the text, but it should release markers and delete nested widgets | 1476 remove the text, but it should release markers and delete nested widgets |
1760 if these are not listed in @code{:children} or @code{:buttons}. | 1477 if such have been used. |
1761 | 1478 |
1762 @vindex value-get@r{ keyword} | 1479 The following predefined function can be used here: |
1763 @item :value-get | 1480 |
1481 @defun widget-children-value-delete widget | |
1482 Delete all @code{:children} and @code{:buttons} in @var{widget}. | |
1483 @end defun | |
1484 | |
1485 @item :value-get | |
1764 Function to extract the value of a widget, as it is displayed in the | 1486 Function to extract the value of a widget, as it is displayed in the |
1765 buffer. | 1487 buffer. |
1766 | 1488 |
1767 The following predefined function can be used here: | 1489 The following predefined function can be used here: |
1768 | 1490 |
1769 @defun widget-value-value-get widget | 1491 @defun widget-value-value-get widget |
1770 Return the @code{:value} property of @var{widget}. | 1492 Return the @code{:value} property of @var{widget}. |
1771 @end defun | 1493 @end defun |
1772 | 1494 |
1773 @vindex format-handler@r{ keyword} | |
1774 @item :format-handler | 1495 @item :format-handler |
1775 Function to handle unknown @samp{%} escapes in the format string. It | 1496 Function to handle unknown @samp{%} escapes in the format string. It |
1776 will be called with the widget and the character that follows the | 1497 will be called with the widget and the escape character as arguments. |
1777 @samp{%} as arguments. You can set this to allow your widget to handle | 1498 You can set this to allow your widget to handle non-standard escapes. |
1778 non-standard escapes. | 1499 |
1779 | |
1780 @findex widget-default-format-handler | |
1781 You should end up calling @code{widget-default-format-handler} to handle | 1500 You should end up calling @code{widget-default-format-handler} to handle |
1782 unknown escape sequences. It will handle the @samp{%h} and any future | 1501 unknown escape sequences. It will handle the @samp{%h} and any future |
1783 escape sequences as well as give an error for unknown escapes. | 1502 escape sequences as well as give an error for unknown escapes. |
1784 | 1503 |
1785 @vindex action@r{ keyword} | |
1786 @item :action | 1504 @item :action |
1787 Function to handle user initiated events. By default, @code{:notify} | 1505 Function to handle user initiated events. By default, @code{:notify} |
1788 the parent. Actions normally do not include mere edits, but refer to | 1506 the parent. Actions normally do not include mere edits, but refer to |
1789 things like invoking buttons or hitting enter in an editable field. To | 1507 things like invoking buttons or hitting enter in an editable field. To |
1790 watch for any change, redefine the @code{:notify} callback. | 1508 watch for any change, redefine the @code{:notify} callback. |
1794 @defun widget-parent-action widget &optional event | 1512 @defun widget-parent-action widget &optional event |
1795 Tell @code{:parent} of @var{widget} to handle the @code{:action}.@* | 1513 Tell @code{:parent} of @var{widget} to handle the @code{:action}.@* |
1796 Optional @var{event} is the event that triggered the action. | 1514 Optional @var{event} is the event that triggered the action. |
1797 @end defun | 1515 @end defun |
1798 | 1516 |
1799 @vindex prompt-value@r{ keyword} | |
1800 @item :prompt-value | 1517 @item :prompt-value |
1801 Function to prompt for a value in the minibuffer. The function should | 1518 Function to prompt for a value in the minibuffer. The function should |
1802 take four arguments, @var{widget}, @var{prompt}, @var{value}, and | 1519 take four arguments, @var{widget}, @var{prompt}, @var{value}, and |
1803 @var{unbound} and should return a value for widget entered by the user. | 1520 @var{unbound} and should return a value for widget entered by the user. |
1804 @var{prompt} is the prompt to use. @var{value} is the default value to | 1521 @var{prompt} is the prompt to use. @var{value} is the default value to |
1805 use, unless @var{unbound} is non-@code{nil}, in which case there is no default | 1522 use, unless @var{unbound} is non-nil. In this case there is no default |
1806 value. The function should read the value using the method most natural | 1523 value. The function should read the value using the method most natural |
1807 for this widget and does not have to check whether it matches. | 1524 for this widget and does not have to check whether it matches. |
1808 @end table | 1525 @end table |
1809 | 1526 |
1810 If you want to define a new widget from scratch, use the @code{default} | 1527 If you want to define a new widget from scratch, use the @code{default} |
1811 widget as its base. | 1528 widget as its base. |
1812 | 1529 |
1813 @deffn Widget default | 1530 @deffn Widget default |
1814 Widget used as a base for other widgets. | 1531 Widget used as a base for other widgets. |
1815 | 1532 |
1816 It provides most of the functionality that is referred to as ``by | 1533 It provides most of the functionality that is referred to as ``by |
1817 default'' in this text. | 1534 default'' in this text. |
1818 @end deffn | 1535 @end deffn |
1819 | 1536 |
1820 In implementing complex hierarchical widgets (@emph{e.g.}, using the | 1537 In implementing complex hierarchical widgets (@emph{e.g.}, using the |
1821 @samp{group} widget), the following functions may be useful. | 1538 @samp{group} widget), the following functions may be useful. |
1822 The syntax for the @var{type} arguments to these functions is described | 1539 The syntax for the @var{type} arguments to these functions is described |
1855 is called implicitly through the @samp{widget-create*} functions. | 1572 is called implicitly through the @samp{widget-create*} functions. |
1856 | 1573 |
1857 @node Widget Browser, Widget Minor Mode, Defining New Widgets, Top | 1574 @node Widget Browser, Widget Minor Mode, Defining New Widgets, Top |
1858 @comment node-name, next, previous, up | 1575 @comment node-name, next, previous, up |
1859 @section Widget Browser | 1576 @section Widget Browser |
1860 @cindex widget browser | |
1861 | 1577 |
1862 There is a separate package to browse widgets. This is intended to help | 1578 There is a separate package to browse widgets. This is intended to help |
1863 programmers who want to examine the content of a widget. The browser | 1579 programmers who want to examine the content of a widget. The browser |
1864 shows the value of each keyword, but uses links for certain keywords | 1580 shows the value of each keyword, but uses links for certain keywords |
1865 such as @samp{:parent}, which avoids printing cyclic structures. | 1581 such as `:parent', which avoids printing cyclic structures. |
1866 | 1582 |
1867 @deffn Command widget-browse @var{widget} | 1583 @deffn Command widget-browse WIDGET |
1868 Create a widget browser for @var{widget}. | 1584 Create a widget browser for WIDGET. |
1869 When called interactively, prompt for @var{widget}. | 1585 When called interactively, prompt for WIDGET. |
1870 @end deffn | 1586 @end deffn |
1871 | 1587 |
1872 @deffn Command widget-browse-other-window @var{widget} | 1588 @deffn Command widget-browse-other-window WIDGET |
1873 Create a widget browser for @var{widget} and show it in another window. | 1589 Create a widget browser for WIDGET and show it in another window. |
1874 When called interactively, prompt for @var{widget}. | 1590 When called interactively, prompt for WIDGET. |
1875 @end deffn | 1591 @end deffn |
1876 | 1592 |
1877 @deffn Command widget-browse-at @var{pos} | 1593 @deffn Command widget-browse-at POS |
1878 Create a widget browser for the widget at @var{pos}. | 1594 Create a widget browser for the widget at POS. |
1879 When called interactively, use the position of point. | 1595 When called interactively, use the position of point. |
1880 @end deffn | 1596 @end deffn |
1881 | 1597 |
1882 @node Widget Minor Mode, Utilities, Widget Browser, Top | 1598 @node Widget Minor Mode, Utilities, Widget Browser, Top |
1883 @comment node-name, next, previous, up | 1599 @comment node-name, next, previous, up |
1884 @section Widget Minor Mode | 1600 @section Widget Minor Mode |
1885 @cindex widget minor mode | |
1886 | 1601 |
1887 There is a minor mode for manipulating widgets in major modes that | 1602 There is a minor mode for manipulating widgets in major modes that |
1888 don't provide any support for widgets themselves. This is mostly | 1603 doesn't provide any support for widgets themselves. This is mostly |
1889 intended to be useful for programmers doing experiments. | 1604 intended to be useful for programmers doing experiments. |
1890 | 1605 |
1891 @deffn Command widget-minor-mode | 1606 @deffn Command widget-minor-mode |
1892 Toggle minor mode for traversing widgets. | 1607 Toggle minor mode for traversing widgets. |
1893 With arg, turn widget mode on if and only if arg is positive. | 1608 With arg, turn widget mode on if and only if arg is positive. |
1894 @end deffn | 1609 @end deffn |
1898 @end defvar | 1613 @end defvar |
1899 | 1614 |
1900 @node Utilities, Widget Wishlist, Widget Minor Mode, Top | 1615 @node Utilities, Widget Wishlist, Widget Minor Mode, Top |
1901 @comment node-name, next, previous, up | 1616 @comment node-name, next, previous, up |
1902 @section Utilities. | 1617 @section Utilities. |
1903 @cindex utility functions for widgets | |
1904 | 1618 |
1905 @defun widget-prompt-value widget prompt [ value unbound ] | 1619 @defun widget-prompt-value widget prompt [ value unbound ] |
1906 Prompt for a value matching @var{widget}, using @var{prompt}.@* | 1620 Prompt for a value matching @var{widget}, using @var{prompt}.@* |
1907 The current value is assumed to be @var{value}, unless @var{unbound} is | 1621 The current value is assumed to be @var{value}, unless @var{unbound} is |
1908 non-@code{nil}.@refill | 1622 non-nil.@refill |
1909 @end defun | 1623 @end defun |
1910 | 1624 |
1911 @defun widget-get-sibling widget | 1625 @defun widget-get-sibling widget |
1912 Get the item which @var{widget} is assumed to toggle.@* | 1626 Get the item @var{widget} is assumed to toggle.@* |
1913 This is only meaningful for radio buttons or checkboxes in a list. | 1627 This is only meaningful for radio buttons or checkboxes in a list. |
1914 @end defun | 1628 @end defun |
1915 | 1629 |
1916 @node Widget Wishlist, Widget Internals, Utilities, Top | 1630 @node Widget Wishlist, Widget Internals, Utilities, Top |
1917 @comment node-name, next, previous, up | 1631 @comment node-name, next, previous, up |
1918 @section Wishlist | 1632 @section Wishlist |
1919 @cindex todo | |
1920 | 1633 |
1921 @itemize @bullet | 1634 @itemize @bullet |
1922 @item | 1635 @item |
1923 It should be possible to add or remove items from a list with @kbd{C-k} | 1636 It should be possible to add or remove items from a list with @kbd{C-k} |
1924 and @kbd{C-o} (suggested by @sc{rms}). | 1637 and @kbd{C-o} (suggested by @sc{rms}). |
1925 | 1638 |
1926 @item | 1639 @item |
1927 The @samp{[INS]} and @samp{[DEL]} buttons should be replaced by a single | 1640 The @samp{[INS]} and @samp{[DEL]} buttons should be replaced by a single |
1928 dash (@samp{-}). The dash should be a button that, when invoked, asks | 1641 dash (@samp{-}). The dash should be a button that, when invoked, ask |
1929 whether you want to add or delete an item (@sc{rms} wanted to git rid of | 1642 whether you want to add or delete an item (@sc{rms} wanted to git rid of |
1930 the ugly buttons, the dash is my idea). | 1643 the ugly buttons, the dash is my idea). |
1931 | 1644 |
1932 @item | 1645 @item |
1933 The @code{menu-choice} tag should be prettier, something like the abbreviated | 1646 The @code{menu-choice} tag should be prettier, something like the abbreviated |
1939 @item | 1652 @item |
1940 Make indentation work with glyphs and proportional fonts. | 1653 Make indentation work with glyphs and proportional fonts. |
1941 | 1654 |
1942 @item | 1655 @item |
1943 Add commands to show overview of object and class hierarchies to the | 1656 Add commands to show overview of object and class hierarchies to the |
1944 browser. | 1657 browser. |
1945 | 1658 |
1946 @item | 1659 @item |
1947 Find a way to disable mouse highlight for inactive widgets. | 1660 Find a way to disable mouse highlight for inactive widgets. |
1948 | 1661 |
1949 @item | 1662 @item |
1950 Find a way to make glyphs look inactive. | 1663 Find a way to make glyphs look inactive. |
1951 | 1664 |
1963 | 1676 |
1964 @item | 1677 @item |
1965 Find clean way to implement variable length list. | 1678 Find clean way to implement variable length list. |
1966 See @code{TeX-printer-list} for an explanation. | 1679 See @code{TeX-printer-list} for an explanation. |
1967 | 1680 |
1968 @item | 1681 @item |
1969 @kbd{C-h} in @code{widget-prompt-value} should give type specific help. | 1682 @kbd{C-h} in @code{widget-prompt-value} should give type specific help. |
1970 | 1683 |
1971 @item | 1684 @item |
1972 Add a @code{mailto} widget. | 1685 A mailto widget. |
1973 | 1686 |
1974 @item | 1687 @item |
1975 @kbd{C-e e} in a fixed size field should go to the end of the text in | 1688 @kbd{C-e e} in a fixed size field should go to the end of the text in |
1976 the field, not the end of the field itself. | 1689 the field, not the end of the field itself. |
1977 | 1690 |
1982 @item | 1695 @item |
1983 Clicking on documentation links should call @code{describe-function} or | 1696 Clicking on documentation links should call @code{describe-function} or |
1984 @code{widget-browse-other-window} and friends directly, instead of going | 1697 @code{widget-browse-other-window} and friends directly, instead of going |
1985 through @code{apropos}. If more than one function is valid for the | 1698 through @code{apropos}. If more than one function is valid for the |
1986 symbol, it should pop up a menu. | 1699 symbol, it should pop up a menu. |
1700 | |
1987 @end itemize | 1701 @end itemize |
1988 | 1702 |
1989 @node Widget Internals, GNU Free Documentation License, Widget Wishlist, Top | 1703 @node Widget Internals, , Widget Wishlist, Top |
1990 @section Internals | 1704 @section Internals |
1991 | 1705 |
1992 This (very brief!) section provides a few notes on the internal | 1706 This (very brief!) section provides a few notes on the internal |
1993 structure and implementation of Emacs widgets. Avoid relying on this | 1707 structure and implementation of Emacs widgets. Avoid relying on this |
1994 information. (We intend to improve it, but this will take some time.) | 1708 information. (We intend to improve it, but this will take some time.) |
2014 a type name or a type, and whose cdr is a property list. Furthermore, | 1728 a type name or a type, and whose cdr is a property list. Furthermore, |
2015 all children of the converted widget must be converted. Finally, in the | 1729 all children of the converted widget must be converted. Finally, in the |
2016 process of appropriate parts of the list structure are copied to ensure | 1730 process of appropriate parts of the list structure are copied to ensure |
2017 that changes in values of one instance do not affect another's. | 1731 that changes in values of one instance do not affect another's. |
2018 | 1732 |
2019 @node GNU Free Documentation License, Index, Widget Internals, Top | 1733 @contents |
2020 @appendix GNU Free Documentation License | |
2021 @include doclicense.texi | |
2022 | |
2023 @node Index, , GNU Free Documentation License, Top | |
2024 @comment node-name, next, previous, up | |
2025 @unnumbered Index | |
2026 | |
2027 This is an alphabetical listing of all concepts, functions, commands, | |
2028 variables, and widgets described in this manual. | |
2029 @printindex cp | |
2030 | |
2031 @bye | 1734 @bye |
2032 | |
2033 @ignore | |
2034 arch-tag: 2b427731-4c61-4e72-85de-5ccec9c623f0 | |
2035 @end ignore |