X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fspam.el;h=e95baf570b9cd5ef52c22d4c13d3fe4fc366d465;hb=931e64049c6d898e55d204449f536e170937a03c;hp=338183f4bc4e655444db76a923fc5e46d739d1a2;hpb=78d559cdec75ba74a49dd053dc65888e983b5a1e;p=gnus diff --git a/lisp/spam.el b/lisp/spam.el index 338183f4b..e95baf570 100644 --- a/lisp/spam.el +++ b/lisp/spam.el @@ -40,6 +40,9 @@ (require 'gnus) ; for the definitions of group content classification and spam processors (require 'message) ;for the message-fetch-field functions +;; for nnimap-split-download-body-default +(eval-when-compile (require 'nnimap)) + ;; autoload executable-find (eval-and-compile ;; executable-find is not autoloaded in Emacs 20 @@ -69,7 +72,15 @@ When nil, only ham and unclassified groups will have their spam moved to the spam-process-destination. When t, spam will also be moved from spam groups." :type 'boolean - :group 'spam-ifile) + :group 'spam) + +(defcustom spam-mark-ham-unread-before-move-from-spam-group nil + "Whether ham should be marked unread before it's moved out of a spam +group according to ham-process-destination. This variable is an +official entry in the international Longest Variable Name +Competition." + :type 'boolean + :group 'spam) (defcustom spam-whitelist (expand-file-name "whitelist" spam-directory) "The location of the whitelist. @@ -112,6 +123,11 @@ are considered spam." :type 'boolean :group 'spam) +(defcustom spam-use-hashcash nil + "Whether hashcash payments should be detected by spam-split." + :type 'boolean + :group 'spam) + (defcustom spam-use-regex-headers nil "Whether a header regular expression match should be used by spam-split. Also see the variable `spam-spam-regex-headers' and `spam-ham-regex-headers'." @@ -262,6 +278,16 @@ your main source of newsgroup names." :type 'string :group 'spam-bogofilter) +(defcustom spam-bogofilter-spam-switch "-s" + "The switch that Bogofilter uses to register spam messages." + :type 'string + :group 'spam-bogofilter) + +(defcustom spam-bogofilter-ham-switch "-n" + "The switch that Bogofilter uses to register ham messages." + :type 'string + :group 'spam-bogofilter) + (defcustom spam-bogofilter-bogosity-positive-spam-header "^\\(Yes\\|Spam\\)" "The regex on `spam-bogofilter-header' for positive spam identification." :type 'regexp @@ -455,6 +481,8 @@ your main source of newsgroup names." ;; now do the actual move (when tomove (dolist (article tomove) + (when spam-mark-ham-unread-before-move-from-spam-group + (gnus-summary-mark-article article gnus-unread-mark)) (gnus-summary-set-process-mark article)) (if copy (gnus-summary-copy-article nil group) @@ -548,6 +576,7 @@ your main source of newsgroup names." (spam-use-ifile . spam-check-ifile) (spam-use-stat . spam-check-stat) (spam-use-blackholes . spam-check-blackholes) + (spam-use-hashcash . spam-check-hashcash) (spam-use-bogofilter-headers . spam-check-bogofilter-headers) (spam-use-bogofilter . spam-check-bogofilter)) "The spam-list-of-checks list contains pairs associating a parameter @@ -596,8 +625,7 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." (defun spam-setup-widening () (dolist (check spam-list-of-statistical-checks) (when (symbol-value check) - (setq nnimap-split-download-body t) - (return)))) + (setq nnimap-split-download-body-default t)))) (add-hook 'gnus-get-new-news-hook 'spam-setup-widening) @@ -648,7 +676,8 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." (if spam-use-dig (let ((query-result (query-dig query-string))) (when query-result - (gnus-message 5 "(DIG): positive blackhole check '%s'" query-result) + (gnus-message 5 "(DIG): positive blackhole check '%s'" + query-result) (push (list ip server query-result) matches))) ;; else, if not using dig.el @@ -659,6 +688,20 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." (when matches spam-split-group))) +;;;; Hashcash. + +(condition-case nil + (progn + (require 'hashcash) + + (defun spam-check-hashcash () + "Check the headers for hashcash payments." + (mail-check-payment))) ;mail-check-payment returns a boolean + + (file-error (progn + (defalias 'mail-check-payment 'ignore) + (defalias 'spam-check-hashcash 'ignore)))) + ;;;; BBDB ;;; original idea for spam-check-BBDB from Alexander Kotelnikov @@ -810,10 +853,16 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)." (insert article-string) (spam-stat-buffer-is-non-spam)))))) + (defun spam-maybe-spam-stat-load () + (when spam-use-stat (spam-stat-load))) + + (defun spam-maybe-spam-stat-save () + (when spam-use-stat (spam-stat-save))) + ;; Add hooks for loading and saving the spam stats - (when spam-use-stat - (add-hook 'gnus-save-newsrc-hook 'spam-stat-save) - (add-hook 'gnus-get-new-news-hook 'spam-stat-load))) + (add-hook 'gnus-save-newsrc-hook 'spam-maybe-spam-stat-save) + (add-hook 'gnus-get-top-new-news-hook 'spam-maybe-spam-stat-load) + (add-hook 'gnus-startup-hook 'spam-maybe-spam-stat-load)) (file-error (progn (defalias 'spam-stat-register-ham-routine 'ignore) @@ -963,7 +1012,8 @@ Uses `gnus-newsgroup-name' if category is nil (for ham registration)." (defun spam-bogofilter-register-with-bogofilter (article-string spam) "Register an article, given as a string, as spam or non-spam." (when (stringp article-string) - (let ((switch (if spam "-s" "-n"))) + (let ((switch (if spam spam-bogofilter-spam-switch + spam-bogofilter-ham-switch))) (with-temp-buffer (insert article-string) (if spam-bogofilter-database-directory