Commit 2528f9c4 authored by Thien-Thi Nguyen's avatar Thien-Thi Nguyen

Use two semicolons as Commentary line prefix.

Add ";;; Code:" stylized comment.
Delete end-of-line whitespace.
Wrap (require 'cl) with `eval-when-compile'.
parent 414f7d4e
2004-01-24 Thien-Thi Nguyen <ttn@gnu.org>
* mail/rmail-spam-filter.el:
Use two semicolons as Commentary line prefix.
Add ";;; Code:" stylized comment.
Delete end-of-line whitespace.
Wrap (require 'cl) with `eval-when-compile'.
2004-01-23 Benjamin Rutt <brutt@bloomington.in.us> 2004-01-23 Benjamin Rutt <brutt@bloomington.in.us>
* vc.el (vc-annotate): Fix improper use of `make-local-variable' * vc.el (vc-annotate): Fix improper use of `make-local-variable'
......
;;; rmail-spam-filter.el --- spam filter for rmail, the emacs mail reader. ;;; rmail-spam-filter.el --- spam filter for RMAIL
;; Copyright (C) 2002 ;; Copyright (C) 2002
;; Free Software Foundation, Inc. ;; Free Software Foundation, Inc.
;; Keywords: email, spam, filter, rmail ;; Keywords: email, spam, filter, rmail
;; Author: Eli Tziperman <eli@beach.weizmann.ac.il> ;; Author: Eli Tziperman <eli@beach.weizmann.ac.il>
...@@ -23,62 +23,64 @@ ...@@ -23,62 +23,64 @@
;; Boston, MA 02111-1307, USA. ;; Boston, MA 02111-1307, USA.
;;; Commentary: ;;; Commentary:
;;; -----------
;;; Automatically recognize and delete junk email before it is ;; Automatically recognize and delete junk email before it is
;;; displayed in rmail/rmail-summary. Spam emails are defined by ;; displayed in rmail/rmail-summary. Spam emails are defined by
;;; specifying one or more of the sender, subject and contents. ;; specifying one or more of the sender, subject and contents.
;;; URL: http://www.weizmann.ac.il/~eli/Downloads/rmail-spam-filter/ ;; URL: http://www.weizmann.ac.il/~eli/Downloads/rmail-spam-filter/
;;; Usage: ;; Usage:
;;; ------ ;; ------
;;; put in your .emacs: ;; put in your .emacs:
;;; (load "rmail-spam-filter.el") ;; (load "rmail-spam-filter.el")
;;; and use customize (in rmail-spam-filter group) to: ;; and use customize (in rmail-spam-filter group) to:
;;; (*) turn on the variable rmail-use-spam-filter, ;; (*) turn on the variable rmail-use-spam-filter,
;;; (*) specify in variable rmail-spam-definitions-alist what sender, ;; (*) specify in variable rmail-spam-definitions-alist what sender,
;;; subject and contents make an email be considered spam. ;; subject and contents make an email be considered spam.
;;; in addition, you may: ;; in addition, you may:
;;; (*) Block future mail with the subject or sender of a message ;; (*) Block future mail with the subject or sender of a message
;;; while reading it in RMAIL: just click on the "Spam" item on the ;; while reading it in RMAIL: just click on the "Spam" item on the
;;; menubar, and add the subject or sender to the list of spam ;; menubar, and add the subject or sender to the list of spam
;;; definitions using the mouse and the appropriate menu item. Â  You ;; definitions using the mouse and the appropriate menu item. Â  You
;;; need to later also save the list of spam definitions using the ;; need to later also save the list of spam definitions using the
;;; same menu item, or alternatively, see variable ;; same menu item, or alternatively, see variable
;;; `rmail-spam-filter-autosave-newly-added-spam-definitions'. ;; `rmail-spam-filter-autosave-newly-added-spam-definitions'.
;;; (*) specify if blind-cc'ed mail (no "To:" header field) is to be ;; (*) specify if blind-cc'ed mail (no "To:" header field) is to be
;;; treated as spam (variable rmail-spam-no-blind-cc; Thanks to Ethan ;; treated as spam (variable rmail-spam-no-blind-cc; Thanks to Ethan
;;; Brown <ethan@gso.saic.com> for this). ;; Brown <ethan@gso.saic.com> for this).
;;; (*) specify if rmail-spam-filter should ignore case of spam ;; (*) specify if rmail-spam-filter should ignore case of spam
;;; definitions (variable rmail-spam-filter-ignore-case; Thanks to ;; definitions (variable rmail-spam-filter-ignore-case; Thanks to
;;; Ethan Brown <ethan@gso.saic.com> for the suggestion). ;; Ethan Brown <ethan@gso.saic.com> for the suggestion).
;;; (*) Specify a "white-list" of trusted senders. If any ;; (*) Specify a "white-list" of trusted senders. If any
;;; rmail-spam-white-list string matches a substring of the "From" ;; rmail-spam-white-list string matches a substring of the "From"
;;; header, the message is flagged as a valid, non-spam message (Ethan ;; header, the message is flagged as a valid, non-spam message (Ethan
;;; Brown <ethan@gso.saic.com>). ;; Brown <ethan@gso.saic.com>).
;;; (*) rmail spam filter also works with bbdb to prevent spam senders ;; (*) rmail spam filter also works with bbdb to prevent spam senders
;;; from entering into the .bbdb file. See variable ;; from entering into the .bbdb file. See variable
;;; "rmail-spam-filter-auto-delete-spam-bbdb-entries". This is done ;; "rmail-spam-filter-auto-delete-spam-bbdb-entries". This is done
;;; in two ways: (a) bbdb is made not to auto-create entries for ;; in two ways: (a) bbdb is made not to auto-create entries for
;;; messages that are deleted by the rmail-spam-filter, (b) when a ;; messages that are deleted by the rmail-spam-filter, (b) when a
;;; message is deleted in rmail, the user is offered to delete the ;; message is deleted in rmail, the user is offered to delete the
;;; sender's bbdb entry as well _if_ it was created at the same day. ;; sender's bbdb entry as well _if_ it was created at the same day.
;;; Code:
(require 'rmail) (require 'rmail)
;; For find-if and other cool common lisp functions we may want to use. (EDB) ;; For find-if and other cool common lisp functions we may want to use. (EDB)
(require 'cl) (eval-when-compile
(require 'cl))
(defgroup rmail-spam-filter nil (defgroup rmail-spam-filter nil
"Spam filter for RMAIL, the mail reader for Emacs." "Spam filter for RMAIL, the mail reader for Emacs."
...@@ -120,7 +122,7 @@ spam, as one of the fields of `rmail-spam-definitions-alist'" ...@@ -120,7 +122,7 @@ spam, as one of the fields of `rmail-spam-definitions-alist'"
"*Seconds to wait after display of message that spam was found." "*Seconds to wait after display of message that spam was found."
:type 'number :type 'number
:group 'rmail-spam-filter ) :group 'rmail-spam-filter )
(defcustom rmail-spam-filter-auto-delete-spam-bbdb-entries nil (defcustom rmail-spam-filter-auto-delete-spam-bbdb-entries nil
"*Non-nil to make sure no entries are made in bbdb for spam emails. "*Non-nil to make sure no entries are made in bbdb for spam emails.
This is done in two ways: (1) bbdb is made not to auto-create entries This is done in two ways: (1) bbdb is made not to auto-create entries
...@@ -161,7 +163,7 @@ of the spam definitions. The strings that specify spam subject, ...@@ -161,7 +163,7 @@ of the spam definitions. The strings that specify spam subject,
sender, etc, may be regexp. For example, to specify that the subject sender, etc, may be regexp. For example, to specify that the subject
may be either 'this is spam' or 'another spam', use the regexp: 'this may be either 'this is spam' or 'another spam', use the regexp: 'this
is spam\|another spam' (without the single quotes)." is spam\|another spam' (without the single quotes)."
:type '(repeat :type '(repeat
(list :format "%v" (list :format "%v"
(cons :format "%v" :value (from . "") (cons :format "%v" :value (from . "")
(const :format "" from) (const :format "" from)
...@@ -177,7 +179,7 @@ is spam\|another spam' (without the single quotes)." ...@@ -177,7 +179,7 @@ is spam\|another spam' (without the single quotes)."
(string :tag "Contents" "")) (string :tag "Contents" ""))
(cons :format "%v" :value (action . output-and-delete) (cons :format "%v" :value (action . output-and-delete)
(const :format "" action) (const :format "" action)
(choice :tag "Action selection" (choice :tag "Action selection"
(const :tag "output to spam folder and delete" output-and-delete) (const :tag "output to spam folder and delete" output-and-delete)
(const :tag "delete spam" delete-spam) (const :tag "delete spam" delete-spam)
)) ))
...@@ -208,7 +210,7 @@ it from rmail file. Called for each new message retrieved by ...@@ -208,7 +210,7 @@ it from rmail file. Called for each new message retrieved by
(save-current-msg) (save-current-msg)
(rmail-spam-filter-saved-bbdb/mail_auto_create_p nil) (rmail-spam-filter-saved-bbdb/mail_auto_create_p nil)
) )
;; make sure bbdb does not create entries for messages while spam ;; make sure bbdb does not create entries for messages while spam
;; filter is scanning the rmail file: ;; filter is scanning the rmail file:
(setq rmail-spam-filter-saved-bbdb/mail_auto_create_p 'bbdb/mail_auto_create_p) (setq rmail-spam-filter-saved-bbdb/mail_auto_create_p 'bbdb/mail_auto_create_p)
...@@ -236,7 +238,7 @@ it from rmail file. Called for each new message retrieved by ...@@ -236,7 +238,7 @@ it from rmail file. Called for each new message retrieved by
;;; do we want to ignore case in spam definitions: ;;; do we want to ignore case in spam definitions:
(setq case-fold-search rmail-spam-filter-ignore-case) (setq case-fold-search rmail-spam-filter-ignore-case)
;; Check for blind CC condition. Set vars such that while ;; Check for blind CC condition. Set vars such that while
;; loop will be bypassed and spam condition will trigger (EDB) ;; loop will be bypassed and spam condition will trigger (EDB)
(if (and rmail-spam-no-blind-cc (if (and rmail-spam-no-blind-cc
...@@ -245,7 +247,7 @@ it from rmail file. Called for each new message retrieved by ...@@ -245,7 +247,7 @@ it from rmail file. Called for each new message retrieved by
(setq exit-while-loop t) (setq exit-while-loop t)
(setq maybe-spam t) (setq maybe-spam t)
(setq this-is-a-spam-email t))) (setq this-is-a-spam-email t)))
;; Check white list, and likewise cause while loop ;; Check white list, and likewise cause while loop
;; bypass. (EDB) ;; bypass. (EDB)
(if (find-if '(lambda (white-str) (if (find-if '(lambda (white-str)
...@@ -255,7 +257,7 @@ it from rmail file. Called for each new message retrieved by ...@@ -255,7 +257,7 @@ it from rmail file. Called for each new message retrieved by
(setq exit-while-loop t) (setq exit-while-loop t)
(setq maybe-spam nil) (setq maybe-spam nil)
(setq this-is-a-spam-email nil))) (setq this-is-a-spam-email nil)))
;; scan all elements of the list rmail-spam-definitions-alist ;; scan all elements of the list rmail-spam-definitions-alist
(while (and (while (and
(< num-element num-spam-definition-elements) (< num-element num-spam-definition-elements)
...@@ -277,7 +279,7 @@ it from rmail file. Called for each new message retrieved by ...@@ -277,7 +279,7 @@ it from rmail file. Called for each new message retrieved by
;; start scanning incoming message: ;; start scanning incoming message:
;;--------------------------------- ;;---------------------------------
;; if sender field is not specified in message being ;; if sender field is not specified in message being
;; scanned, AND if "from" field does not appear in spam ;; scanned, AND if "from" field does not appear in spam
;; definitions for this element, this may still be spam ;; definitions for this element, this may still be spam
...@@ -585,7 +587,7 @@ it from rmail file. Called for each new message retrieved by ...@@ -585,7 +587,7 @@ it from rmail file. Called for each new message retrieved by
(defun rmail-bbdb-auto-delete-spam-entries () (defun rmail-bbdb-auto-delete-spam-entries ()
"When deleting a message in RMAIL, check to see if the bbdb entry "When deleting a message in RMAIL, check to see if the bbdb entry
was created today, and if it was, prompt to delete it too. This function was created today, and if it was, prompt to delete it too. This function
needs to be called via the `rmail-delete-message-hook' like this: needs to be called via the `rmail-delete-message-hook' like this:
\(add-hook 'rmail-delete-message-hook 'rmail-bbdb-auto-delete-spam-entries)" \(add-hook 'rmail-delete-message-hook 'rmail-bbdb-auto-delete-spam-entries)"
(interactive) (interactive)
...@@ -604,14 +606,14 @@ needs to be called via the `rmail-delete-message-hook' like this: ...@@ -604,14 +606,14 @@ needs to be called via the `rmail-delete-message-hook' like this:
"Make sure senderes of rmail messages marked as deleted are not added to bbdb. "Make sure senderes of rmail messages marked as deleted are not added to bbdb.
Need to add this as a hook like this: Need to add this as a hook like this:
\(setq bbdb/mail-auto-create-p 'rmail-spam-filter-bbdb-dont-create-entries-for-spam) \(setq bbdb/mail-auto-create-p 'rmail-spam-filter-bbdb-dont-create-entries-for-spam)
and this is also used in conjunction with rmail-bbdb-auto-delete-spam-entries. and this is also used in conjunction with rmail-bbdb-auto-delete-spam-entries.
More doc: rmail-bbdb-auto-delete-spam-entries will delete newly created bbdb More doc: rmail-bbdb-auto-delete-spam-entries will delete newly created bbdb
entries of mail that is deleted. However, if one scrolls back to the deleted entries of mail that is deleted. However, if one scrolls back to the deleted
messages, then the sender is again added to the bbdb. This function messages, then the sender is again added to the bbdb. This function
prevents this. Also, don't create entries for messages in the `rmail-spam-file'." prevents this. Also, don't create entries for messages in the `rmail-spam-file'."
(interactive) (interactive)
(not (not
;; don't create a bbdb entry if one of the following conditions is satisfied: ;; don't create a bbdb entry if one of the following conditions is satisfied:
(or (or
;; 1) looking at a deleted message: ;; 1) looking at a deleted message:
(rmail-message-deleted-p rmail-current-message) (rmail-message-deleted-p rmail-current-message)
...@@ -631,4 +633,4 @@ prevents this. Also, don't create entries for messages in the `rmail-spam-file' ...@@ -631,4 +633,4 @@ prevents this. Also, don't create entries for messages in the `rmail-spam-file'
(provide 'rmail-spam-filter) (provide 'rmail-spam-filter)
;;; arch-tag: 03e1d45d-b72f-4dd7-8f04-e7fd78249746 ;;; arch-tag: 03e1d45d-b72f-4dd7-8f04-e7fd78249746
;;; rmail-spam-filter ends here ;;; rmail-spam-filter.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment