added spam.el and spam-stat.el fixes
authorTeodor Zlatanov <tzz@lifelogs.com>
Sat, 12 Oct 2002 01:21:22 +0000 (01:21 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Sat, 12 Oct 2002 01:21:22 +0000 (01:21 +0000)
lisp/ChangeLog
lisp/spam-stat.el
lisp/spam.el

index 8b630b9..3d3fb30 100644 (file)
@@ -1,3 +1,12 @@
+2002-10-11  Ted Zlatanov <tzz@lifelogs.com>
+
+       * spam.el: more compilation fixes for BBDB
+
+        * spam-stat.el added code from Alex Schroeder <alex@gnu.org>
+        (spam-stat-reduce-size): Interactive.
+        (spam-stat-reset): New function.
+        (spam-stat-save): Interactive.
+
 2002-10-11  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus.el: Autoload gnus-delay-initialize.
index 70d20bc..38fd9b7 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; 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
 
@@ -353,6 +353,7 @@ Use `spam-stat-ngood', `spam-stat-nbad', `spam-stat-good',
 
 (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 '(")
@@ -387,6 +388,12 @@ has appeared in bad mails."
          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
@@ -506,6 +513,7 @@ This removes all words that occur less than COUNT from the dictionary.
 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)
index 8138b7f..f638148 100644 (file)
@@ -45,8 +45,7 @@
 (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")
@@ -66,6 +65,9 @@
 (defvar spam-use-bogofilter t
   "True if bogofilter should be used.")
 
+(defvar spam-use-bbdb t
+  "True if BBDB should be used.")
+
 (defvar spam-split-group "spam"
   "Usual group name where spam should be split.")
 
@@ -154,23 +156,24 @@ Such articles will be transmitted to `bogofilter -s' on group exit.")
 \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-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.
@@ -272,18 +275,19 @@ The regular expression is matched against the address.")
     (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
 (condition-case nil
-    (require 'bbdb)
-  (file-error (defalias 'spam-check-bbdb 'ignore)))
+    (progn
+      (require 'bbdb-com)
+        ;;; 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)))))
+  (file-error (setq spam-list-of-checks
+                   (delete (assoc 'spam-use-bbdb spam-list-of-checks)
+                           spam-list-of-checks))))
 
 (defun spam-check-blacklist ()
   ;; FIXME!  Should it detect when file timestamps change?