[mew-dist 27558] mew-absfilter.el のパッチ (その四)
Masayuki Ataka
m.asayuki.ataka at example.com
2007年 1月 17日 (水) 12:06:44 JST
安宅です。
mew-absfilter.el 1.37 で mew-use-suffix を nil にした時
旧パッチで (ファイルが特定できない) 不具合が出る
ことが分かったので、パッチを書き直しました。
※同様の内容は、私のブログでも公開しております。
clmemo at example.com: mew-absfilter 1.37 へのパッチ その四
http://at-aka.blogspot.com/2007/01/mew-absfilter-137.html
----Input with T-Code!
http://at-aka.blogspot.com
m.asayuki.ataka+mobile at example.com
Masayuki Ataka / 安宅 正之
--- 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")
Mew-dist メーリングリストの案内