Mercurial > emacs
comparison lispref/customize.texi @ 53319:36b31fc002f2
2003-12-12 Jesper Harder <harder@ifa.au.dk>
* cus-edit.el (custom-add-parent-links): Define "many".
2003-12-08 Per Abrahamsen <abraham@dina.kvl.dk>
* wid-edit.el (widget-child-value-get, widget-child-value-inline)
(widget-child-validate, widget-type-value-create)
(widget-type-default-get, widget-type-match): New functions.
(lazy): New widget.
(menu-choice, checklist, radio-button-choice, editable-list)
(group, documentation-string): Removed redundant (per 2003-10-25
change) calls to `widget-children-value-delete'.
(widget-choice-value-get, widget-choice-value-inline): Removed
functions.
(menu-choice): Updated widget.
author | Per Abrahamsen <abraham@dina.kvl.dk> |
---|---|
date | Sat, 27 Dec 2003 16:41:13 +0000 |
parents | 1a5c50faf357 |
children | 9856d5a15940 |
comparison
equal
deleted
inserted
replaced
53318:d7e333de59f9 | 53319:36b31fc002f2 |
---|---|
1 @c -*-texinfo-*- | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | 2 @c This is part of the GNU Emacs Lisp Reference Manual. |
3 @c Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. | 3 @c Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. |
4 @c See the file elisp.texi for copying conditions. | 4 @c See the file elisp.texi for copying conditions. |
5 @setfilename ../info/customize | 5 @setfilename ../info/customize |
6 @node Customization, Loading, Macros, Top | 6 @node Customization, Loading, Macros, Top |
7 @chapter Writing Customization Definitions | 7 @chapter Writing Customization Definitions |
8 | 8 |
371 @menu | 371 @menu |
372 * Simple Types:: | 372 * Simple Types:: |
373 * Composite Types:: | 373 * Composite Types:: |
374 * Splicing into Lists:: | 374 * Splicing into Lists:: |
375 * Type Keywords:: | 375 * Type Keywords:: |
376 * Defining New Types:: | |
376 @end menu | 377 @end menu |
377 | 378 |
378 All customization types are implemented as widgets; see @ref{Top, , | 379 All customization types are implemented as widgets; see @ref{Top, , |
379 Introduction, widget, The Emacs Widget Library}, for details. | 380 Introduction, widget, The Emacs Widget Library}, for details. |
380 | 381 |
1054 arguments, which will be used when creating the @code{radio-button} or | 1055 arguments, which will be used when creating the @code{radio-button} or |
1055 @code{checkbox} associated with this item. | 1056 @code{checkbox} associated with this item. |
1056 @end ignore | 1057 @end ignore |
1057 @end table | 1058 @end table |
1058 | 1059 |
1060 @node Defining New Types | |
1061 @subsection Defining New Types | |
1062 | |
1063 In the previous sections we have described how to construct elaborate | |
1064 type specifications for @code{defcustom}. In some cases you may want to | |
1065 give such a type specification a name. The obvious case is when you are | |
1066 using the same type for many user options, rather than repeat the | |
1067 specification for each option, you can give the type specification a | |
1068 name once, and use that name each @code{defcustom}. The other case is | |
1069 when a user option accept a recursive datastructure. To make it | |
1070 possible for a datatype to refer to itself, it needs to have a name. | |
1071 | |
1072 Since custom types are implemented as widgets, the way to define a new | |
1073 customize type is to define a new widget. We are not going to describe | |
1074 the widget interface here in details, see @ref{Top, , Introduction, | |
1075 widget, The Emacs Widget Library}, for that. Instead we are going to | |
1076 demonstrate the minimal functionality needed for defining new customize | |
1077 types by a simple example. | |
1078 | |
1079 @example | |
1080 (define-widget 'binary-tree-of-string 'lazy | |
1081 "A binary tree made of cons-cells and strings." | |
1082 :offset 4 | |
1083 :tag "Node" | |
1084 :type '(choice (string :tag "Leaf" :value "") | |
1085 (cons :tag "Interior" | |
1086 :value ("" . "") | |
1087 binary-tree-of-string | |
1088 binary-tree-of-string))) | |
1089 | |
1090 (defcustom foo-bar "" | |
1091 "Sample variable holding a binary tree of strings." | |
1092 :type 'binary-tree-of-string) | |
1093 @end example | |
1094 | |
1095 The function to define a new widget is name @code{define-widget}. The | |
1096 first argument is the symbol we want to make a new widget type. The | |
1097 second argument is a symbol representing an existing widget, the new | |
1098 widget is going to be defined in terms of difference from the existing | |
1099 widget. For the purpose of defining new customization types, the | |
1100 @code{lazy} widget is perfect, because it accept a @code{:type} keyword | |
1101 argument with the same syntax as the keyword argument to | |
1102 @code{defcustom} with the same name. The third argument is a | |
1103 documentation string for the new widget. You will be able to see that | |
1104 string with the @kbd{M-x widget-browse @key{ret} binary-tree-of-string | |
1105 @key{ret}} command. | |
1106 | |
1107 After these mandatory arguments follows the keyword arguments. The most | |
1108 important is @code{:type}, which describes the datatype we want to match | |
1109 with this widget. Here a @code{binary-tree-of-string} is described as | |
1110 being either a string, or a cons-cell whose car and cdr are themselves | |
1111 both @code{binary-tree-of-string}. Note the reference to the widget | |
1112 type we are currently in the process of defining. The @code{:tag} | |
1113 attribute is a string to name the widget in the user interface, and the | |
1114 @code{:offset} argument are there to ensure that child nodes are | |
1115 indented four spaces relatively to the parent node, making the tree | |
1116 structure apparent in the customization buffer. | |
1117 | |
1118 The @code{defcustom} shows how the new widget can be used as an ordinary | |
1119 customization type. | |
1120 | |
1121 If you wonder about the name @code{lazy}, know that the other composite | |
1122 widgets convert their inferior widgets to internal form when the widget | |
1123 is instantiated in a buffer. This conversion is recursive, so the | |
1124 inferior widgets will convert @emph{their} inferior widgets. If the | |
1125 datastructure is itself recursive, this conversion will go on forever, | |
1126 or at least until Emacs run out of stack space. The @code{lazy} widget | |
1127 stop this recursion, it will only convert its @code{:type} argument when | |
1128 needed. | |
1129 | |
1059 @ignore | 1130 @ignore |
1060 arch-tag: d1b8fad3-f48c-4ce4-a402-f73b5ef19bd2 | 1131 arch-tag: d1b8fad3-f48c-4ce4-a402-f73b5ef19bd2 |
1061 @end ignore | 1132 @end ignore |