From 81da98a54a25669af5a3acbbdd91e0dbb8b70065 Mon Sep 17 00:00:00 2001 From: hmurata Date: Sun, 11 Jan 2004 15:21:33 +0000 Subject: [PATCH] * elmo-spam.el (elmo-spam-scheme): Add 'bsfilter' as a candidate. * elsp-bsfilter.el: New file. * WL-ELS (ELMO-MODULES): Added elsp-bsfilter. --- ChangeLog | 4 ++ WL-ELS | 2 +- elmo/ChangeLog | 4 ++ elmo/elmo-spam.el | 3 +- elmo/elsp-bsfilter.el | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 elmo/elsp-bsfilter.el diff --git a/ChangeLog b/ChangeLog index 4062161..dd2abc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-01-11 Hiroya Murata + + * WL-ELS (ELMO-MODULES): Added elsp-bsfilter. + 2004-01-11 Yuuichi Teranishi * WL-ELS (ELMO-MODULES): Added elsp-sa. diff --git a/WL-ELS b/WL-ELS index 3966b15..e334285 100644 --- a/WL-ELS +++ b/WL-ELS @@ -23,7 +23,7 @@ elmo-archive elmo-pipe elmo-cache elmo-internal elmo-flag elmo-sendlog elmo-dop elmo-nmz elmo-split - elmo-spam elsp-bogofilter elsp-sa + elmo-spam elsp-bogofilter elsp-sa elsp-bsfilter modb modb-entity modb-legacy modb-standard )) diff --git a/elmo/ChangeLog b/elmo/ChangeLog index e9ab7c9..d08e41d 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,5 +1,9 @@ 2004-01-11 Hiroya Murata + * elmo-spam.el (elmo-spam-scheme): Add 'bsfilter' as a candidate. + + * elsp-bsfilter.el: New file. + * elmo-pipe.el (elmo-folder-list-unreads, elmo-folder-list-answereds, elmo-folder-list-importants, diff --git a/elmo/elmo-spam.el b/elmo/elmo-spam.el index 48ba52e..63bd6f4 100644 --- a/elmo/elmo-spam.el +++ b/elmo/elmo-spam.el @@ -45,7 +45,8 @@ :type '(choice (const :tag "none" nil) (const :tag "Bogofilter" bogofilter) (const :tag "Spamfilter" spamfilter) - (const :tag "SpamAssassin" sa)) + (const :tag "SpamAssassin" sa) + (const :tag "Bsfilter" bsfilter)) :group 'elmo-spam) (eval-and-compile diff --git a/elmo/elsp-bsfilter.el b/elmo/elsp-bsfilter.el new file mode 100644 index 0000000..8444c9c --- /dev/null +++ b/elmo/elsp-bsfilter.el @@ -0,0 +1,112 @@ +;;; elsp-bsfilter.el --- Bsfilter support for elmo-spam. + +;; Copyright (C) 2004 Hiroya Murata +;; Copyright (C) 2004 Yuuichi Teranishi + +;; Author: Hiroya Murata +;; 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) +(require 'luna) + +(defgroup elmo-spam-bsfilter nil + "Spam bsfilter configuration." + :group 'elmo-spam) + +(defcustom elmo-spam-bsfilter-shell-program (or explicit-shell-file-name + shell-file-name) + "*" + :type 'string + :group 'elmo-spam-bsfilter) + +(defcustom elmo-spam-bsfilter-shell-switch shell-command-switch + "*" + :type 'string + :group 'elmo-spam-bsfilter) + +(defcustom elmo-spam-bsfilter-program "bsfilter" + "*Program name of the Bsfilter." + :type '(string :tag "Program name of the bsfilter") + :group 'elmo-spam-bsfilter) + +(defcustom elmo-spam-bsfilter-args nil + "*Argument list for bsfilter." + :type '(repeat string) + :group 'elmo-spam-bsfilter) + +(defcustom elmo-spam-bsfilter-update-switch "--synchronous-auto-update" + "*The switch that Bsfilter uses to update database with classify." + :type 'string + :group 'elmo-spam-bsfilter) + +(defcustom elmo-spam-bsfilter-database-directory nil + "*Directory path of the Bsfilter databases." + :type '(choice (directory :tag "Location of the Bsfilter database directory") + (const :tag "Use the default")) + :group 'elmo-spam-bsfilter) + +(eval-and-compile + (luna-define-class elsp-bsfilter (elsp-generic))) + +(defsubst elsp-bsfilter-call-bsfilter (&rest args) + (apply #'call-process-region + (point-min) (point-max) + elmo-spam-bsfilter-shell-program + nil nil nil + (append (list elmo-spam-bsfilter-shell-switch + elmo-spam-bsfilter-program) + elmo-spam-bsfilter-args + (delq nil (elmo-flatten args))))) + +(luna-define-method elmo-spam-buffer-spam-p ((processor elsp-bsfilter) + buffer &optional register) + (with-current-buffer buffer + (= 0 (elsp-bsfilter-call-bsfilter + (if register elmo-spam-bsfilter-update-switch) + (if elmo-spam-bsfilter-database-directory + (list "--homedir" elmo-spam-bsfilter-database-directory)))))) + +(defsubst elsp-bsfilter-register-buffer (buffer spam restore) + (with-current-buffer buffer + (elsp-bsfilter-call-bsfilter + "--update" + (if elmo-spam-bsfilter-database-directory + (list "--homedir" elmo-spam-bsfilter-database-directory)) + (if restore (if spam "--sub-clean" "--sub-spam")) + (if spam "--add-spam" "--add-clean")))) + +(luna-define-method elmo-spam-register-spam-buffer ((processor elsp-bsfilter) + buffer &optional restore) + (elsp-bsfilter-register-buffer buffer t restore)) + +(luna-define-method elmo-spam-register-good-buffer ((processor elsp-bsfilter) + buffer &optional restore) + (elsp-bsfilter-register-buffer buffer nil restore)) + +(require 'product) +(product-provide (provide 'elsp-bsfilter) (require 'elmo-version)) + +;;; elsp-bsfilter.el ends here -- 1.7.10.4