Mercurial > hg > xemacs-beta
comparison man/lispref/customize.texi @ 1833:eed841acc858
[xemacs-hg @ 2003-12-19 14:28:45 by youngs]
2003-12-15 Steve Youngs <sryoungs@bigpond.net.au>
* wid-edit.el (lazy): New.
(widget-child-value-get): New.
(widget-child-value-inline): New.
(widget-child-validate): New.
(widget-type-value-create): New.
(widget-type-default-get): New.
(widget-type-match): New.
This adds a "lazy" widget to allow the definition of recursive
datatypes for customize. The composite widgets expand their
subtypes immediately, which cause obvious problems for recursive
datatypes. The "lazy" will only expand them when needed, hense
the name.
From Per Abrahamsen <abraham@dina.kvl.dk>
2003-12-15 Steve Youngs <sryoungs@bigpond.net.au>
* lispref/customize.texi (Defining New Types): New node.
From Per Abrahamsen <abraham@dina.kvl.dk>
author | youngs |
---|---|
date | Fri, 19 Dec 2003 14:29:07 +0000 |
parents | 47c30044fc4e |
children | 4f0a1f4cc111 |
comparison
equal
deleted
inserted
replaced
1832:5d8dcaecc32b | 1833:eed841acc858 |
---|---|
323 @menu | 323 @menu |
324 * Simple Types:: | 324 * Simple Types:: |
325 * Composite Types:: | 325 * Composite Types:: |
326 * Splicing into Lists:: | 326 * Splicing into Lists:: |
327 * Type Keywords:: | 327 * Type Keywords:: |
328 * Defining New Types:: | |
328 @end menu | 329 @end menu |
329 | 330 |
330 @node Simple Types | 331 @node Simple Types |
331 @subsection Simple Types | 332 @subsection Simple Types |
332 | 333 |
850 | 851 |
851 Called interactively, prompt the user for @var{behavior}, and take | 852 Called interactively, prompt the user for @var{behavior}, and take |
852 @var{force} from the prefix argument. | 853 @var{force} from the prefix argument. |
853 @end defun | 854 @end defun |
854 | 855 |
856 @node Defining New Types | |
857 @subsection Defining New Types | |
858 | |
859 In the previous sections we have described how to construct elaborate | |
860 type specifications for @code{defcustom}. In some cases you may want to | |
861 give such a type specification a name. The obvious case is when you are | |
862 using the same type for many user options, rather than repeat the | |
863 specification for each option, you can give the type specification a | |
864 name once, and use that name each @code{defcustom}. The other case is | |
865 when a user option accept a recursive datastructure. To make it | |
866 possible for a datatype to refer to itself, it needs to have a name. | |
867 | |
868 Since custom types are implemented as widgets, the way to define a new | |
869 customize type is to define a new widget. We are not going to describe | |
870 the widget interface here in details, see @ref{Top, , Introduction, | |
871 widget, The Emacs Widget Library}, for that. Instead we are going to | |
872 demonstrate the minimal functionality needed for defining new customize | |
873 types by a simple example. | |
874 | |
875 @example | |
876 (define-widget 'binary-tree-of-string 'lazy | |
877 "A binary tree made of cons-cells and strings." | |
878 :offset 4 | |
879 :tag "Node" | |
880 :type '(choice (string :tag "Leaf" :value "") | |
881 (cons :tag "Interior" | |
882 :value ("" . "") | |
883 binary-tree-of-string | |
884 binary-tree-of-string))) | |
885 | |
886 (defcustom foo-bar "" | |
887 "Sample variable holding a binary tree of strings." | |
888 :type 'binary-tree-of-string) | |
889 @end example | |
890 | |
891 The function to define a new widget is name @code{define-widget}. The | |
892 first argument is the symbol we want to make a new widget type. The | |
893 second argument is a symbol representing an existing widget, the new | |
894 widget is going to be defined in terms of difference from the existing | |
895 widget. For the purpose of defining new customization types, the | |
896 @code{lazy} widget is perfect, because it accept a @code{:type} keyword | |
897 argument with the same syntax as the keyword argument to | |
898 @code{defcustom} with the same name. The third argument is a | |
899 documentation string for the new widget. You will be able to see that | |
900 string with the @kbd{M-x widget-browse @key{ret} binary-tree-of-string | |
901 @key{ret}} command. | |
902 | |
903 After these mandatory arguments follows the keyword arguments. The most | |
904 important is @code{:type}, which describes the datatype we want to match | |
905 with this widget. Here a @code{binary-tree-of-string} is described as | |
906 being either a string, or a cons-cell whose car and cdr are themselves | |
907 both @code{binary-tree-of-string}. Note the reference to the widget | |
908 type we are currently in the process of defining. The @code{:tag} | |
909 attribute is a string to name the widget in the user interface, and the | |
910 @code{:offset} argument are there to ensure that child nodes are | |
911 indented four spaces relatively to the parent node, making the tree | |
912 structure apparent in the customization buffer. | |
913 | |
914 The @code{defcustom} shows how the new widget can be used as an ordinary | |
915 customization type. |