diff options
| author | Stephen Gildea | 2006-11-11 20:20:28 +0000 |
|---|---|---|
| committer | Stephen Gildea | 2006-11-11 20:20:28 +0000 |
| commit | a4de8c3dfc0a6942cf72b2e515b1ca580d84fce2 (patch) | |
| tree | b37385982bdcd6c0f03c76ec9af519032e8f637d /lisp/mh-e | |
| parent | dc786b8afdba9af780c2194b7a550a9be42862b0 (diff) | |
| download | emacs-a4de8c3dfc0a6942cf72b2e515b1ca580d84fce2.tar.gz emacs-a4de8c3dfc0a6942cf72b2e515b1ca580d84fce2.zip | |
mh-junk.el (mh-spamassassin-blacklist, mh-spamassassin-whitelist):
use mh-junk-background consistently in call-process calls.
(mh-bogofilter-blacklist, mh-bogofilter-whitelist,
mh-spamprobe-blacklist, mh-spamprobe-whitelist): use
with-current-buffer so the right thing happens if
mh-junk-background is t. (closes SF #1594802).
mh-e.el (mh-junk-background): document that On value is 0;
t may be used for debugging.
Diffstat (limited to 'lisp/mh-e')
| -rw-r--r-- | lisp/mh-e/ChangeLog | 13 | ||||
| -rw-r--r-- | lisp/mh-e/mh-e.el | 4 | ||||
| -rw-r--r-- | lisp/mh-e/mh-junk.el | 84 |
3 files changed, 69 insertions, 32 deletions
diff --git a/lisp/mh-e/ChangeLog b/lisp/mh-e/ChangeLog index bbf770c04cb..8c36e3dcbf1 100644 --- a/lisp/mh-e/ChangeLog +++ b/lisp/mh-e/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2006-11-11 Stephen Gildea <gildea@stop.mail-abuse.org> | ||
| 2 | |||
| 3 | * mh-junk.el (mh-spamassassin-blacklist, mh-spamassassin-whitelist): | ||
| 4 | use mh-junk-background consistently in call-process calls. | ||
| 5 | |||
| 6 | * (mh-bogofilter-blacklist, mh-bogofilter-whitelist, | ||
| 7 | mh-spamprobe-blacklist, mh-spamprobe-whitelist): use | ||
| 8 | with-current-buffer so the right thing happens if | ||
| 9 | mh-junk-background is t. (closes SF #1594802). | ||
| 10 | |||
| 11 | * mh-e.el (mh-junk-background): document that On value is 0; | ||
| 12 | t may be used for debugging. | ||
| 13 | |||
| 1 | 2006-11-10 Andreas Schwab <schwab@suse.de> | 14 | 2006-11-10 Andreas Schwab <schwab@suse.de> |
| 2 | 15 | ||
| 3 | * mh-e.el (mh-draft-folder): Avoid starting sentence with "nil". | 16 | * mh-e.el (mh-draft-folder): Avoid starting sentence with "nil". |
diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el index 74f62c5c20e..e8078e2154f 100644 --- a/lisp/mh-e/mh-e.el +++ b/lisp/mh-e/mh-e.el | |||
| @@ -1690,7 +1690,9 @@ The function is always called with SYMBOL bound to | |||
| 1690 | By default, the programs are run in the foreground, but this can | 1690 | By default, the programs are run in the foreground, but this can |
| 1691 | be slow when junking large numbers of messages. If you have | 1691 | be slow when junking large numbers of messages. If you have |
| 1692 | enough memory or don't junk that many messages at the same time, | 1692 | enough memory or don't junk that many messages at the same time, |
| 1693 | you might try turning on this option." | 1693 | you might try turning on this option (that is, setting its value to 0). |
| 1694 | If the value is t, the programs' output is saved in the MH-E log buffer; | ||
| 1695 | this may be useful for debugging." | ||
| 1694 | :type '(choice (const :tag "Off" nil) | 1696 | :type '(choice (const :tag "Off" nil) |
| 1695 | (const :tag "On" 0)) | 1697 | (const :tag "On" 0)) |
| 1696 | :group 'mh-junk | 1698 | :group 'mh-junk |
diff --git a/lisp/mh-e/mh-junk.el b/lisp/mh-e/mh-junk.el index 67f267d672f..68ab072d7e3 100644 --- a/lisp/mh-e/mh-junk.el +++ b/lisp/mh-e/mh-junk.el | |||
| @@ -195,30 +195,33 @@ done by adding the following to your crontab: | |||
| 195 | (let ((current-folder mh-current-folder) | 195 | (let ((current-folder mh-current-folder) |
| 196 | (msg-file (mh-msg-filename msg mh-current-folder)) | 196 | (msg-file (mh-msg-filename msg mh-current-folder)) |
| 197 | (sender)) | 197 | (sender)) |
| 198 | (save-excursion | 198 | (message "Reporting message %d..." msg) |
| 199 | (message "Reporting message %d..." msg) | 199 | (mh-truncate-log-buffer) |
| 200 | (mh-truncate-log-buffer) | 200 | ;; Put call-process output in log buffer if we are saving it |
| 201 | (call-process mh-spamassassin-executable msg-file mh-log-buffer nil | 201 | ;; (this happens if mh-junk-background is t). |
| 202 | (with-current-buffer mh-log-buffer | ||
| 203 | (call-process mh-spamassassin-executable msg-file mh-junk-background nil | ||
| 202 | ;;"--report" "--remove-from-whitelist" | 204 | ;;"--report" "--remove-from-whitelist" |
| 203 | "-r" "-R") ; spamassassin V2.20 | 205 | "-r" "-R") ; spamassassin V2.20 |
| 204 | (when mh-sa-learn-executable | 206 | (when mh-sa-learn-executable |
| 205 | (message "Recategorizing this message as spam...") | 207 | (message "Recategorizing message %d as spam..." msg) |
| 206 | (call-process mh-sa-learn-executable msg-file mh-log-buffer nil | 208 | (mh-truncate-log-buffer) |
| 207 | "--single" "--spam" "--local" "--no-rebuild")) | 209 | (call-process mh-sa-learn-executable msg-file mh-junk-background nil |
| 208 | (message "Blacklisting message %d..." msg) | 210 | "--single" "--spam" "--local" "--no-rebuild"))) |
| 209 | (set-buffer (get-buffer-create mh-temp-buffer)) | 211 | (message "Blacklisting sender of message %d..." msg) |
| 212 | (with-current-buffer (get-buffer-create mh-temp-buffer) | ||
| 210 | (erase-buffer) | 213 | (erase-buffer) |
| 211 | (call-process (expand-file-name mh-scan-prog mh-progs) | 214 | (call-process (expand-file-name mh-scan-prog mh-progs) |
| 212 | nil mh-junk-background nil | 215 | nil t nil |
| 213 | (format "%s" msg) current-folder | 216 | (format "%d" msg) current-folder |
| 214 | "-format" "%<(mymbox{from})%|%(addr{from})%>") | 217 | "-format" "%<(mymbox{from})%|%(addr{from})%>") |
| 215 | (goto-char (point-min)) | 218 | (goto-char (point-min)) |
| 216 | (if (search-forward-regexp "^\\(.+\\)$" nil t) | 219 | (if (search-forward-regexp "^\\(.+\\)$" nil t) |
| 217 | (progn | 220 | (progn |
| 218 | (setq sender (match-string 0)) | 221 | (setq sender (match-string 0)) |
| 219 | (mh-spamassassin-add-rule "blacklist_from" sender) | 222 | (mh-spamassassin-add-rule "blacklist_from" sender) |
| 220 | (message "Blacklisting message %d...done" msg)) | 223 | (message "Blacklisting sender of message %d...done" msg)) |
| 221 | (message "Blacklisting message %d...not done (from my address)" msg))))) | 224 | (message "Blacklisting sender of message %d...not done (from my address)" msg))))) |
| 222 | 225 | ||
| 223 | ;;;###mh-autoload | 226 | ;;;###mh-autoload |
| 224 | (defun mh-spamassassin-whitelist (msg) | 227 | (defun mh-spamassassin-whitelist (msg) |
| @@ -234,28 +237,31 @@ See `mh-spamassassin-blacklist' for more information." | |||
| 234 | (let ((msg-file (mh-msg-filename msg mh-current-folder)) | 237 | (let ((msg-file (mh-msg-filename msg mh-current-folder)) |
| 235 | (show-buffer (get-buffer mh-show-buffer)) | 238 | (show-buffer (get-buffer mh-show-buffer)) |
| 236 | from) | 239 | from) |
| 237 | (save-excursion | 240 | (with-current-buffer (get-buffer-create mh-temp-buffer) |
| 238 | (set-buffer (get-buffer-create mh-temp-buffer)) | ||
| 239 | (erase-buffer) | 241 | (erase-buffer) |
| 240 | (message "Removing spamassassin markup from message...") | 242 | (message "Removing spamassassin markup from message %d..." msg) |
| 241 | (call-process mh-spamassassin-executable msg-file mh-temp-buffer nil | 243 | (call-process mh-spamassassin-executable msg-file t nil |
| 242 | ;; "--remove-markup" | 244 | ;; "--remove-markup" |
| 243 | "-d") ; spamassassin V2.20 | 245 | "-d") ; spamassassin V2.20 |
| 244 | (if show-buffer | 246 | (if show-buffer |
| 245 | (kill-buffer show-buffer)) | 247 | (kill-buffer show-buffer)) |
| 246 | (write-file msg-file) | 248 | (write-file msg-file) |
| 247 | (when mh-sa-learn-executable | 249 | (when mh-sa-learn-executable |
| 248 | (message "Recategorizing this message as ham...") | 250 | (message "Recategorizing message %d as ham..." msg) |
| 249 | (call-process mh-sa-learn-executable msg-file mh-temp-buffer nil | 251 | (mh-truncate-log-buffer) |
| 250 | "--single" "--ham" "--local" "--no-rebuild")) | 252 | ;; Put call-process output in log buffer if we are saving it |
| 251 | (message "Whitelisting message %d..." msg) | 253 | ;; (this happens if mh-junk-background is t). |
| 254 | (with-current-buffer mh-log-buffer | ||
| 255 | (call-process mh-sa-learn-executable msg-file mh-junk-background nil | ||
| 256 | "--single" "--ham" "--local" "--no-rebuild"))) | ||
| 257 | (message "Whitelisting sender of message %d..." msg) | ||
| 252 | (setq from | 258 | (setq from |
| 253 | (car (mh-funcall-if-exists | 259 | (car (mh-funcall-if-exists |
| 254 | ietf-drums-parse-address (mh-get-header-field "From:")))) | 260 | ietf-drums-parse-address (mh-get-header-field "From:")))) |
| 255 | (kill-buffer nil) | 261 | (kill-buffer nil) |
| 256 | (unless (or (null from) (equal from "")) | 262 | (unless (or (null from) (equal from "")) |
| 257 | (mh-spamassassin-add-rule "whitelist_from" from)) | 263 | (mh-spamassassin-add-rule "whitelist_from" from)) |
| 258 | (message "Whitelisting message %d...done" msg)))) | 264 | (message "Whitelisting sender of message %d...done" msg)))) |
| 259 | 265 | ||
| 260 | (defun mh-spamassassin-add-rule (rule body) | 266 | (defun mh-spamassassin-add-rule (rule body) |
| 261 | "Add a new rule to \"~/.spamassassin/user_prefs\". | 267 | "Add a new rule to \"~/.spamassassin/user_prefs\". |
| @@ -375,8 +381,12 @@ The \"Bogofilter tuning HOWTO\" describes how you can fine-tune Bogofilter." | |||
| 375 | (unless mh-bogofilter-executable | 381 | (unless mh-bogofilter-executable |
| 376 | (error "Unable to find the bogofilter executable")) | 382 | (error "Unable to find the bogofilter executable")) |
| 377 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) | 383 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) |
| 378 | (call-process mh-bogofilter-executable msg-file mh-junk-background | 384 | (mh-truncate-log-buffer) |
| 379 | nil "-s"))) | 385 | ;; Put call-process output in log buffer if we are saving it |
| 386 | ;; (this happens if mh-junk-background is t). | ||
| 387 | (with-current-buffer mh-log-buffer | ||
| 388 | (call-process mh-bogofilter-executable msg-file mh-junk-background | ||
| 389 | nil "-s")))) | ||
| 380 | 390 | ||
| 381 | ;;;###mh-autoload | 391 | ;;;###mh-autoload |
| 382 | (defun mh-bogofilter-whitelist (msg) | 392 | (defun mh-bogofilter-whitelist (msg) |
| @@ -386,8 +396,12 @@ See `mh-bogofilter-blacklist' for more information." | |||
| 386 | (unless mh-bogofilter-executable | 396 | (unless mh-bogofilter-executable |
| 387 | (error "Unable to find the bogofilter executable")) | 397 | (error "Unable to find the bogofilter executable")) |
| 388 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) | 398 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) |
| 389 | (call-process mh-bogofilter-executable msg-file mh-junk-background | 399 | (mh-truncate-log-buffer) |
| 390 | nil "-n"))) | 400 | ;; Put call-process output in log buffer if we are saving it |
| 401 | ;; (this happens if mh-junk-background is t). | ||
| 402 | (with-current-buffer mh-log-buffer | ||
| 403 | (call-process mh-bogofilter-executable msg-file mh-junk-background | ||
| 404 | nil "-n")))) | ||
| 391 | 405 | ||
| 392 | 406 | ||
| 393 | 407 | ||
| @@ -423,8 +437,12 @@ update SpamProbe's training." | |||
| 423 | (unless mh-spamprobe-executable | 437 | (unless mh-spamprobe-executable |
| 424 | (error "Unable to find the spamprobe executable")) | 438 | (error "Unable to find the spamprobe executable")) |
| 425 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) | 439 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) |
| 426 | (call-process mh-spamprobe-executable msg-file mh-junk-background | 440 | (mh-truncate-log-buffer) |
| 427 | nil "spam"))) | 441 | ;; Put call-process output in log buffer if we are saving it |
| 442 | ;; (this happens if mh-junk-background is t). | ||
| 443 | (with-current-buffer mh-log-buffer | ||
| 444 | (call-process mh-spamprobe-executable msg-file mh-junk-background | ||
| 445 | nil "spam")))) | ||
| 428 | 446 | ||
| 429 | ;;;###mh-autoload | 447 | ;;;###mh-autoload |
| 430 | (defun mh-spamprobe-whitelist (msg) | 448 | (defun mh-spamprobe-whitelist (msg) |
| @@ -434,8 +452,12 @@ See `mh-spamprobe-blacklist' for more information." | |||
| 434 | (unless mh-spamprobe-executable | 452 | (unless mh-spamprobe-executable |
| 435 | (error "Unable to find the spamprobe executable")) | 453 | (error "Unable to find the spamprobe executable")) |
| 436 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) | 454 | (let ((msg-file (mh-msg-filename msg mh-current-folder))) |
| 437 | (call-process mh-spamprobe-executable msg-file mh-junk-background | 455 | (mh-truncate-log-buffer) |
| 438 | nil "good"))) | 456 | ;; Put call-process output in log buffer if we are saving it |
| 457 | ;; (this happens if mh-junk-background is t). | ||
| 458 | (with-current-buffer mh-log-buffer | ||
| 459 | (call-process mh-spamprobe-executable msg-file mh-junk-background | ||
| 460 | nil "good")))) | ||
| 439 | 461 | ||
| 440 | (provide 'mh-junk) | 462 | (provide 'mh-junk) |
| 441 | 463 | ||