Mort aux spams!
Par Benjamin Drieu le vendredi 6 août 2004, 10:00 - Emacs - Lien permanent
Ça y est, j'ai installé bogofilter pour éradiquer consciencieusement mes spams. Le seul problème : je n'ai pas envie de m'embêter à trier mes spams pour lui envoyer dans sa base. Du coup, j'ai écrit un petit script {@emacs} pour faire ça automatiquement avec {@gnus}. Il suffit de mettre ce code dans un répertoire donné et de le charger via son fichier .gnus. Ensuite, il suffira de taper BS à partir du buffer summary pour tagguer un spam et BH pour tagguer un non spam. C'est pas beau la vie ? ;-)
(defun gnus-summary-pipe-to-bogospam (&optional command)
"Pipe this article to subprocess."
(gnus-eval-in-buffer-window gnus-article-buffer
(save-restriction
(widen)
(shell-command-on-region (point-min) (point-max) "bogofilter -s" nil)
(message "Message marked as SPAM"))))
(defun gnus-summary-pipe-to-bogoham (&optional command)
"Pipe this article to subprocess."
(gnus-eval-in-buffer-window gnus-article-buffer
(save-restriction
(widen)
(shell-command-on-region (point-min) (point-max) "bogofilter -n" nil)
(message "Message marked as HAM"))))
(defun bogo-spam (&optional arg headers)
(interactive (gnus-interactive "P\ny"))
(require 'gnus-art)
(let ((gnus-default-article-saver 'gnus-summary-pipe-to-bogospam)
(gnus-save-all-headers gnus-save-all-headers))
(gnus-summary-save-article arg t))
(let ((buffer (get-buffer "*Shell Command Output*")))
(when (and buffer
(not (zerop (buffer-size buffer))))
(gnus-configure-windows 'pipe))))
(defun bogo-ham (&optional arg headers)
(interactive (gnus-interactive "P\ny"))
(require 'gnus-art)
(let ((gnus-default-article-saver 'gnus-summary-pipe-to-bogoham)
(gnus-save-all-headers gnus-save-all-headers))
(gnus-summary-save-article arg t))
(let ((buffer (get-buffer "*Shell Command Output*")))
(when (and buffer
(not (zerop (buffer-size buffer))))
(gnus-configure-windows 'pipe))))
(gnus-define-keys gnus-summary-mode-map "BS" bogo-spam "BH" bogo-ham)