(elmo-spam-bogofilter-max-messages-per-process): New user option.
authorhmurata <hmurata>
Sun, 25 Jan 2004 10:16:03 +0000 (10:16 +0000)
committerhmurata <hmurata>
Sun, 25 Jan 2004 10:16:03 +0000 (10:16 +0000)
(elmo-spam-bogofilter-register-messages): New internal function.
(elmo-spam-register-spam-messages): Define.
(elmo-spam-register-good-messages): Ditto.

elmo/ChangeLog
elmo/elsp-bogofilter.el

index 7e12506..5d507c8 100644 (file)
@@ -1,3 +1,11 @@
+2004-01-25  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * elsp-bogofilter.el
+       (elmo-spam-bogofilter-max-messages-per-process): New user option.
+       (elmo-spam-bogofilter-register-messages): New internal function.
+       (elmo-spam-register-spam-messages): Define.
+       (elmo-spam-register-good-messages): Ditto.
+
 2004-01-24  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * elsp-bogofilter.el (elmo-spam-bogofilter-arguments-alist):
index 6cda961..41adb35 100644 (file)
                 (const :tag "Use the default"))
   :group 'elmo-spam-bogofilter)
 
+(defcustom elmo-spam-bogofilter-max-messages-per-process 30
+  "Number of messages processed at one once"
+  :type 'integer
+  :group 'elmo-spam-bogofilter)
+
 (defcustom elmo-spam-bogofilter-arguments-alist
   '((classify
      (if elmo-spam-bogofilter-debug "-vv")
@@ -118,6 +123,43 @@ Must be return a string or list of string."
                                                    buffer &optional restore)
   (elsp-bogofilter-register-buffer buffer nil restore))
 
+(defsubst elmo-spam-bogofilter-register-messages (folder numbers spam restore)
+  (with-temp-buffer
+    (buffer-disable-undo (current-buffer))
+    (while numbers
+      (let ((count 0))
+       (while (and numbers
+                   (< count elmo-spam-bogofilter-max-messages-per-process))
+         (insert "From MAILER-DAEMON\n"
+                 (with-temp-buffer
+                   (elmo-spam-message-fetch folder (car numbers))
+                   (goto-char (point-min))
+                   (while (re-search-forward "^>*From " nil t)
+                     (goto-char (match-beginning 0))
+                     (insert ?>)
+                     (forward-line))
+                   (buffer-substring (point-min) (point-max)))
+                 "\n\n")
+         (setq count (1+ count)
+               numbers (cdr numbers)))
+       (elsp-bogofilter-register-buffer (current-buffer) spam restore)
+       (elmo-progress-notify 'elmo-spam-register count)
+       (erase-buffer)))))
+
+(luna-define-method elmo-spam-register-spam-messages :around
+  ((processor elsp-bogofilter) folder &optional numbers restore)
+  (let ((numbers (or numbers (elmo-folder-list-messages folder t t))))
+    (if (> (length numbers) 1)
+       (elmo-spam-bogofilter-register-messages folder numbers t restore)
+      (luna-call-next-method))))
+
+(luna-define-method elmo-spam-register-good-messages :around
+  ((processor elsp-bogofilter) folder &optional numbers restore)
+  (let ((numbers (or numbers (elmo-folder-list-messages folder t t))))
+    (if (> (length numbers) 1)
+       (elmo-spam-bogofilter-register-messages folder numbers nil restore)
+      (luna-call-next-method))))
+
 (require 'product)
 (product-provide (provide 'elsp-bogofilter) (require 'elmo-version))