From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/50247 Path: main.gmane.org!not-for-mail From: Michael Shields Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] New spam processor: ham copy Date: Fri, 21 Feb 2003 21:46:06 +0000 Organization: Mad Science Research Labs Sender: owner-ding@hpc.uh.edu Message-ID: <877kbt9ujl.fsf@mulligatwani.msrl.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1045864031 7996 80.91.224.249 (21 Feb 2003 21:47:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 21 Feb 2003 21:47:11 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18mL0f-00024m-00 for ; Fri, 21 Feb 2003 22:47:09 +0100 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 18mL02-0005Yw-00; Fri, 21 Feb 2003 15:46:30 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Fri, 21 Feb 2003 15:47:28 -0600 (CST) Original-Received: from sclp3.sclp.com (sclp3.sclp.com [66.230.238.2]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id PAA27761 for ; Fri, 21 Feb 2003 15:47:15 -0600 (CST) Original-Received: (qmail 65582 invoked by alias); 21 Feb 2003 21:46:13 -0000 Original-Received: (qmail 65577 invoked from network); 21 Feb 2003 21:46:13 -0000 Original-Received: from challah.msrl.com (198.137.194.222) by 66.230.238.6 with SMTP; 21 Feb 2003 21:46:13 -0000 Original-Received: (qmail 3243 invoked from network); 21 Feb 2003 21:46:07 -0000 Original-Received: from localhost (HELO mulligatwani.msrl.com) (127.0.0.1) by localhost with SMTP; 21 Feb 2003 21:46:07 -0000 Original-To: ding@gnus.org Original-Lines: 136 User-Agent: Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.4 (Military Intelligence) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:50247 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:50247 I've set up my Gnus configuration to copy ham and move spam to dedicated groups for later processing, as someone suggested here a few weeks ago. This lets me run Bayesian trainers across them from a cronjob on the server. Gnus is already able to move spam to a dedicated group, but the ham copying support is new. I also found and fixed a bug in spam-ham-move-routine and spam-mark-spam-as-expired-and-move-routine: they set the process mark on all articles to be moved and then call gnus-summary-move-article, but if there are no articles to be moved, g-s-m-a will move the current article. lisp/ChangeLog addition: 2003-02-21 Michael Shields * gnus.el (gnus-install-group-spam-parameters): New. * spam.el (spam-group-ham-processor-copy-p): New. * spam.el (spam-summary-prepare-exit): Support for ham copying. * spam.el (spam-mark-spam-as-expired-and-move-routine): Fix bug that would cause the current message to be moved if the group had no spam. * spam.el (spam-ham-move-routine): New `copy' argument. gnus source patch: Diff command: cvs -q diff -u Files affected: lisp/spam.el lisp/gnus.el Index: lisp/gnus.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/gnus.el,v retrieving revision 6.159 diff -u -r6.159 gnus.el --- lisp/gnus.el 20 Feb 2003 01:31:11 -0000 6.159 +++ lisp/gnus.el 21 Feb 2003 21:52:01 -0000 @@ -1845,6 +1845,10 @@ "The BBDB summary exit ham processor. Only applicable to non-spam (unclassified and ham) groups.") + (defvar gnus-group-ham-exit-processor-copy "copy" + "The ham copy exit ham processor. +Only applicable to non-spam (unclassified and ham) groups.") + (gnus-define-group-parameter spam-process :type list @@ -1860,7 +1864,8 @@ (variable-item gnus-group-ham-exit-processor-ifile) (variable-item gnus-group-ham-exit-processor-stat) (variable-item gnus-group-ham-exit-processor-whitelist) - (variable-item gnus-group-ham-exit-processor-BBDB)))) + (variable-item gnus-group-ham-exit-processor-BBDB) + (variable-item gnus-group-ham-exit-processor-copy)))) :function-document "Which spam or ham processors will be applied to the GROUP articles at summary exit." :variable gnus-spam-process-newsgroups @@ -1884,7 +1889,8 @@ (variable-item gnus-group-ham-exit-processor-ifile) (variable-item gnus-group-ham-exit-processor-stat) (variable-item gnus-group-ham-exit-processor-whitelist) - (variable-item gnus-group-ham-exit-processor-BBDB)))) + (variable-item gnus-group-ham-exit-processor-BBDB) + (variable-item gnus-group-ham-exit-processor-copy)))) :parameter-document "Which spam processors will be applied to the spam or ham GROUP articles at summary exit.") Index: lisp/spam.el =================================================================== RCS file: /usr/local/cvsroot/gnus/lisp/spam.el,v retrieving revision 6.71 diff -u -r6.71 spam.el --- lisp/spam.el 20 Feb 2003 00:39:05 -0000 6.71 +++ lisp/spam.el 21 Feb 2003 21:52:02 -0000 @@ -336,6 +349,9 @@ (defun spam-group-ham-processor-BBDB-p (group) (spam-group-processor-p group 'gnus-group-ham-exit-processor-BBDB)) +(defun spam-group-ham-processor-copy-p (group) + (spam-group-processor-p group 'gnus-group-ham-exit-processor-copy)) + ;;; Summary entry and exit processing. (defun spam-summary-prepare () @@ -394,6 +410,11 @@ (gnus-message 5 "Registering ham with the BBDB") (spam-BBDB-register-routine))) + (when (spam-group-ham-processor-copy-p gnus-newsgroup-name) + (gnus-message 5 "Copying ham") + (spam-ham-move-routine + (gnus-parameter-ham-process-destination gnus-newsgroup-name) t)) + ;; now move all ham articles out of spam groups (when (spam-group-spam-contents-p gnus-newsgroup-name) (gnus-message 5 "Moving ham messages from spam group") @@ -424,13 +445,14 @@ (push article tomove))) ;; now do the actual move - (when (stringp group) + (when (and tomove + (stringp group)) (dolist (article tomove) (gnus-summary-set-process-mark article)) (when tomove (gnus-summary-move-article nil group)))) (gnus-summary-yank-process-mark)) -(defun spam-ham-move-routine (&optional group) +(defun spam-ham-move-routine (&optional group copy) (gnus-summary-kill-process-mark) (let ((articles gnus-newsgroup-articles) article ham-mark-values mark tomove) @@ -443,9 +465,12 @@ (push article tomove))) ;; now do the actual move - (dolist (article tomove) - (gnus-summary-set-process-mark article)) - (when tomove (gnus-summary-move-article nil group)))) + (when tomove + (dolist (article tomove) + (gnus-summary-set-process-mark article)) + (if copy + (gnus-summary-copy-article nil group) + (gnus-summary-move-article nil group))))) (gnus-summary-yank-process-mark)) (defun spam-generic-register-routine (spam-func ham-func) -- Shields.