From: teranisi Date: Sun, 11 Jan 2004 08:15:10 +0000 (+0000) Subject: * elmo-spam.el (elmo-spam-scheme): Add 'sa' as a candidate. X-Git-Tag: wl-2_11_23~4 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=50d2f26db946febf03c279d86e20d61852b43f24;p=elisp%2Fwanderlust.git * elmo-spam.el (elmo-spam-scheme): Add 'sa' as a candidate. * elsp-sa.el: New file. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index a8037d1..5493ea2 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,9 @@ +2004-01-11 Yuuichi Teranishi + + * elmo-spam.el (elmo-spam-scheme): Add 'sa' as a candidate. + + * elsp-sa.el: New file. + 2003-12-17 Hiroya Murata * modb-standard.el (modb-standard-message-entity): New function. diff --git a/elmo/elmo-spam.el b/elmo/elmo-spam.el index 5bf47ec..48ba52e 100644 --- a/elmo/elmo-spam.el +++ b/elmo/elmo-spam.el @@ -44,7 +44,8 @@ "*Scheme of spam processor implementation. " :type '(choice (const :tag "none" nil) (const :tag "Bogofilter" bogofilter) - (const :tag "Spamfilter" spamfilter)) + (const :tag "Spamfilter" spamfilter) + (const :tag "SpamAssassin" sa)) :group 'elmo-spam) (eval-and-compile diff --git a/elmo/elsp-sa.el b/elmo/elsp-sa.el new file mode 100644 index 0000000..e4bd6f2 --- /dev/null +++ b/elmo/elsp-sa.el @@ -0,0 +1,107 @@ +;;; elsp-sa.el --- SpamAssassin support for elmo-spam. +;; Copyright (C) 2004 Yuuichi Teranishi + +;; Author: Yuuichi Teranishi +;; 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) + +(defgroup elmo-spam-spamassassin nil + "Spam SpamAssassin configuration." + :group 'elmo-spam) + +(defcustom elmo-spam-spamassassin-program "spamassassin" + "Program name for SpamAssassin." + :type '(file :tag "Program name of SpamAssassin.") + :group 'elmo-spam-spamassassin) + +(defcustom elmo-spam-spamassassin-learn-program "sa-learn" + "Program name for SpamAssassin Learner." + :type '(file :tag "Program name of SpamAssassin Learner.") + :group 'elmo-spam-spamassassin) + +(defcustom elmo-spam-spamassassin-program-arguments '("-e") + "Program argument list for SpamAssassin." + :type '(file :tag "Program name of SpamAssassin Learner.") + :group 'elmo-spam-spamassassin) + +(defcustom elmo-spam-spamassassin-learn-program-arguments nil + "Program argument list for SpamAssassin Learner." + :type '(file :tag "Program name of SpamAssassin Learner.") + :group 'elmo-spam-spamassassin) + +(defcustom elmo-spamassassin-debug nil + "Non-nil to debug elmo spamassassin spam backend." + :type 'boolean + :group 'elmo-spam-spamassassin) + +(eval-and-compile + (luna-define-class elsp-sa (elsp-generic)) + (luna-define-internal-accessors 'elsp-sa)) + +(defun elmo-spamassassin-call (type &rest args) + (let ((pair (cond + ((eq type 'check) + (cons elmo-spam-spamassassin-program + elmo-spam-spamassassin-program-arguments)) + ((eq type 'learn) + (cons + elmo-spam-spamassassin-learn-program + elmo-spam-spamassassin-learn-program-arguments)) + (t (error "Internal error."))))) + (apply #'call-process-region + (point-min) (point-max) + (car pair) + nil (if elmo-spamassassin-debug + (get-buffer-create "*Debug ELMO SpamAssassin*")) + nil (delq nil (append (cdr pair) args))))) + +(luna-define-method elmo-spam-buffer-spam-p ((processor elsp-sa) + buffer &optional register) + (let ((result (with-current-buffer buffer + (not (eq 0 (elmo-spamassassin-call 'check)))))) + (when register + (if result + (elmo-spam-register-spam-buffer processor buffer) + (elmo-spam-register-good-buffer processor buffer))) + result)) + +(luna-define-method elmo-spam-register-spam-buffer ((processor elsp-sa) + buffer &optional restore) + (with-current-buffer buffer + (eq 0 (apply 'elmo-spamassassin-call 'learn + (list (when restore "--forget") "--spam"))))) + +(luna-define-method elmo-spam-register-good-buffer ((processor elsp-sa) + buffer &optional restore) + (with-current-buffer buffer + (eq 0 (apply 'elmo-spamassassin-call 'learn + (list (when restore "--forget") "--ham"))))) + +(require 'product) +(product-provide (provide 'elsp-sa) (require 'elmo-version)) + +;;; elsp-sa.el ends here