1 ;;; elsp-spamfilter.el --- Spamfilter support for elmo-spam.
3 ;; Copyright (C) 2003 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
4 ;; Copyright (C) 2003 Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Author: Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
7 ;; Keywords: mail, net news, spam
9 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
38 (defgroup elmo-spam-spamfilter nil
39 "Spam spamfilter configuration."
42 (defcustom elmo-spam-spamfilter-corpus-filename
43 (expand-file-name ".spamfilter" elmo-msgdb-directory
)
44 "Filename of the Spamfilter corpus."
45 :type
'(file :tag
"Filename of the Spamfilter corpus")
46 :group
'elmo-spam-spamfilter
)
49 (luna-define-class elsp-spamfilter
(elsp-generic)
50 (good-corpus bad-corpus modified
))
51 (luna-define-internal-accessors 'elsp-spamfilter
))
53 (luna-define-method initialize-instance
:around
((processor elsp-spamfilter
)
55 (luna-call-next-method)
56 (let ((spamf-good-corpus (make-spamf-corpus
57 :name
"spamf-good-corpus"
58 :table
(make-hash-table :test
#'eq
)
60 (spamf-bad-corpus (make-spamf-corpus
61 :name
"spamf-bad-corpus"
62 :table
(make-hash-table :test
#'eq
)
64 (spamf-load-corpus-from-file elmo-spam-spamfilter-corpus-filename
)
65 (elsp-spamfilter-set-good-corpus-internal processor spamf-good-corpus
)
66 (elsp-spamfilter-set-bad-corpus-internal processor spamf-bad-corpus
)
69 (luna-define-method elmo-spam-modified-p
((processor elsp-spamfilter
))
70 (elsp-spamfilter-modified-internal processor
))
72 (luna-define-method elmo-spam-save-status
((processor elsp-spamfilter
))
73 (spamf-save-corpus-to-file
74 elmo-spam-spamfilter-corpus-filename
75 (elsp-spamfilter-good-corpus-internal processor
)
76 (elsp-spamfilter-bad-corpus-internal processor
))
77 (elsp-spamfilter-set-modified-internal processor nil
))
79 (defun elsp-spamfilter-decode-buffer (buffer)
81 (mime-open-entity 'elmo-buffer buffer
)
84 (defsubst elsp-spamfilter-register-buffer-internal
(processor buffer spam
)
85 (spamf-register-words-buffer
87 (elsp-spamfilter-bad-corpus-internal processor
)
88 (elsp-spamfilter-good-corpus-internal processor
))
90 (elsp-spamfilter-set-modified-internal processor t
))
92 (luna-define-method elmo-spam-buffer-spam-p
((processor elsp-spamfilter
)
93 buffer
&optional register
)
95 (elsp-spamfilter-decode-buffer buffer
)
96 (let ((spam (spamf-spam-buffer-p
98 (elsp-spamfilter-good-corpus-internal processor
)
99 (elsp-spamfilter-bad-corpus-internal processor
))))
101 (elsp-spamfilter-register-buffer-internal
102 processor
(current-buffer) spam
))
105 (luna-define-method elmo-spam-register-spam-buffer
((processor elsp-spamfilter
)
106 buffer
&optional restore
)
108 (elsp-spamfilter-decode-buffer buffer
)
109 (elsp-spamfilter-register-buffer-internal processor
(current-buffer) t
)))
111 (luna-define-method elmo-spam-register-good-buffer
((processor elsp-spamfilter
)
112 buffer
&optional restore
)
114 (elsp-spamfilter-decode-buffer buffer
)
115 (elsp-spamfilter-register-buffer-internal processor
(current-buffer) nil
)))
118 (product-provide (provide 'elsp-spamfilter
) (require 'elmo-version
))
120 ;;; elsp-spamfilter.el ends here