Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Re: nnmail-split-fancy: How to Write ``X but not Y''?
       [not found] <ywr4rd2iwcn.fsf@ioka.flux.utah.edu>
@ 2002-09-12 16:47 ` Eric Eide
  0 siblings, 0 replies; only message in thread
From: Eric Eide @ 2002-09-12 16:47 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-09-12 16:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ywr4rd2iwcn.fsf@ioka.flux.utah.edu>
2002-09-12 16:47 ` nnmail-split-fancy: How to Write ``X but not Y''? Eric Eide

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).