Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Eric Eide <eeide@cs.utah.edu>
Subject: Re: nnmail-split-fancy: How to Write ``X but not Y''?
Date: Thu, 12 Sep 2002 10:47:05 -0600 (MDT)	[thread overview]
Message-ID: <ywrhegv40l2.fsf@ioka.flux.utah.edu> (raw)
In-Reply-To: <ywr4rd2iwcn.fsf@ioka.flux.utah.edu>

I solved my splitting problem by writing a function, `my-nnmail-split-unless'.
In my fancy nnmail split, I use it like this:

    ("subject" "Emacs\\|XEmacs"
     ;; But not XEmacs mailing list messages.
     (: my-nnmail-split-unless '("sender" "xemacs.*@xemacs\\.org" junk)
	"subject.emacs"))

The idea is that if the interpretation of the first split returns a non-nil
value, then the second split is ignored.  Otherwise, the second split is
processed.

In the example above, the `junk' return value of the test split is ignored.
Only the truth value of the test split is important; and `junk' is a convenient
true value.  (The XEmacs list messages are handled elsewhere, by other splits.)

FWIW, below is the defintion of `my-nnmail-split-unless'.  Maybe someone else
will find this to be useful!

Eric.

(defun my-nnmail-split-unless (avoid-split split)
  "If message does not match AVOID-SPLIT, return SPLIT; else return nil.

AVOID-SPLIT is a Gnus `nnmail-split-fancy'-style split.  The split is
interpreted, and if it returns any non-nil value, this function returns nil
\(an ignored split\).  Otherwise, this function returns SPLIT, which is then
interpreted in the normal manner by Gnus.

Note that the specific value returned from the interpretation of AVOID-SPLIT is
discarded; only its truth value is important.  The symbol `junk' is a useful
value to return from the AVOID-SPLIT, to signal that the subsequent SPLIT
should not be processed.

This function is useful for weeding out messages that you don't want to go into
a group.  For instance, consider the following split:

  \(\"subject\" \"Emacs\\\\|XEmacs\"
   \(: my-nnmail-split-unless '(from \"bozo\" junk\) \"subject.emacs\"\)\)

This split will put Emacs-subject and XEmacs-subject messages, except those
from \`bozo\', into the group `subject.emacs'."
  (if (nnmail-split-it avoid-split)
      nil
    split))

-- 
-------------------------------------------------------------------------------
Eric Eide <eeide@cs.utah.edu>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX


           reply	other threads:[~2002-09-12 16:47 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <ywr4rd2iwcn.fsf@ioka.flux.utah.edu>]

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=ywrhegv40l2.fsf@ioka.flux.utah.edu \
    --to=eeide@cs.utah.edu \
    /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).