From: yamaoka Date: Fri, 10 Jan 2003 05:53:43 +0000 (+0000) Subject: Synch with Oort Gnus. X-Git-Tag: t-gnus-6_15_12-00-quimby~9 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=02003a03dfb3854011ec85a20113ce524784160e;p=elisp%2Fgnus.git- Synch with Oort Gnus. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ced3649..d6e4560 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,24 @@ +2003-01-10 Teodor Zlatanov + + * spam.el (spam-use-stat): new variable + (spam-group-spam-processor-stat-p) + (spam-group-ham-processor-stat-p): new convenience functions + (spam-summary-prepare-exit): add spam/ham processors to sequence + (spam-list-of-checks): add spam-use-stat to list of checks + (spam-split): conditionally load the spam-stat tables + (spam-stat-register-spam-routine, spam-stat-register-ham-routine, + spam-check-ifile): new functions + + * spam-stat.el (spam-stat): typo fix + (spam-stat-install-hooks): new variable + (spam-stat-split-fancy-spam-group): added documentation clarification + (spam-stat-split-fancy-spam-threshhold): new variable + (spam-stat-install-hooks): make hooks conditional + (spam-stat-split-fancy): use spam-stat-split-fancy-spam-threshhold + + * gnus.el (gnus-group-ham-exit-processor-stat, spam-process): add + spam-stat ham/spam processor symbols + 2003-01-10 Lars Magne Ingebrigtsen * gnus-start.el (gnus-read-newsrc-el-file): Make sure the .eld diff --git a/lisp/gnus.el b/lisp/gnus.el index 323eb2f..cf7bdbd 100644 --- a/lisp/gnus.el +++ b/lisp/gnus.el @@ -1829,6 +1829,10 @@ When a spam group is entered, all unread articles are marked as spam.") "The ifile summary exit spam processor. Only applicable to spam groups.") +(defvar gnus-group-spam-exit-processor-stat "stat" + "The spam-stat summary exit spam processor. +Only applicable to spam groups.") + (defvar gnus-group-spam-exit-processor-bogofilter "bogofilter" "The Bogofilter summary exit spam processor. Only applicable to spam groups.") @@ -1841,6 +1845,10 @@ Only applicable to spam groups.") "The ifile summary exit ham processor. Only applicable to non-spam (unclassified and ham) groups.") +(defvar gnus-group-ham-exit-processor-stat "stat-ham" + "The spam-stat summary exit ham processor. +Only applicable to non-spam (unclassified and ham) groups.") + (defvar gnus-group-ham-exit-processor-whitelist "whitelist" "The whitelist summary exit ham processor. Only applicable to non-spam (unclassified and ham) groups.") @@ -1857,9 +1865,11 @@ Only applicable to non-spam (unclassified and ham) groups.") (list :tag "Spam Summary Exit Processor Choices" (set (variable-item gnus-group-spam-exit-processor-ifile) + (variable-item gnus-group-spam-exit-processor-stat) (variable-item gnus-group-spam-exit-processor-bogofilter) (variable-item gnus-group-spam-exit-processor-blacklist) (variable-item gnus-group-ham-exit-processor-ifile) + (variable-item gnus-group-ham-exit-processor-stat) (variable-item gnus-group-ham-exit-processor-whitelist) (variable-item gnus-group-ham-exit-processor-BBDB)))) :function-document @@ -1878,9 +1888,11 @@ for mail groups." (regexp :tag "Group Regexp") (set :tag "Spam/Ham Summary Exit Processor" (variable-item gnus-group-spam-exit-processor-ifile) + (variable-item gnus-group-spam-exit-processor-stat) (variable-item gnus-group-spam-exit-processor-bogofilter) (variable-item gnus-group-spam-exit-processor-blacklist) (variable-item gnus-group-ham-exit-processor-ifile) + (variable-item gnus-group-ham-exit-processor-stat) (variable-item gnus-group-ham-exit-processor-whitelist) (variable-item gnus-group-ham-exit-processor-BBDB)))) :parameter-document diff --git a/lisp/spam-stat.el b/lisp/spam-stat.el index 7a01ec3..fc134f9 100644 --- a/lisp/spam-stat.el +++ b/lisp/spam-stat.el @@ -127,7 +127,7 @@ "Statistical spam detection for Emacs. Use the functions to build a dictionary of words and their statistical distribution in spam and non-spam mails. Then use a function to determine -wether a buffer contains spam or not." +whether a buffer contains spam or not." :group 'gnus) (defcustom spam-stat-file "~/.spam-stat.el" @@ -136,6 +136,12 @@ See `spam-stat-to-hash-table' for the format of the file." :type 'file :group 'spam-stat) +(defcustom spam-stat-install-hooks t + "Whether spam-stat should install its hooks in Gnus. +This is set to nil if you use spam-stat through spam.el." + :type 'boolean + :group 'spam-stat) + (defcustom spam-stat-unknown-word-score 0.2 "The score to use for unknown words. Also used for words that don't appear often enough." @@ -155,10 +161,16 @@ This variable says how many characters this will be." (defcustom spam-stat-split-fancy-spam-group "mail.spam" "Name of the group where spam should be stored, if -`spam-stat-split-fancy' is used in fancy splitting rules." +`spam-stat-split-fancy' is used in fancy splitting rules. Has no +effect when spam-stat is invoked through spam.el." :type 'string :group 'spam-stat) +(defcustom spam-stat-split-fancy-spam-threshhold 0.9 + "Spam score threshhold in spam-stat-split-fancy." + :type 'number + :group 'spam-stat) + (defvar spam-stat-syntax-table (let ((table (copy-syntax-table text-mode-syntax-table))) (modify-syntax-entry ?- "w" table) @@ -226,10 +238,11 @@ This uses `gnus-article-buffer'." (set-buffer gnus-original-article-buffer) (spam-stat-store-current-buffer))) -(add-hook 'nnmail-prepare-incoming-message-hook - 'spam-stat-store-current-buffer) -(add-hook 'gnus-select-article-hook - 'spam-stat-store-gnus-article-buffer) +(when spam-stat-install-hooks + (add-hook 'nnmail-prepare-incoming-message-hook + 'spam-stat-store-current-buffer) + (add-hook 'gnus-select-article-hook + 'spam-stat-store-gnus-article-buffer)) ;; Data -- not using defstruct in order to save space and time @@ -471,7 +484,7 @@ check the variable `spam-stat-score-data'." (progn (set-buffer spam-stat-buffer) (goto-char (point-min)) - (when (> (spam-stat-score-buffer) 0.9) + (when (> (spam-stat-score-buffer) spam-stat-split-fancy-spam-threshhold) (when (boundp 'nnmail-split-trace) (mapc (lambda (entry) (push entry nnmail-split-trace)) diff --git a/lisp/spam.el b/lisp/spam.el index e11115a..cb171df 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -120,6 +120,11 @@ The regular expression is matched against the address." :type 'boolean :group 'spam) +(defcustom spam-use-stat nil + "Whether spam-stat should be used by spam-split." + :type 'boolean + :group 'spam) + (defcustom spam-split-group "spam" "Group name where incoming spam should be put by spam-split." :type 'string @@ -279,6 +284,12 @@ articles before they get registered by Bogofilter." (defun spam-group-ham-processor-ifile-p (group) (spam-group-processor-p group 'gnus-group-ham-exit-processor-ifile)) +(defun spam-group-spam-processor-stat-p (group) + (spam-group-processor-p group 'gnus-group-spam-exit-processor-stat)) + +(defun spam-group-ham-processor-stat-p (group) + (spam-group-processor-p group 'gnus-group-ham-exit-processor-stat)) + (defun spam-group-ham-processor-whitelist-p (group) (spam-group-processor-p group 'gnus-group-ham-exit-processor-whitelist)) @@ -302,6 +313,9 @@ articles before they get registered by Bogofilter." (spam-group-spam-processor-ifile-p gnus-newsgroup-name)) (spam-ifile-register-spam-routine)) + (when (spam-group-spam-processor-stat-p gnus-newsgroup-name) + (spam-stat-register-spam-routine)) + (when (spam-group-spam-processor-bogofilter-p gnus-newsgroup-name) (spam-blacklist-register-routine)) @@ -321,6 +335,8 @@ articles before they get registered by Bogofilter." (spam-whitelist-register-routine)) (when (spam-group-ham-processor-ifile-p gnus-newsgroup-name) (spam-ifile-register-ham-routine)) + (when (spam-group-ham-processor-stat-p gnus-newsgroup-name) + (spam-stat-register-ham-routine)) (when (spam-group-ham-processor-BBDB-p gnus-newsgroup-name) (spam-BBDB-register-routine))) @@ -432,6 +448,7 @@ articles before they get registered by Bogofilter." (spam-use-whitelist . spam-check-whitelist) (spam-use-BBDB . spam-check-BBDB) (spam-use-ifile . spam-check-ifile) + (spam-use-stat . spam-check-stat) (spam-use-blackholes . spam-check-blackholes) (spam-use-bogofilter . spam-check-bogofilter)) "The spam-list-of-checks list contains pairs associating a parameter @@ -453,6 +470,9 @@ example like this: (: spam-split) See the Info node `(gnus)Fancy Mail Splitting' for more details." (interactive) + + ;; load the spam-stat tables if needed + (when spam-use-stat (spam-stat-load)) (let ((list-of-checks spam-list-of-checks) decision) @@ -580,7 +600,6 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." (setq return category) ;; else, if spam-ifile-all-categories is not set... (when (string-equal spam-ifile-spam-category category) - ;; always accept the ifile category (setq return spam-split-group)))))) return)) @@ -615,6 +634,52 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)." (spam-get-article-as-string article) nil)))) +;;;; spam-stat + +(condition-case nil + (progn + (let ((spam-stat-install-hooks nil)) + (require 'spam-stat)) + + (defun spam-check-stat () + "Check the spam-stat backend for the classification of this message" + (let ((spam-stat-split-fancy-spam-group spam-split-group) ; override + (spam-stat-buffer (buffer-name)) ; stat the current buffer + category return) + (spam-stat-split-fancy))) + + (defun spam-stat-register-spam-routine () + (spam-generic-register-routine + (lambda (article) + (let ((article-string (spam-get-article-as-string article))) + (with-temp-buffer + (insert-string article-string) + (spam-stat-buffer-is-spam)))) + nil) + (spam-stat-save)) + + (defun spam-stat-register-ham-routine () + (spam-generic-register-routine + nil + (lambda (article) + (let ((article-string (spam-get-article-as-string article))) + (with-temp-buffer + (insert-string article-string) + (spam-stat-buffer-is-non-spam))))) + (spam-stat-save))) + + (file-error (progn + (defalias 'spam-stat-register-ham-routine 'ignore) + (defalias 'spam-stat-register-spam-routine 'ignore) + (defalias 'spam-stat-buffer-is-spam 'ignore) + (defalias 'spam-stat-buffer-is-non-spam 'ignore) + (defalias 'spam-stat-split-fancy 'ignore) + (defalias 'spam-stat-load 'ignore) + (defalias 'spam-stat-save 'ignore) + (defalias 'spam-check-stat 'ignore)))) + + + ;;;; Blacklists and whitelists. (defvar spam-whitelist-cache nil)