/[emacs]/emacs/lisp/mail/rmail-spam-filter.el
ViewVC logotype

Diff of /emacs/lisp/mail/rmail-spam-filter.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by lute, Mon Jul 4 17:46:22 2005 UTC revision 1.11 by ttn, Sat Aug 6 18:54:05 2005 UTC
# Line 1  Line 1 
1  ;;; rmail-spam-filter.el  --- spam filter for rmail, the emacs mail reader.  ;;; rmail-spam-filter.el  --- spam filter for rmail, the emacs mail reader.
2    
3  ;; Copyright (C) 2002  ;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 ;;              Free Software Foundation, Inc.  
4  ;; Keywords: email, spam, filter, rmail  ;; Keywords: email, spam, filter, rmail
5  ;; Author: Eli Tziperman <eli AT deas.harvard.edu>  ;; Author: Eli Tziperman <eli AT deas.harvard.edu>
6    
# Line 183  may be either 'this is spam' or 'another Line 182  may be either 'this is spam' or 'another
182  is spam\\|another spam' (without the single quotes).  To specify that  is spam\\|another spam' (without the single quotes).  To specify that
183  if the contents contain both this and that the message is spam,  if the contents contain both this and that the message is spam,
184  specify 'this\\&that' in the appropriate spam definition field."  specify 'this\\&that' in the appropriate spam definition field."
185    :type '(repeat    :type '(repeat
186            (list :format "%v"            (list :format "%v"
187             (cons :format "%v" :value (from . "")             (cons :format "%v" :value (from . "")
188                   (const :format ""  from)                   (const :format ""  from)
# Line 202  specify 'this\\&that' in the appropriate Line 201  specify 'this\\&that' in the appropriate
201                   (string :tag "Contents"  ""))                   (string :tag "Contents"  ""))
202             (cons :format "%v" :value (action . output-and-delete)             (cons :format "%v" :value (action . output-and-delete)
203                   (const :format "" action)                   (const :format "" action)
204                   (choice :tag "Action selection"                   (choice :tag "Action selection"
205                    (const :tag "output to spam folder and delete" output-and-delete)                    (const :tag "output to spam folder and delete" output-and-delete)
206                    (const :tag "delete spam" delete-spam)                    (const :tag "delete spam" delete-spam)
207                    ))                    ))
# Line 218  for interaction with `rsf-bbdb-auto-dele Line 217  for interaction with `rsf-bbdb-auto-dele
217  (defun check-field (field-symbol message-data definition result)  (defun check-field (field-symbol message-data definition result)
218    "Check if field-symbol is in `rsf-definitions-alist'.    "Check if field-symbol is in `rsf-definitions-alist'.
219  Capture maybe-spam and this-is-a-spam-email in a cons in result,  Capture maybe-spam and this-is-a-spam-email in a cons in result,
220  where maybe-spam is in first and this-is-a-spam-email is in rest.  where maybe-spam is in first and this-is-a-spam-email is in rest.
221  The values are returned by destructively changing result.  The values are returned by destructively changing result.
222  If FIELD-SYMBOL field does not exist AND is not specified,  If FIELD-SYMBOL field does not exist AND is not specified,
223  this may still be spam due to another element...  this may still be spam due to another element...
# Line 259  it from rmail file.  Called for each new Line 258  it from rmail file.  Called for each new
258          (save-current-msg)          (save-current-msg)
259          (rsf-saved-bbdb/mail_auto_create_p nil)          (rsf-saved-bbdb/mail_auto_create_p nil)
260          )          )
261        
262      ;; make sure bbdb does not create entries for messages while spam      ;; make sure bbdb does not create entries for messages while spam
263      ;; filter is scanning the rmail file:      ;; filter is scanning the rmail file:
264      (setq rsf-saved-bbdb/mail_auto_create_p 'bbdb/mail_auto_create_p)      (setq rsf-saved-bbdb/mail_auto_create_p 'bbdb/mail_auto_create_p)
# Line 291  it from rmail file.  Called for each new Line 290  it from rmail file.  Called for each new
290    
291          ;;; do we want to ignore case in spam definitions:          ;;; do we want to ignore case in spam definitions:
292            (setq case-fold-search rsf-ignore-case)            (setq case-fold-search rsf-ignore-case)
293            
294          ;; Check for blind CC condition.  Set vars such that while          ;; Check for blind CC condition.  Set vars such that while
295          ;; loop will be bypassed and spam condition will trigger          ;; loop will be bypassed and spam condition will trigger
296          (if (and rsf-no-blind-cc          (if (and rsf-no-blind-cc
# Line 339  it from rmail file.  Called for each new Line 338  it from rmail file.  Called for each new
338    
339              ;; start scanning incoming message:              ;; start scanning incoming message:
340              ;;---------------------------------              ;;---------------------------------
341                
342              ;; Maybe the different fields should also be done in a              ;; Maybe the different fields should also be done in a
343              ;; loop to make the whole thing more flexible              ;; loop to make the whole thing more flexible
344              ;; if sender field is not specified in message being              ;; if sender field is not specified in message being
# Line 352  it from rmail file.  Called for each new Line 351  it from rmail file.  Called for each new
351              ;; next, if spam was not ruled out already, check subject:              ;; next, if spam was not ruled out already, check subject:
352              (check-field 'subject message-subject definition maybe-spam)              (check-field 'subject message-subject definition maybe-spam)
353              ;; next, if spam was not ruled out already, check content-type:              ;; next, if spam was not ruled out already, check content-type:
354              (check-field 'content-type message-content-type              (check-field 'content-type message-content-type
355                           definition maybe-spam)                           definition maybe-spam)
356              ;; next, if spam was not ruled out already, check              ;; next, if spam was not ruled out already, check
357              ;; contents: if contents field is not specified, this may              ;; contents: if contents field is not specified, this may
358              ;; still be spam due to another element...              ;; still be spam due to another element...
359              (check-field 'contents              (check-field 'contents
360                           (buffer-substring                           (buffer-substring
361                            (rmail-msgbeg msg) (rmail-msgend msg))                            (rmail-msgbeg msg) (rmail-msgend msg))
362                           definition maybe-spam)                           definition maybe-spam)
363                
364              ;; if the search in rsf-definitions-alist found              ;; if the search in rsf-definitions-alist found
365              ;; that this email is spam, output the email to the spam              ;; that this email is spam, output the email to the spam
366              ;; rmail file, mark the email for deletion, leave the              ;; rmail file, mark the email for deletion, leave the
# Line 378  it from rmail file.  Called for each new Line 377  it from rmail file.  Called for each new
377                (setq num-element (+ num-element 1)))                (setq num-element (+ num-element 1)))
378              )              )
379            )            )
380            
381          ;; (BK) re-set originally used variables          ;; (BK) re-set originally used variables
382          (setq this-is-a-spam-email (rest maybe-spam)          (setq this-is-a-spam-email (rest maybe-spam)
383                maybe-spam (first maybe-spam))                maybe-spam (first maybe-spam))
# Line 610  automatically, no user input is required Line 609  automatically, no user input is required
609          (while definitions          (while definitions
610            (setq current (car definitions))            (setq current (car definitions))
611            (setq definitions (cdr definitions))            (setq definitions (cdr definitions))
612            (setq result            (setq result
613                  (append result                  (append result
614                          (list                          (list
615                           (list (assoc 'from current)                           (list (assoc 'from current)
616                                 (assoc 'to current)                                 (assoc 'to current)
617                                 (assoc 'subject current)                                 (assoc 'subject current)

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26