Synch with Oort Gnus.
authoryamaoka <yamaoka>
Thu, 2 Jan 2003 00:25:01 +0000 (00:25 +0000)
committeryamaoka <yamaoka>
Thu, 2 Jan 2003 00:25:01 +0000 (00:25 +0000)
lisp/ChangeLog
lisp/gnus.el
lisp/spam.el

index 967fefe..3bb4911 100644 (file)
@@ -1,3 +1,31 @@
+2003-01-01  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * spam.el (spam-summary-prepare-exit): added slots for spam- and
+       ham-processing of articles; use the new
+       spam-group-(spam|ham)-contents-p functions
+       (spam-group-spam-contents-p, spam-group-ham-contents-p): new
+       convenience functions
+       (spam-mark-junk-as-spam-routine): use the new
+       spam-group-spam-contents-p function
+
+       * gnus.el (spam-process, spam-contents, spam-process-destination):
+       added new parameters with corresponding global variables
+       (gnus-group-spam-exit-processor-ifile,
+       gnus-group-spam-exit-processor-bogofilter,
+       gnus-group-spam-exit-processor-blacklist,
+       gnus-group-spam-exit-processor-whitelist,
+       gnus-group-spam-exit-processor-BBDB,
+       gnus-group-spam-classification-spam,
+       gnus-group-spam-classification-ham): added new symbols for the
+       spam-process and spam-contents parameters
+
+       * spam.el (spam-ham-marks, spam-spam-marks): changed list
+       customization and list itself to store mark symbol rather than
+       mark character.
+       (spam-bogofilter-register-routine): added logic to generate mark
+       values list from spam-ham-marks and spam-spam-marks, so (member)
+       would work.
+
 2003-01-02  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * message.el (message-cross-post-followup-to): Fix comment.
index acaf2ed..36e90bd 100644 (file)
@@ -1775,6 +1775,134 @@ articles to list when the group is a large newsgroup (see
 `gnus-large-newsgroup').  If it is `nil', the default value is the
 total number of articles in the group.")
 
+;; group parameters for spam processing added by Ted Zlatanov <tzz@lifelogs.com>
+(defvar gnus-group-spam-classification-spam t
+  "Spam group classification (requires spam.el).
+This group contains spam messages.  On summary entry, unread messages
+will be marked as spam.  On summary exit, the specified spam
+processors will be invoked on spam-marked messages, then those
+messages will be expired, so the spam processor will only see a
+spam-marked message once.")
+
+(defvar gnus-group-spam-classification-ham 'ask
+  "The ham value for the spam group parameter (requires spam.el).
+On summary exit, the specified ham processors will be invoked on
+ham-marked messages.  Exercise caution, since the ham processor will
+see the same message more than once because there is no ham message
+registry.")
+
+(gnus-define-group-parameter
+ spam-contents
+ :type list
+ :function-document
+ "The spam type (spam, ham, or neither) of the group."
+ :variable gnus-spam-newsgroup-contents
+ :variable-default nil
+ :variable-document
+ "*Groups in which to automatically mark new articles as spam on
+summary entry.  If non-nil, this should be a list of group name
+regexps that should match all groups in which to do automatic spam
+tagging, associated with a classification (spam, ham, or neither).
+This only makes sense for mail groups."
+ :variable-group spam
+ :variable-type '(repeat 
+                        (list :tag "Group contents spam/ham classification"
+                         (regexp :tag "Group")
+                         (choice
+                          (variable-item gnus-group-spam-classification-spam)
+                          (variable-item gnus-group-spam-classification-ham)
+                          (other :tag "Unclassified" nil))))
+
+ :parameter-type '(list :tag "Group contents spam/ham classification"
+                  (choice :tag "Group contents classification for spam sorting"
+                          (variable-item gnus-group-spam-classification-spam)
+                          (variable-item gnus-group-spam-classification-ham)
+                          (other :tag "Unclassified" nil)))
+ :parameter-document
+ "The spam classification (spam, ham, or neither) of this group.
+When a spam group is entered, all unread articles are marked as spam.")
+
+(defvar gnus-group-spam-exit-processor-ifile "ifile"
+  "The ifile summary exit spam processor.
+Only applicable to spam groups.")
+
+(defvar gnus-group-spam-exit-processor-bogofilter "bogofilter"
+  "The Bogofilter summary exit spam processor.
+Only applicable to spam groups.")
+
+(defvar gnus-group-spam-exit-processor-blacklist "blacklist"
+  "The Blacklist summary exit spam processor.
+Only applicable to spam groups.")
+
+(defvar gnus-group-ham-exit-processor-whitelist "whitelist"
+  "The whitelist summary exit ham processor.
+Only applicable to non-spam (unclassified and ham) groups.")
+
+(defvar gnus-group-ham-exit-processor-BBDB "bbdb"
+  "The BBDB summary exit ham processor.
+Only applicable to non-spam (unclassified and ham) groups.")
+
+(gnus-define-group-parameter
+ spam-process
+ :type list
+ :parameter-type '(choice :tag "Spam Summary Exit Processor"
+                          :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-bogofilter)
+                           (variable-item gnus-group-spam-exit-processor-blacklist)
+                           (variable-item gnus-group-ham-exit-processor-whitelist)
+                           (variable-item gnus-group-ham-exit-processor-BBDB))))
+ :function-document
+ "Which spam or ham processors will be applied to the GROUP articles at summary exit."
+ :variable gnus-spam-process-newsgroups
+ :variable-default nil
+ :variable-document
+ "*Groups in which to automatically process spam or ham articles with
+a backend on summary exit.  If non-nil, this should be a list of group
+name regexps that should match all groups in which to do automatic
+spam processing, associated with the appropriate processor.  This only makes sense
+for mail groups."
+ :variable-group spam
+ :variable-type '(repeat :tag "Spam/Ham Processors" 
+                        (list :tag "Spam Summary Exit Processor Choices"
+                         (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-bogofilter)
+                              (variable-item gnus-group-spam-exit-processor-blacklist)
+                              (variable-item gnus-group-ham-exit-processor-whitelist)
+                              (variable-item gnus-group-ham-exit-processor-BBDB))))
+ :parameter-document
+ "Which spam processors will be applied to the spam or ham GROUP articles at summary exit.")
+
+(gnus-define-group-parameter
+ spam-process-destination
+ :parameter-type '(choice :tag "Destination for spam-processed articles at summary exit"
+                         (string :tag "Move to a group")
+                         (other :tag "Expire" nil))
+ :function-document
+ "Where spam-processed articles will go at summary exit."
+ :variable gnus-spam-process-destinations
+ :variable-default nil
+ :variable-document
+ "*Groups in which to explicitly send spam-processed articles to
+another group, or expire them (the default).  If non-nil, this should
+be a list of group name regexps that should match all groups in which
+to do spam-processed article moving, associated with the destination
+group or `nil' for explicit expiration.  This only makes sense for
+mail groups."
+ :variable-group spam
+ :variable-type '(repeat :tag "Spam-processed articles destination" 
+                        (list
+                         (regexp :tag "Group Regexp") 
+                         (choice :tag "Destination for spam-processed articles at summary exit"
+                                 (string :tag "Move to a group")
+                                 (other :tag "Expire" nil))))
+ :parameter-document
+ "Where spam-processed articles will go at summary exit.")
+
 (defcustom gnus-group-uncollapsed-levels 1
   "Number of group name elements to leave alone when making a short group name."
   :group 'gnus-group-visual
index a8d02a0..c067ceb 100644 (file)
@@ -37,6 +37,7 @@
 (require 'gnus-sum)
 
 (require 'gnus-uu)                     ; because of key prefix issues
+(require 'gnus)        ; for the definitions of group content classification and spam processors
 
 ;; FIXME!  We should not require `message' until we actually need
 ;; them.  Best would be to declare needed functions as auto-loadable.
@@ -221,19 +222,42 @@ articles before they get registered by Bogofilter."
 (push '((eq mark gnus-spam-mark) . spam-face)
       gnus-summary-highlight)
 
+;; convenience functions
+(defun spam-group-spam-contents-p (group)
+  (if (stringp group)
+      (or (member group spam-junk-mailgroups)
+         (memq 'gnus-group-spam-classification-spam (gnus-parameter-spam-contents group)))
+    nil))
+  
+(defun spam-group-ham-contents-p (group)
+  (if (stringp group)
+      (memq 'gnus-group-spam-classification-ham (gnus-parameter-spam-contents group))
+    nil))
+  
+
 ;;; Hooks dispatching.  A bit raw for now.
 
 (defun spam-summary-prepare ()
   (spam-mark-junk-as-spam-routine))
 
 (defun spam-summary-prepare-exit ()
-  (spam-bogofilter-register-routine))
+  (spam-bogofilter-register-routine)
+  (when (spam-group-spam-contents-p gnus-newsgroup-name)
+    (                                
+     ;; TODO: the spam processors here
+     ;; TODO: the spam-processed articles will be moved here
+     ))
+  (when (spam-group-ham-contents-p gnus-newsgroup-name)
+    (
+     ;; TODO: the ham processors here
+     )))
 
 (add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
 (add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
 
 (defun spam-mark-junk-as-spam-routine ()
-  (when (member gnus-newsgroup-name spam-junk-mailgroups)
+  ;; check the global list of group names spam-junk-mailgroups and the group parameters
+  (when (spam-group-spam-contents-p gnus-newsgroup-name)
     (let ((articles gnus-newsgroup-articles)
          article)
       (while articles
@@ -530,6 +554,7 @@ spamicity coefficient of each, and the overall article spamicity."
          article mark ham-articles spam-articles spam-mark-values ham-mark-values)
 
       ;; marks are stored as symbolic values, so we have to dereference them for memq to work
+      ;; we wouldn't have to do this if gnus-summary-article-mark returned a symbol.
       (dolist (mark spam-ham-marks)
        (push (symbol-value mark) ham-mark-values))