[Spambayes-checkins] spambayes/contrib muttrc, 1.3, 1.4 spambayes.el, 1.4, 1.5

Neale Pickett npickett at users.sourceforge.net
Wed Oct 15 01:02:10 EDT 2003


Update of /cvsroot/spambayes/spambayes/contrib
In directory sc8-pr-cvs1:/tmp/cvs-serv12145/contrib

Modified Files:
	muttrc spambayes.el 
Log Message:
* Modified muttrc and spambayes.el that actually work with what's being
  shipped :)
* Expanded documentation of sb_filter.py


Index: muttrc
===================================================================
RCS file: /cvsroot/spambayes/spambayes/contrib/muttrc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** muttrc	5 Jun 2003 04:28:37 -0000	1.3
--- muttrc	15 Oct 2003 05:02:08 -0000	1.4
***************
*** 7,16 ****
  ##
  ##   :0fw
! ##   | hammiefilter.py -t
  ##
  ##
! ## This binds 'S' to refile as spam and move to a 'caughtspam' folder.
! ## 'H' will refile as ham and move to your inbox.  You will want to use
! ## these on every misclassified message.
  ##
  ## As a special bonus, all tagged spam will be colored red on black.
--- 7,17 ----
  ##
  ##   :0fw
! ##   | sb_filter.py -t
  ##
  ##
! ## This binds 'S' to train on the current message as spam, and 'H' to
! ## train on the current message as ham.  Both of these commands
! ## re-classify the message and send it through procmail, so you'll have
! ## two copies after running them.
  ##
  ## As a special bonus, all tagged spam will be colored red on black.
***************
*** 20,26 ****
  ## helping out with the muttisms.
  ##
! folder-hook . "macro index S '|hammiefilter.py -s\n <save-message>=caughtspam\n'"
! folder-hook . "macro pager S '|hammiefilter.py -s\n <save-message>=caughtspam\n'"
! folder-hook . "macro index H '|hammiefilter.py -g\r <save-message>!\r'"
! folder-hook . "macro pager H '|hammiefilter.py -g\r <save-message>!\r'"
  color index red black "~h 'X-Spambayes-Disposition: spam' ~F"
--- 21,38 ----
  ## helping out with the muttisms.
  ##
! macro index S "|sb_filter.py -s | procmail\n"
! macro pager S "|sb_filter.py -s | procmail\n"
! macro index H "|sb_filter.py -g | procmail\n"
! macro pager H "|sb_filter.py -g | procmail\n"
  color index red black "~h 'X-Spambayes-Disposition: spam' ~F"
+ 
+ ## If you're feeling bold and don't mind the possibility of losing mail,
+ ## you can uncomment these lines.  These bindings automatically delete
+ ## the message in addition to retraining and sending through procmail.
+ ## If there's a problem with sb_filter, though, the message will be lost
+ ## forever.
+ ##
+ #macro index S "<delete-message>|sb_filter.py -s | procmail\n"
+ #macro pager S "<delete-message>|sb_filter.py -s | procmail\n"
+ #macro index H "<delete-message>|sb_filter.py -g | procmail\n"
+ #macro pager H "<delete-message>|sb_filter.py -g | procmail\n"

Index: spambayes.el
===================================================================
RCS file: /cvsroot/spambayes/spambayes/contrib/spambayes.el,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** spambayes.el	10 Jun 2003 14:03:26 -0000	1.4
--- spambayes.el	15 Oct 2003 05:02:08 -0000	1.5
***************
*** 1,5 ****
  ;; spambayes.el -- integrate spambayes into Gnus and VM
  ;; Copyright (C) 2003 Neale Pickett <neale at woozle.org>
! ;; Time-stamp: <2003-06-06 10:07:09 neale>
  
  ;; This is free software; you can redistribute it and/or modify it under
--- 1,5 ----
  ;; spambayes.el -- integrate spambayes into Gnus and VM
  ;; Copyright (C) 2003 Neale Pickett <neale at woozle.org>
! ;; Time-stamp: <2003-10-14 21:59:11 neale>
  
  ;; This is free software; you can redistribute it and/or modify it under
***************
*** 19,42 ****
  ;; Purpose:
  ;;
! ;; Functions to put spambayes into Gnus.  
! ;;
! ;; This assumes you are already filtering with a procmail recipie
! ;; similar to:
! ;;
! ;;   :0fw
! ;;   | hammiefilter.py -t
! ;;
! ;; If you can't run procmail on all your incoming messages, you shold
! ;; have a look at spam.el, which is included with Oort Gnus.
! ;;
! ;; This binds "B s" to "refile as spam", and "B h" to "refile as ham".
! ;; After refiling, the message is rescored and respooled.  I haven't yet
! ;; run across a case where refiling doesn't change a message's score
! ;; well into the ham or spam range.  If this happens to you, please let
! ;; me know.
  
- ;; Installation:
- ;;
- ;;
  ;; GNUS
  ;; ----
--- 19,24 ----
  ;; Purpose:
  ;;
! ;; Functions to put spambayes into Gnus and VM.
  
  ;; GNUS
  ;; ----
***************
*** 44,55 ****
  ;; following lines in ~/.gnus:
  ;;
! ;; (load-library "spambayes")
! ;; (add-hook
! ;;  'gnus-sum-load-hook
! ;;  (lambda nil
! ;;    (define-key gnus-summary-mode-map [(B) (s)] 'spambayes-gnus-refile-as-spam)
! ;;    (define-key gnus-summary-mode-map [(B) (h)] 'spambayes-gnus-refile-as-ham)))
  ;;
  ;;
  ;; VM (Courtesy of Prabhu Ramachandran <prabhu at aero.iitm.ernet.in>)
  ;; ----
--- 26,55 ----
  ;; following lines in ~/.gnus:
  ;;
! ;; (setq gnus-sum-load-hook
! ;;   (lambda ()
! ;;     (require 'spambayes)
! ;;     (define-key gnus-summary-mode-map [(B) (s)] 'spambayes-gnus-refile-as-spam)
! ;;     (define-key gnus-summary-mode-map [(B) (h)] 'spambayes-gnus-refile-as-ham)))
! ;;
! ;; In summary mode, "B h" will refile a message as ham, and "B s",
! ;; appropriately enough, will refile a message as spam.
  ;;
  ;;
+ ;; You can also put the following in ~/.gnus to run messages through the
+ ;; filter as Gnus reads them in:
+ ;;
+ ;;  (setq nnmail-prepare-incoming-message-hook 'spambayes-filter-buffer)
+ ;;
+ ;; You can then use Gnus message splitting (looking at the
+ ;; X-Spambayes-Classification header) to file messages based on the
+ ;; spambayes score.
+ ;;
+ ;; Some folks may prefer using procmail to score messages when they
+ ;; arrive.  See README.txt in the distribution for more information on
+ ;; how to do this.
+ 
+ 
+ 
+ 
  ;; VM (Courtesy of Prabhu Ramachandran <prabhu at aero.iitm.ernet.in>)
  ;; ----
***************
*** 70,74 ****
  ;;         )
  ;; )
! ;; 
  ;; Hitting the 'A' key will refile messages to the SPAM and UNSURE folders.
  ;;
--- 70,74 ----
  ;;         )
  ;; )
! ;;
  ;; Hitting the 'A' key will refile messages to the SPAM and UNSURE folders.
  ;;
***************
*** 83,94 ****
  
  
! (defvar spambayes-spam-group "spam"
!   "Group name for spam messages")
! 
! (defvar spambayes-hammiefilter "~/src/spambayes/hammiefilter.py"
!   "Path to the hammiefilter program")
  
  ;; Gnus
  
  (defun spambayes-gnus-retrain (is-spam)
    "Retrain on all processable articles, or the one under the cursor.
--- 83,108 ----
  
  
! (defvar spambayes-filter-program "/usr/local/bin/sb_filter.py"
!   "Path to the sb_filter program.")
  
+ 
  ;; Gnus
  
+ (defun spambayes-filter-buffer (&optional buffer)
+   "Filter a buffer through Spambayes.
+ 
+ This pipes the a buffer through Spambayes, which adds its headers.  The
+ output of Spambayes replaces the contents of the buffer.  If no buffer
+ is specified, the current buffer is used.
+ "
+   (shell-command-on-region
+    (point-min)
+    (point-max)
+    (concat
+     spambayes-filter-program
+     " -f")
+    (or buffer (current-buffer))
+    t))
+ 
  (defun spambayes-gnus-retrain (is-spam)
    "Retrain on all processable articles, or the one under the cursor.
***************
*** 108,112 ****
  		       (point-max)
  		       (concat
! 			spambayes-hammiefilter
  			(if is-spam " -s" " -g")
  			" -f")
--- 122,126 ----
  		       (point-max)
  		       (concat
! 			spambayes-filter-program
  			(if is-spam " -s" " -g")
  			" -f")
***************
*** 128,132 ****
    "Retrain and refilter all process-marked messages as spam, then respool them"
    (interactive)
!   (spambayes-retrain 't)
    (gnus-summary-respool-article nil (gnus-group-method gnus-newsgroup-name)))
  
--- 142,146 ----
    "Retrain and refilter all process-marked messages as spam, then respool them"
    (interactive)
!   (spambayes-gnus-retrain 't)
    (gnus-summary-respool-article nil (gnus-group-method gnus-newsgroup-name)))
  
***************
*** 134,141 ****
    "Retrain and refilter all process-marked messages as ham, then respool them"
    (interactive)
!   (spambayes-retrain nil)
    (gnus-summary-respool-article nil (gnus-group-method gnus-newsgroup-name)))
  
  
  ;;; VM
  
--- 148,156 ----
    "Retrain and refilter all process-marked messages as ham, then respool them"
    (interactive)
!   (spambayes-gnus-retrain nil)
    (gnus-summary-respool-article nil (gnus-group-method gnus-newsgroup-name)))
  
  
+ 
  ;;; VM
  
***************
*** 148,154 ****
    (interactive)
    (message (concat "Retraining" (if is-spam " as SPAM" " as HAM") " ..."))
!   (vm-pipe-message-to-command 
!    (concat spambayes-hammiefilter (if is-spam " -s" " -g") " -f") nil)
!   (message (concat "Done retraining messages" 
                     (if is-spam " as SPAM" " as HAM") ".") )
  )
--- 163,169 ----
    (interactive)
    (message (concat "Retraining" (if is-spam " as SPAM" " as HAM") " ..."))
!   (vm-pipe-message-to-command
!    (concat spambayes-filter-program (if is-spam " -s" " -g") " -f") nil)
!   (message (concat "Done retraining messages"
                     (if is-spam " as SPAM" " as HAM") ".") )
  )
***************
*** 165,166 ****
--- 180,183 ----
    (spambayes-vm-retrain nil)
  )
+ 
+ (provide 'spambayes)





More information about the Spambayes-checkins mailing list