* spam.el (spam-group-ham-mark-p, spam-group-spam-mark-p)
authorTeodor Zlatanov <tzz@lifelogs.com>
Wed, 19 Mar 2003 22:57:55 +0000 (22:57 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Wed, 19 Mar 2003 22:57:55 +0000 (22:57 +0000)
(spam-group-ham-marks, spam-group-spam-marks): new functions
(spam-spam-marks, spam-ham-marks): removed in favor of the
spam-marks and ham-marks parameters
(spam-generic-register-routine, spam-ham-move-routine): use the
new spam-group-{spam,ham}-mark-p functions
* gnus.el (spam-marks, ham-marks): new group parameters with
default values same as the old spam-spam-marks and spam-ham-marks

lisp/ChangeLog
lisp/gnus.el
lisp/spam.el

index fe5ce9c..c026e41 100644 (file)
@@ -1,3 +1,15 @@
+2003-03-19  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * spam.el (spam-group-ham-mark-p, spam-group-spam-mark-p) 
+       (spam-group-ham-marks, spam-group-spam-marks): new functions
+       (spam-spam-marks, spam-ham-marks): removed in favor of the
+       spam-marks and ham-marks parameters
+       (spam-generic-register-routine, spam-ham-move-routine): use the
+       new spam-group-{spam,ham}-mark-p functions
+
+       * gnus.el (spam-marks, ham-marks): new group parameters with
+       default values same as the old spam-spam-marks and spam-ham-marks
+
 2003-03-19  Simon Josefsson  <jas@extundo.com>
 
        * gnus-art.el (gnus-article-decode-hook): Add IDNA.
index 03f7af9..cd52c60 100644 (file)
@@ -1949,7 +1949,50 @@ mail groups, and only works in spam groups."
                      (string :tag "Move to a group")
                      (const :tag "Expire" nil))))
    :parameter-document
-   "Where ham articles will go at summary exit from a spam group."))
+   "Where ham articles will go at summary exit from a spam group.")
+
+  (gnus-define-group-parameter 
+   ham-marks
+   :type 'list
+   :parameter-type '(list :tag "Ham mark choices"
+                         (set 
+                          (variable-item gnus-del-mark)
+                          (variable-item gnus-read-mark)
+                          (variable-item gnus-killed-mark)
+                          (variable-item gnus-kill-file-mark)
+                          (variable-item gnus-low-score-mark)))
+
+   :parameter-document
+   "Marks considered ham (positively not spam).  Such articles will be
+processed as ham (non-spam) on group exit.  When nil, the global
+spam-ham-marks variable takes precedence."
+   :variable-default '((".*" ((gnus-del-mark 
+                              gnus-read-mark
+                              gnus-killed-mark 
+                              gnus-kill-file-mark
+                              gnus-low-score-mark))))
+   :variable-group spam
+   :variable-document
+   "*Groups in which to explicitly set the ham marks to some value.")
+
+  (gnus-define-group-parameter 
+   spam-marks
+   :type 'list
+   :parameter-type '(list :tag "Spam mark choices"
+                         (set 
+                          (variable-item gnus-spam-mark)
+                          (variable-item gnus-killed-mark)
+                          (variable-item gnus-kill-file-mark)
+                          (variable-item gnus-low-score-mark)))
+
+   :parameter-document
+   "Marks considered spam.
+Such articles will be processed as spam on group exit.  When nil, the global
+spam-spam-marks variable takes precedence."
+   :variable-default '((".*" ((gnus-spam-mark))))
+   :variable-group spam
+   :variable-document
+   "*Groups in which to explicitly set the spam marks to some value."))
 
 (defcustom gnus-group-uncollapsed-levels 1
   "Number of group name elements to leave alone when making a short group name."
index e95baf5..d4c8627 100644 (file)
@@ -190,29 +190,6 @@ All unmarked article in such group receive the spam mark on group entry."
   :type 'regexp
   :group 'spam)
 
-(defcustom spam-ham-marks (list 'gnus-del-mark 'gnus-read-mark 
-                               'gnus-killed-mark 'gnus-kill-file-mark 
-                               'gnus-low-score-mark)
-  "Marks considered as being ham (positively not spam).
-Such articles will be processed as ham (non-spam) on group exit."
-  :type '(set
-         (variable-item gnus-del-mark)
-         (variable-item gnus-read-mark)
-         (variable-item gnus-killed-mark)
-         (variable-item gnus-kill-file-mark)
-         (variable-item gnus-low-score-mark))
-  :group 'spam)
-
-(defcustom spam-spam-marks (list 'gnus-spam-mark)
-  "Marks considered as being spam (positively spam).
-Such articles will be transmitted to `bogofilter -s' on group exit."
-  :type '(set 
-         (variable-item gnus-spam-mark)
-         (variable-item gnus-killed-mark)
-         (variable-item gnus-kill-file-mark)
-         (variable-item gnus-low-score-mark))
-  :group 'spam)
-
 (defcustom spam-face 'gnus-splash-face
   "Face for spam-marked articles"
   :type 'face
@@ -316,6 +293,29 @@ your main source of newsgroup names."
       gnus-summary-highlight)
 
 ;; convenience functions
+(defun spam-group-ham-mark-p (group mark &optional spam)
+  (when (stringp group)
+    (let* ((marks (spam-group-ham-marks group spam))
+          (marks (if (symbolp mark) 
+                     marks 
+                   (mapcar 'symbol-value marks))))
+      (memq mark marks))))
+
+(defun spam-group-spam-mark-p (group mark)
+  (spam-group-ham-mark-p group mark t))
+
+(defun spam-group-ham-marks (group &optional spam)
+  (when (stringp group)
+    (let* ((marks (if spam
+                    (gnus-parameter-spam-marks group)
+                  (gnus-parameter-ham-marks group)))
+          (marks (car marks))
+          (marks (if (listp (car marks)) (car marks) marks)))
+      marks)))
+
+(defun spam-group-spam-marks (group)
+  (spam-group-ham-marks group t))
+
 (defun spam-group-spam-contents-p (group)
   (if (stringp group)
       (or (member group spam-junk-mailgroups)
@@ -469,13 +469,12 @@ your main source of newsgroup names."
 (defun spam-ham-move-routine (&optional group copy)
   (gnus-summary-kill-process-mark)
   (let ((articles gnus-newsgroup-articles)
-       article ham-mark-values mark tomove)
+       article mark tomove)
     (when (stringp group)              ; this routine will do nothing
                                        ; without a valid group
-      (dolist (mark spam-ham-marks)
-       (push (symbol-value mark) ham-mark-values))
       (dolist (article articles)
-       (when (memq (gnus-summary-article-mark article) ham-mark-values)
+       (when (spam-group-spam-mark-p gnus-newsgroup-name
+                                     (gnus-summary-article-mark article))
          (push article tomove)))
 
       ;; now do the actual move
@@ -491,24 +490,17 @@ your main source of newsgroup names."
  
 (defun spam-generic-register-routine (spam-func ham-func)
   (let ((articles gnus-newsgroup-articles)
-       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))
-
-    (dolist (mark spam-spam-marks)
-      (push (symbol-value mark) spam-mark-values))
+       article mark ham-articles spam-articles)
 
     (while articles
       (setq article (pop articles)
            mark (gnus-summary-article-mark article))
-      (cond ((memq mark spam-mark-values) (push article spam-articles))
+      (cond ((spam-group-spam-mark-p nus-newsgroup-name mark) 
+            (push article spam-articles))
            ((memq article gnus-newsgroup-saved))
-           ((memq mark ham-mark-values) (push article ham-articles))))
+           ((spam-group-ham-mark-p gnus-newsgroup-name mark)
+            (push article ham-articles))))
+
     (when (and ham-articles ham-func)
       (mapc ham-func ham-articles))    ; we use mapc because unlike
                                        ; mapcar it discards the