Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Hubert Canon <hcanon@alussinan.org>
Subject: Re: how convert my huge nnmail-split-methods into nnmail-split-fancy ?
Date: Tue, 08 Jul 2003 10:06:35 +0200	[thread overview]
Message-ID: <uadbpe92s.fsf.hcanon@alussinan.org> (raw)
In-Reply-To: <4nu1afh13f.fsf@lockgroove.bwh.harvard.edu>

Ted Zlatanov <tzz@lifelogs.com> schrieb :

> On Tue, 24 Jun 2003, hcanon@alussinan.org wrote:
>> I am trying to use spam-split but I discovered that I need to use
>> nnmail-split-fancy. The problem is that I already have a
>> nnmail-split-methods which has grown out of proportions (3 pages).
>> 
>> Is there a way to use spam-split as is, or should I convert my
>> nnmail-split-methods into a nnmail-split-fancy ? Is there a way
>> (some macro or function) to do it automatically ?
>
> There isn't one currently, but it shouldn't be too hard to write one
> (spam-split-methods maybe).  The key is to cache the return of
> (spam-split) because the group checking function seems to be invoked
> for every mailbox in the nnmail-split-methods list.  I don't use
> nnmail-split-methods so I can't test this very well, but the general
> algorithm should be:

I tried your proposed method, and it seems to work : I have some spams
going into the spam group. But I don't get many spam anymore, so I am
not totally sure that I don't loose some of them.


> 1. initialize a hashtable spam-split-methods-cache outside
>    spam-split-methods
>
> (setq spam-split-methods-cache 
>   (make-hash-table
>     :test 'equal))
>
> 2. spam-split-methods
>
> a) get the message-id
>
> b) if no entry in spam-split-methods-cache for that message ID, make
> entry with the result of (spam-split)
>
> c) get the spam-split-methods-cache entry for the current message-ID,
> and compare it to the group name passed to us from the splitting
> functionality
>
> (defun spam-split-methods (groupname)
> "Call spam-split for consumption by nnmail-split-methods"
>  (let ((message-id (message-fetch-field "Message-ID"))
>        (val (gethash message-id spam-split-methods-cache)))
>   (when (and (stringp groupname) (stringp message-id))
>    (unless val
>     (setq val (spam-split))
>     (puthash message-id val spam-split-methods-cache))
>    (equal groupname val))))

I corrected your `let' with the obvious `let*'

> This is untested, let me know by e-mail if there are problems and the
> result will probably make it to spam.el eventually.

For the moment, it seems to work. I will use it some more time to
convince me that it really works. I would be more confident if other
volunteer to try it.


-- 
Hubert Canon
Please excuse my bad English


           reply	other threads:[~2003-07-08  8:06 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <4nu1afh13f.fsf@lockgroove.bwh.harvard.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=uadbpe92s.fsf.hcanon@alussinan.org \
    --to=hcanon@alussinan.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).