;; Author: Alex Schroeder <alex@gnu.org>
;; Maintainer: Alex Schroeder <alex@gnu.org>
-;; Version: 0.3.3
+;; Version: 0.3.4
;; Keywords: spam filtering gnus
;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SpamStat
(defun spam-stat-save ()
"Save the `spam-stat' hash table as lisp file."
+ (interactive)
(with-temp-buffer
(let ((standard-output (current-buffer)))
(insert "(setq spam-stat (spam-stat-to-hash-table '(")
entries)
table))
+(defun spam-stat-reset ()
+ "Reset `spam-stat' to an empty hash-table.
+This deletes all the statistics."
+ (interactive)
+ (setq spam-stat (make-hash-table :test 'equal)))
+
;; Scoring buffers
(defvar spam-stat-score-data nil
COUNT defaults to 5. It also removes all words whose spam score
is less than DISTANCE from 0.5. DISTANCE defaults to 0.1, meaning that
all words with score between 0.4 and 0.6 are removed."
+ (interactive)
(setq count (or count 5)
distance (or distance 0.1))
(maphash (lambda (key entry)
(eval-when-compile
(condition-case nil
(require 'bbdb-com)
- (file-error (defalias 'bbdb-search 'ignore))
- (error)))
+ (file-error (defalias 'bbdb-search 'ignore))))
;; autoload executable-find
(autoload 'executable-find "executable")
+;; autoload ifile-spam-filter
+(autoload 'ifile-spam-filter "ifile-gnus")
+
;;; Main parameters.
(defvar spam-use-blacklist t
(defvar spam-use-bogofilter t
"True if bogofilter should be used.")
+(defvar spam-use-bbdb t
+ "True if BBDB should be used.")
+
+(defvar spam-use-bbdb t
+ "True if ifile should be used.")
+
(defvar spam-split-group "spam"
"Usual group name where spam should be split.")
\f
;;;; Spam determination.
-;; The following list contains pairs associating a parameter variable with a
-;; spam checking function. If the parameter variable is true, then the
-;; checking function is called, and its value decides what happens. Each
-;; individual check may return `nil', `t', or a mailgroup name. The value
-;; `nil' means that the check does not yield a decision, and so, that further
-;; checks are needed. The value `t' means that the message is definitely not
-;; spam, and that further spam checks should be inhibited. Otherwise, a
-;; mailgroup name is returned where the mail should go, and further checks are
-;; also inhibited. The usual mailgroup name is the value of
-;; `spam-split-group', meaning that the message is definitely a spam.
(defvar spam-list-of-checks
'((spam-use-blacklist . spam-check-blacklist)
(spam-use-whitelist . spam-check-whitelist)
(spam-use-bbdb . spam-check-bbdb)
+ (spam-use-ifile . spam-check-ifile)
(spam-use-blackholes . spam-check-blackholes)
- (spam-use-bogofilter . spam-check-bogofilter)))
+ (spam-use-bogofilter . spam-check-bogofilter))
+"The spam-list-of-checks list contains pairs associating a parameter
+variable with a spam checking function. If the parameter variable is
+true, then the checking function is called, and its value decides what
+happens. Each individual check may return `nil', `t', or a mailgroup
+name. The value `nil' means that the check does not yield a decision,
+and so, that further checks are needed. The value `t' means that the
+message is definitely not spam, and that further spam checks should be
+inhibited. Otherwise, a mailgroup name is returned where the mail
+should go, and further checks are also inhibited. The usual mailgroup
+name is the value of `spam-split-group', meaning that the message is
+definitely a spam.")
(defun spam-split ()
"Split this message into the `spam' group if it is spam.
(setq spam-whitelist-cache (spam-parse-list spam-whitelist)))
(if (spam-from-listed-p spam-whitelist-cache) nil spam-split-group))
-;;; copied from code by Alexander Kotelnikov <sacha@giotto.sj.ru>
-(defun spam-check-bbdb ()
- "We want messages from people who are in the BBDB not to be split to spam"
- (let ((who (message-fetch-field "from")))
- (when who
- (setq who (regexp-quote (cadr (gnus-extract-address-components who))))
- (if (bbdb-search (bbdb-records) nil nil who) nil spam-split-group))))
-
-;; let spam-check-bbdb be nil if the BBDB can't be loaded
+;;; original idea from Alexander Kotelnikov <sacha@giotto.sj.ru>
+(condition-case nil
+ (progn
+ (require 'bbdb-com)
+ (defun spam-check-bbdb ()
+ "We want messages from people who are in the BBDB not to be split to spam"
+ (let ((who (message-fetch-field "from")))
+ (when who
+ (setq who (regexp-quote (cadr (gnus-extract-address-components who))))
+ (if (bbdb-search (bbdb-records) nil nil who) nil spam-split-group)))))
+ (file-error (setq spam-list-of-checks
+ (delete (assoc 'spam-use-bbdb spam-list-of-checks)
+ spam-list-of-checks))))
+
+;;; check the ifile backend; return nil if the mail was NOT classified as spam
(condition-case nil
- (require 'bbdb)
- (file-error (defalias 'spam-check-bbdb 'ignore)))
+ (progn
+ (require 'ifile-gnus)
+ ;;;
+ (defun spam-check-ifile ()
+ (let ((ifile-primary-spam-group spam-split-group))
+ (ifile-spam-filter nil))))
+ (file-error (setq spam-list-of-checks
+ (delete (assoc 'spam-use-ifile spam-list-of-checks)
+ spam-list-of-checks))))
(defun spam-check-blacklist ()
;; FIXME! Should it detect when file timestamps change?