最近、ぼくの H"
(defun mew-add-bogo-blacklist (&optional white)
"Bogofilter の spam list にいれる。C-u で nospam list にいれる。"
(interactive "P")
(mew-summary-not-in-queue
(mew-summary-not-in-draft
(save-excursion
(mew-summary-goto-message)
(let* ((bogo (mew-which-exec "bogofilter"))
(fld (mew-summary-folder-name))
(msg (mew-summary-message-number)))
(when (and bogo fld msg)
(with-temp-buffer
(let ((coding-system-for-write mew-cs-text-for-write)
(coding-system-for-read mew-cs-text-for-read))
(insert-file-contents (mew-expand-folder fld msg))
(if (not (y-or-n-p (format "Add `%s' to %s? " (mew-header-get-value "From:")
(if white "*noSpam* list" "*SPAM* list"))))
(error "Nothing to do.")
(when (string= (mew-header-get-value "From:")
"emacs-w3m-admin@namazu.org")
(goto-char (point-min))
(if (and (re-search-forward "^------- Forwarded Message" nil t)
(re-search-forward "^Received: " nil t))
(delete-region (point-min) (line-beginning-position))
(error "???")))
(apply 'call-process-region (point-min) (point-max) bogo
'delete (current-buffer) nil
(if white '("-S" "-n") '("-s"))))))
(if white
(when (string= fld "+spam")
(mew-summary-refile-body '("+inbox")))
(when (not (string= fld "+spam"))
(mew-summary-refile-body '("+spam"))))
(message "%s/%s to %s" fld msg (if white "noSpam." "SPAM!!"))))))))
(defun mew-bogo-check (&optional arg)
"Bogofilter を使った Spam check。C-u なら region。"
(interactive "P")
(if (mew-summary-or-virtual-p)
(mew-summary-not-in-queue
(mew-summary-not-in-draft
(if arg
(mew-bogo-check-region)
(mew-bogo-check-one))))
(message "This command can be used in Mew.")))
(defun mew-bogo-check-region ()
(let* ((begend (mew-summary-get-region))
(spam 0)
(total 0)
beg end pos)
(when begend
(setq beg (car begend))
(setq end (cdr begend))
(save-restriction
(narrow-to-region beg end)
(mew-decode-syntax-delete)
(when (mew-sinfo-get-disp-msg)
(mew-summary-toggle-disp-msg))
(goto-char (point-min))
(setq pos (point))
(while (not (eobp))
(setq total (1+ total))
(when (mew-bogo-check-one)
(setq spam (1+ spam)))
(forward-line 1)))
(message "%d/%d detect." spam total))))
(defun mew-bogo-check-one ()
(save-excursion
(mew-summary-goto-message)
(let* ((fld (mew-summary-folder-name))
(msg (mew-summary-message-number))
(bogo (mew-which-exec "bogofilter"))
ret)
(when (and bogo fld msg)
(with-temp-buffer
(let ((coding-system-for-write mew-cs-text-for-write)
(coding-system-for-read mew-cs-text-for-read))
(insert-file-contents (mew-expand-folder fld msg))
(goto-char (point-min))
(when (string= (mew-header-get-value "From:")
"emacs-w3m-admin@namazu.org")
(goto-char (point-min))
(if (and (re-search-forward "^------- Forwarded Message" nil t)
(re-search-forward "^Received: " nil t))
(delete-region (point-min) (line-beginning-position))
(error "???")))
(apply 'call-process-region (point-min) (point-max) bogo
'delete (current-buffer) nil '("-u" "-e" "-p"))
(goto-char (point-min))
(when (and (re-search-forward "^X-Bogosity: " nil t)
(looking-at "Yes"))
(setq ret t))))
(if ret
(progn
(when (not (string= fld "+spam"))
(mew-summary-refile-body '("+spam")))
(message "%s/%s is Spam!!" fld msg))
(when (string= fld "+spam")
(mew-summary-refile-body '("+inbox")))
(message "%s/%s is noSpam." fld msg))
ret))))
思いっ切りぼくの環境に依存しているので注意。だけど、本当は、mew-pop-command-dele() にで組み込んで spam のチェックをしないとあまりうれしくないな。