X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/e31331e5cb40d3e56e4160229b33f2dad9d5e4ab..6b4093c022450f5fd3bac9010b48602461b6956a:/lisp/mh-e/mh-junk.el diff --git a/lisp/mh-e/mh-junk.el b/lisp/mh-e/mh-junk.el index 9d02db0dc1..e3ca8ad24e 100644 --- a/lisp/mh-e/mh-junk.el +++ b/lisp/mh-e/mh-junk.el @@ -1,6 +1,6 @@ ;;; mh-junk.el --- MH-E interface to anti-spam measures -;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. ;; Author: Satyaki Das , ;; Bill Wohler @@ -9,10 +9,10 @@ ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs 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. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,9 +20,7 @@ ;; 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., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -115,6 +113,7 @@ http://spamassassin.org/. To use SpamAssassin, add the following recipes to \".procmailrc\": + PATH=$PATH:/usr/bin/mh MAILDIR=$HOME/`mhparam Path` # Fight spam with SpamAssassin. @@ -192,30 +191,33 @@ done by adding the following to your crontab: (let ((current-folder mh-current-folder) (msg-file (mh-msg-filename msg mh-current-folder)) (sender)) - (save-excursion - (message "Reporting message %d..." msg) - (mh-truncate-log-buffer) - (call-process mh-spamassassin-executable msg-file mh-log-buffer nil + (message "Reporting message %d..." msg) + (mh-truncate-log-buffer) + ;; Put call-process output in log buffer if we are saving it + ;; (this happens if mh-junk-background is t). + (with-current-buffer mh-log-buffer + (call-process mh-spamassassin-executable msg-file mh-junk-background nil ;;"--report" "--remove-from-whitelist" "-r" "-R") ; spamassassin V2.20 - (when mh-sa-learn-executable - (message "Recategorizing this message as spam...") - (call-process mh-sa-learn-executable msg-file mh-log-buffer nil - "--single" "--spam" "--local" "--no-rebuild")) - (message "Blacklisting message %d..." msg) - (set-buffer (get-buffer-create mh-temp-buffer)) + (when mh-sa-learn-executable + (message "Recategorizing message %d as spam..." msg) + (mh-truncate-log-buffer) + (call-process mh-sa-learn-executable msg-file mh-junk-background nil + "--single" "--spam" "--local" "--no-rebuild"))) + (message "Blacklisting sender of message %d..." msg) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (call-process (expand-file-name mh-scan-prog mh-progs) - nil mh-junk-background nil - (format "%s" msg) current-folder + nil t nil + (format "%d" msg) current-folder "-format" "%<(mymbox{from})%|%(addr{from})%>") (goto-char (point-min)) (if (search-forward-regexp "^\\(.+\\)$" nil t) (progn (setq sender (match-string 0)) (mh-spamassassin-add-rule "blacklist_from" sender) - (message "Blacklisting message %d...done" msg)) - (message "Blacklisting message %d...not done (from my address)" msg))))) + (message "Blacklisting sender of message %d...done" msg)) + (message "Blacklisting sender of message %d...not done (from my address)" msg))))) ;;;###mh-autoload (defun mh-spamassassin-whitelist (msg) @@ -231,28 +233,31 @@ See `mh-spamassassin-blacklist' for more information." (let ((msg-file (mh-msg-filename msg mh-current-folder)) (show-buffer (get-buffer mh-show-buffer)) from) - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) - (message "Removing spamassassin markup from message...") - (call-process mh-spamassassin-executable msg-file mh-temp-buffer nil + (message "Removing spamassassin markup from message %d..." msg) + (call-process mh-spamassassin-executable msg-file t nil ;; "--remove-markup" "-d") ; spamassassin V2.20 (if show-buffer (kill-buffer show-buffer)) (write-file msg-file) (when mh-sa-learn-executable - (message "Recategorizing this message as ham...") - (call-process mh-sa-learn-executable msg-file mh-temp-buffer nil - "--single" "--ham" "--local --no-rebuild")) - (message "Whitelisting message %d..." msg) + (message "Recategorizing message %d as ham..." msg) + (mh-truncate-log-buffer) + ;; Put call-process output in log buffer if we are saving it + ;; (this happens if mh-junk-background is t). + (with-current-buffer mh-log-buffer + (call-process mh-sa-learn-executable msg-file mh-junk-background nil + "--single" "--ham" "--local" "--no-rebuild"))) + (message "Whitelisting sender of message %d..." msg) (setq from (car (mh-funcall-if-exists ietf-drums-parse-address (mh-get-header-field "From:")))) (kill-buffer nil) (unless (or (null from) (equal from "")) (mh-spamassassin-add-rule "whitelist_from" from)) - (message "Whitelisting message %d...done" msg)))) + (message "Whitelisting sender of message %d...done" msg)))) (defun mh-spamassassin-add-rule (rule body) "Add a new rule to \"~/.spamassassin/user_prefs\". @@ -343,6 +348,7 @@ type of message to start doing a good job. To use bogofilter, add the following recipes to \".procmailrc\": + PATH=$PATH:/usr/bin/mh MAILDIR=$HOME/`mhparam Path` # Fight spam with bogofilter. @@ -372,8 +378,12 @@ The \"Bogofilter tuning HOWTO\" describes how you can fine-tune Bogofilter." (unless mh-bogofilter-executable (error "Unable to find the bogofilter executable")) (let ((msg-file (mh-msg-filename msg mh-current-folder))) - (call-process mh-bogofilter-executable msg-file mh-junk-background - nil "-s"))) + (mh-truncate-log-buffer) + ;; Put call-process output in log buffer if we are saving it + ;; (this happens if mh-junk-background is t). + (with-current-buffer mh-log-buffer + (call-process mh-bogofilter-executable msg-file mh-junk-background + nil "-s")))) ;;;###mh-autoload (defun mh-bogofilter-whitelist (msg) @@ -383,8 +393,12 @@ See `mh-bogofilter-blacklist' for more information." (unless mh-bogofilter-executable (error "Unable to find the bogofilter executable")) (let ((msg-file (mh-msg-filename msg mh-current-folder))) - (call-process mh-bogofilter-executable msg-file mh-junk-background - nil "-n"))) + (mh-truncate-log-buffer) + ;; Put call-process output in log buffer if we are saving it + ;; (this happens if mh-junk-background is t). + (with-current-buffer mh-log-buffer + (call-process mh-bogofilter-executable msg-file mh-junk-background + nil "-n")))) @@ -401,6 +415,7 @@ distribution or from http://spamprobe.sourceforge.net. To use SpamProbe, add the following recipes to \".procmailrc\": + PATH=$PATH:/usr/bin/mh MAILDIR=$HOME/`mhparam Path` # Fight spam with SpamProbe. @@ -420,8 +435,12 @@ update SpamProbe's training." (unless mh-spamprobe-executable (error "Unable to find the spamprobe executable")) (let ((msg-file (mh-msg-filename msg mh-current-folder))) - (call-process mh-spamprobe-executable msg-file mh-junk-background - nil "spam"))) + (mh-truncate-log-buffer) + ;; Put call-process output in log buffer if we are saving it + ;; (this happens if mh-junk-background is t). + (with-current-buffer mh-log-buffer + (call-process mh-spamprobe-executable msg-file mh-junk-background + nil "spam")))) ;;;###mh-autoload (defun mh-spamprobe-whitelist (msg) @@ -431,8 +450,12 @@ See `mh-spamprobe-blacklist' for more information." (unless mh-spamprobe-executable (error "Unable to find the spamprobe executable")) (let ((msg-file (mh-msg-filename msg mh-current-folder))) - (call-process mh-spamprobe-executable msg-file mh-junk-background - nil "good"))) + (mh-truncate-log-buffer) + ;; Put call-process output in log buffer if we are saving it + ;; (this happens if mh-junk-background is t). + (with-current-buffer mh-log-buffer + (call-process mh-spamprobe-executable msg-file mh-junk-background + nil "good")))) (provide 'mh-junk)