* spam.el (spam-list-of-processors): use nil for nonexistent processors
authorTeodor Zlatanov <tzz@lifelogs.com>
Mon, 24 May 2004 19:04:30 +0000 (19:04 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Mon, 24 May 2004 19:04:30 +0000 (19:04 +0000)
(spam-group-processor-p): fixed function so it works properly
(spam-group-processor-multiple-p)
(spam-group-spam-processor-report-gmane-p)
(spam-group-spam-processor-report-resend-p)
(spam-group-spam-processor-bogofilter-p)
(spam-group-spam-processor-blacklist-p)
(spam-group-spam-processor-ifile-p)
(spam-group-ham-processor-ifile-p)
(spam-group-spam-processor-spamoracle-p)
(spam-group-spam-processor-crm114-p)
(spam-group-ham-processor-bogofilter-p)
(spam-group-spam-processor-stat-p)
(spam-group-ham-processor-stat-p)
(spam-group-ham-processor-whitelist-p)
(spam-group-ham-processor-BBDB-p)
(spam-group-ham-processor-spamoracle-p)
(spam-group-ham-processor-copy-p): functions removed with some
prejudice against unneeded code
(spam-report-articles-resend)
(spam-report-resend-register-routine): allow the group/topic
spam-resend-to value to override spam-report-resend-to
(spam-summary-prepare-exit): invoke spam-group-processor-p
properly now

* spam-report.el (spam-report-resend-to, spam-report-resend):
start with resend-to set to nil, and then ask the user if
necessary.  From Daniel Pittman <daniel@rimspace.net>.

* gnus.el (spam-resend-to): new group/topic parameter
(spam-process): move the OBSOLETE processors to the end of the
choices.

lisp/ChangeLog
lisp/gnus.el
lisp/spam-report.el
lisp/spam.el

index 7cad120..832415b 100644 (file)
@@ -1,5 +1,38 @@
 2004-05-24  Teodor Zlatanov  <tzz@lifelogs.com>
 
+       * spam.el (spam-list-of-processors): use nil for nonexistent processors
+       (spam-group-processor-p): fixed function so it works properly
+       (spam-group-processor-multiple-p)
+       (spam-group-spam-processor-report-gmane-p)
+       (spam-group-spam-processor-report-resend-p)
+       (spam-group-spam-processor-bogofilter-p)
+       (spam-group-spam-processor-blacklist-p)
+       (spam-group-spam-processor-ifile-p)
+       (spam-group-ham-processor-ifile-p)
+       (spam-group-spam-processor-spamoracle-p)
+       (spam-group-spam-processor-crm114-p)
+       (spam-group-ham-processor-bogofilter-p)
+       (spam-group-spam-processor-stat-p)
+       (spam-group-ham-processor-stat-p)
+       (spam-group-ham-processor-whitelist-p)
+       (spam-group-ham-processor-BBDB-p)
+       (spam-group-ham-processor-spamoracle-p)
+       (spam-group-ham-processor-copy-p): functions removed with some
+       prejudice against unneeded code
+       (spam-report-articles-resend)
+       (spam-report-resend-register-routine): allow the group/topic
+       spam-resend-to value to override spam-report-resend-to
+       (spam-summary-prepare-exit): invoke spam-group-processor-p
+       properly now
+
+       * spam-report.el (spam-report-resend-to, spam-report-resend):
+       start with resend-to set to nil, and then ask the user if
+       necessary.  From Daniel Pittman <daniel@rimspace.net>.
+
+       * gnus.el (spam-resend-to): new group/topic parameter
+       (spam-process): move the OBSOLETE processors to the end of the
+       choices.
+
        * spam-report.el (spam-report-resend): spam-report-resend takes a
        list of articles, not separate article numbers.  From Daniel
        Pittman <daniel@rimspace.net>.
index 8bc84e6..2377eab 100644 (file)
@@ -1823,6 +1823,24 @@ This only makes sense for mail groups."
    "The spam classification (spam, ham, or neither) of this group.
 When a spam group is entered, all unread articles are marked as spam.")
 
+  (gnus-define-group-parameter
+   spam-resend-to
+   :type list
+   :function-document
+   "The address to get spam resent (through spam-report-resend)."
+   :variable gnus-spam-resend-to
+   :variable-default nil
+   :variable-document
+   "The address to get spam resent (through spam-report-resend)."
+   :variable-group spam
+   :variable-type '(repeat
+                   (list :tag "Group address for resending spam"
+                         (regexp :tag "Group")
+                         (string :tag "E-mail address for resending spam (requires the spam-use-resend exit processor)")))
+   :parameter-type 'string :tag "E-mail address for resending spam (requires the spam-use-resend exit processor)"
+   :parameter-document
+   "The address to get spam resent (through spam-report-resend).")
+
   (defvar gnus-group-spam-exit-processor-ifile "ifile"
     "OBSOLETE: The ifile summary exit spam processor.")
 
@@ -1879,19 +1897,6 @@ Only applicable to non-spam (unclassified and ham) groups.")
      :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-spamoracle)
-           (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-spamoracle)
-           (variable-item gnus-group-ham-exit-processor-copy)
            (const :tag "Spam: Bogofilter"    (spam spam-use-bogofilter))
            (const :tag "Spam: Blacklist"     (spam spam-use-blacklist))
            (const :tag "Spam: Bsfilter"      (spam spam-use-bsfilter))
@@ -1911,7 +1916,20 @@ Only applicable to non-spam (unclassified and ham) groups.")
            (const :tag "Ham: Spam-stat"      (ham spam-use-stat))
            (const :tag "Ham: SpamAssassin"   (ham spam-use-spamassassin))
            (const :tag "Ham: CRM114"         (ham spam-use-crm114))
-           (const :tag "Ham: Whitelist"      (ham spam-use-whitelist)))))
+           (const :tag "Ham: Whitelist"      (ham spam-use-whitelist))
+           (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-spamoracle)
+           (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-spamoracle)
+           (variable-item gnus-group-ham-exit-processor-copy))))
    :function-document
    "Which spam or ham processors will be applied when the summary is exited."
    :variable gnus-spam-process-newsgroups
@@ -1928,19 +1946,6 @@ spam processing, associated with the appropriate processor."
                  (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-spamoracle)
-                  (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-spamoracle)
-                  (variable-item gnus-group-ham-exit-processor-copy)
                   (const :tag "Spam: Bogofilter"    (spam spam-use-bogofilter))
                   (const :tag "Spam: Blacklist"     (spam spam-use-blacklist))
                   (const :tag "Spam: Bsfilter"      (spam spam-use-bsfilter))
@@ -1959,7 +1964,20 @@ spam processing, associated with the appropriate processor."
                   (const :tag "Ham: Spam Oracle"    (ham spam-use-spamoracle))
                   (const :tag "Ham: SpamAssassin"   (ham spam-use-spamassassin))
                   (const :tag "Ham: CRM114"         (ham spam-use-crm114))
-                  (const :tag "Ham: Whitelist"      (ham spam-use-whitelist)))))
+                  (const :tag "Ham: Whitelist"      (ham spam-use-whitelist))
+                  (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-spamoracle)
+                  (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-spamoracle)
+                  (variable-item gnus-group-ham-exit-processor-copy))))
 
    :parameter-document
    "Which spam or ham processors will be applied when the summary is exited.")
index b3aa3ec..78f29b6 100644 (file)
@@ -79,11 +79,10 @@ The function must accept the arguments `host' and `report'."
   :type 'file
   :group 'spam-report)
 
-(defcustom spam-report-resend-to (or 
-                                 (when (length user-mail-address) 
-                                   user-mail-address)
-                                 "nonexistent-user-please-fix@invalid.domain")
-  "Email address that spam articles are resent to when reporting."
+(defcustom spam-report-resend-to nil
+  "Email address that spam articles are resent to when reporting.
+If not set, the user will be prompted to enter a value which will be
+saved for future use."
   :type 'string
   :group 'spam-report)
 
@@ -99,6 +98,10 @@ undo that change.")
     (gnus-message 6 
                  "Reporting spam article %d to <%s>..." 
                  article spam-report-resend-to)
+    (unless spam-report-resend-to
+      (customize-set-variable 
+       spam-report-resend-to
+       (read-from-minibuffer "email address to resend SPAM to? ")))
     ;; This is ganked from the `gnus-summary-resend-message' function.
     ;; It involves rendering the SPAM, which is undesirable, but there does
     ;; not seem to be a nicer way to achieve this.
@@ -134,6 +137,7 @@ undo that change.")
            (gnus-message 3 "Could not find X-Report-Spam in article %d..."
                          article)))))))
 
+
 (defun spam-report-url-ping (host report)
   "Ping a host through HTTP, addressing a specific GET resource using
 the function specified by `spam-report-url-ping-function'."
index c24be26..4d4c9f0 100644 (file)
@@ -713,16 +713,16 @@ finds ham or spam.")
     nil))
 
 (defvar spam-list-of-processors
-  ;; note the CRM114, resend and gmane processors are not defined in gnus.el
-  '((gnus-group-spam-exit-processor-report-gmane spam spam-use-gmane)
-    (gnus-group-spam-exit-processor-report-resend spam spam-use-resend)
+  ;; note the nil processors are not defined in gnus.el
+  '((nil spam spam-use-gmane)
+    (nil spam spam-use-resend)
     (gnus-group-spam-exit-processor-bogofilter   spam spam-use-bogofilter)
     (gnus-group-spam-exit-processor-bsfilter    spam spam-use-bsfilter)
     (gnus-group-spam-exit-processor-blacklist    spam spam-use-blacklist)
     (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-crm114       spam spam-use-crm114)
+    (nil spam spam-use-crm114)
     (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)
@@ -733,81 +733,34 @@ finds ham or spam.")
     (gnus-group-ham-exit-processor-copy          ham spam-use-ham-copy)
     (gnus-group-ham-exit-processor-spamassassin  ham spam-use-spamassassin)
     (gnus-group-ham-exit-processor-spamoracle    ham spam-use-spamoracle)
-    (gnus-group-ham-exit-processor-crm114        ham spam-use-crm114))
+    (nil ham spam-use-crm114))
   "The `spam-list-of-processors' list.
-This list contains pairs associating a ham/spam exit processor
-variable with a classification and a spam-use-* variable.")
-
-(defun spam-group-processor-p (group processor)
+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.")
+
+(defun spam-group-processor-p (group check &optional classification)
+  "Checks if GROUP has a CHECK with CLASSIFICATION registered.
+Also accepts the obsolete processors, which can be found in
+gnus.el and in spam-list-of-processors."
   (if (and (stringp group)
-          (symbolp processor))
-      (or (member processor (nth 0 (gnus-parameter-spam-process group)))
-         (spam-group-processor-multiple-p
-          group
-          (cdr-safe (assoc processor spam-list-of-processors))))
+          (symbolp check))
+      (let ((old-style (assq check spam-list-of-processors))
+           (parameters (nth 0 (gnus-parameter-spam-process group)))
+           found)
+       (if old-style  ; old-style processor
+           (spam-group-processor-p group (nth 2 old-style) (nth 1 old-style))
+         ;; now search for the parameter
+         (dolist (parameter parameters)
+           (when (and (null found)
+                      (listp parameter)
+                      (eq classification (nth 0 parameter))
+                      (eq check (nth 1 parameter)))
+             (setq found t)))
+         found))
     nil))
 
-(defun spam-group-processor-multiple-p (group processor-info)
-  (let* ((classification (nth 0 processor-info))
-        (check (nth 1 processor-info))
-        (parameters (nth 0 (gnus-parameter-spam-process group)))
-        found)
-    (dolist (parameter parameters)
-      (when (and (null found)
-                (listp parameter)
-                (eq classification (nth 0 parameter))
-                (eq check (nth 1 parameter)))
-       (setq found t)))
-    found))
-
-(defun spam-group-spam-processor-report-gmane-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-report-gmane))
-
-(defun spam-group-spam-processor-report-resend-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-report-resend))
-
-(defun spam-group-spam-processor-bogofilter-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-bogofilter))
-
-(defun spam-group-spam-processor-blacklist-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-blacklist))
-
-(defun spam-group-spam-processor-ifile-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-ifile))
-
-(defun spam-group-ham-processor-ifile-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-ifile))
-
-(defun spam-group-spam-processor-spamoracle-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-spamoracle))
-
-(defun spam-group-spam-processor-crm114-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-crm114))
-
-(defun spam-group-ham-processor-bogofilter-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-bogofilter))
-
-(defun spam-group-spam-processor-stat-p (group)
-  (spam-group-processor-p group 'gnus-group-spam-exit-processor-stat))
-
-(defun spam-group-ham-processor-stat-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-stat))
-
-(defun spam-group-ham-processor-whitelist-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-whitelist))
-
-(defun spam-group-ham-processor-BBDB-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-BBDB))
-
-(defun spam-group-ham-processor-copy-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-copy))
-
-(defun spam-group-ham-processor-spamoracle-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-spamoracle))
-
-(defun spam-group-ham-processor-crm114-p (group)
-  (spam-group-processor-p group 'gnus-group-ham-exit-processor-crm114))
-
 (defun spam-report-articles-gmane (n)
   "Report the current message as spam via Gmane.
 Respects the process/prefix convention."
@@ -821,7 +774,9 @@ Respects the process/prefix convention."
 Respects the process/prefix convention.  Also see
 `spam-report-resend-to'."
   (interactive "P")
-  (let ((articles (gnus-summary-work-articles n)))
+  (let ((spam-report-resend-to 
+        (gnus-parameter-spam-resend-to gnus-newsgroup-name))
+       (articles (gnus-summary-work-articles n)))
     (spam-report-resend articles)
     (dolist (article articles)
       (gnus-summary-remove-process-mark article))))
@@ -938,7 +893,7 @@ Will not return a nil score."
            (classification (nth 1 processor-param))
            (check (nth 2 processor-param)))
        (when (and (eq 'spam classification)
-                  (spam-group-processor-p gnus-newsgroup-name processor))
+                  (spam-group-processor-p gnus-newsgroup-name check classification))
          (spam-register-routine classification check))))
 
     (unless (and spam-move-spam-nonspam-groups-only
@@ -969,10 +924,10 @@ Will not return a nil score."
              (classification (nth 1 processor-param))
              (check (nth 2 processor-param)))
          (when (and (eq 'ham classification)
-                    (spam-group-processor-p gnus-newsgroup-name processor))
+                    (spam-group-processor-p gnus-newsgroup-name check classification))
            (spam-register-routine classification check)))))
 
-    (when (spam-group-ham-processor-copy-p gnus-newsgroup-name)
+    (when (spam-group-processor-p gnus-newsgroup-name 'ham 'spam-use-ham-copy)
       (let ((num
             (spam-ham-copy-routine
              (gnus-parameter-ham-process-destination gnus-newsgroup-name))))
@@ -2152,7 +2107,8 @@ REMOVE not nil, remove the ADDRESSES."
     (apply 'spam-report-gmane articles)))
 
 (defun spam-report-resend-register-routine (articles)
-  (spam-report-resend articles))
+  (let ((spam-report-resend-to (gnus-parameter-spam-resend-to gnus-newsgroup-name)))
+       (spam-report-resend articles)))
 
 \f
 ;;;; Bogofilter