Synch with Oort Gnus.
authoryamaoka <yamaoka>
Fri, 3 Jan 2003 05:38:03 +0000 (05:38 +0000)
committeryamaoka <yamaoka>
Fri, 3 Jan 2003 05:38:03 +0000 (05:38 +0000)
lisp/ChangeLog
lisp/gnus-group.el
lisp/mml.el
lisp/spam.el

index cce5b84..fd83dfa 100644 (file)
@@ -1,3 +1,22 @@
+2003-01-03  Jesper Harder  <harder@ifa.au.dk>
+
+       * mml.el (mml-insert-tag): Don't quote non-ASCII unibyte
+       characters.
+
+2003-01-02  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * spam.el (spam-group-spam-contents-p, spam-group-ham-contents-p)
+       (spam-group-processor-p, spam-group-processor-bogofilter-p) 
+       (spam-group-processor-ifile-p, spam-group-processor-blacklist-p) 
+       (spam-group-processor-whitelist-p, spam-group-processor-BBDB-p) 
+       (spam-mark-spam-as-expired-and-move-routine) 
+       (spam-generic-register-routine, spam-BBDB-register-routine) 
+       (spam-ifile-register-routine, spam-blacklist-register-routine) 
+       (spam-whitelist-register-routine): new functions
+       (spam-summary-prepare-exit): added summary exit processing (expire
+       or move) of spam-marked articles for spam groups; added slots for
+       all the spam-*-register-routine functions
+
 2003-01-03  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus-msg.el (gnus-setup-message): Get the evaliation order
index 24d9cd6..fe2a114 100644 (file)
@@ -1207,57 +1207,57 @@ if it is a string, only list groups matching REGEXP."
              params (gnus-info-params info)
              newsrc (cdr newsrc)
              unread (car (gnus-gethash group gnus-newsrc-hashtb)))
-       (if not-in-list
-           (setq not-in-list (delete group not-in-list)))
-       (and
-        (gnus-group-prepare-logic
-         group
-         (and unread           ; This group might be unchecked
-              (or (not (stringp regexp))
-                  (string-match regexp group))
-              (<= (setq clevel (gnus-info-level info)) level)
-              (>= clevel lowest)
-              (cond
-               ((functionp predicate)
-                (funcall predicate info))
-               (predicate t)           ; We list all groups?
-               (t
-                (or
-                 (if (eq unread t)     ; Unactivated?
-                     gnus-group-list-inactive-groups
+       (when not-in-list
+         (setq not-in-list (delete group not-in-list)))
+       (when (gnus-group-prepare-logic
+              group
+              (and unread              ; This group might be unchecked
+                   (or (not (stringp regexp))
+                       (string-match regexp group))
+                   (<= (setq clevel (gnus-info-level info)) level)
+                   (>= clevel lowest)
+                   (cond
+                    ((functionp predicate)
+                     (funcall predicate info))
+                    (predicate t)      ; We list all groups?
+                    (t
+                     (or
+                      (if (eq unread t) ; Unactivated?
+                          gnus-group-list-inactive-groups
                                        ; We list unactivated
-                   (> unread 0))
+                        (> unread 0))
                                        ; We list groups with unread articles
-                 (and gnus-list-groups-with-ticked-articles
-                      (cdr (assq 'tick (gnus-info-marks info))))
+                      (and gnus-list-groups-with-ticked-articles
+                           (cdr (assq 'tick (gnus-info-marks info))))
                                        ; And groups with tickeds
-                 ;; Check for permanent visibility.
-                 (and gnus-permanently-visible-groups
-                      (string-match gnus-permanently-visible-groups group))
-                 (memq 'visible params)
-                 (cdr (assq 'visible params)))))))
-        (gnus-group-insert-group-line
-         group (gnus-info-level info)
-         (gnus-info-marks info) unread (gnus-info-method info)))))
+                      ;; Check for permanent visibility.
+                      (and gnus-permanently-visible-groups
+                           (string-match gnus-permanently-visible-groups
+                                         group))
+                      (memq 'visible params)
+                      (cdr (assq 'visible params)))))))
+         (gnus-group-insert-group-line
+          group (gnus-info-level info)
+          (gnus-info-marks info) unread (gnus-info-method info)))))
 
     ;; List dead groups.
-    (if (or gnus-group-listed-groups
-           (and (>= level gnus-level-zombie)
-                (<= lowest gnus-level-zombie)))
-       (gnus-group-prepare-flat-list-dead
-        (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
-        gnus-level-zombie ?Z
-        regexp))
-    (if not-in-list
-       (dolist (group gnus-zombie-list)
-         (setq not-in-list (delete group not-in-list))))
-    (if (or gnus-group-listed-groups
-           (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
-       (gnus-group-prepare-flat-list-dead
-        (gnus-union
-         not-in-list
-         (setq gnus-killed-list (sort gnus-killed-list 'string<)))
-        gnus-level-killed ?K regexp))
+    (when (or gnus-group-listed-groups
+             (and (>= level gnus-level-zombie)
+                  (<= lowest gnus-level-zombie)))
+      (gnus-group-prepare-flat-list-dead
+       (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
+       gnus-level-zombie ?Z
+       regexp))
+    (when not-in-list
+      (dolist (group gnus-zombie-list)
+       (setq not-in-list (delete group not-in-list))))
+    (when (or gnus-group-listed-groups
+             (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)))
+      (gnus-group-prepare-flat-list-dead
+       (gnus-union
+       not-in-list
+       (setq gnus-killed-list (sort gnus-killed-list 'string<)))
+       gnus-level-killed ?K regexp))
 
     (gnus-group-set-mode-line)
     (setq gnus-group-list-mode (cons level predicate))
index d19ecaa..97ed2c7 100644 (file)
@@ -1,5 +1,5 @@
 ;;; mml.el --- A package for parsing and validating MML documents
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; This file is part of GNU Emacs.
@@ -939,7 +939,9 @@ See Info node `(emacs-mime)Composing'.
       (when value
        ;; Quote VALUE if it contains suspicious characters.
        (when (string-match "[\"'\\~/*;() \t\n]" value)
-         (setq value (prin1-to-string value)))
+         (setq value (with-output-to-string
+                       (let (print-escape-nonascii)
+                         (prin1 value)))))
        (insert (format " %s=%s" key value)))))
   (insert ">\n"))
 
index c067ceb..946135e 100644 (file)
@@ -233,7 +233,27 @@ articles before they get registered by Bogofilter."
   (if (stringp group)
       (memq 'gnus-group-spam-classification-ham (gnus-parameter-spam-contents group))
     nil))
-  
+
+(defun spam-group-processor-p (group processor)
+  (if (and (stringp group)
+          (symbolp processor))
+      (member processor (car (gnus-parameter-spam-process group)))
+    nil))
+
+(defun spam-group-processor-bogofilter-p (group)
+  (spam-group-processor-p group 'gnus-group-spam-exit-processor-bogofilter))
+
+(defun spam-group-processor-ifile-p (group)
+  (spam-group-processor-p group 'gnus-group-spam-exit-processor-ifile))
+
+(defun spam-group-processor-blacklist-p (group)
+  (spam-group-processor-p group 'gnus-group-spam-exit-processor-blacklist))
+
+(defun spam-group-processor-whitelist-p (group)
+  (spam-group-processor-p group 'gnus-group-ham-exit-processor-whitelist))
+
+(defun spam-group-processor-BBDB-p (group)
+  (spam-group-processor-p group 'gnus-group-ham-exit-processor-BBDB))
 
 ;;; Hooks dispatching.  A bit raw for now.
 
@@ -241,16 +261,31 @@ articles before they get registered by Bogofilter."
   (spam-mark-junk-as-spam-routine))
 
 (defun spam-summary-prepare-exit ()
-  (spam-bogofilter-register-routine)
+  ;; The spam processors are invoked for any group, spam or ham or neither
+  (when (or (and spam-use-bogofilter spam-bogofilter-path)
+           (spam-group-processor-bogofilter-p gnus-newsgroup-name))
+    (spam-bogofilter-register-routine))
+  
+  (when (or spam-use-ifile
+           (spam-group-processor-ifile-p gnus-newsgroup-name))
+    (spam-ifile-register-routine))
+  
+  (when (or spam-use-blacklist
+           (spam-group-processor-bogofilter-p gnus-newsgroup-name))
+    (spam-blacklist-register-routine))
+
+  ;; Only for spam groups, we expire and maybe move articles
   (when (spam-group-spam-contents-p gnus-newsgroup-name)
-    (                                
-     ;; TODO: the spam processors here
-     ;; TODO: the spam-processed articles will be moved here
-     ))
+    (spam-mark-spam-as-expired-and-move-routine (gnus-parameter-spam-process-destination gnus-newsgroup-name)))
+
   (when (spam-group-ham-contents-p gnus-newsgroup-name)
-    (
-     ;; TODO: the ham processors here
-     )))
+    ;; TODO: the ham processors here
+    (when (or spam-use-whitelist
+             (spam-group-processor-whitelist-p gnus-newsgroup-name))
+      (spam-whitelist-register-routine))
+    (when (or spam-use-BBDB
+             (spam-group-processor-BBDB-p gnus-newsgroup-name))
+      (spam-BBDB-register-routine))))
 
 (add-hook 'gnus-summary-prepare-hook 'spam-summary-prepare)
 (add-hook 'gnus-summary-prepare-exit-hook 'spam-summary-prepare-exit)
@@ -264,6 +299,41 @@ articles before they get registered by Bogofilter."
        (setq article (pop articles))
        (when (eq (gnus-summary-article-mark article) gnus-unread-mark)
          (gnus-summary-mark-article article gnus-spam-mark))))))
+
+(defun spam-mark-spam-as-expired-and-move-routine (&optional group)
+  (let ((articles gnus-newsgroup-articles)
+       article)
+    (while articles
+      (setq article (pop articles))
+      (when (eq (gnus-summary-article-mark article) gnus-spam-mark)
+       (gnus-summary-mark-article article gnus-expirable-mark)
+       (when (stringp group)
+         (let ((gnus-current-article article))
+           (gnus-summary-move-article nil group)))))))
+(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))
+
+    (while articles
+      (setq article (pop articles)
+           mark (gnus-summary-article-mark article))
+      (cond ((memq mark spam-mark-values) (push article spam-articles))
+           ((memq article gnus-newsgroup-saved))
+           ((memq mark ham-mark-values) (push article ham-articles))))
+    (when (and ham-articles ham-func)
+      (funcall ham-func ham-articles))
+    (when (and spam-articles spam-func)
+      (funcall spam-func spam-articles))))
+
 \f
 ;;;; Spam determination.
 
@@ -389,12 +459,20 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
                    (delete (assoc 'spam-use-bbdb spam-list-of-checks)
                            spam-list-of-checks))))
 
+;; TODO: add BBDB registration
+(defun spam-BBDB-register-routine
+  (spam-generic-register-routine nil nil))
+
 ;;; check the ifile backend; return nil if the mail was NOT classified as spam
 ;;; TODO: we can't (require) ifile, because it will insinuate itself automatically
 (defun spam-check-ifile ()
   (let ((ifile-primary-spam-group spam-split-group))
     (ifile-spam-filter nil)))
 
+;; TODO: add ifile registration
+(defun spam-ifile-register-routine
+  (spam-generic-register-routine nil nil))
+
 (defun spam-check-blacklist ()
   ;; FIXME!  Should it detect when file timestamps change?
   (unless spam-blacklist-cache
@@ -430,6 +508,12 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details."
              cache nil)))
     found))
 
+;; TODO: add blacklist and whitelist registrations
+(defun spam-blacklist-register-routine
+  (spam-generic-register-routine nil nil))
+(defun spam-whitelist-register-routine
+  (spam-generic-register-routine nil nil))
+
 \f
 ;;;; Training via Bogofilter.   Last updated 2002-09-02.
 
@@ -549,28 +633,27 @@ spamicity coefficient of each, and the overall article spamicity."
          (display-buffer (current-buffer)))))))
 
 (defun spam-bogofilter-register-routine ()
-  (when (and spam-use-bogofilter spam-bogofilter-path)
-    (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))
-
-      (while articles
-       (setq article (pop articles)
-             mark (gnus-summary-article-mark article))
-       (cond ((memq mark spam-mark-values) (push article spam-articles))
-             ((memq article gnus-newsgroup-saved))
-             ((memq mark ham-mark-values) (push article ham-articles))))
-      (when ham-articles
-       (spam-bogofilter-articles "ham" "-n" ham-articles))
-      (when spam-articles
-       (spam-bogofilter-articles "SPAM" "-s" spam-articles)))))
+  (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))
+
+    (while articles
+      (setq article (pop articles)
+           mark (gnus-summary-article-mark article))
+      (cond ((memq mark spam-mark-values) (push article spam-articles))
+           ((memq article gnus-newsgroup-saved))
+           ((memq mark ham-mark-values) (push article ham-articles))))
+    (when ham-articles
+      (spam-bogofilter-articles "ham" "-n" ham-articles))
+    (when spam-articles
+      (spam-bogofilter-articles "SPAM" "-s" spam-articles))))
 
 (defun spam-bogofilter-articles (type option articles)
   (let ((output-buffer (get-buffer-create spam-bogofilter-output-buffer-name))