Mew でスパム・フィルター bsfilter を走らせる Elisp mew-absfilter.el のお話。
- clmemo@aka: mew-absfilter 1.37 へのパッチ その三
- clmemo@aka: mew-absfilter 1.37 への patch その二
- clmemo@aka: Mew と bsfilter と mew-absfilter.el
上記エントリーの続き。
パッチその三をあてると、
(setq mew-use-suffix nil) (setq mew-suffix ".mew")
な条件で、スパム・フィルターがメールを見つけられないバグがあることを発見した。mew-absfilter.el 1.37 に対するパッチを公開する。
※パッチその三をあててる方は、逆パッチしてから下記パッチをあてられたし。
パッチ
--- mew-absfilter.el.org 2005-05-17 11:54:00.000000000 +0900 +++ mew-absfilter.el 2007-01-16 13:06:26.000000000 +0900 @@ -112,7 +112,7 @@ ;; spam check (defun mew-absfilter-collect-message-region (begin end) - "Returns a list of message number in region." + "Returns a list of message number or number.suffix in region." (let (msgs) (save-excursion (save-restriction @@ -121,7 +121,7 @@ (while (not (eobp)) (when (and (mew-summary-markable) (mew-sumsyn-match mew-regex-sumsyn-short)) - (push (mew-sumsyn-message-number) msgs)) + (push (mew-msg-get-filename (mew-sumsyn-message-number)) msgs)) (forward-line)))) (nreverse msgs))) @@ -178,8 +178,8 @@ (set-buffer vfolder) (save-excursion (dolist (msg msgs) - (if (or (re-search-forward (mew-regex-sumsyn-msg msg) nil t) - (re-search-backward (mew-regex-sumsyn-msg msg) nil t)) + (if (or (re-search-forward (mew-absfilter-regex-sumsyn-msg msg) nil t) + (re-search-backward (mew-absfilter-regex-sumsyn-msg msg) nil t)) (mew-absfilter-summary-spam-one 'no-msg) ;; if msg is not found, try to mark in physical folder (push msg spam))))))) @@ -187,10 +187,16 @@ (set-buffer case:folder) (save-excursion (dolist (msg spam) - (when (or (re-search-forward (mew-regex-sumsyn-msg msg) nil t) - (re-search-backward (mew-regex-sumsyn-msg msg) nil t)) + (when (or (re-search-forward (mew-absfilter-regex-sumsyn-msg msg) nil t) + (re-search-backward (mew-absfilter-regex-sumsyn-msg msg) nil t)) (mew-absfilter-summary-spam-one 'no-msg)))))))) +(defun mew-absfilter-regex-sumsyn-msg (msg) + (mew-regex-sumsyn-msg + (if (and mew-use-suffix mew-suffix) + (substring msg 0 (- (length mew-suffix))) + msg))) + (defun mew-absfilter-sentinel (process event) ;; exit status of "bsfilter --list-spam" ;; 0: some spams are found @@ -224,7 +230,7 @@ (when (mew-sumsyn-match mew-regex-sumsyn-short) (let* ((msg (mew-sumsyn-message-number)) (case:folder (mew-sumsyn-folder-name)) - (file (mew-expand-folder case:folder msg))) + (file (mew-absfilter-expand-msg case:folder msg))) (when (eq (mew-summary-get-mark) mew-absfilter-mark-spam) (mew-summary-undo)) (unless mark-only @@ -239,12 +245,20 @@ (when (mew-sumsyn-match mew-regex-sumsyn-short) (let* ((msg (mew-sumsyn-message-number)) (case:folder (mew-sumsyn-folder-name)) - (file (mew-expand-folder case:folder msg))) + (file (mew-absfilter-expand-msg case:folder msg))) (mew-absfilter-summary-spam-one) (unless mark-only (mew-absfilter-add-spam (list file)) (message "Learned as spam")))))) +(defun mew-absfilter-expand-msg (folder msg) + "Expand message MSG in FOLDER. +Function `mew-expand-new-msg' is defined after Mew 4.2.53. +Use `mew-expand-folder' iff `mew-expand-new-msg' is not available." + (if (fboundp 'mew-expand-new-msg) + (mew-expand-new-msg folder msg) + (mew-expand-folder folder msg))) + (defun mew-absfilter-mark-learn-clean (&optional mark-only) "Learn all messages marked with '*' as clean (not spam)." (interactive "P")
No comments:
Post a Comment