Synch to No Gnus 200402270146.
[elisp/gnus.git-] / lisp / spam.el
index dc1a24a..aa4ff13 100644 (file)
@@ -73,7 +73,7 @@
 (defgroup spam nil
   "Spam configuration.")
 
-(defcustom spam-directory "~/News/spam/"
+(defcustom spam-directory (nnheader-concat gnus-directory "spam/")
   "Directory for spam whitelists and blacklists."
   :type 'directory
   :group 'spam)
@@ -499,9 +499,9 @@ order for SpamAssassin to recognize the new registered spam."
 ;;; Key bindings for spam control.
 
 (gnus-define-keys gnus-summary-mode-map
-  "St" spam-bogofilter-score
+  "St" spam-generic-score
   "Sx" gnus-summary-mark-as-spam
-  "Mst" spam-bogofilter-score
+  "Mst" spam-generic-score
   "Msx" gnus-summary-mark-as-spam
   "\M-d" gnus-summary-mark-as-spam)
 
@@ -585,14 +585,14 @@ finds ham or spam.")
     (gnus-group-spam-exit-processor-ifile        spam spam-use-ifile)
     (gnus-group-spam-exit-processor-stat         spam spam-use-stat)
     (gnus-group-spam-exit-processor-spamoracle   spam spam-use-spamoracle)
-    (gnus-group-spam-exit-processor-spamassassin spam spam-use-spam-spamassassin)
+    (gnus-group-spam-exit-processor-spamassassin spam spam-use-spamassassin)
     (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-stat          ham spam-use-stat)
     (gnus-group-ham-exit-processor-whitelist     ham spam-use-whitelist)
     (gnus-group-ham-exit-processor-BBDB          ham spam-use-BBDB)
     (gnus-group-ham-exit-processor-copy          ham spam-use-ham-copy)
-    (gnus-group-ham-exit-processor-spamassassin  ham spam-use-ham-spamassassin)
+    (gnus-group-ham-exit-processor-spamassassin  ham spam-use-spamassassin)
     (gnus-group-ham-exit-processor-spamoracle    ham spam-use-spamoracle))
   "The `spam-list-of-processors' list.
 This list contains pairs associating a ham/spam exit processor
@@ -667,6 +667,15 @@ Respects the process/prefix convention."
     (gnus-summary-remove-process-mark article)
     (spam-report-gmane article)))
 
+(defun spam-generic-score ()
+  (interactive)
+  "Invoke whatever scoring method we can."
+  (if (or
+       spam-use-spamassassin
+       spam-use-spamassassin-headers)
+      (spam-spamassassin-score)
+    (spam-bogofilter-score)))
+
 ;;; Summary entry and exit processing.
 
 (defun spam-summary-prepare ()
@@ -690,7 +699,7 @@ Respects the process/prefix convention."
             (new-articles (spam-list-articles
                            gnus-newsgroup-articles
                            classification))
-            (changed-articles (gnus-set-difference old-articles new-articles)))
+            (changed-articles (gnus-set-difference new-articles old-articles)))
        ;; now that we have the changed articles, we go through the processors
        (dolist (processor-param spam-list-of-processors)
          (let ((processor (nth 0 processor-param))
@@ -954,6 +963,7 @@ Respects the process/prefix convention."
     (spam-use-regex-body               .       spam-check-regex-body)
     (spam-use-whitelist                .       spam-check-whitelist)
     (spam-use-BBDB                     .       spam-check-BBDB)
+    (spam-use-BBDB-exclusive           .       spam-check-BBDB)
     (spam-use-ifile                    .       spam-check-ifile)
     (spam-use-spamoracle               .       spam-check-spamoracle)
     (spam-use-stat                     .       spam-check-stat)
@@ -1132,6 +1142,10 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                         nil
                         spam-whitelist-unregister-routine
                         nil)
+    (spam-use-ham-copy   nil
+                        nil
+                        nil
+                        nil)
     (spam-use-BBDB      spam-BBDB-register-routine
                         nil
                         spam-BBDB-unregister-routine
@@ -1238,7 +1252,7 @@ functions")
                            gnus-newsgroup-articles
                            classification)))
        ;; process them
-       (gnus-message 5 "%s %d %s articles with classification %s, check %s"
+       (gnus-message 5 "%s %d %s articles as %s using backend %s"
                      (if unregister "Unregistering" "Registering")
                      (length articles)
                      (if specific-articles "specific" "")
@@ -1270,8 +1284,10 @@ functions")
           type
           cell-list))
 
-      (gnus-error 5 (format "%s called with bad ID, type, classification, check, or group"
-                           "spam-log-processing-to-registry")))))
+      (gnus-error 
+       5 
+       (format "%s call with bad ID, type, classification, spam-check, or group"
+              "spam-log-processing-to-registry")))))
 
 ;;; check if a ham- or spam-processor registration has been done
 (defun spam-log-registered-p (id type)
@@ -1280,8 +1296,10 @@ functions")
             (spam-process-type-valid-p type))
        (cdr-safe (gnus-registry-fetch-extra id type))
       (progn
-       (gnus-error 5 (format "%s called with bad ID, type, classification, or check"
-                             "spam-log-registered-p"))
+       (gnus-error 
+        5 
+        (format "%s called with bad ID, type, classification, or spam-check"
+                "spam-log-registered-p"))
        nil))))
 
 ;;; check what a ham- or spam-processor registration says
@@ -1300,6 +1318,7 @@ functions")
        nil
       decision)))
 
+
 ;;; check if a ham- or spam-processor registration needs to be undone
 (defun spam-log-unregistration-needed-p (id type classification check)
   (when spam-log-to-registry
@@ -1316,8 +1335,10 @@ functions")
                (setq found t))))
          found)
       (progn
-       (gnus-error 5 (format "%s called with bad ID, type, classification, or check"
-                             "spam-log-unregistration-needed-p"))
+       (gnus-error 
+        5 
+        (format "%s called with bad ID, type, classification, or spam-check"
+                "spam-log-unregistration-needed-p"))
        nil))))
 
 
@@ -1340,7 +1361,7 @@ functions")
           type
           new-cell-list))
       (progn
-       (gnus-error 5 (format "%s called with bad ID, type, check, or group"
+       (gnus-error 5 (format "%s call with bad ID, type, spam-check, or group"
                              "spam-log-undo-registration"))
        nil))))
 
@@ -1967,7 +1988,7 @@ REMOVE not nil, remove the ADDRESSES."
                  (goto-char (point-min))
                  (when (re-search-forward "^X-Spam: yes;" nil t)
                    spam-split-group))
-             (error "Error running spamoracle" status))))))))
+             (error "Error running spamoracle: %s" status))))))))
 
 (defun spam-spamoracle-learn (articles article-is-spam-p &optional unregister)
   "Run spamoracle in training mode."
@@ -1989,8 +2010,8 @@ REMOVE not nil, remove the ADDRESSES."
                           `("-f" ,spam-spamoracle-database
                             "add" ,arg)
                         `("add" ,arg)))))
-         (when (not (eq 0 status))
-           (error "Error running spamoracle" status)))))))
+         (unless (eq 0 status)
+           (error "Error running spamoracle: %s" status)))))))
 
 (defun spam-spamoracle-learn-ham (articles &optional unregister)
   (spam-spamoracle-learn articles nil unregister))
@@ -2088,10 +2109,10 @@ REMOVE not nil, remove the ADDRESSES."
 (defun spam-spamassassin-register-ham-routine (articles &optional unregister)
   (spam-spamassassin-register-with-sa-learn articles nil unregister))
 
-(defun spam-assassin-register-spam-routine (articles)
+(defun spam-spamassassin-unregister-spam-routine (articles)
   (spam-spamassassin-register-with-sa-learn articles t t))
 
-(defun spam-assassin-register-ham-routine (articles)
+(defun spam-spamassassin-unregister-ham-routine (articles)
   (spam-spamassassin-register-with-sa-learn articles nil t))
 \f
 ;;;; Hooks