Gnus development mailing list
 help / color / mirror / Atom feed
* bbdb and nnmail-split-fancy
@ 2002-04-03 22:58 Michael Cook
  2002-04-04  0:49 ` David Z Maze
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michael Cook @ 2002-04-03 22:58 UTC (permalink / raw)


does anyone know offhand how to get nnmail-split-fancy to pay
attention to what's in my bbdb address book?
that is, i want to say:

 if the message is addressed to me then
    if the message is from someone in my address book
       put the message into my inbox
    else
       put the message into the folder "other".

(seems like there should be a bbdb section in the gnus info pages.)

m.



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

* Re: bbdb and nnmail-split-fancy
  2002-04-03 22:58 bbdb and nnmail-split-fancy Michael Cook
@ 2002-04-04  0:49 ` David Z Maze
  2002-04-06  7:07 ` Michael Cook
  2002-04-06  7:39 ` Jack Twilley
  2 siblings, 0 replies; 6+ messages in thread
From: David Z Maze @ 2002-04-04  0:49 UTC (permalink / raw)


Michael Cook <michael@waxrat.com> writes:
> does anyone know offhand how to get nnmail-split-fancy to pay
> attention to what's in my bbdb address book?
> that is, i want to say:
> 
>  if the message is addressed to me then
>     if the message is from someone in my address book
>        put the message into my inbox
>     else
>        put the message into the folder "other".

My .gnus file has the following construct:

(defun dzm-bbdb-split-fancy ()
  "Create a fancy mail split according to bbdb rules.
Look at entries in the bbdb.  For every entry with a \"mail-group\"
field, generate an appropriate split."
  (cons '&
	(apply 'nconc
	       (mapcan
		(lambda (rec)
		  (let ((nets (bbdb-record-net rec))
			(group (bbdb-record-getprop rec 'mail-group)))
		    (if group
			(cons
			 (mapcar
			  (lambda (net)
			    (list 'any (regexp-quote net) group))
			  nets)
			 nil))))
		(bbdb-records)))))

This looks rather Schemeful to me now, probably because I wrote it
around the time I was taking 6.001, MIT's introductory computer
science class, which apparently the esteemed Mr. Saklad hasn't had the
benefit of.  But the output of this can be dropped directly into
nnmail-split-fancy, like so:

(setq nnmail-split-fancy
      ;; Split to the first matching...
      `(|
        ;; Mailing lists...
        (&
         (any "ding@gnus\\.org" "mail.lists.ding")
         ;; etc.
        )
        ;; Individuals we know of from bbdb
        ,(dzm-bbdb-split-fancy)
        ;; Personal mail (or not)
        (any "dmaze@.*mit\\.edu" "mail.misc.personal")
        "mail.misc.impersonal"))

(Now, to figure out how to augment this recipe to use the new spam.el
stuff...)

-- 
David Maze             dmaze@mit.edu          http://www.mit.edu/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell




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

* Re: bbdb and nnmail-split-fancy
  2002-04-03 22:58 bbdb and nnmail-split-fancy Michael Cook
  2002-04-04  0:49 ` David Z Maze
@ 2002-04-06  7:07 ` Michael Cook
  2002-04-06  7:39 ` Jack Twilley
  2 siblings, 0 replies; 6+ messages in thread
From: Michael Cook @ 2002-04-06  7:07 UTC (permalink / raw)


Michael Cook <michael@waxrat.com> writes:

> does anyone know offhand how to get nnmail-split-fancy to pay
> attention to what's in my bbdb address book?

ok, how about this:

(defun split-if-in-bbdb (field split)
  ;; FIELD is "from" or "to" or "cc".
  ;; SPLIT is an `nnmail-split-fancy' "split" construct.
  (let ((from (message-fetch-field field)))
    (and from
	 (let ((comp (condition-case ()
			 (mail-extract-address-components from)
		       (error nil))))
	   (and (bbdb-search-simple (car comp) (cadr comp))
		split)))))

then, in nnmail-split-fancy, something like this:

  (setq nnmail-split-fancy
        '(| ...
            (: split-if-in-bbdb "from" "inbox")
            "other"))

so, if the sender of the message is in your bbdb, then the message
gets split into your inbox folder.  otherwise, it gets split into
your "other" folder.

m.



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

* Re: bbdb and nnmail-split-fancy
  2002-04-03 22:58 bbdb and nnmail-split-fancy Michael Cook
  2002-04-04  0:49 ` David Z Maze
  2002-04-06  7:07 ` Michael Cook
@ 2002-04-06  7:39 ` Jack Twilley
  2002-04-06 17:20   ` Michael Cook
  2 siblings, 1 reply; 6+ messages in thread
From: Jack Twilley @ 2002-04-06  7:39 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


There are more sophisticated ways to get nnmail-split-fancy to work
with bbdb.

I have records for people that have gnus-private values and records
for mailing lists that have gnus-public values.  It's bbdb-gnus.el in
bbdb.  Very straightforward stuff.  Here's my nnmail-split-fancy:

 '(| ("mail.gnus-warning" "duplication of messages" "duplicate")
     (any "jmt\\+usenet@.*"
	  (| ("subject" "re:.*" "mail.misc")
	     ("references" ".*@.*" "mail.misc")
	     "mail.spam"))
     (any "usenet@.*" "mail.spam")
     ;; other mail
     (from "Cron Daemon" "mail.cron")
     (from mail "mail.warning")
     (from "root" "mail.root")
     ;; people and mailing lists
     (: jmt-bbdb-gnus-split-fancy)
     ;; diplomacy stuff
     (: judge-split)
     ;; and everything else...
     (to "jmt" "mail.misc")
     "mail.spam")

Short and sweet.  If I implement any more sophisticated attempts at
reducing spam, I'll do it with elisp and (: ...) since that looks easy
enough.

Here's the wrapper function:

(defun jmt-bbdb-gnus-split-fancy () 
  "this is just a boring wrapper function"
  (let ((x (bbdb/gnus-split-method)))
    (when x (cons '& x))))

Here's two example records:

judge-maint mailing list
            net: judge-maint@diplom.org, judge-maint@igo.org
    gnus-public: list.judge-maint .*
    last-access: 2002-03-28

Lisa-Marie Presley
            net: lisa_presley@hotmail.com
   gnus-private: people.Lisa_Presley
    last-access: 2002-03-28

Hope that helps!

Jack.
- -- 
Jack Twilley
jmt at twilley dot org
http colon slash slash www dot twilley dot org slash tilde jmt slash
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8rqZOGPFSfAB/ezgRAsV+AKDA+QcuQ0bTEZJ/bQr62KX6WAXaJwCcDNNZ
IuftojZw+udc7clHuPMS1Uk=
=eK3l
-----END PGP SIGNATURE-----



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

* Re: bbdb and nnmail-split-fancy
  2002-04-06  7:39 ` Jack Twilley
@ 2002-04-06 17:20   ` Michael Cook
  2002-04-06 20:46     ` Jack Twilley
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Cook @ 2002-04-06 17:20 UTC (permalink / raw)


Jack Twilley <jmt+usenet@twilley.org> writes:

> There are more sophisticated ways to get nnmail-split-fancy to work
> with bbdb.
>
> I have records for people that have gnus-private values and records
> for mailing lists that have gnus-public values.  It's bbdb-gnus.el in
> bbdb.  Very straightforward stuff.

the downside is that you need to manage those gnus-private and
gnus-public values in the bbdb records.  which is a little more
work, at least.

the split-if-in-bbdb approach doesn't require you to edit any of
your bbdb records.  and it makes for a nice spam detection
heuristic.  if someone sends me mail, even if they address it
directly to me (like most spammers seem to do these days), it'll
still get split into my "other" folder instead of into my "inbox"
folder.  i need to scan my other folder's *summary* buffer
occasionally to see if any non-spam ended up there.  but if that
happens, i just select the non-spam message and type `:' to add the
sender to my bbdb.  kinda nice, i think.

btw, here is is again with a minor fix:

(defun split-if-in-bbdb (field split)
  ;; FIELD is "from" or "to" or "cc".
  ;; SPLIT is an `nnmail-split-fancy' "split" construct.
  (let ((from (message-fetch-field field)))
    (and from
	 (let ((comp (condition-case ()
			 (mail-extract-address-components from)
		       (error nil))))
	   (and comp
		(bbdb-search-simple (car comp) (cadr comp))
		split)))))

m.



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

* Re: bbdb and nnmail-split-fancy
  2002-04-06 17:20   ` Michael Cook
@ 2002-04-06 20:46     ` Jack Twilley
  0 siblings, 0 replies; 6+ messages in thread
From: Jack Twilley @ 2002-04-06 20:46 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


>>>>> "Michael" == Michael Cook <michael@waxrat.com> writes:

Jack> There are more sophisticated ways to get nnmail-split-fancy to
Jack> work with bbdb.

Jack> I have records for people that have gnus-private values and
Jack> records for mailing lists that have gnus-public values.  It's
Jack> bbdb-gnus.el in bbdb.  Very straightforward stuff.

Michael> the downside is that you need to manage those gnus-private
Michael> and gnus-public values in the bbdb records.  which is a
Michael> little more work, at least.

Adding one line to one record that is from someone I know isn't too
much work for me.  Especially when my bbdb gets the occasional bit of
litter in it as I add darn near every address I see.

Michael> the split-if-in-bbdb approach doesn't require you to edit any
Michael> of your bbdb records.  and it makes for a nice spam detection
Michael> heuristic.  if someone sends me mail, even if they address it
Michael> directly to me (like most spammers seem to do these days),
Michael> it'll still get split into my "other" folder instead of into
Michael> my "inbox" folder.  i need to scan my other folder's
Michael> *summary* buffer occasionally to see if any non-spam ended up
Michael> there.  but if that happens, i just select the non-spam
Michael> message and type `:' to add the sender to my bbdb.  kinda
Michael> nice, i think.

This heuristic only works if you assume that no spammers are in your
bbdb.  This is not necessarily true if all senders and recipients are
added to bbdb by default.  

[...]

Jack.
(to each their own)
- -- 
Jack Twilley
jmt at twilley dot org
http colon slash slash www dot twilley dot org slash tilde jmt slash
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8r17KGPFSfAB/ezgRAsBYAKDdXNiRwfUO5VDki5wfpCyB+RbJKgCfeYq7
5JT+io/1UK3QtVkVqrcGHMM=
=wFI8
-----END PGP SIGNATURE-----



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

end of thread, other threads:[~2002-04-06 20:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-03 22:58 bbdb and nnmail-split-fancy Michael Cook
2002-04-04  0:49 ` David Z Maze
2002-04-06  7:07 ` Michael Cook
2002-04-06  7:39 ` Jack Twilley
2002-04-06 17:20   ` Michael Cook
2002-04-06 20:46     ` Jack Twilley

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