1 ;;; elsp-sa.el --- SpamAssassin support for elmo-spam.
2 ;; Copyright (C) 2004 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Keywords: mail, net news, spam
7 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
32 (defgroup elmo-spam-spamassassin nil
33 "Spam SpamAssassin configuration."
36 (defcustom elmo-spam-spamassassin-program "spamassassin"
37 "Program name for SpamAssassin."
38 :type '(file :tag "Program name of SpamAssassin.")
39 :group 'elmo-spam-spamassassin)
41 (defcustom elmo-spam-spamassassin-learn-program "sa-learn"
42 "Program name for SpamAssassin Learner."
43 :type '(file :tag "Program name of SpamAssassin Learner.")
44 :group 'elmo-spam-spamassassin)
46 (defcustom elmo-spam-spamassassin-program-arguments '("-e")
47 "Program argument list for SpamAssassin."
48 :type '(file :tag "Program name of SpamAssassin Learner.")
49 :group 'elmo-spam-spamassassin)
51 (defcustom elmo-spam-spamassassin-learn-program-arguments nil
52 "Program argument list for SpamAssassin Learner."
53 :type '(file :tag "Program name of SpamAssassin Learner.")
54 :group 'elmo-spam-spamassassin)
56 (defcustom elmo-spamassassin-debug nil
57 "Non-nil to debug elmo spamassassin spam backend."
59 :group 'elmo-spam-spamassassin)
62 (luna-define-class elsp-sa (elsp-generic))
63 (luna-define-internal-accessors 'elsp-sa))
65 (defun elmo-spamassassin-call (type &rest args)
68 (cons elmo-spam-spamassassin-program
69 elmo-spam-spamassassin-program-arguments))
72 elmo-spam-spamassassin-learn-program
73 elmo-spam-spamassassin-learn-program-arguments))
74 (t (error "Internal error.")))))
75 (apply #'call-process-region
76 (point-min) (point-max)
78 nil (if elmo-spamassassin-debug
79 (get-buffer-create "*Debug ELMO SpamAssassin*"))
80 nil (delq nil (append (cdr pair) args)))))
82 (luna-define-method elmo-spam-buffer-spam-p ((processor elsp-sa)
83 buffer &optional register)
84 (let ((result (with-current-buffer buffer
85 (not (eq 0 (elmo-spamassassin-call 'check))))))
88 (elmo-spam-register-spam-buffer processor buffer)
89 (elmo-spam-register-good-buffer processor buffer)))
92 (luna-define-method elmo-spam-register-spam-buffer ((processor elsp-sa)
93 buffer &optional restore)
94 (with-current-buffer buffer
95 (eq 0 (apply 'elmo-spamassassin-call 'learn
96 (list (when restore "--forget") "--spam")))))
98 (luna-define-method elmo-spam-register-good-buffer ((processor elsp-sa)
99 buffer &optional restore)
100 (with-current-buffer buffer
101 (eq 0 (apply 'elmo-spamassassin-call 'learn
102 (list (when restore "--forget") "--ham")))))
105 (product-provide (provide 'elsp-sa) (require 'elmo-version))
107 ;;; elsp-sa.el ends here