* gnus.el (spam-process-destination, ham-process-destination):
authorTeodor Zlatanov <tzz@lifelogs.com>
Thu, 23 Oct 2003 21:51:08 +0000 (21:51 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Thu, 23 Oct 2003 21:51:08 +0000 (21:51 +0000)
allow multiple groups as a choice

* spam.el (spam-mark-spam-as-expired-and-move-routine): added multiple
group support (multiple copies, then delete)
(spam-ham-copy-routine): new function
(spam-ham-move-routine): new function
(spam-ham-copy-or-move-routine): new function (used to be
spam-ham-move-routine), handle multiple groups
(spam-summary-prepare-exit): call the new functions

lisp/ChangeLog
lisp/gnus.el
lisp/spam.el

index 1462cc2..3667ba9 100644 (file)
@@ -1,9 +1,19 @@
 2003-10-23  Teodor Zlatanov  <tzz@lifelogs.com>
 
+       * gnus.el (spam-process-destination, ham-process-destination):
+       allow multiple groups as a choice
+
        * spam.el (spam-check-blackholes): remove "[IP address]"
        requirement, now just "IP address" is enough for detection for
        blackhole checking
        (spam-check-blackholes): oops, the dots were not escaped
+       (spam-mark-spam-as-expired-and-move-routine): added multiple group
+       support (multiple copies, then delete)
+       (spam-ham-copy-routine): new function
+       (spam-ham-move-routine): new function
+       (spam-ham-copy-or-move-routine): new function (used to be
+       spam-ham-move-routine), handle multiple groups
+       (spam-summary-prepare-exit): call the new functions
 
 2003-10-23  Simon Josefsson  <jas@extundo.com>
 
index 205e17e..962d0f0 100644 (file)
@@ -1885,25 +1885,27 @@ Only applicable to non-spam (unclassified and ham) groups.")
   (gnus-define-group-parameter
    spam-process
    :type list
-   :parameter-type '(choice :tag "Spam Summary Exit Processor"
-                           :value nil
-                           (list :tag "Spam Summary Exit Processor Choices"
-                                 (set
-                                  (variable-item gnus-group-spam-exit-processor-ifile)
-                                  (variable-item gnus-group-spam-exit-processor-stat)
-                                  (variable-item gnus-group-spam-exit-processor-bogofilter)
-                                  (variable-item gnus-group-spam-exit-processor-blacklist)
-                                  (variable-item gnus-group-spam-exit-processor-report-gmane)
-                                  (variable-item gnus-group-spam-exit-processor-spamoracle)
-                                  (variable-item gnus-group-ham-exit-processor-bogofilter)
-                                  (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-copy)
-                                  (variable-item gnus-group-ham-exit-processor-spamoracle))))
+   :parameter-type 
+   '(choice 
+     :tag "Spam Summary Exit Processor"
+     :value nil
+     (list :tag "Spam Summary Exit Processor Choices"
+          (set
+           (variable-item gnus-group-spam-exit-processor-ifile)
+           (variable-item gnus-group-spam-exit-processor-stat)
+           (variable-item gnus-group-spam-exit-processor-bogofilter)
+           (variable-item gnus-group-spam-exit-processor-blacklist)
+           (variable-item gnus-group-spam-exit-processor-report-gmane)
+           (variable-item gnus-group-spam-exit-processor-spamoracle)
+           (variable-item gnus-group-ham-exit-processor-bogofilter)
+           (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-copy)
+           (variable-item gnus-group-ham-exit-processor-spamoracle))))
    :function-document
-   "Which spam or ham processors will be applied to the GROUP articles at summary exit."
+   "Which spam or ham processors will be applied when the summary is exited."
    :variable gnus-spam-process-newsgroups
    :variable-default nil
    :variable-document
@@ -1912,29 +1914,34 @@ a backend on summary exit.  If non-nil, this should be a list of group
 name regexps that should match all groups in which to do automatic
 spam processing, associated with the appropriate processor."
    :variable-group spam
-   :variable-type '(repeat :tag "Spam/Ham Processors"
-                          (list :tag "Spam Summary Exit Processor Choices"
-                                (regexp :tag "Group Regexp")
-                                (set :tag "Spam/Ham Summary Exit Processor"
-                                     (variable-item gnus-group-spam-exit-processor-ifile)
-                                     (variable-item gnus-group-spam-exit-processor-stat)
-                                     (variable-item gnus-group-spam-exit-processor-bogofilter)
-                                     (variable-item gnus-group-spam-exit-processor-blacklist)
-                                     (variable-item gnus-group-spam-exit-processor-report-gmane)
-                                     (variable-item gnus-group-ham-exit-processor-bogofilter)
-                                     (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-copy))))
+   :variable-type 
+   '(repeat :tag "Spam/Ham Processors"
+           (list :tag "Spam Summary Exit Processor Choices"
+                 (regexp :tag "Group Regexp")
+                 (set 
+                  :tag "Spam/Ham Summary Exit Processor"
+                  (variable-item gnus-group-spam-exit-processor-ifile)
+                  (variable-item gnus-group-spam-exit-processor-stat)
+                  (variable-item gnus-group-spam-exit-processor-bogofilter)
+                  (variable-item gnus-group-spam-exit-processor-blacklist)
+                  (variable-item gnus-group-spam-exit-processor-report-gmane)
+                  (variable-item gnus-group-ham-exit-processor-bogofilter)
+                  (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-copy))))
    :parameter-document
-   "Which spam processors will be applied to the spam or ham GROUP articles at summary exit.")
+   "Which spam or ham processors will be appliedwhen the summary is exited.")
 
   (gnus-define-group-parameter
    spam-process-destination
-   :parameter-type '(choice :tag "Destination for spam-processed articles at summary exit"
-                           (string :tag "Move to a group")
-                           (const :tag "Expire" nil))
+   :parameter-type 
+   '(choice :tag "Destination for spam-processed articles at summary exit"
+           (string :tag "Move to a group")
+           (repeat :tag "Move to multiple groups"
+                   (string :tag "Destination group"))
+           (const :tag "Expire" nil))
    :function-document
    "Where spam-processed articles will go at summary exit."
    :variable gnus-spam-process-destinations
@@ -1947,23 +1954,29 @@ to do spam-processed article moving, associated with the destination
 group or nil for explicit expiration.  This only makes sense for
 mail groups."
    :variable-group spam
-   :variable-type '(repeat
-                   :tag "Spam-processed articles destination"
-                   (list
-                    (regexp :tag "Group Regexp")
-                    (choice
-                     :tag "Destination for spam-processed articles at summary exit"
-                     (string :tag "Move to a group")
-                     (const :tag "Expire" nil))))
+   :variable-type 
+   '(repeat
+     :tag "Spam-processed articles destination"
+     (list
+      (regexp :tag "Group Regexp")
+      (choice
+       :tag "Destination for spam-processed articles at summary exit"
+       (string :tag "Move to a group")
+       (repeat :tag "Move to multiple groups"
+              (string :tag "Destination group"))
+       (const :tag "Expire" nil))))
    :parameter-document
    "Where spam-processed articles will go at summary exit.")
-
+  
   (gnus-define-group-parameter
    ham-process-destination
-   :parameter-type '(choice
-                    :tag "Destination for ham articles at summary exit from a spam group"
-                    (string :tag "Move to a group")
-                    (const :tag "Do nothing" nil))
+   :parameter-type 
+   '(choice
+     :tag "Destination for ham articles at summary exit from a spam group"
+     (string :tag "Move to a group")
+     (repeat :tag "Move to multiple groups"
+            (string :tag "Destination group"))
+     (const :tag "Do nothing" nil))
    :function-document
    "Where ham articles will go at summary exit from a spam group."
    :variable gnus-ham-process-destinations
@@ -1976,14 +1989,17 @@ to do ham article moving, associated with the destination
 group or nil for explicit ignoring.  This only makes sense for
 mail groups, and only works in spam groups."
    :variable-group spam
-   :variable-type '(repeat
-                   :tag "Ham articles destination"
-                   (list
-                    (regexp :tag "Group Regexp")
-                    (choice
-                     :tag "Destination for ham articles at summary exit from spam group"
-                     (string :tag "Move to a group")
-                     (const :tag "Expire" nil))))
+   :variable-type 
+   '(repeat
+     :tag "Ham articles destination"
+     (list
+      (regexp :tag "Group Regexp")
+      (choice
+       :tag "Destination for ham articles at summary exit from spam group"
+       (string :tag "Move to a group")
+       (repeat :tag "Move to multiple groups"
+              (string :tag "Destination group"))
+       (const :tag "Expire" nil))))
    :parameter-document
    "Where ham articles will go at summary exit from a spam group.")
 
index 0ab7d27..a7d84ee 100644 (file)
@@ -525,8 +525,8 @@ spamoracle database."
 
     (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))
+      (spam-ham-copy-routine
+       (gnus-parameter-ham-process-destination gnus-newsgroup-name)))
 
     ;; now move all ham articles out of spam groups
     (when (spam-group-spam-contents-p gnus-newsgroup-name)
@@ -548,7 +548,7 @@ spamoracle database."
       (dolist (article articles)
        (gnus-summary-mark-article article gnus-spam-mark)))))
 
-(defun spam-mark-spam-as-expired-and-move-routine (&optional group)
+(defun spam-mark-spam-as-expired-and-move-routine (&rest groups)
   (gnus-summary-kill-process-mark)
   (let ((articles gnus-newsgroup-articles)
        article tomove)
@@ -557,36 +557,55 @@ spamoracle database."
        (gnus-summary-mark-article article gnus-expirable-mark)
        (push article tomove)))
 
-    ;; now do the actual move
-    (when (and tomove
-              (stringp group))
-      (dolist (article tomove)
-       (gnus-summary-set-process-mark article))
-      (when tomove (gnus-summary-move-article nil group))))
+    ;; now do the actual copies
+    (dolist (group groups)
+      (when (and tomove
+                (stringp group))
+       (dolist (article tomove)
+         (gnus-summary-set-process-mark article))
+       (when tomove
+         (gnus-summary-copy-article nil group))))
+
+    ;; now delete the articles
+    (dolist (article tomove)
+      (gnus-summary-set-process-mark article))
+    (when tomove
+      (gnus-summary-delete-article nil)))
+
   (gnus-summary-yank-process-mark))
  
-(defun spam-ham-move-routine (&optional group copy)
+(defun spam-ham-copy-or-move-routine (copy &rest groups)
   (gnus-summary-kill-process-mark)
   (let ((articles gnus-newsgroup-articles)
-       article mark tomove)
-    (when (stringp group)              ; this routine will do nothing
-                                       ; without a valid group
-      (dolist (article articles)
-       (when (spam-group-ham-mark-p gnus-newsgroup-name
-                                    (gnus-summary-article-mark article))
-         (push article tomove)))
+       article mark todo)
+    (dolist (article articles)
+      (when (spam-group-ham-mark-p gnus-newsgroup-name
+                                  (gnus-summary-article-mark article))
+       (push article todo)))
 
-      ;; now do the actual move
-      (when tomove
-       (dolist (article tomove)
+    ;; now do the actual move
+    (dolist (group groups)
+      (when todo
+       (dolist (article todo)
          (when spam-mark-ham-unread-before-move-from-spam-group
-           (gnus-summary-mark-article article gnus-unread-mark))           
+           (gnus-summary-mark-article article gnus-unread-mark))
          (gnus-summary-set-process-mark article))
-       (if copy
-           (gnus-summary-copy-article nil group)
-         (gnus-summary-move-article nil group)))))
+       (gnus-summary-copy-article nil group)))
+  
+    ;; now delete the articles
+    (dolist (article todo)
+      (gnus-summary-set-process-mark article))
+    (when todo
+      (gnus-summary-delete-article nil)))
+  
   (gnus-summary-yank-process-mark))
  
+(defun spam-ham-copy-routine (&rest groups)
+  (spam-ham-copy-or-move-routine t groups))
+(defun spam-ham-move-routine (&rest groups)
+  (spam-ham-copy-or-move-routine nil groups))
 (defun spam-generic-register-routine (spam-func ham-func)
   (let ((articles gnus-newsgroup-articles)
        article mark ham-articles spam-articles)