1 ;;; elsp-spamoracle.el --- SpamOracle support for elmo-spam.
3 ;; Copyright (C) 2004 Daishi Kato <daishi@axlight.com>
5 ;; Author: Daishi Kato <daishi@axlight.com>
6 ;; Keywords: mail, net news, spam
8 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
33 (defgroup elmo-spam-spamoracle nil
34 "Spam spamoracle configuration."
37 (defcustom elmo-spam-spamoracle-program
"spamoracle"
38 "Program name of the SpamOracle."
39 :type
'(string :tag
"Program name of the SpamOracle")
40 :group
'elmo-spam-spamoracle
)
42 (defcustom elmo-spam-spamoracle-config-filename nil
43 "Filename of the SpamOracle config."
44 :type
'(file :tag
"Filename of the SpamOracle config")
45 :group
'elmo-spam-spamoracle
)
47 (defcustom elmo-spam-spamoracle-database-filename
48 (expand-file-name ".spamoracle.db" elmo-msgdb-directory
)
49 "Filename of the SpamOracle database."
50 :type
'(file :tag
"Filename of the SpamOracle database")
51 :group
'elmo-spam-spamoracle
)
53 (defcustom elmo-spam-spamoracle-spam-header-regexp
"^X-Spam: yes;"
54 "Regexp of the SpamOracle spam header."
55 :type
'(string :tag
"Regexp of the SpamOracle spam header")
56 :group
'elmo-spam-spamoracle
)
59 (luna-define-class elsp-spamoracle
(elsp-generic)))
61 (defsubst elmo-spam-spamoracle-call
(type)
66 (list "add" "-v" "-spam"))
68 (list "add" "-v" "-good"))))
69 (output-buffer (get-buffer-create "*Output ELMO SpamOracle*")))
70 (with-current-buffer output-buffer
72 (apply #'call-process-region
73 (point-min) (point-max)
74 elmo-spam-spamoracle-program
77 (append (if elmo-spam-spamoracle-config-filename
79 elmo-spam-spamoracle-config-filename
))
80 (if elmo-spam-spamoracle-database-filename
82 elmo-spam-spamoracle-database-filename
))
85 (with-current-buffer output-buffer
86 (goto-char (point-min))
87 (let ((body-point (re-search-forward "^$" nil t
)))
88 (goto-char (point-min))
89 (re-search-forward elmo-spam-spamoracle-spam-header-regexp
93 (luna-define-method elmo-spam-buffer-spam-p
((processor elsp-spamoracle
)
94 buffer
&optional register
)
95 (let ((result (with-current-buffer buffer
96 (elmo-spam-spamoracle-call 'check
))))
99 (elmo-spam-register-spam-buffer processor buffer
)
100 (elmo-spam-register-good-buffer processor buffer
)))
103 (luna-define-method elmo-spam-register-spam-buffer
((processor elsp-spamoracle
)
104 buffer
&optional restore
)
105 (with-current-buffer buffer
106 (elmo-spam-spamoracle-call 'add-spam
)))
108 (luna-define-method elmo-spam-register-good-buffer
((processor elsp-spamoracle
)
109 buffer
&optional restore
)
110 (with-current-buffer buffer
111 (elmo-spam-spamoracle-call 'add-good
)))
114 (product-provide (provide 'elsp-spamoracle
) (require 'elmo-version
))
116 ;;; elsp-spamoracle.el ends here