Synch to Gnus 200311251206.
[elisp/gnus.git-] / lisp / spam.el
index 436e2a2..4280e26 100644 (file)
@@ -556,41 +556,43 @@ spamoracle database."
        (gnus-summary-mark-article article gnus-spam-mark)))))
 
 (defun spam-mark-spam-as-expired-and-move-routine (&rest groups)
-  (gnus-summary-kill-process-mark)
-  (let ((articles gnus-newsgroup-articles)
-       (backend-supports-deletions
-        (gnus-check-backend-function
-         'request-move-article gnus-newsgroup-name))
-       article tomove deletep)
-    (dolist (article articles)
-      (when (eq (gnus-summary-article-mark article) gnus-spam-mark)
-       (gnus-summary-mark-article article gnus-expirable-mark)
-       (push article tomove)))
+  (if (and groups (listp (car groups)))
+      (apply 'spam-mark-spam-as-expired-and-move-routine (car groups))
+    (gnus-summary-kill-process-mark)
+    (let ((articles gnus-newsgroup-articles)
+         (backend-supports-deletions
+          (gnus-check-backend-function
+           'request-move-article gnus-newsgroup-name))
+         article tomove deletep)
+      (dolist (article articles)
+       (when (eq (gnus-summary-article-mark article) gnus-spam-mark)
+         (gnus-summary-mark-article article gnus-expirable-mark)
+         (push article tomove)))
     
-    ;; now do the actual copies
-    (dolist (group groups)
-      (when (and tomove
-                (stringp 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
+           (if (or (not backend-supports-deletions)
+                   (> (length groups) 1))
+               (progn 
+                 (gnus-summary-copy-article nil group)
+                 (setq deletep t))
+             (gnus-summary-move-article nil group)))))
+    
+      ;; now delete the articles, if there was a copy done, and the
+      ;; backend allows it
+      (when (and deletep backend-supports-deletions)
        (dolist (article tomove)
          (gnus-summary-set-process-mark article))
        (when tomove
-         (if (or (not backend-supports-deletions)
-               (> (length groups) 1))
-             (progn 
-               (gnus-summary-copy-article nil group)
-               (setq deletep t))
-           (gnus-summary-move-article nil group)))))
-    
-    ;; now delete the articles, if there was a copy done, and the
-    ;; backend allows it
-    (when (and deletep backend-supports-deletions)
-      (dolist (article tomove)
-       (gnus-summary-set-process-mark article))
-      (when tomove
-       (let ((gnus-novice-user nil))   ; don't ask me if I'm sure
-         (gnus-summary-delete-article nil))))
+         (let ((gnus-novice-user nil)) ; don't ask me if I'm sure
+           (gnus-summary-delete-article nil))))
     
-    (gnus-summary-yank-process-mark)))
+      (gnus-summary-yank-process-mark))))
  
 (defun spam-ham-copy-or-move-routine (copy groups)
   (gnus-summary-kill-process-mark)
@@ -598,12 +600,17 @@ spamoracle database."
        (backend-supports-deletions
         (gnus-check-backend-function
          'request-move-article gnus-newsgroup-name))
-       article mark todo deletep)
+       (respool-method (gnus-find-method-for-group gnus-newsgroup-name))
+       article mark todo deletep respool)
     (dolist (article articles)
       (when (spam-group-ham-mark-p gnus-newsgroup-name
                                   (gnus-summary-article-mark article))
        (push article todo)))
 
+    (when (member 'respool groups)
+      (setq respool t)                 ; boolean for later
+      (setq groups '("fake"))) ; when respooling, groups are dynamic so fake it
+
     ;; now do the actual move
     (dolist (group groups)
       (when (and todo (stringp group))
@@ -612,12 +619,14 @@ spamoracle database."
            (gnus-summary-mark-article article gnus-unread-mark))
          (gnus-summary-set-process-mark article))
 
-       (if (or (not backend-supports-deletions)
-               (> (length groups) 1))
-           (progn 
-             (gnus-summary-copy-article nil group)
-             (setq deletep t))
-         (gnus-summary-move-article nil group))))
+       (if respool                        ; respooling is with a "fake" group
+           (gnus-summary-respool-article nil respool-method)
+         (if (or (not backend-supports-deletions) ; else, we are not respooling
+                 (> (length groups) 1))
+             (progn                    ; if copying, copy and set deletep
+               (gnus-summary-copy-article nil group)
+               (setq deletep t))
+           (gnus-summary-move-article nil group))))) ; else move articles
     
     ;; now delete the articles, unless a) copy is t, and there was a copy done
     ;;                                 b) a move was done to a single group
@@ -633,10 +642,14 @@ spamoracle database."
   (gnus-summary-yank-process-mark))
  
 (defun spam-ham-copy-routine (&rest groups)
-  (spam-ham-copy-or-move-routine t groups))
+  (if (and groups (listp (car groups)))
+      (apply 'spam-ham-copy-routine (car groups))
+    (spam-ham-copy-or-move-routine t groups)))
  
 (defun spam-ham-move-routine (&rest groups)
-  (spam-ham-copy-or-move-routine nil groups))
+  (if (and groups (listp (car groups)))
+      (apply 'spam-ham-move-routine (car groups))
+    (spam-ham-copy-or-move-routine nil groups)))
  
 (defun spam-generic-register-routine (spam-func ham-func)
   (let ((articles gnus-newsgroup-articles)