From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/2720 Path: news.gmane.org!not-for-mail From: Hubert Canon Newsgroups: gmane.emacs.gnus.user Subject: Re: =?iso-8859-15?q?how_convert_my_huge_nnmail-split-methods_in?= =?iso-8859-15?q?to_nnmail-split-fancy=A0=3F?= Date: Tue, 08 Jul 2003 10:06:35 +0200 Organization: Chapi Chapo Message-ID: References: <4nu1afh13f.fsf@lockgroove.bwh.harvard.edu> Reply-To: Hubert Canon NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1138669050 16105 80.91.229.2 (31 Jan 2006 00:57:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Jan 2006 00:57:30 +0000 (UTC) Original-X-From: nobody Tue Jan 17 17:31:07 2006 Original-Path: quimby.gnus.org!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!skynet.be!skynet.be!freenix!usenet-fr.net!proxad.net!feeder2-1.proxad.net!news3-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.gnus X-Comment: membre du CAS, du GASDPQL, du MACQPAD et du MMQLPI X-Accept-Language: fr,fr-BE,en,en-UK,en-US,de,ar,tr,it User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (windows-nt) X-Face: N&lH"8+zC:K;58u"[H=J}}Xq~hK4nJ$ePLUL+33~!G}\Ff$@_X.}=%cJ;Z`RA;5qm~|8kE? Ted Zlatanov 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