* Re: how convert my huge nnmail-split-methods into nnmail-split-fancy ?
[not found] ` <4nu1afh13f.fsf@lockgroove.bwh.harvard.edu>
@ 2003-07-08 8:06 ` Hubert Canon
0 siblings, 0 replies; only message in thread
From: Hubert Canon @ 2003-07-08 8:06 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] only message in thread