* wl.el (toplevel): Require wl-spam when compile.
authorhmurata <hmurata>
Tue, 21 Oct 2003 03:00:47 +0000 (03:00 +0000)
committerhmurata <hmurata>
Tue, 21 Oct 2003 03:00:47 +0000 (03:00 +0000)
(wl-save-status): Call wl-spam-save-status.

* wl-spam.el (wl-spam-register-spam-messages): New function.
(wl-spam-register-good-messages): Ditto.
(wl-spam-save-status): Ditto.
(wl-summary-mode-map): Bind
wl-summary-target-mark-register-as-spam to "ms" and
wl-summary-target-mark-register-as-good to "mn".
(wl-summary-register-as-spam): Abolish optional argument; Use
wl-spam-register-spam-messages.
(wl-summary-register-as-spam-all): Use
wl-spam-register-spam-messages.
(wl-summary-register-as-good): Abolish optional argument; Use
wl-spam-register-good-messages.
(wl-summary-register-as-good-all): Use
wl-spam-register-good-messages.
(wl-summary-target-mark-register-as-spam): New funtion.
(wl-summary-target-mark-register-as-good): Ditto.

* elmo-spam.el (elmo-spam-save-status): New API.

* elsp-spamfilter.el: New file.

* WL-ELS (ELMO-MODULES): Added elsp-spamfilter only if spamfilter
is installed.

ChangeLog
WL-ELS
elmo/ChangeLog
elmo/elmo-spam.el
elmo/elsp-spamfilter.el [new file with mode: 0644]
wl/ChangeLog
wl/wl-spam.el
wl/wl.el

index 54ecdd9..ed5d637 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-21  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * WL-ELS (ELMO-MODULES): Added elsp-spamfilter only if spamfilter
+       is installed.
+
 2003-10-20  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * WL-ELS (WL-MODULES): Added wl-spam.
diff --git a/WL-ELS b/WL-ELS
index ab438ba..bf5c322 100644 (file)
--- a/WL-ELS
+++ b/WL-ELS
@@ -52,6 +52,9 @@
 (if (module-installed-p 'shimbun)
     (add-to-list 'ELMO-MODULES 'elmo-shimbun))
 
+(if (module-installed-p 'spamfilter)
+    (add-to-list 'ELMO-MODULES 'elsp-spamfilter))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; SEMI
 
index 55e69c6..2f17b4e 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-21  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * elmo-spam.el (elmo-spam-save-status): New API.
+
+       * elsp-spamfilter.el: New file.
+
 2003-10-21  TAKAHASHI Kaoru  <kaoru@kaisei.org>
 
        * elmo-split.el (toplevel): Add `elmo-spam-processor' args.
index 9d3ed38..30f2a13 100644 (file)
@@ -62,6 +62,9 @@ PROCESSOR is spam processor structure.")
   "Register contents of BUFFER as non spam.
 PROCESSOR is spam processor structure.")
 
+(luna-define-generic elmo-spam-save-status (processor)
+  "Save status of the PROCESSOR.")
+
 ;; optional method
 (luna-define-generic elmo-spam-message-spam-p (processor folder number)
   "Return non-nil if the message in the FOLDER with NUMBER is spam.
diff --git a/elmo/elsp-spamfilter.el b/elmo/elsp-spamfilter.el
new file mode 100644 (file)
index 0000000..e5dcc55
--- /dev/null
@@ -0,0 +1,108 @@
+;;; elsp-spamfilter.el --- Spamfilter support for elmo-spam.
+
+;; Copyright (C) 2003 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+;; Copyright (C) 2003 Yuuichi Teranishi <teranisi@gohome.org>
+
+;; Author: Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+;; Keywords: mail, net news, spam
+
+;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+;;
+
+;;; Commentary:
+;;
+
+;;; Code:
+;;
+(require 'elmo-spam)
+
+(require 'luna)
+(require 'mime-view)
+(require 'spamfilter)
+
+(defgroup elmo-spam-spamfilter nil
+  "Spam spamfilter configuration."
+  :group 'elmo-spam)
+
+(defcustom elmo-spam-spamfilter-corpus-filename
+  (expand-file-name ".spamfilter" elmo-msgdb-directory)
+  "Filename of the Spamfilter corpus."
+  :type '(file :tag "Filename of the Spamfilter corpus")
+  :group 'elmo-spam-spamfilter)
+
+(eval-and-compile
+  (luna-define-class elsp-spamfilter (elsp-generic)
+                    (good-corpus bad-corpus))
+  (luna-define-internal-accessors 'elsp-spamfilter))
+
+(luna-define-method initialize-instance :around ((processor elsp-spamfilter)
+                                                &rest init-args)
+  (luna-call-next-method)
+  (let ((spamf-good-corpus (make-spamf-corpus
+                           :name "spamf-good-corpus"
+                           :table (make-hash-table :test #'eq)
+                           :message-count 0))
+       (spamf-bad-corpus  (make-spamf-corpus
+                           :name "spamf-bad-corpus"
+                           :table (make-hash-table :test #'eq)
+                           :message-count 0)))
+    (spamf-load-corpus-from-file elmo-spam-spamfilter-corpus-filename)
+    (elsp-spamfilter-set-good-corpus-internal processor spamf-good-corpus)
+    (elsp-spamfilter-set-bad-corpus-internal  processor spamf-bad-corpus)
+    processor))
+
+(luna-define-method elmo-spam-save-status ((processor elsp-spamfilter))
+  (spamf-save-corpus-to-file
+   elmo-spam-spamfilter-corpus-filename
+   (elsp-spamfilter-good-corpus-internal processor)
+   (elsp-spamfilter-bad-corpus-internal  processor)))
+
+(defun elmo-spam-spamfilter-decode-buffer (buffer)
+  (mime-display-message
+   (mime-open-entity 'elmo-buffer buffer)
+   (current-buffer)))
+
+(luna-define-method elmo-spam-buffer-spam-p ((processor elsp-spamfilter)
+                                            buffer)
+  (with-temp-buffer
+    (elmo-spam-spamfilter-decode-buffer buffer)
+    (spamf-spam-buffer-p
+     (current-buffer)
+     (elsp-spamfilter-good-corpus-internal processor)
+     (elsp-spamfilter-bad-corpus-internal  processor))))
+
+(luna-define-method elmo-spam-register-spam-buffer ((processor elsp-spamfilter)
+                                                   buffer)
+  (with-temp-buffer
+    (elmo-spam-spamfilter-decode-buffer buffer)
+    (spamf-register-good-buffer
+     (current-buffer)
+     (elsp-spamfilter-good-corpus-internal processor))))
+
+(luna-define-method elmo-spam-register-good-buffer ((processor elsp-spamfilter)
+                                                   buffer)
+  (with-temp-buffer
+    (elmo-spam-spamfilter-decode-buffer buffer)
+    (spamf-register-spam-buffer
+     (current-buffer)
+     (elsp-spamfilter-bad-corpus-internal  processor))))
+
+(require 'product)
+(product-provide (provide 'elsp-spamfilter) (require 'elmo-version))
+
+;;; elsp-spamfilter.el ends here
index 0ae9c07..2461d14 100644 (file)
@@ -1,3 +1,25 @@
+2003-10-21  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * wl.el (toplevel): Require wl-spam when compile.
+       (wl-save-status): Call wl-spam-save-status.
+
+       * wl-spam.el (wl-spam-register-spam-messages): New function.
+       (wl-spam-register-good-messages): Ditto.
+       (wl-spam-save-status): Ditto.
+       (wl-summary-mode-map): Bind
+       wl-summary-target-mark-register-as-spam to "ms" and
+       wl-summary-target-mark-register-as-good to "mn".
+       (wl-summary-register-as-spam): Abolish optional argument; Use
+       wl-spam-register-spam-messages.
+       (wl-summary-register-as-spam-all): Use
+       wl-spam-register-spam-messages.
+       (wl-summary-register-as-good): Abolish optional argument; Use
+       wl-spam-register-good-messages.
+       (wl-summary-register-as-good-all): Use
+       wl-spam-register-good-messages.
+       (wl-summary-target-mark-register-as-spam): New funtion.
+       (wl-summary-target-mark-register-as-good): Ditto.
+
 2003-10-20  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * wl-spam.el: New file.
index 9d0fbde..e038e88 100644 (file)
@@ -66,7 +66,6 @@
                               (const :tag "none" nil))))
   :group 'wl-spam)
 
-
 (defun wl-spam-folder-guess-domain (folder-name)
   (cond ((string= folder-name wl-spam-folder-name)
         'spam)
        (apply function number args)))
     (message "Checking spam...done")))
 
+(defun wl-spam-register-spam-messages (folder numbers)
+  (let ((total (length numbers)))
+    (elmo-with-progress-display (> total elmo-display-progress-threshold)
+       (elmo-spam-register total "Register spam messages...")
+      (elmo-spam-register-spam-messages (elmo-spam-processor)
+                                       wl-summary-buffer-elmo-folder
+                                       numbers))
+    (message "Register spam messages...done")))
+
+(defun wl-spam-register-good-messages (folder numbers)
+  (let ((total (length numbers)))
+    (elmo-with-progress-display (> total elmo-display-progress-threshold)
+       (elmo-spam-register total "Register good messages...")
+      (elmo-spam-register-good-messages (elmo-spam-processor)
+                                       wl-summary-buffer-elmo-folder
+                                       numbers))
+    (message "Register good messages...done")))
+
+(defun wl-spam-save-status ()
+  (interactive)
+  (elmo-spam-save-status (elmo-spam-processor)))
+
 ;; insinuate into summary mode
 (defvar wl-summary-spam-map nil)
 
     (define-key map "S" 'wl-summary-register-as-spam-all)
     (define-key map "n" 'wl-summary-register-as-good)
     (define-key map "N" 'wl-summary-register-as-good-all)
-    (setq wl-summary-spam-map map)
-    (define-key wl-summary-mode-map "k" wl-summary-spam-map)))
+    (setq wl-summary-spam-map map)))
+
+(define-key wl-summary-mode-map "k" wl-summary-spam-map)
+
+(define-key wl-summary-mode-map "ms" 'wl-summary-target-mark-register-as-spam)
+(define-key wl-summary-mode-map "mn" 'wl-summary-target-mark-register-as-good)
 
 (eval-when-compile
   ;; Avoid compile warnings
                             #'wl-summary-refile
                             wl-spam-folder-name))
 
-(defun wl-summary-register-as-spam (&optional all)
-  (interactive "P")
-  (let ((numbers (if all
-                    wl-summary-buffer-number-list
-                  (list (wl-summary-message-number)))))
-    (elmo-spam-register-spam-messages (elmo-spam-processor)
-                                     wl-summary-buffer-elmo-folder
-                                     numbers)))
+(defun wl-summary-register-as-spam ()
+  (interactive)
+  (let ((number (wl-summary-message-number)))
+    (when number
+      (wl-spam-register-spam-messages wl-summary-buffer-elmo-folder
+                                     (list number)))))
 
 (defun wl-summary-register-as-spam-all ()
   (interactive)
-  (wl-summary-register-as-spam 'all))
+  (wl-spam-register-spam-messages wl-summary-buffer-elmo-folder
+                                 wl-summary-buffer-number-list))
 
-(defun wl-summary-register-as-good (&optional all)
-  (interactive "P")
-  (let ((numbers (if all
-                    wl-summary-buffer-number-list
-                  (list (wl-summary-message-number)))))
-    (elmo-spam-register-good-messages (elmo-spam-processor)
-                                     wl-summary-buffer-elmo-folder
-                                     numbers)))
+(defun wl-summary-target-mark-register-as-spam ()
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (let ((inhibit-read-only t)
+         (buffer-read-only nil)
+         wl-summary-buffer-disp-msg)
+      (wl-spam-register-spam-messages wl-summary-buffer-elmo-folder
+                                     wl-summary-buffer-target-mark-list)
+      (dolist (number wl-summary-buffer-target-mark-list)
+       (wl-summary-unset-mark number)))))
+
+(defun wl-summary-register-as-good ()
+  (interactive)
+  (let ((number (wl-summary-message-number)))
+    (when number
+      (wl-spam-register-good-messages wl-summary-buffer-elmo-folder
+                                     (list number)))))
 
 (defun wl-summary-register-as-good-all ()
   (interactive)
-  (wl-summary-register-as-good 'all))
+  (wl-spam-register-good-messages wl-summary-buffer-elmo-folder
+                                 wl-summary-buffer-number-list))
+
+(defun wl-summary-target-mark-register-as-good ()
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (let ((inhibit-read-only t)
+         (buffer-read-only nil)
+         wl-summary-buffer-disp-msg)
+      (wl-spam-register-good-messages wl-summary-buffer-elmo-folder
+                                     wl-summary-buffer-target-mark-list)
+      (dolist (number wl-summary-buffer-target-mark-list)
+       (wl-summary-unset-mark number)))))
 
 ;; hook functions and other
 (defun wl-summary-auto-check-spam ()
index 26d3f7d..ac7859d 100644 (file)
--- a/wl/wl.el
+++ b/wl/wl.el
@@ -73,7 +73,8 @@
   (require 'smtp)
   (require 'wl-score)
   (require 'wl-fldmgr)
-  (require 'wl-mime))
+  (require 'wl-mime)
+  (require 'wl-spam))
 
 (defun wl-plugged-init (&optional make-alist)
   (setq elmo-plugged wl-plugged)
@@ -648,6 +649,7 @@ Entering Plugged mode calls the value of `wl-plugged-mode-hook'."
   (wl-refile-alist-save)
   (wl-folder-info-save)
   (and (featurep 'wl-fldmgr) (wl-fldmgr-exit))
+  (and (featurep 'wl-spam) (wl-spam-save-status))
   (elmo-crosspost-message-alist-save)
   (message "Saving summary and folder status...done"))