Gnus development mailing list
 help / color / mirror / Atom feed
* nnmail-split-fancy customization type
@ 2003-12-09 12:20 Per Abrahamsen
  2003-12-15 23:20 ` Katsumi Yamaoka
  0 siblings, 1 reply; 4+ messages in thread
From: Per Abrahamsen @ 2003-12-09 12:20 UTC (permalink / raw)


Hi!

I just gave the nnmail-split-fancy defcustom a proper :type argument.
Computers are fast enough for that these days.

The :type should handle the documented syntax of nnmail-split-fancy,
but it caught a couple of errors in my setting of that variable.

It is implemented on top of a "nnmail-lazy" widget, which I'm also
going to commit to Emacs (under the name "lazy") when their CVS server
start working again.  I hope someone else will commit it to XEmacs
CVS.

If you have some recursive datastructures you want to create a :type
for, I suggest you look at the "nnmail-lazy" (or "lazy") widgets.  

I have commited the following patch:

Index: ChangeLog
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/ChangeLog,v
retrieving revision 6.2687
diff -u -r6.2687 ChangeLog
--- ChangeLog	8 Dec 2003 14:17:35 -0000	6.2687
+++ ChangeLog	9 Dec 2003 11:24:53 -0000
@@ -1,3 +1,8 @@
+2003-12-09  Per Abrahamsen  <abraham@dina.kvl.dk>
+
+	* nnmail.el (nnmail-lazy, nnmail-split-fancy): New widgets.
+	(nnmail-split-fancy): Use it.
+
 2003-12-08  Joel Ray Holveck <joelh@piquan.org>  (tiny change)
 
 	* gnus-sum.el (gnus-summary-save-parts-1): Consider the "name"
Index: nnmail.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/nnmail.el,v
retrieving revision 6.83
diff -u -r6.83 nnmail.el
--- nnmail.el	12 Nov 2003 20:54:36 -0000	6.83
+++ nnmail.el	9 Dec 2003 11:24:53 -0000
@@ -363,6 +363,64 @@
   :type '(choice (const :tag "infinite" nil)
                  (number :tag "count")))
 
+(define-widget 'nnmail-lazy 'default
+  "Base widget for recursive datastructures.
+
+This is copy of the `lazy' widget in Emacs 21.4 provided for compatibility."
+  :format "%{%t%}: %v"
+  :convert-widget 'widget-value-convert-widget
+  :value-create (lambda (widget)
+                  (let ((value (widget-get widget :value))
+                        (type (widget-get widget :type)))
+                    (widget-put widget :children 
+                                (list (widget-create-child-value 
+                                       widget (widget-convert type) value)))))
+  :value-delete 'widget-children-value-delete
+  :value-get (lambda (widget)
+               (widget-value (car (widget-get widget :children))))
+  :value-inline (lambda (widget)
+                  (widget-apply (car (widget-get widget :children))
+                                :value-inline))
+  :default-get (lambda (widget)
+                 (widget-default-get
+                  (widget-convert (widget-get widget :type))))
+  :match (lambda (widget value)
+           (widget-apply (widget-convert (widget-get widget :type))
+                         :match value))
+  :validate (lambda (widget)
+              (widget-apply (car (widget-get widget :children)) :validate)))
+
+(define-widget 'nnmail-split-fancy 'nnmail-lazy
+  "Widget for customizing splits in the variable of the same name."
+  :tag "Split"
+  :type '(menu-choice :value (any ".*value.*" "misc")
+                      :tag "Type"
+                      (string :tag "Destination")
+                      (list :tag "Or" :value (|)
+                            (const :format "" |)
+                            (editable-list :inline t nnmail-split-fancy))
+                      (list :tag "And" :value (&)
+                            (const :format "" &)
+                            (editable-list :inline t nnmail-split-fancy))
+                      (list :tag "Function with fixed arguments"
+                            :value (:)
+                            (const :format "" :value :)
+                            function 
+                            (editable-list :inline t (sexp :tag "Arg"))
+                            )
+                      (list :tag "Function with split arguments" :value (!)
+                            (const :format "" !)
+                            function
+                            (editable-list :inline t nnmail-split-fancy))
+                      (list :tag "Field match" 
+                            (choice :tag "Field" 
+                                    regexp symbol)
+                            (choice :tag "Match"
+                                    regexp 
+                                    (symbol :value mail))
+                            nnmail-split-fancy)
+                      (const :tag "Junk" junk)))
+
 (defcustom nnmail-split-fancy "mail.misc"
   "Incoming mail can be split according to this fancy variable.
 To enable this, set `nnmail-split-methods' to `nnmail-split-fancy'.
@@ -438,8 +496,7 @@
 	  ;; Unmatched mail goes to the catch all group.
 	  \"misc.misc\"))"
   :group 'nnmail-split
-  ;; Sigh!
-  :type 'sexp)
+  :type 'nnmail-split-fancy)
 
 (defcustom nnmail-split-abbrev-alist
   '((any . "from\\|to\\|cc\\|sender\\|apparently-to\\|resent-from\\|resent-to\\|resent-cc")




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: nnmail-split-fancy customization type
  2003-12-09 12:20 nnmail-split-fancy customization type Per Abrahamsen
@ 2003-12-15 23:20 ` Katsumi Yamaoka
  2003-12-16 10:38   ` Per Abrahamsen
  0 siblings, 1 reply; 4+ messages in thread
From: Katsumi Yamaoka @ 2003-12-15 23:20 UTC (permalink / raw)


>>>>> In <rjpteyuqri.fsf@sheridan.dina.kvl.dk>
>>>>>	Per Abrahamsen <abraham@dina.kvl.dk> wrote:

> Hi!

> I just gave the nnmail-split-fancy defcustom a proper :type argument.
> Computers are fast enough for that these days.

> The :type should handle the documented syntax of nnmail-split-fancy,
> but it caught a couple of errors in my setting of that variable.

> It is implemented on top of a "nnmail-lazy" widget, which I'm also
> going to commit to Emacs (under the name "lazy") when their CVS server
> start working again.  I hope someone else will commit it to XEmacs
> CVS.

> If you have some recursive datastructures you want to create a :type
> for, I suggest you look at the "nnmail-lazy" (or "lazy") widgets.  

> I have commited the following patch:

I made nnmail-split-fancy customizable also with Emacs 20
yesterday.  However, I've noticed that a problem is not only it.
It is mismatched even to the example of its docstring.  Am I
misunderstanding?  I'm interested in customization even though
I'm not using it. :-p
-- 
Katsumi Yamaoka <yamaoka@jpl.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: nnmail-split-fancy customization type
  2003-12-15 23:20 ` Katsumi Yamaoka
@ 2003-12-16 10:38   ` Per Abrahamsen
  2003-12-16 10:44     ` Katsumi Yamaoka
  0 siblings, 1 reply; 4+ messages in thread
From: Per Abrahamsen @ 2003-12-16 10:38 UTC (permalink / raw)


Katsumi Yamaoka <yamaoka@jpl.org> writes:

> It is mismatched even to the example of its docstring.  

I forgot to add support for restrictions, fixed now.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: nnmail-split-fancy customization type
  2003-12-16 10:38   ` Per Abrahamsen
@ 2003-12-16 10:44     ` Katsumi Yamaoka
  0 siblings, 0 replies; 4+ messages in thread
From: Katsumi Yamaoka @ 2003-12-16 10:44 UTC (permalink / raw)


>>>>> In <rj3cblt5c1.fsf@sheridan.dina.kvl.dk>
>>>>>	Per Abrahamsen <abraham@dina.kvl.dk> wrote:

> Katsumi Yamaoka <yamaoka@jpl.org> writes:

>> It is mismatched even to the example of its docstring.

> I forgot to add support for restrictions, fixed now.

Wow! that's gorgeous.  Thank you.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-12-16 10:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-09 12:20 nnmail-split-fancy customization type Per Abrahamsen
2003-12-15 23:20 ` Katsumi Yamaoka
2003-12-16 10:38   ` Per Abrahamsen
2003-12-16 10:44     ` Katsumi Yamaoka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).