spam.el (gnus-summary-mode-map): Bind to "$".
[gnus] / lisp / spam.el
index 8ffb2aa..9e193cc 100644 (file)
@@ -1,26 +1,26 @@
 ;;; spam.el --- Identifying spam
 
-;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
-;; Keywords: network
+;; Maintainer: Ted Zlatanov <tzz@lifelogs.com>
+;; Keywords: network, spam, mail, bogofilter, BBDB, dspam, dig, whitelist, blacklist, gmane, hashcash, spamassassin, bsfilter, ifile, stat, crm114, spamoracle
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 ;;{{{ compilation directives and autoloads/requires
 
+;; For Emacs < 22.2.
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+
 (eval-when-compile (require 'cl))
-(eval-when-compile (require 'spam-report))
 
+(require 'message)             ;for the message-fetch-field functions
 (require 'gnus-sum)
-
 (require 'gnus-uu)                     ; because of key prefix issues
 ;;; for the definitions of group content classification and spam processors
 (require 'gnus)
-(require 'message)             ;for the message-fetch-field functions
+
+(eval-when-compile (require 'spam-report))
+(eval-when-compile (require 'hashcash))
 
 ;; for nnimap-split-download-body-default
 (eval-when-compile (require 'nnimap))
 
 ;; autoload query-dig
-(eval-and-compile
-  (autoload 'query-dig "dig"))
+(autoload 'query-dig "dig")
 
 ;; autoload spam-report
 (eval-and-compile
   (autoload 'spam-report-gmane "spam-report")
+  (autoload 'spam-report-gmane-spam "spam-report")
+  (autoload 'spam-report-gmane-ham "spam-report")
   (autoload 'spam-report-resend "spam-report"))
 
 ;; autoload gnus-registry
-(eval-and-compile
-  (autoload 'gnus-registry-group-count "gnus-registry")
-  (autoload 'gnus-registry-add-group "gnus-registry")
-  (autoload 'gnus-registry-store-extra-entry "gnus-registry")
-  (autoload 'gnus-registry-fetch-extra "gnus-registry"))
+(autoload 'gnus-registry-group-count "gnus-registry")
+(autoload 'gnus-registry-add-group "gnus-registry")
+(autoload 'gnus-registry-store-extra-entry "gnus-registry")
+(autoload 'gnus-registry-fetch-extra "gnus-registry")
 
-;; autoload query-dns
-(eval-and-compile
-  (autoload 'query-dns "dns"))
+;; autoload dns-query
+(autoload 'dns-query "dns")
 
 ;;}}}
 
 ;;{{{ Main parameters.
 (defvar spam-backends nil
   "List of spam.el backends with all the pertinent data.
-Populated by spam-install-backend-super.")
+Populated by `spam-install-backend-super'.")
 
 (defgroup spam nil
   "Spam configuration."
@@ -87,13 +91,13 @@ Populated by spam-install-backend-super.")
 
 (defcustom spam-summary-exit-behavior 'default
   "Exit behavior at the time of summary exit.
-Note that setting the spam-use-move or spam-use-copy backends on
+Note that setting the `spam-use-move' or `spam-use-copy' backends on
 a group through group/topic parameters overrides this mechanism."
-  :type '(choice (const 'default :tag 
+  :type '(choice (const 'default :tag
                        "Move spam out of all groups.  Move ham out of spam groups.")
-                (const 'move-all :tag 
+                (const 'move-all :tag
                        "Move spam out of all groups.  Move ham out of all groups.")
-                (const 'move-none :tag 
+                (const 'move-none :tag
                        "Never move spam or ham out of any groups."))
   :group 'spam)
 
@@ -105,6 +109,7 @@ a group through group/topic parameters overrides this mechanism."
 (defcustom spam-mark-new-messages-in-spam-group-as-spam t
   "Whether new messages in a spam group should get the spam-mark."
   :type 'boolean
+  ;; :version "22.1" ;; Gnus 5.10.8 / No Gnus 0.3
   :group 'spam)
 
 (defcustom spam-log-to-registry nil
@@ -119,8 +124,7 @@ a group through group/topic parameters overrides this mechanism."
 
 (defcustom spam-split-symbolic-return-positive nil
   "Whether `spam-split' should ALWAYS work with symbols or group names.
-Do not set this if you use `spam-split' in a fancy split
-  method."
+Do not set this if you use `spam-split' in a fancy split method."
   :type 'boolean
   :group 'spam)
 
@@ -134,7 +138,7 @@ without losing it to the automatic spam-marking process."
 
 (defcustom spam-mark-ham-unread-before-move-from-spam-group nil
   "Whether ham should be marked unread before it's moved.
-The article is moved out of a spam group according to ham-process-destination.
+The article is moved out of a spam group according to `ham-process-destination'.
 This variable is an official entry in the international Longest Variable Name
 Competition."
   :type 'boolean
@@ -169,7 +173,7 @@ The regular expression is matched against the address."
   :group 'spam)
 
 (defcustom spam-use-dig t
-  "Whether `query-dig' should be used instead of `query-dns'."
+  "Whether `query-dig' should be used instead of `dns-query'."
   :type 'boolean
   :group 'spam)
 
@@ -367,6 +371,7 @@ Only meaningful if you enable `spam-use-blackholes'."
   :group 'spam)
 ;; backward-compatibility alias
 (put 'spam-face 'face-alias 'spam)
+(put 'spam-face 'obsolete-face "22.1")
 
 (defcustom spam-face 'spam
   "Face for spam-marked articles."
@@ -398,7 +403,7 @@ Only meaningful if you enable `spam-use-regex-body'."
   :group 'spam)
 
 (defcustom spam-summary-score-preferred-header nil
-  "Preferred header to use for spam-summary-score."
+  "Preferred header to use for `spam-summary-score'."
   :type '(choice :tag "Header name"
          (symbol :tag "SpamAssassin etc" X-Spam-Status)
          (symbol :tag "Bogofilter"       X-Bogosity)
@@ -409,14 +414,18 @@ Only meaningful if you enable `spam-use-regex-body'."
   "Spam ifile configuration."
   :group 'spam)
 
-(defcustom spam-ifile-path (executable-find "ifile")
-  "File path of the ifile executable program."
+(make-obsolete-variable 'spam-ifile-path 'spam-ifile-program
+                        "Gnus 5.10.9 (Emacs 22.1)")
+(defcustom spam-ifile-program (executable-find "ifile")
+  "Name of the ifile program."
   :type '(choice (file :tag "Location of ifile")
                 (const :tag "ifile is not installed"))
   :group 'spam-ifile)
 
-(defcustom spam-ifile-database-path nil
-  "File path of the ifile database."
+(make-obsolete-variable 'spam-ifile-database-path 'spam-ifile-database
+                        "Gnus 5.10.9 (Emacs 22.1)")
+(defcustom spam-ifile-database nil
+  "File name of the ifile database."
   :type '(choice (file :tag "Location of the ifile database")
                 (const :tag "Use the default"))
   :group 'spam-ifile)
@@ -444,8 +453,10 @@ your main source of newsgroup names."
   "Spam bogofilter configuration."
   :group 'spam)
 
-(defcustom spam-bogofilter-path (executable-find "bogofilter")
-  "File path of the Bogofilter executable program."
+(make-obsolete-variable 'spam-bogofilter-path 'spam-bogofilter-program
+                        "Gnus 5.10.9 (Emacs 22.1)")
+(defcustom spam-bogofilter-program (executable-find "bogofilter")
+  "Name of the Bogofilter program."
   :type '(choice (file :tag "Location of bogofilter")
                 (const :tag "Bogofilter is not installed"))
   :group 'spam-bogofilter)
@@ -483,7 +494,8 @@ your main source of newsgroup names."
   :group 'spam-bogofilter)
 
 (defcustom spam-bogofilter-database-directory nil
-  "Directory path of the Bogofilter databases."
+  "Location of the Bogofilter database.
+When nil, use the default location."
   :type '(choice (directory
                  :tag "Location of the Bogofilter database directory")
                 (const :tag "Use the default"))
@@ -493,8 +505,10 @@ your main source of newsgroup names."
   "Spam bsfilter configuration."
   :group 'spam)
 
-(defcustom spam-bsfilter-path (executable-find "bsfilter")
-  "File path of the Bsfilter executable program."
+(make-obsolete-variable 'spam-bsfilter-path 'spam-bsfilter-program
+                        "Gnus 5.10.9 (Emacs 22.1)")
+(defcustom spam-bsfilter-program (executable-find "bsfilter")
+  "Name of the Bsfilter program."
   :type '(choice (file :tag "Location of bsfilter")
                 (const :tag "Bsfilter is not installed"))
   :group 'spam-bsfilter)
@@ -514,7 +528,7 @@ your main source of newsgroup names."
   :type 'string
   :group 'spam-bsfilter)
 
-(defcustom spam-bsfilter-ham-switch "--add-ham"
+(defcustom spam-bsfilter-ham-switch "--add-clean"
   "The switch that Bsfilter uses to register ham messages."
   :type 'string
   :group 'spam-bsfilter)
@@ -557,8 +571,10 @@ When nil, use the default spamoracle database."
   "Spam SpamAssassin configuration."
   :group 'spam)
 
-(defcustom spam-spamassassin-path (executable-find "spamassassin")
-  "File path of the spamassassin executable program.
+(make-obsolete-variable 'spam-spamassassin-path
+  'spam-spamassassin-program "Gnus 5.10.9 (Emacs 22.1)")
+(defcustom spam-assassin-program (executable-find "spamassassin")
+  "Name of the spamassassin program.
 Hint: set this to \"spamc\" if you have spamd running.  See the spamc and
 spamd man pages for more information on these programs."
   :type '(choice (file :tag "Location of spamc")
@@ -587,8 +603,10 @@ identification"
   :type 'string
   :group 'spam-spamassassin)
 
-(defcustom spam-sa-learn-path (executable-find "sa-learn")
-  "File path of the sa-learn executable program."
+(make-obsolete-variable 'spam-sa-learn-path 'spam-sa-learn-program
+                        "Gnus 5.10.9 (Emacs 22.1)")
+(defcustom spam-sa-learn-program (executable-find "sa-learn")
+  "Name of the sa-learn program."
   :type '(choice (file :tag "Location of spamassassin")
                 (const :tag "spamassassin is not installed"))
   :group 'spam-spamassassin)
@@ -603,17 +621,17 @@ order for SpamAssassin to recognize the new registered spam."
   :group 'spam-spamassassin)
 
 (defcustom spam-sa-learn-spam-switch "--spam"
-  "The switch that sa-learn uses to register spam messages"
+  "The switch that sa-learn uses to register spam messages."
   :type 'string
   :group 'spam-spamassassin)
 
 (defcustom spam-sa-learn-ham-switch "--ham"
-  "The switch that sa-learn uses to register ham messages"
+  "The switch that sa-learn uses to register ham messages."
   :type 'string
   :group 'spam-spamassassin)
 
 (defcustom spam-sa-learn-unregister-switch "--forget"
-  "The switch that sa-learn uses to unregister messages messages"
+  "The switch that sa-learn uses to unregister messages messages."
   :type 'string
   :group 'spam-spamassassin)
 
@@ -642,12 +660,12 @@ order for SpamAssassin to recognize the new registered spam."
   :type 'string
   :group 'spam-crm114)
 
-(defcustom spam-crm114-spam-strong-switch "--UNKNOWN"
+(defcustom spam-crm114-spam-strong-switch "--unlearn"
   "The switch that CRM114 Mailfilter uses to unregister ham messages."
   :type 'string
   :group 'spam-crm114)
 
-(defcustom spam-crm114-ham-strong-switch "--UNKNOWN"
+(defcustom spam-crm114-ham-strong-switch "--unlearn"
   "The switch that CRM114 Mailfilter uses to unregister spam messages."
   :type 'string
   :group 'spam-crm114)
@@ -671,7 +689,8 @@ order for SpamAssassin to recognize the new registered spam."
   "Sx" gnus-summary-mark-as-spam
   "Mst" spam-generic-score
   "Msx" gnus-summary-mark-as-spam
-  "\M-d" gnus-summary-mark-as-spam)
+  "\M-d" gnus-summary-mark-as-spam
+  "$" gnus-summary-mark-as-spam)
 
 (defvar spam-cache-lookups t
   "Whether spam.el will try to cache lookups using `spam-caches'.")
@@ -704,7 +723,7 @@ finds ham or spam.")
 ;;{{{ convenience functions
 
 (defun spam-clear-cache (symbol)
-  "Clear the spam-caches entry for a check."
+  "Clear the `spam-caches' entry for a check."
   (remhash symbol spam-caches))
 
 (defun spam-xor (a b)
@@ -712,7 +731,7 @@ finds ham or spam.")
   (and (or a b) (not (and a b))))
 
 (defun spam-set-difference (list1 list2)
-  "Return a set difference of LIST1 and LIST2.  
+  "Return a set difference of LIST1 and LIST2.
 When either list is nil, the other is returned."
   (if (and list1 list2)
       ;; we have two non-nil lists
@@ -819,15 +838,14 @@ Accepts incoming CHECK, ham registration function HRF, spam
 registration function SRF, ham unregistration function HUF, spam
 unregistration function SUF, and an indication whether the
 backend is STATISTICAL."
-
   (setq spam-backends (add-to-list 'spam-backends backend))
   (while properties
     (let ((property (pop properties))
          (value (pop properties)))
       (if (spam-backend-property-valid-p property)
          (put backend property value)
-       (gnus-error 
-        5 
+       (gnus-error
+        5
         "spam-install-backend-super got an invalid property %s"
         property)))))
 
@@ -857,7 +875,7 @@ The value nil means that the check does not yield a decision, and
 so, that further checks are needed.  The value t means that the
 message is definitely not spam, and that further spam checks
 should be inhibited.  Otherwise, a mailgroup name or the symbol
-'spam (depending on spam-split-symbolic-return) is returned where
+'spam (depending on `spam-split-symbolic-return') is returned where
 the mail should go, and further checks are also inhibited.  The
 usual mailgroup name is the value of `spam-split-group', meaning
 that the message is definitely a spam."
@@ -874,7 +892,7 @@ that the message is definitely a spam."
        (setq info (format "Backend %s has the following properties:\n"
                           backend))
        (dolist (property (spam-backend-properties))
-         (setq info (format "%s%s=%s\n" 
+         (setq info (format "%s%s=%s\n"
                             info
                             property
                             (get backend property))))
@@ -889,13 +907,13 @@ CLASSIFICATION is 'ham or 'spam."
   (if (and
        (spam-classification-valid-p classification)
        (spam-backend-function-type-valid-p type))
-      (let ((retrieval 
-            (intern 
+      (let ((retrieval
+            (intern
              (format "spam-backend-%s-%s-function"
                      classification
                      type))))
        (funcall retrieval backend))
-    (gnus-error 
+    (gnus-error
      5
      "%s was passed invalid backend %s, classification %s, or type %s"
      "spam-backend-function"
@@ -903,21 +921,21 @@ CLASSIFICATION is 'ham or 'spam."
      classification
      type)))
 
-(defun spam-backend-article-list-property (classification 
+(defun spam-backend-article-list-property (classification
                                           &optional unregister)
   "Property name of article list with CLASSIFICATION and UNREGISTER."
   (let* ((r (if unregister "unregister" "register"))
         (prop (format "%s-%s" classification r)))
     prop))
 
-(defun spam-backend-get-article-todo-list (backend 
-                                          classification 
+(defun spam-backend-get-article-todo-list (backend
+                                          classification
                                           &optional unregister)
-  "Get the articles to be processed for BACKEND and CLASSIFICATION.  
+  "Get the articles to be processed for BACKEND and CLASSIFICATION.
 With UNREGISTER, get articles to be unregistered.
 This is a temporary storage function - nothing here persists."
   (get
-   backend 
+   backend
    (intern (spam-backend-article-list-property classification unregister))))
 
 (defun spam-backend-put-article-todo-list (backend classification list &optional unregister)
@@ -959,7 +977,7 @@ The previous backend settings for ALIAS are erased."
 
   ;; install alias with no properties at first
   (spam-install-backend-super alias)
-  
+
   (dolist (property (spam-backend-properties))
     (put alias property (get backend property))))
 
@@ -973,8 +991,8 @@ Accepts ham registration function HRF, spam registration function
 SRF, ham unregistration function HUF, spam unregistration
 function SUF.  The backend has no incoming check and can't be
 statistical."
-  (spam-install-backend-super 
-   backend 
+  (spam-install-backend-super
+   backend
    'hrf hrf 'srf srf 'huf huf 'suf suf 'mover t))
 
 (defun spam-install-nocheck-backend (backend hrf srf huf suf)
@@ -983,7 +1001,7 @@ Accepts ham registration function HRF, spam registration function
 SRF, ham unregistration function HUF, spam unregistration
 function SUF.  The backend has no incoming check and can't be
 statistical (it could be, but in practice that doesn't happen)."
-  (spam-install-backend-super 
+  (spam-install-backend-super
    backend
    'hrf hrf 'srf srf 'huf huf 'suf suf))
 
@@ -992,8 +1010,8 @@ statistical (it could be, but in practice that doesn't happen)."
 Accepts incoming CHECK, ham registration function HRF, spam
 registration function SRF, ham unregistration function HUF, spam
 unregistration function SUF.  The backend won't be
-statistical (use spam-install-statistical-backend for that)."
-  (spam-install-backend-super 
+statistical (use `spam-install-statistical-backend' for that)."
+  (spam-install-backend-super
    backend
    'check check 'hrf hrf 'srf srf 'huf huf 'suf suf))
 
@@ -1002,15 +1020,15 @@ statistical (use spam-install-statistical-backend for that)."
 Accepts incoming CHECK, ham registration function HRF, spam
 registration function SRF, ham unregistration function HUF, spam
 unregistration function SUF.  The backend will be
-statistical (use spam-install-backend for non-statistical
+statistical (use `spam-install-backend' for non-statistical
 backends)."
-  (spam-install-backend-super 
+  (spam-install-backend-super
    backend
    'check check 'statistical t 'hrf hrf 'srf srf 'huf huf 'suf suf))
 
 (defun spam-install-statistical-checkonly-backend (backend check)
   "Install a statistical BACKEND than can only CHECK for spam."
-  (spam-install-backend-super 
+  (spam-install-backend-super
    backend
    'check check 'statistical t))
 
@@ -1055,11 +1073,10 @@ backends)."
                              nil)
 
 (spam-install-nocheck-backend 'spam-use-gmane
-                             nil
+                             'spam-report-gmane-unregister-routine
                              'spam-report-gmane-register-routine
-                             ;; does Gmane support unregistration?
-                             nil
-                             nil)
+                             'spam-report-gmane-register-routine
+                             'spam-report-gmane-unregister-routine)
 
 (spam-install-nocheck-backend 'spam-use-resend
                              'spam-report-resend-register-ham-routine
@@ -1067,7 +1084,7 @@ backends)."
                              nil
                              nil)
 
-(spam-install-backend 'spam-use-BBDB    
+(spam-install-backend 'spam-use-BBDB
                      'spam-check-BBDB
                      'spam-BBDB-register-routine
                      nil
@@ -1111,7 +1128,7 @@ backends)."
                                  'spam-stat-unregister-ham-routine
                                  'spam-stat-unregister-spam-routine)
 
-(spam-install-statistical-backend 'spam-use-spamassassin 
+(spam-install-statistical-backend 'spam-use-spamassassin
                                  'spam-check-spamassassin
                                  'spam-spamassassin-register-ham-routine
                                  'spam-spamassassin-register-spam-routine
@@ -1136,10 +1153,8 @@ backends)."
                                  'spam-check-crm114
                                  'spam-crm114-register-ham-routine
                                  'spam-crm114-register-spam-routine
-                                 ;; does CRM114 Mailfilter support unregistration?
-                                 nil
-                                 nil)
-
+                                 'spam-crm114-unregister-ham-routine
+                                 'spam-crm114-unregister-spam-routine)
 ;;}}}
 
 ;;{{{ scoring and summary formatting
@@ -1150,8 +1165,12 @@ backends)."
              spam-use-spamassassin-headers
              spam-use-regex-headers)
       (push 'X-Spam-Status list))
-    (when spam-use-bogofilter
+    (when (or spam-use-bogofilter
+             spam-use-regex-headers)
       (push 'X-Bogosity list))
+    (when (or spam-use-crm114
+             spam-use-regex-headers)
+      (push 'X-CRM114-Status list))
     list))
 
 (defun spam-user-format-function-S (headers)
@@ -1170,39 +1189,46 @@ backends)."
        (return))))
     result))
 
+(defvar spam-spamassassin-score-regexp
+  ".*\\b\\(?:score\\|hits\\)=\\(-?[0-9.]+\\)"
+  "Regexp matching SpamAssassin score header.
+The first group must match the number.")
+
 (defun spam-extra-header-to-number (header headers)
   "Transform an extra HEADER to a number, using list of HEADERS.
 Note this has to be fast."
-  (if (gnus-extra-header header headers)
-      (cond
-       ((eq header 'X-Spam-Status)
-       (string-to-number (gnus-replace-in-string
-                          (gnus-extra-header header headers)
-                          ".*hits=" "")))
-       ;; for CRM checking, it's probably faster to just do the string match
-       ((and spam-use-crm114 (string-match "( pR: \\([0-9.-]+\\)" header))
-       (match-string 1 header))
-       ((eq header 'X-Bogosity)
-       (string-to-number (gnus-replace-in-string
-                          (gnus-replace-in-string
-                           (gnus-extra-header header headers)
-                           ".*spamicity=" "")
-                          ",.*" "")))
-       (t nil))
-    nil))
+  (let ((header-content (gnus-extra-header header headers)))
+    (if header-content
+        (cond
+         ((eq header 'X-Spam-Status)
+          (string-to-number (gnus-replace-in-string
+                             header-content
+                             spam-spamassassin-score-regexp
+                             "\\1")))
+         ;; for CRM checking, it's probably faster to just do the string match
+         ((string-match "( pR: \\([0-9.-]+\\)" header-content)
+          (- (string-to-number (match-string 1 header-content))))
+         ((eq header 'X-Bogosity)
+          (string-to-number (gnus-replace-in-string
+                             (gnus-replace-in-string
+                              header-content
+                              ".*spamicity=" "")
+                             ",.*" "")))
+         (t nil))
+      nil)))
 
 (defun spam-summary-score (headers &optional specific-header)
   "Score an article for the summary buffer, as fast as possible.
 With SPECIFIC-HEADER, returns only that header's score.
 Will not return a nil score."
   (let (score)
-    (dolist (header 
+    (dolist (header
             (if specific-header
                 (list specific-header)
               (spam-necessary-extra-headers)))
-      (setq score 
+      (setq score
            (spam-extra-header-to-number header headers))
-      (when score 
+      (when score
        (return)))
     (or score 0)))
 
@@ -1230,7 +1256,7 @@ Will not return a nil score."
   (let (found)
     (dolist (backend (spam-backend-list))
       (when (and (spam-backend-statistical-p backend)
-                (or (symbol-value backend) 
+                (or (symbol-value backend)
                     (memq backend force-symbols)))
        (setq found backend)))
     found))
@@ -1244,6 +1270,7 @@ Will not return a nil score."
     (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-spamassassin)
+    (gnus-group-spam-exit-processor-report-gmane spam spam-use-gmane) ;; Buggy?
     (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)
@@ -1258,14 +1285,14 @@ This list contains pairs associating the obsolete ham/spam exit
 processor variables with a classification and a spam-use-*
 variable.  When the processor variable is nil, just the
 classification and spam-use-* check variable are used.  This is
-superceded by the new spam backend code, so it's only consulted
+superseded by the new spam backend code, so it's only consulted
 for backwards compatibility.")
 
 (defun spam-group-processor-p (group backend &optional classification)
   "Checks if GROUP has a BACKEND with CLASSIFICATION registered.
 Also accepts the obsolete processors, which can be found in
 gnus.el and in spam-list-of-processors.  In the case of mover
-backends, checks the setting of spam-summary-exit-behavior in
+backends, checks the setting of `spam-summary-exit-behavior' in
 addition to the set values for the group."
   (if (and (stringp group)
           (symbolp backend))
@@ -1286,7 +1313,7 @@ addition to the set values for the group."
          ;; spam-summary-exit-behavior-logic for mover backends
          (unless found
            (when (spam-backend-mover-p backend)
-             (setq 
+             (setq
               found
               (cond
                ((eq spam-summary-exit-behavior 'move-all) t)
@@ -1296,7 +1323,7 @@ addition to the set values for the group."
                     ;; move ham out of spam groups
                     (and (eq classification 'ham)
                          (spam-group-spam-contents-p group))))
-               (t (gnus-error 5 "Unknown spam-summary-exit-behavior: %s" 
+               (t (gnus-error 5 "Unknown spam-summary-exit-behavior: %s"
                               spam-summary-exit-behavior))))))
 
          found))
@@ -1356,8 +1383,8 @@ addition to the set values for the group."
            ;; call spam-register-routine with specific articles to unregister,
            ;; when there are articles to unregister and the check is enabled
            (when (and unregister-list (symbol-value backend))
-             (spam-backend-put-article-todo-list backend 
-                                                 classification 
+             (spam-backend-put-article-todo-list backend
+                                                 classification
                                                  unregister-list
                                                  t))))))
 
@@ -1369,7 +1396,7 @@ addition to the set values for the group."
                 gnus-newsgroup-name
                 backend
                 classification)
-           (spam-backend-put-article-todo-list backend 
+           (spam-backend-put-article-todo-list backend
                                                classification
                                                (spam-list-articles
                                                 gnus-newsgroup-articles
@@ -1428,11 +1455,11 @@ addition to the set values for the group."
                          article)
            (gnus-summary-mark-article article gnus-expirable-mark))
          (gnus-summary-set-process-mark article)
-           
+
          (if respool              ; respooling is with a "fake" group
              (let ((spam-split-disabled
                     (or spam-split-disabled
-                        (and (eq classification 'ham) 
+                        (and (eq classification 'ham)
                              spam-disable-spam-split-during-ham-respool))))
                (gnus-message 9 "Respooling article %d with method %s"
                              article respool-method)
@@ -1447,7 +1474,7 @@ addition to the set values for the group."
              (gnus-message 9 "Moving article %d to group %s"
                            article group)
              (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
       ;;                                 c) backend-supports-deletions is nil
@@ -1459,33 +1486,33 @@ addition to the set values for the group."
          (when articles
            (let ((gnus-novice-user nil)) ; don't ask me if I'm sure
              (gnus-summary-delete-article nil)))))
-       
+
       (gnus-summary-yank-process-mark)
       (length articles))))
 
 (defun spam-copy-spam-routine (articles)
-  (spam-copy-or-move-routine 
-   t 
+  (spam-copy-or-move-routine
+   t
    (gnus-parameter-spam-process-destination gnus-newsgroup-name)
    articles
    'spam))
 
 (defun spam-move-spam-routine (articles)
-  (spam-copy-or-move-routine 
+  (spam-copy-or-move-routine
    nil
    (gnus-parameter-spam-process-destination gnus-newsgroup-name)
    articles
    'spam))
 
 (defun spam-copy-ham-routine (articles)
-  (spam-copy-or-move-routine 
-   t 
+  (spam-copy-or-move-routine
+   t
    (gnus-parameter-ham-process-destination gnus-newsgroup-name)
    articles
    'ham))
 
 (defun spam-move-ham-routine (articles)
-  (spam-copy-or-move-routine 
+  (spam-copy-or-move-routine
    nil
    (gnus-parameter-ham-process-destination gnus-newsgroup-name)
    articles
@@ -1541,9 +1568,9 @@ to find it out)."
         ((equal field 'extra)
          (mail-header-extra data-header))
         (t
-         (gnus-error 
-          5 
-          "spam-fetch-field-fast: unknown field %s requested" 
+         (gnus-error
+          5
+          "spam-fetch-field-fast: unknown field %s requested"
           field)
          nil))
        (gnus-message 6 "Article %d has a nil data header" article)))))
@@ -1579,8 +1606,7 @@ to find it out)."
        article))))
 
 (defun spam-fetch-article-header (article)
-  (save-excursion
-    (set-buffer gnus-summary-buffer)
+  (with-current-buffer gnus-summary-buffer
     (gnus-read-header article)
     (nth 3 (assq article gnus-newsgroup-data))))
 ;;}}}
@@ -1592,7 +1618,7 @@ to find it out)."
 This function can be used as an entry in the variable `nnmail-split-fancy',
 for example like this: (: spam-split).  It can take checks as
 parameters.  A string as a parameter will set the
-spam-split-group to that string.
+`spam-split-group' to that string.
 
 See the Info node `(gnus)Fancy Mail Splitting' for more details."
   (interactive)
@@ -1644,7 +1670,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                decision))))))))
 
 (defun spam-find-spam ()
-  "This function will detect spam in the current newsgroup using spam-split."
+  "Detect spam in the current newsgroup using `spam-split'."
   (interactive)
 
   (let* ((group gnus-newsgroup-name)
@@ -1656,7 +1682,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                     gnus-newsgroup-unseen))
         article-cannot-be-faked)
 
-    
+
     (dolist (backend methods)
       (when (spam-backend-statistical-p backend)
        (setq article-cannot-be-faked t)
@@ -1673,10 +1699,10 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
               (subject (spam-fetch-field-subject-fast article))
               (sender (spam-fetch-field-from-fast article))
               registry-lookup)
-          
+
           (unless id
             (gnus-message 6 "Article %d has no message ID!" article))
-        
+
           (when (and id spam-log-to-registry)
             (setq registry-lookup (spam-log-registration-type id 'incoming))
             (when registry-lookup
@@ -1703,12 +1729,12 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                           (apply 'spam-split methods))))))
             (if (equal split-return 'spam)
                 (gnus-summary-mark-article article gnus-spam-mark))
-          
+
             (when (and id split-return spam-log-to-registry)
               (when (zerop (gnus-registry-group-count id))
                 (gnus-registry-add-group
                  id group subject sender))
-              
+
               (unless registry-lookup
                 (spam-log-processing-to-registry
                  id
@@ -1734,11 +1760,11 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
              (delcount 0))
 
          ;; clear the old lists right away
-         (spam-backend-put-article-todo-list backend 
+         (spam-backend-put-article-todo-list backend
                                              classification
                                              nil
                                              nil)
-         (spam-backend-put-article-todo-list backend 
+         (spam-backend-put-article-todo-list backend
                                              classification
                                              nil
                                              t)
@@ -1749,29 +1775,29 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
              (incf delcount)
              (setq rlist (delq article rlist))
              (setq ulist (delq article ulist))))
-         
+
          (unless (zerop delcount)
-           (gnus-message 
-            9 
+           (gnus-message
+            9
             "%d messages were saved the trouble of unregistering and then registering"
             delcount))
-         
+
          ;; unregister articles
          (unless (zerop (length ulist))
            (let ((num (spam-unregister-routine classification backend ulist)))
              (when (> num 0)
-               (gnus-message 
+               (gnus-message
                 6
                 "%d %s messages were unregistered by backend %s."
                 num
                 classification
                 backend))))
-           
+
            ;; register articles
            (unless (zerop (length rlist))
              (let ((num (spam-register-routine classification backend rlist)))
                (when (> num 0)
-                 (gnus-message 
+                 (gnus-message
                   6
                   "%d %s messages were registered by backend %s."
                   num
@@ -1779,12 +1805,12 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                   backend)))))))))
 
 (defun spam-unregister-routine (classification
-                               backend 
+                               backend
                                specific-articles)
   (spam-register-routine classification backend specific-articles t))
 
 (defun spam-register-routine (classification
-                             backend 
+                             backend
                              specific-articles
                              &optional unregister)
   (when (and (spam-classification-valid-p classification)
@@ -2011,9 +2037,9 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                        (push (list ip server query-result)
                              matches)))
                  ;; else, if not using dig.el
-                 (when (query-dns query-string)
+                 (when (dns-query query-string)
                    (gnus-message 6 "positive blackhole check")
-                   (push (list ip server (query-dns query-string 'TXT))
+                   (push (list ip server (dns-query query-string 'TXT))
                          matches)))))))))
     (when matches
       spam-split-group)))
@@ -2021,18 +2047,10 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
 
 ;;{{{ Hashcash.
 
-(eval-when-compile
-  (autoload 'mail-check-payment "hashcash"))
-
-(condition-case nil
-    (progn
-      (require 'hashcash)
+(defun spam-check-hashcash ()
+  "Check the headers for hashcash payments."
+  (ignore-errors (mail-check-payment)))         ;mail-check-payment returns a boolean
 
-      (defun spam-check-hashcash ()
-       "Check the headers for hashcash payments."
-       (mail-check-payment)))   ;mail-check-payment returns a boolean
-
-  (file-error))
 ;;}}}
 
 ;;{{{ BBDB
@@ -2047,6 +2065,9 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
   (autoload 'bbdb-create-internal "bbdb")
   (autoload 'bbdb-search-simple "bbdb"))
 
+;; Autoloaded in message, which we require.
+(declare-function gnus-extract-address-components "gnus-util" (from))
+
 (eval-and-compile
   (when (condition-case nil
            (progn
@@ -2113,7 +2134,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
              (save-excursion
                (save-window-excursion
                  (bbdb-records nil t)
-                 (mapatoms 
+                 (mapatoms
                   (lambda (symbol)
                     (intern (downcase (symbol-name symbol)) bbdb-cache))
                   bbdb-hashtable))))
@@ -2136,11 +2157,12 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
 ;;; check the ifile backend; return nil if the mail was NOT classified
 ;;; as spam
 
+
 (defun spam-get-ifile-database-parameter ()
-  "Get the command-line parameter for ifile's database from
-  spam-ifile-database-path."
-  (if spam-ifile-database-path
-      (format "--db-file=%s" spam-ifile-database-path)
+  "Return the command-line parameter for ifile's database.
+See `spam-ifile-database'."
+  (if spam-ifile-database
+      (format "--db-file=%s" spam-ifile-database)
     nil))
 
 (defun spam-check-ifile ()
@@ -2150,10 +2172,9 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
     (with-temp-buffer
       (let ((temp-buffer-name (buffer-name))
            (db-param (spam-get-ifile-database-parameter)))
-       (save-excursion
-         (set-buffer article-buffer-name)
+       (with-current-buffer article-buffer-name
          (apply 'call-process-region
-                (point-min) (point-max) spam-ifile-path
+                (point-min) (point-max) spam-ifile-program
                 nil temp-buffer-name nil "-c"
                 (if db-param `(,db-param "-q") `("-q"))))
        ;; check the return now (we're back in the temp buffer)
@@ -2181,7 +2202,7 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)."
          (when (stringp article-string)
            (insert article-string))))
       (apply 'call-process-region
-            (point-min) (point-max) spam-ifile-path
+            (point-min) (point-max) spam-ifile-program
             nil nil nil
             add-or-delete-option category
             (if db `(,db "-h") `("-h"))))))
@@ -2289,16 +2310,15 @@ With a non-nil REMOVE, remove them."
 
 (defun spam-enter-list (addresses file &optional remove)
   "Enter ADDRESSES into the given FILE.
-Either the whitelist or the blacklist files can be used.  With
-REMOVE not nil, remove the ADDRESSES."
+Either the whitelist or the blacklist files can be used.
+With a non-nil REMOVE, remove the ADDRESSES."
   (if (stringp addresses)
       (spam-enter-list (list addresses) file remove)
     ;; else, we have a list of addresses here
     (unless (file-exists-p (file-name-directory file))
       (make-directory (file-name-directory file) t))
-    (save-excursion
-      (set-buffer
-       (find-file-noselect file))
+    (with-current-buffer
+       (find-file-noselect file)
       (dolist (a addresses)
        (when (stringp a)
          (goto-char (point-min))
@@ -2435,13 +2455,17 @@ REMOVE not nil, remove the ADDRESSES."
 ;;{{{ Spam-report glue (gmane and resend reporting)
 (defun spam-report-gmane-register-routine (articles)
   (when articles
-    (apply 'spam-report-gmane articles)))
+    (apply 'spam-report-gmane-spam articles)))
+
+(defun spam-report-gmane-unregister-routine (articles)
+  (when articles
+    (apply 'spam-report-gmane-ham 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 
+  (let* ((resend-to-gp
          (if ham
              (gnus-parameter-ham-resend-to gnus-newsgroup-name)
            (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
@@ -2466,7 +2490,7 @@ REMOVE not nil, remove the ADDRESSES."
 
 ;; return something sensible if the score can't be determined
 (defun spam-bogofilter-score (&optional recheck)
-  "Get the Bogofilter spamicity score"
+  "Get the Bogofilter spamicity score."
   (interactive "P")
   (save-window-excursion
     (gnus-summary-show-article t)
@@ -2483,10 +2507,10 @@ REMOVE not nil, remove the ADDRESSES."
   (when (eq spam-bogofilter-valid 'unknown)
     (setq spam-bogofilter-valid
          (not (string-match "^bogofilter version 0\\.\\([0-9]\\|1[01]\\)\\."
-                            (shell-command-to-string 
-                             (format "%s -V" spam-bogofilter-path))))))
+                            (shell-command-to-string
+                             (format "%s -V" spam-bogofilter-program))))))
   spam-bogofilter-valid)
-  
+
 (defun spam-check-bogofilter (&optional score)
   "Check the Bogofilter backend for the classification of this message."
   (if (spam-verify-bogofilter)
@@ -2495,16 +2519,15 @@ REMOVE not nil, remove the ADDRESSES."
            return)
        (with-temp-buffer
          (let ((temp-buffer-name (buffer-name)))
-           (save-excursion
-             (set-buffer article-buffer-name)
+           (with-current-buffer article-buffer-name
              (apply 'call-process-region
                     (point-min) (point-max)
-                    spam-bogofilter-path
+                    spam-bogofilter-program
                     nil temp-buffer-name nil
                     (if db `("-d" ,db "-v") `("-v"))))
            (setq return (spam-check-bogofilter-headers score))))
        return)
-    (gnus-error "`spam.el' doesnt support obsolete bogofilter versions")))
+    (gnus-error 5 "`spam.el' doesn't support obsolete bogofilter versions")))
 
 (defun spam-bogofilter-register-with-bogofilter (articles
                                                 spam
@@ -2524,13 +2547,13 @@ REMOVE not nil, remove the ADDRESSES."
          (when (stringp article-string)
            (with-temp-buffer
              (insert article-string)
-             
+
              (apply 'call-process-region
                     (point-min) (point-max)
-                    spam-bogofilter-path
+                    spam-bogofilter-program
                     nil nil nil switch
                     (if db `("-d" ,db "-v") `("-v")))))))
-    (gnus-error "`spam.el' doesnt support obsolete bogofilter versions")))
+    (gnus-error 5 "`spam.el' doesn't support obsolete bogofilter versions")))
 
 (defun spam-bogofilter-register-spam-routine (articles &optional unregister)
   (spam-bogofilter-register-with-bogofilter articles t unregister))
@@ -2553,8 +2576,7 @@ REMOVE not nil, remove the ADDRESSES."
   (let ((article-buffer-name (buffer-name)))
     (with-temp-buffer
       (let ((temp-buffer-name (buffer-name)))
-       (save-excursion
-         (set-buffer article-buffer-name)
+       (with-current-buffer article-buffer-name
          (let ((status
                 (apply 'call-process-region
                        (point-min) (point-max)
@@ -2615,7 +2637,7 @@ REMOVE not nil, remove the ADDRESSES."
   (if score                            ; scoring mode
       (let ((header (message-fetch-field spam-spamassassin-spam-status-header)))
        (when header
-         (if (string-match "hits=\\(-?[0-9.]+\\)" header)
+         (if (string-match spam-spamassassin-score-regexp header)
              (match-string 1 header)
            "0")))
     ;; spam detection mode
@@ -2630,10 +2652,9 @@ REMOVE not nil, remove the ADDRESSES."
   (let ((article-buffer-name (buffer-name)))
     (with-temp-buffer
       (let ((temp-buffer-name (buffer-name)))
-       (save-excursion
-         (set-buffer article-buffer-name)
+       (with-current-buffer article-buffer-name
          (apply 'call-process-region
-                (point-min) (point-max) spam-spamassassin-path
+                (point-min) (point-max) spam-assassin-program
                 nil temp-buffer-name nil spam-spamassassin-arguments))
        ;; check the return now (we're back in the temp buffer)
        (goto-char (point-min))
@@ -2665,8 +2686,7 @@ REMOVE not nil, remove the ADDRESSES."
          ;; group the articles into mbox format
          (dolist (article articles)
            (let (article-string)
-             (save-excursion
-               (set-buffer summary-buffer-name)
+             (with-current-buffer summary-buffer-name
                (setq article-string (spam-get-article-as-string article)))
              (when (stringp article-string)
                (insert "From \n") ; mbox separator (sa-learn only checks the
@@ -2677,7 +2697,7 @@ REMOVE not nil, remove the ADDRESSES."
          ;; call sa-learn on all messages at the same time
          (apply 'call-process-region
                 (point-min) (point-max)
-                spam-sa-learn-path
+                spam-sa-learn-program
                 nil nil nil "--mbox"
                 (if spam-sa-learn-rebuild
                     (list action)
@@ -2710,7 +2730,7 @@ REMOVE not nil, remove the ADDRESSES."
 
 ;; return something sensible if the score can't be determined
 (defun spam-bsfilter-score (&optional recheck)
-  "Get the Bsfilter spamicity score"
+  "Get the Bsfilter spamicity score."
   (interactive "P")
   (save-window-excursion
     (gnus-summary-show-article t)
@@ -2723,17 +2743,16 @@ REMOVE not nil, remove the ADDRESSES."
       (or score "0"))))
 
 (defun spam-check-bsfilter (&optional score)
-  "Check the Bsfilter backend for the classification of this message"
+  "Check the Bsfilter backend for the classification of this message."
   (let ((article-buffer-name (buffer-name))
        (dir spam-bsfilter-database-directory)
        return)
     (with-temp-buffer
       (let ((temp-buffer-name (buffer-name)))
-       (save-excursion
-         (set-buffer article-buffer-name)
+       (with-current-buffer article-buffer-name
          (apply 'call-process-region
                 (point-min) (point-max)
-                spam-bsfilter-path
+                spam-bsfilter-program
                 nil temp-buffer-name nil
                 "--pipe"
                 "--insert-flag"
@@ -2761,7 +2780,7 @@ REMOVE not nil, remove the ADDRESSES."
          (insert article-string)
          (apply 'call-process-region
                 (point-min) (point-max)
-                spam-bsfilter-path
+                spam-bsfilter-program
                 nil nil nil switch
                 "--update"
                 (when spam-bsfilter-database-directory
@@ -2797,7 +2816,7 @@ REMOVE not nil, remove the ADDRESSES."
 
 ;; return something sensible if the score can't be determined
 (defun spam-crm114-score ()
-  "Get the CRM114 Mailfilter pR"
+  "Get the CRM114 Mailfilter pR."
   (interactive)
   (save-window-excursion
     (gnus-summary-show-article t)
@@ -2809,14 +2828,13 @@ REMOVE not nil, remove the ADDRESSES."
       (or score "0"))))
 
 (defun spam-check-crm114 (&optional score)
-  "Check the CRM114 Mailfilter backend for the classification of this message"
+  "Check the CRM114 Mailfilter backend for the classification of this message."
   (let ((article-buffer-name (buffer-name))
        (db spam-crm114-database-directory)
        return)
     (with-temp-buffer
       (let ((temp-buffer-name (buffer-name)))
-       (save-excursion
-         (set-buffer article-buffer-name)
+       (with-current-buffer article-buffer-name
          (apply 'call-process-region
                 (point-min) (point-max)
                 spam-crm114-program
@@ -2871,9 +2889,9 @@ REMOVE not nil, remove the ADDRESSES."
 (defun spam-initialize (&rest symbols)
   "Install the spam.el hooks and do other initialization.
 When SYMBOLS is given, set those variables to t.  This is so you
-can call spam-initialize before you set spam-use-* variables on
+can call `spam-initialize' before you set spam-use-* variables on
 explicitly, and matters only if you need the extra headers
-installed through spam-necessary-extra-headers."
+installed through `spam-necessary-extra-headers'."
   (interactive)
 
   (dolist (var symbols)
@@ -2897,7 +2915,7 @@ installed through spam-necessary-extra-headers."
   (add-hook 'gnus-summary-prepared-hook 'spam-find-spam))
 
 (defun spam-unload-hook ()
-  "Uninstall the spam.el hooks"
+  "Uninstall the spam.el hooks."
   (interactive)
   (remove-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save)
   (remove-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load)
@@ -2915,5 +2933,4 @@ installed through spam-necessary-extra-headers."
 
 (provide 'spam)
 
-;;; arch-tag: 07e6e0ca-ab0a-4412-b445-1f6c72a4f27f
 ;;; spam.el ends here