Gnus development mailing list
 help / color / mirror / Atom feed
From: Kan-Ru Chen <kanru@kanru.info>
To: ding@gnus.org
Subject: Re: Fancy Mail Splitting documentation needs improved?
Date: Mon, 20 Dec 2010 17:28:23 +0800	[thread overview]
Message-ID: <871v5cu72g.fsf@anar.kanru.info> (raw)
In-Reply-To: <m2vd2pzlnb.fsf@verilab.com> (Tommy Kelly's message of "Sun, 19 Dec 2010 12:02:16 -0600")

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]

Tommy Kelly <tommy.kelly@verilab.com> writes:

> OK, I'm stopping here for comments from y'all. Note that I'm thinking
> aloud in the above. For example, the idea that there are four 
> forms of split could probably be simplified into a single syntax
> covering all forms. But I haven't figure out what that looks like yet.

Great idea and rewrite!  I was confused at first when reading the
fancy split method, as I thought the | and & operations was logical
operations, but instead they are group operations. Each SPLIT will be
processed (&) or until one matched (|).

I am implementing the logical operators, so the split rule will look
like sieve rule:

--8<---------------cut here---------------start------------->8---
(setq nnmail-split-fancy
      `(| (or (("x-bogosity" "spam" t)
               ("x-spam-status" "yes" t)
               ("list-id" ".*yahoogroups.com" t)
               (to "undisclosed.*recipients" t))
              "mail.spam")
          (or (("list-id" "awesome" t)
               ("list-id" "notmuch" t)
               ("list-id" "madbutterfly" t))
              "mail.list")
          ,(format-time-string "mail.misc-%Y")))
--8<---------------cut here---------------end--------------->8---

The logical operator syntax is:

--8<---------------cut here---------------start------------->8---
(<OP> (<CLAUSE 1> <CLAUSE 2> ...)
      SPLIT)
--8<---------------cut here---------------end--------------->8---

Each clause is a field split that returns non-nil SPLIT, if the OP of
the clauses was true, then split to SPLIT.

The syntax is not finalized yet, but already fulfilled my needs.  I'd
like to drop the third argument of field split, so that the clauses
looks more clear.  I need your comments!

- Kanru

P.S. Draft patch attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fancysplit.patch --]
[-- Type: text/x-diff, Size: 1443 bytes --]

diff --git a/lisp/nnmail.el b/lisp/nnmail.el
index c86e96b..00de781 100644
--- a/lisp/nnmail.el
+++ b/lisp/nnmail.el
@@ -1389,6 +1389,10 @@ See the documentation for the variable `nnmail-split-fancy' for details."
      ((null split)
       nil)
 
+     ;; t split
+     ((eq split t)
+      (list t))
+
      ;; A group name.  Do the \& and \N subs into the string.
      ((stringp split)
       (when nnmail-split-tracing
@@ -1401,6 +1405,28 @@ See the documentation for the variable `nnmail-split-fancy' for details."
 	(push "junk" nnmail-split-trace))
       (list 'junk))
 
+     ;; Logical OR operation.
+     ((eq (car split) 'or)
+      (let (done
+            (clauses (cadr split))
+            (split (cddr split)))
+        (while (and (not done) (car clauses))
+          (setq done (car (nnmail-split-it (car clauses)))
+                clauses (cdr clauses)))
+        (when done
+          (nnmail-split-it (car split)))))
+
+     ;; Logical AND operation.
+     ((eq (car split) 'and)
+      (let ((done t)
+            (clauses (cadr split))
+            (split (cddr split)))
+        (while (and done (car clauses))
+          (setq done (car (nnmail-split-it (car clauses)))
+                clauses (cdr clauses)))
+        (when (and done (null clauses))
+          (nnmail-split-it (car split)))))
+
      ;; Builtin & operation.
      ((eq (car split) '&)
       (apply 'nconc (mapcar 'nnmail-split-it (cdr split))))

  reply	other threads:[~2010-12-20  9:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-19 18:02 Tommy Kelly
2010-12-20  9:28 ` Kan-Ru Chen [this message]
2010-12-20 17:11   ` Lars Magne Ingebrigtsen
2010-12-21  3:36     ` Kan-Ru Chen
2011-01-02  6:56       ` Lars Magne Ingebrigtsen
2011-01-09 13:00         ` Kan-Ru Chen
2011-01-09 13:27           ` Andreas Schwab
2011-01-09 15:10             ` Kan-Ru Chen
2011-01-11 18:58               ` Lars Magne Ingebrigtsen
2010-12-20 17:16 ` Lars Magne Ingebrigtsen
2010-12-20 17:53   ` Tommy Kelly
2010-12-20 17:56     ` Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871v5cu72g.fsf@anar.kanru.info \
    --to=kanru@kanru.info \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).