;; ;; wanderlustのelmo-mark枝で実装された ;; 一時マークとそれに対するアクションを定義する機能 ;; を使って、wanderlustのsummaryモードでbsfilterを使おう。 ;; akira yamada ;; ;; 使い方みたいなもの: ;; ;; ・未読メッセージを開いたときにbsfilterで判定 ;; → SPAM判定されたらSマークを付ける(後でSPAMゴミ箱送り) ;; ・summaryモードでbs ;; → その場でbsfilter --add-spam --sub-cleanし、 ;; さらにSマークを付ける(同上) ;; ・summaryモードでbc ;; → その場でbsfilter --add-clean --sub-spamする(マークは付けない) ;; ・summaryモードでx(o/O/dマークの処理時) ;; → 処理の前にbsfilter --updateする ;; → Sマークの付いたメールをSPAMゴミ箱へ ;; → o/O/dマークの付いたメール(の一部)をbsfilter --add-cleanする(todo) ;; ;; 履歴: ;; ;; ・2003-07-18 ;; とりあえずでっちあげた。コードがきたない。 ;; そのうちだれかがもっとキレイなものを作ってくれるだろう。 ;; ; SPAMゴミ箱 (defvar wl-bsfilter-spam-filterd-folder "%INBOX.Trash.Filtered") (defvar wl-bsfilter-command "bsfilter") (defvar wl-bsfilter-add-spam-option "--add-spam") (defvar wl-bsfilter-add-spam-again-option "--sub-clean --add-spam") (defvar wl-bsfilter-add-clean-option "--add-clean") (defvar wl-bsfilter-add-clean-again-option "--sub-spam --add-clean") (defvar wl-bsfilter-update-option "--update") (defvar wl-bsfilter-test-option "") (wl-defface wl-highlight-summary-spam-face '( (((type tty) (background dark)) (:foreground "Black")) (((class color) (background dark)) (:foreground "Black")) (((class color) (background light)) (:foreground "Black"))) "Face used for displaying messages mark as SPAM." :group 'wl-summary-faces :group 'wl-faces) (setq wl-summary-mark-action-list (cons '("S" spam nil wl-summary-register-temp-mark wl-summary-exec-action-spam wl-highlight-summary-spam-face "spam messages.") wl-summary-mark-action-list)) (setq wl-summary-reserve-mark-list (cons "S" wl-summary-reserve-mark-list)) (setq wl-summary-skip-mark-list (cons "S" wl-summary-skip-mark-list)) (wl-summary-define-mark-action) (defadvice wl-summary-exec (before wl-bsfilter-update activate) "" (interactive) (shell-command (format "%s %s" wl-bsfilter-command wl-bsfilter-update-option))) (defadvice wl-summary-redisplay (before wl-bsfilter-test activate) "" (let ((mark (wl-summary-persistent-mark))) (if (or (string= mark "N") (string= mark "U") (string= mark "!")) (wl-bsfilter-test-message nil nil)))) (define-key wl-summary-mode-map "bS" 'wl-summary-spam) (define-key wl-summary-mode-map "tbS" 'wl-thread-spam) (define-key wl-summary-mode-map "mbS" 'wl-summary-target-mark-spam) (define-key wl-summary-mode-map "rbS" 'wl-summary-spam-region) (define-key wl-summary-mode-map "bs" 'wl-bsfilter-add-spam-again-message) (define-key wl-summary-mode-map "bC" 'wl-bsfilter-add-clean-message) (define-key wl-summary-mode-map "bc" 'wl-bsfilter-add-clean-again-message) (define-key wl-summary-mode-map "bm" 'wl-bsfilter-test-message) (defun wl-summary-add-spam (action number) (wl-thread-jump-to-msg number) (wl-bsfilter-add-spam-message nil nil) nil) (defun wl-summary-exec-action-spam (mark-list) (wl-summary-move-mark-list-messages mark-list wl-bsfilter-spam-filterd-folder "Moving messages to SPAM-box...")) (defun wl-bsfilter-pipe-message-subr (prefix command) (save-excursion (wl-summary-set-message-buffer-or-redisplay) (set-buffer (wl-message-get-original-buffer)) (goto-char (point-min)) ; perhaps this line won't be necessary (if prefix (search-forward "\n\n")) (shell-command-on-region (point) (point-max) command nil))) (defun wl-bsfilter-pipe-message (prefix command arg) "" (if (null (wl-summary-message-number)) (message "No message.") (setq command (format "%s %s" wl-bsfilter-command arg)) (wl-bsfilter-pipe-message-subr prefix command))) (defun wl-bsfilter-add-clean-message (prefix command) "" (interactive (list current-prefix-arg nil)) (wl-bsfilter-pipe-message prefix command wl-bsfilter-add-clean-option) (wl-summary-unmark)) (defun wl-bsfilter-add-clean-again-message (prefix command) "" (interactive (list current-prefix-arg nil)) (wl-bsfilter-pipe-message prefix command wl-bsfilter-add-clean-again-option) (wl-summary-unmark)) (defun wl-bsfilter-add-spam-message (prefix command) "" (interactive (list current-prefix-arg nil)) (wl-bsfilter-pipe-message prefix command wl-bsfilter-add-spam-option) (wl-summary-set-mark "S" (wl-summary-message-number) t)) (defun wl-bsfilter-add-spam-again-message (prefix command) "" (interactive (list current-prefix-arg nil)) (wl-bsfilter-pipe-message prefix command wl-bsfilter-add-spam-again-option) (wl-summary-set-mark "S" (wl-summary-message-number) t)) (defun wl-bsfilter-test-message (prefix command) "" (interactive (list current-prefix-arg nil)) (if (= 0 (wl-bsfilter-pipe-message prefix command wl-bsfilter-test-option)) (progn (wl-summary-set-mark "S" (wl-summary-message-number) t) (message "This mail is a SPAM")) (message "This mail is not a SPAM"))) (defun wl-bsfilter-update () "" (interactive) (shell-command (format "%s %s" wl-bsfilter-command wl-bsfilter-update-option))) (provide 'wl-bsfilter)