1
;;; elsp-bsfilter.el --- Bsfilter support for elmo-spam.
3
;; Copyright (C) 2004 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
4
;; Copyright (C) 2004 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.
35
(defgroup elmo-spam-bsfilter nil
36
"Spam bsfilter configuration."
39
(defcustom elmo-spam-bsfilter-shell-program "ruby"
42
:group 'elmo-spam-bsfilter)
44
(defcustom elmo-spam-bsfilter-shell-switch nil
47
:group 'elmo-spam-bsfilter)
49
(defcustom elmo-spam-bsfilter-program (exec-installed-p "bsfilter")
50
"*Program name of the Bsfilter."
51
:type '(string :tag "Program name of the bsfilter")
52
:group 'elmo-spam-bsfilter)
54
(defcustom elmo-spam-bsfilter-args nil
55
"*Argument list for bsfilter."
56
:type '(repeat string)
57
:group 'elmo-spam-bsfilter)
59
(defcustom elmo-spam-bsfilter-update-switch "--synchronous-auto-update"
60
"*The switch that Bsfilter uses to update database with classify."
62
:group 'elmo-spam-bsfilter)
64
(defcustom elmo-spam-bsfilter-database-directory nil
65
"*Directory path of the Bsfilter databases."
66
:type '(choice (directory :tag "Location of the Bsfilter database directory")
67
(const :tag "Use the default"))
68
:group 'elmo-spam-bsfilter)
70
(defcustom elmo-spam-bsfilter-debug nil
71
"Non-nil to debug elmo bsfilter spam backend."
73
:group 'elmo-spam-bsfilter-debug)
76
(luna-define-class elsp-bsfilter (elsp-generic)))
78
(defsubst elsp-bsfilter-call-bsfilter (&rest args)
79
(apply #'call-process-region
80
(point-min) (point-max)
81
elmo-spam-bsfilter-shell-program
82
nil (if elmo-spam-bsfilter-debug
83
(get-buffer-create "*Debug ELMO Bsfilter*"))
85
(append (list elmo-spam-bsfilter-shell-switch
86
elmo-spam-bsfilter-program)
87
elmo-spam-bsfilter-args
88
(elmo-flatten args)))))
90
(luna-define-method elmo-spam-buffer-spam-p ((processor elsp-bsfilter)
91
buffer &optional register)
92
(with-current-buffer buffer
93
(= 0 (elsp-bsfilter-call-bsfilter
94
(if register elmo-spam-bsfilter-update-switch)
95
(if elmo-spam-bsfilter-database-directory
96
(list "--homedir" elmo-spam-bsfilter-database-directory))))))
98
(defsubst elsp-bsfilter-register-buffer (buffer spam restore)
99
(with-current-buffer buffer
100
(elsp-bsfilter-call-bsfilter
102
(if elmo-spam-bsfilter-database-directory
103
(list "--homedir" elmo-spam-bsfilter-database-directory))
104
(if restore (if spam "--sub-clean" "--sub-spam"))
105
(if spam "--add-spam" "--add-clean"))))
107
(luna-define-method elmo-spam-register-spam-buffer ((processor elsp-bsfilter)
108
buffer &optional restore)
109
(elsp-bsfilter-register-buffer buffer t restore))
111
(luna-define-method elmo-spam-register-good-buffer ((processor elsp-bsfilter)
112
buffer &optional restore)
113
(elsp-bsfilter-register-buffer buffer nil restore))
116
(product-provide (provide 'elsp-bsfilter) (require 'elmo-version))
118
;;; elsp-bsfilter.el ends here