On 9 Apr 2002, Stephen J. Turnbull wrote:
>> I think it's very unlikely to get added to 21.4.
This is
>> definitely a feature.
Simon> Is 21.4 feature frozen?
Only about 14 months now. ;-)
Darn.
Simon> Maybe it could go into 21.5.
Yes, definitely we should synch custom stuff for 21.5.
Support for new widgets shouldn't be a problem, but in general custom
stuff is likely to be somewhat controversial. Please try to get Jan
Vroonhof's <jan(a)xemacs.org> opinion on any internal changes, as he has
an on-going project to make Customize "theme-able". Hrvoje Niksic
<hrvoje(a)xemacs.org> also has worked a lot on Customize. Both are
currently busy with day job but usually respond quickly to direct
questions.
Jan, Hrvoje, what do you think of the patch below? It adds the alist and
plist widget from Emacs. The alist widget solve's browse-url.el's
problem, I did not test the plist widget but it looks OK.
I am wondering about how to change browse-url.el. It seems as if the two
options are to either use (repeat (cons regexp function)) or to add the
alist widget to mail-lib, loading it only for old XEmacs that does not
have this feature. The first solution might not be the right thing
(otherwise, why was the alist widget invented?). This is a generic
problem with the package system and we've been here before though...
2002-04-09 Simon Josefsson <jas(a)extundo.com>
Add plist and alist widgets, from Emacs.
* wid-edit.el (plist): New widget.
(widget-plist-value-type): New variable.
(widget-plist-convert-widget, widget-plist-convert-option): New
function.
(alist): New widget.
(widget-alist-value-type): New variable.
(widget-alist-convert-widget, widget-alist-convert-option): New
function.
Index: lisp/wid-edit.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/wid-edit.el,v
retrieving revision 1.21
diff -u -r1.21 wid-edit.el
--- lisp/wid-edit.el 2002/03/15 07:43:22 1.21
+++ lisp/wid-edit.el 2002/04/09 12:14:59
@@ -3584,7 +3584,96 @@
(and (consp value)
(widget-group-match widget
(widget-apply widget :value-to-internal value))))
+
+;;; The `plist' Widget.
+;;
+;; Property lists.
+(define-widget 'plist 'list
+ "A property list."
+:key-type '(symbol :tag "Key")
+:value-type '(sexp :tag "Value")
+:convert-widget 'widget-plist-convert-widget
+:tag "Plist")
+
+(defvar widget-plist-value-type) ;Dynamic variable
+
+(defun widget-plist-convert-widget (widget)
+ ;; Handle `:options'.
+ (let* ((options (widget-get widget :options))
+ (widget-plist-value-type (widget-get widget :value-type))
+ (other `(editable-list :inline t
+ (group :inline t
+ ,(widget-get widget :key-type)
+ ,widget-plist-value-type)))
+ (args (if options
+ (list `(checklist :inline t
+ :greedy t
+ ,@(mapcar 'widget-plist-convert-option
+ options))
+ other)
+ (list other))))
+ (widget-put widget :args args)
+ widget))
+
+(defun widget-plist-convert-option (option)
+ ;; Convert a single plist option.
+ (let (key-type value-type)
+ (if (listp option)
+ (let ((key (nth 0 option)))
+ (setq value-type (nth 1 option))
+ (if (listp key)
+ (setq key-type key)
+ (setq key-type `(const ,key))))
+ (setq key-type `(const ,option)
+ value-type widget-plist-value-type))
+ `(group :format "Key: %v" :inline t ,key-type ,value-type)))
+
+
+;;; The `alist' Widget.
+;;
+;; Association lists.
+
+(define-widget 'alist 'list
+ "An association list."
+:key-type '(sexp :tag "Key")
+:value-type '(sexp :tag "Value")
+:convert-widget 'widget-alist-convert-widget
+:tag "Alist")
+
+(defvar widget-alist-value-type) ;Dynamic variable
+
+(defun widget-alist-convert-widget (widget)
+ ;; Handle `:options'.
+ (let* ((options (widget-get widget :options))
+ (widget-alist-value-type (widget-get widget :value-type))
+ (other `(editable-list :inline t
+ (cons :format "%v"
+ ,(widget-get widget :key-type)
+ ,widget-alist-value-type)))
+ (args (if options
+ (list `(checklist :inline t
+ :greedy t
+ ,@(mapcar 'widget-alist-convert-option
+ options))
+ other)
+ (list other))))
+ (widget-put widget :args args)
+ widget))
+
+(defun widget-alist-convert-option (option)
+ ;; Convert a single alist option.
+ (let (key-type value-type)
+ (if (listp option)
+ (let ((key (nth 0 option)))
+ (setq value-type (nth 1 option))
+ (if (listp key)
+ (setq key-type key)
+ (setq key-type `(const ,key))))
+ (setq key-type `(const ,option)
+ value-type widget-alist-value-type))
+ `(cons :format "Key: %v" ,key-type ,value-type)))
+
(define-widget 'choice 'menu-choice
"A union of several sexp types."
:tag "Choice"