Synch to No Gnus 200406071711.
[elisp/gnus.git-] / lisp / spam.el
index a158364..af3c838 100644 (file)
@@ -38,6 +38,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl))
+(eval-when-compile (require 'spam-report))
 
 (require 'path-util)
 (require 'gnus-sum)
@@ -704,7 +705,7 @@ finds ham or spam.")
 
 (defun spam-group-spam-contents-p (group)
   "Is GROUP a spam group?"
-  (if (stringp group)
+  (if (and (stringp group) (< 0 (length group)))
       (or (member group spam-junk-mailgroups)
          (memq 'gnus-group-spam-classification-spam
                (gnus-parameter-spam-contents group)))
@@ -729,6 +730,8 @@ finds ham or spam.")
     (gnus-group-spam-exit-processor-spamoracle   spam spam-use-spamoracle)
     (nil spam spam-use-crm114)
     (gnus-group-spam-exit-processor-spamassassin spam spam-use-spamassassin)
+
+    (nil ham spam-use-resend)
     (gnus-group-ham-exit-processor-ifile         ham spam-use-ifile)
     (gnus-group-ham-exit-processor-bogofilter    ham spam-use-bogofilter)
     (gnus-group-ham-exit-processor-bsfilter      ham spam-use-bsfilter)
@@ -774,15 +777,19 @@ Respects the process/prefix convention."
     (gnus-summary-remove-process-mark article)
     (spam-report-gmane article)))
 
-(defun spam-report-articles-resend (n)
+(defun spam-report-articles-resend (n &optional ham)
   "Report the current message as spam by resending it.
 Respects the process/prefix convention.  Also see
-`spam-report-resend-to'."
+`spam-report-resend-to'.  Operates as ham when HAM is set."
   (interactive "P")
-  (let ((spam-report-resend-to 
-        (gnus-parameter-spam-resend-to gnus-newsgroup-name))
-       (articles (gnus-summary-work-articles n)))
-    (spam-report-resend articles)
+  (let* ((gp
+         (if ham 
+             (gnus-parameter-ham-resend-to gnus-newsgroup-name)
+           (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
+         (spam-report-resend-to (or (car-safe gp)
+                                    spam-report-resend-to))
+         (articles (gnus-summary-work-articles n)))
+    (spam-report-resend articles ham)
     (dolist (article articles)
       (gnus-summary-remove-process-mark article))))
 
@@ -908,15 +915,18 @@ Will not return a nil score."
             (num (spam-mark-spam-as-expired-and-move-routine group)))
        (when (> num 0)
          (gnus-message 6
-                       "%d spam messages are marked as expired and moved it to %s"
-                       num group))))
+                       "%d spam messages are marked as expired%s."
+                       num
+                       (if group 
+                           (format " and moved it to %s" group)
+                         "")))))
 
     ;; now we redo spam-mark-spam-as-expired-and-move-routine to only
     ;; expire spam, in case the above did not expire them
     (let ((num (spam-mark-spam-as-expired-and-move-routine nil)))
       (when (> num 0)
        (gnus-message 6
-                     "%d spam messages are markd as expired without moving it"
+                     "%d spam messages were marked as expired."
                      num)))
 
     (when (or (spam-group-ham-contents-p gnus-newsgroup-name)
@@ -937,7 +947,7 @@ Will not return a nil score."
             (spam-ham-copy-routine
              (gnus-parameter-ham-process-destination gnus-newsgroup-name))))
        (when (> num 0)
-         (gnus-message 6 "%d ham messages are copied" num))))
+         (gnus-message 6 "%d ham messages were copied" num))))
 
     ;; now move all ham articles out of spam groups
     (when (spam-group-spam-contents-p gnus-newsgroup-name)
@@ -945,7 +955,7 @@ Will not return a nil score."
             (spam-ham-move-routine
              (gnus-parameter-ham-process-destination gnus-newsgroup-name))))
        (when (> num 0)
-         (gnus-message 6 "%d ham messages are moved from spam group" num)))))
+         (gnus-message 6 "%d ham messages were moved from spam group" num)))))
 
   (setq spam-old-ham-articles nil)
   (setq spam-old-spam-articles nil))
@@ -1377,7 +1387,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                         ;; does Gmane support unregistration?
                         nil
                         nil)
-    (spam-use-resend     nil
+    (spam-use-resend     spam-report-resend-register-ham-routine
                         spam-report-resend-register-routine
                         nil
                         nil)
@@ -1472,21 +1482,22 @@ functions")
                            gnus-newsgroup-articles
                            classification)))
        ;; process them
-       (gnus-message 5 "%s %d %s articles as %s using backend %s"
-                     (if unregister "Unregistering" "Registering")
-                     (length articles)
-                     (if specific-articles "specific" "")
-                     (symbol-name classification)
-                     (symbol-name check))
-       (funcall run-function articles)
-       ;; now log all the registrations (or undo them, depending on unregister)
-       (dolist (article articles)
-         (funcall log-function
-                  (spam-fetch-field-message-id-fast article)
-                  'process
-                  classification
-                  check
-                  gnus-newsgroup-name))))))
+        (when (> (length articles) 0)
+         (gnus-message 5 "%s %d %s articles as %s using backend %s"
+                       (if unregister "Unregistering" "Registering")
+                       (length articles)
+                       (if specific-articles "specific" "")
+                       (symbol-name classification)
+                       (symbol-name check))
+         (funcall run-function articles)
+         ;; now log all the registrations (or undo them, depending on unregister)
+         (dolist (article articles)
+           (funcall log-function
+                    (spam-fetch-field-message-id-fast article)
+                    'process
+                    classification
+                    check
+                    gnus-newsgroup-name)))))))
 
 ;;; log a ham- or spam-processor invocation to the registry
 (defun spam-log-processing-to-registry (id type classification check group)
@@ -2113,9 +2124,17 @@ REMOVE not nil, remove the ADDRESSES."
   (when articles
     (apply 'spam-report-gmane articles)))
 
-(defun spam-report-resend-register-routine (articles)
-  (let ((spam-report-resend-to (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
-       (spam-report-resend articles)))
+(defun spam-report-resend-register-ham-routine (articles)
+  (spam-report-resend-register-routine articles t))
+
+(defun spam-report-resend-register-routine (articles &optional ham)
+  (let* ((resend-to-gp 
+         (if ham
+             (gnus-parameter-ham-resend-to gnus-newsgroup-name)
+           (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
+         (spam-report-resend-to (or (car-safe resend-to-gp)
+                                    spam-report-resend-to)))
+    (spam-report-resend articles ham)))
 
 \f
 ;;;; Bogofilter