annotate lisp/mail/rmail-spam-filter.el @ 101661:26b8d12cf7a4

(rmail-reply): Handle empty folders.
author Glenn Morris <rgm@gnu.org>
date Fri, 30 Jan 2009 03:46:31 +0000
parents 5389a1f33e22
children d6de2e3c19e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
1 ;;; rmail-spam-filter.el --- spam filter for rmail, the emacs mail reader.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
2
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
4 ;; Free Software Foundation, Inc.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
5 ;; Keywords: email, spam, filter, rmail
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
6 ;; Author: Eli Tziperman <eli AT deas.harvard.edu>
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
7
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
9
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; (at your option) any later version.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
14
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
19
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94674
ef65fa4dca3b Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
22
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
23 ;;; Commentary:
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
24 ;;; -----------
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
25
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
26 ;;; Automatically recognize and delete junk email before it is
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
27 ;;; displayed in rmail/rmail-summary. Spam emails are defined by
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
28 ;;; specifying one or more of the sender, subject and contents.
54002
e712b82ead1a (vm-use-spam-filter)
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53730
diff changeset
29 ;;; URL: http://www.weizmann.ac.il/~eli/Downloads/rmail-spam-filter/
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
30
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
31 ;;; Usage:
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
32 ;;; ------
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
33
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
34 ;;; put in your .emacs:
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
35
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
36 ;;; (require 'rmail-spam-filter)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
37
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
38 ;;; and use customize (in rmail-spam-filter group) to:
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
39
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
40 ;;; (*) turn on the variable rmail-use-spam-filter,
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
41
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
42 ;;; (*) specify in variable rsf-definitions-alist what sender,
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
43 ;;; subject and contents make an email be considered spam.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
44
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
45 ;;; in addition, you may:
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
46
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
47 ;;; (*) Block future mail with the subject or sender of a message
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
48 ;;; while reading it in RMAIL: just click on the "Spam" item on the
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
49 ;;; menubar, and add the subject or sender to the list of spam
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
50 ;;; definitions using the mouse and the appropriate menu item. You
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
51 ;;; need to later also save the list of spam definitions using the
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
52 ;;; same menu item, or alternatively, see variable
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
53 ;;; `rsf-autosave-newly-added-definitions'.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
54
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
55 ;;; (*) specify if blind-cc'ed mail (no "To:" header field) is to be
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
56 ;;; treated as spam (variable rsf-no-blind-cc; Thanks to Ethan
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
57 ;;; Brown <ethan@gso.saic.com> for this).
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
58
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
59 ;;; (*) specify if rmail-spam-filter should ignore case of spam
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
60 ;;; definitions (variable rsf-ignore-case; Thanks to
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
61 ;;; Ethan Brown <ethan@gso.saic.com> for the suggestion).
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
62
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
63 ;;; (*) Specify a "white-list" of trusted senders. If any
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
64 ;;; rsf-white-list string matches a substring of the "From"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
65 ;;; header, the message is flagged as a valid, non-spam message (Ethan
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
66 ;;; Brown <ethan@gso.saic.com>).
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
67
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
68 ;;; (*) rmail-spam-filter is best used with a general purpose spam
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
69 ;;; filter such as the procmail-based http://www.spambouncer.org/.
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
70 ;;; Spambouncer is set to only mark messages as spam/blocked/bulk/OK
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
71 ;;; via special headers, and these headers may then be defined in
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
72 ;;; rmail-spam-filter such that the spam is rejected by
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
73 ;;; rmail-spam-filter itself.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
74
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
75 (require 'rmail)
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
76 (require 'rmailsum)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
77
65209
afdca0591e8c (bbdb/mail_auto_create_p, rmail-summary-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
78 (defvar rmail-summary-mode-map)
afdca0591e8c (bbdb/mail_auto_create_p, rmail-summary-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
79
53685
2d1c4cfccc4a Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 53665
diff changeset
80 (eval-when-compile
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
81 (require 'cl)) ; for setf
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
82
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
83 (defgroup rmail-spam-filter nil
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
84 "Spam filter for RMAIL, the mail reader for Emacs."
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
85 :group 'rmail)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
86
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
87 (defcustom rmail-use-spam-filter nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
88 "Non-nil to activate the rmail spam filter.
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
89 Specify `rsf-definitions-alist' to define what you consider spam
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
90 emails."
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
91 :type 'boolean
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
92 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
93
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
94 (defcustom rsf-file "~/XRMAIL-SPAM"
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
95 "Name of rmail file for optionally saving some of the spam.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
96 Spam may be either just deleted, or saved in a separate spam file to
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
97 be looked at at a later time. Whether the spam is just deleted or
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
98 also saved in a separete spam file is specified for each definition of
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
99 spam, as one of the fields of `rsf-definitions-alist'"
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
100 :type 'string
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
101 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
102
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
103 (defcustom rsf-no-blind-cc nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
104 "Non-nil to treat blind CC (no To: header) as spam."
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
105 :type 'boolean
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
106 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
107
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
108 (defcustom rsf-ignore-case nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
109 "Non-nil to ignore case in `rsf-definitions-alist'."
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
110 :type 'boolean
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
111 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
112
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
113 (defcustom rsf-beep nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
114 "Non-nil to beep if spam is found."
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
115 :type 'boolean
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
116 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
117
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
118 (defcustom rsf-sleep-after-message 2.0
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
119 "Seconds to wait after display of message that spam was found."
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
120 :type 'number
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
121 :group 'rmail-spam-filter )
53685
2d1c4cfccc4a Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 53665
diff changeset
122
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
123 (defcustom rsf-min-region-to-spam-list 7
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
124 "Minimum size of region that you can add to the spam list.
72643
27b1d7466c09 (rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
125 This is a size limit on text that you can specify as
27b1d7466c09 (rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
126 indicating a message is spam. The aim is to avoid
27b1d7466c09 (rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
127 accidentally adding a too short region, which would result
27b1d7466c09 (rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
128 in false positive identification of spam."
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
129 :type 'integer
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
130 :group 'rmail-spam-filter )
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
131
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
132 (defcustom rsf-autosave-newly-added-definitions nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
133 "Non-nil to auto save new spam entries.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
134 New entries entered via the spam menu bar item are then saved to
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
135 customization file immediately after being added via the menu bar, and
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
136 do not require explicitly saving the file after adding the new
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
137 entries."
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
138 :type 'boolean
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
139 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
140
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
141 (defcustom rsf-white-list nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
142 "List of strings to identify valid senders.
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
143 If any rsf-white-list string matches a substring of the 'From'
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
144 header, the message is flagged as a valid, non-spam message. Example:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
145 If your domain is emacs.com then including 'emacs.com' in your
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
146 rsf-white-list would flag all mail from your colleagues as
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
147 valid."
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
148 :type '(repeat string)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
149 :group 'rmail-spam-filter )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
150
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
151 (defcustom rsf-definitions-alist nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
152 "Alist matching strings defining what messages are considered spam.
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
153 Each definition may contain specifications of one or more of the
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
154 elements {subject, sender, recipients or contents}, as well as a
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
155 definition of what to do with the spam (action item). A spam e-mail
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
156 is defined as one that fits all of the specified elements of any one
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
157 of the spam definitions. The strings that specify spam subject,
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
158 sender, etc, may be regexp. For example, to specify that the subject
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
159 may be either 'this is spam' or 'another spam', use the regexp: 'this
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
160 is spam\\|another spam' (without the single quotes). To specify that
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
161 if the contents contain both this and that the message is spam,
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
162 specify 'this\\&that' in the appropriate spam definition field."
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
163 :type '(repeat
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
164 (list :format "%v"
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
165 (cons :format "%v" :value (from . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
166 (const :format "" from)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
167 (string :tag "From" ""))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
168 (cons :format "%v" :value (to . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
169 (const :format "" to)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
170 (string :tag "To" ""))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
171 (cons :format "%v" :value (subject . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
172 (const :format "" subject)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
173 (string :tag "Subject" ""))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
174 (cons :format "%v" :value (content-type . "")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
175 (const :format "" content-type)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
176 (string :tag "Content-Type" ""))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
177 (cons :format "%v" :value (contents . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
178 (const :format "" contents)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
179 (string :tag "Contents" ""))
91817
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
180 (cons :format "%v" :value (x-spam-status . "")
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
181 (const :format "" x-spam-status)
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
182 (string :tag "X-Spam-Status" ""))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
183 (cons :format "%v" :value (action . output-and-delete)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
184 (const :format "" action)
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
185 (choice :tag "Action selection"
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
186 (const :tag "output to spam folder and delete" output-and-delete)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
187 (const :tag "delete spam" delete-spam)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
188 ))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
189 ))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
190 :group 'rmail-spam-filter)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
191
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
192 ;; FIXME nothing uses this.
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
193 (defvar rsf-scanning-messages-now nil
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
194 "Non-nil when `rmail-spam-filter' scans messages.")
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
195
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
196 ;; the advantage over the automatic filter definitions is the AND conjunction
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
197 ;; of in-one-definition-elements
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
198 (defun rsf-check-field (field-symbol message-data definition result)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
199 "Check if field-symbol is in `rsf-definitions-alist'.
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
200 Capture maybe-spam and this-is-a-spam-email in a cons in result,
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
201 where maybe-spam is in the car and this-is-a-spam-email is in the cdr.
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
202 The values are returned by destructively changing result.
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
203 If FIELD-SYMBOL field does not exist AND is not specified,
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
204 this may still be spam due to another element...
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
205 if (car result) is nil, we already have a contradiction in another
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
206 field"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
207 (let ((definition-field (cdr (assoc field-symbol definition))))
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
208 (if (and (car result) (> (length definition-field) 0))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
209 ;; only in this case can maybe-spam change from t to nil
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
210 ;; ... else, if FIELD-SYMBOL field does appear in the message,
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
211 ;; and it also appears in spam definition list, this
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
212 ;; is potentially a spam:
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
213 (if (and message-data
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
214 (string-match definition-field message-data))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
215 ;; if we do not get a contradiction from another field, this is
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
216 ;; spam
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
217 (setf (cdr result) t)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
218 ;; the message data contradicts the specification, this is no spam
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
219 (setf (car result) nil)))))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
220
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
221 (defun rmail-spam-filter (msg)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
222 "Return nil if msg is spam based on rsf-definitions-alist.
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
223 If spam, optionally output msg to a file `rsf-file' and delete
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
224 it from rmail file. Called for each new message retrieved by
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
225 `rmail-get-new-mail'."
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
226
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
227 (let ((old-message)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
228 (return-value)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
229 (this-is-a-spam-email)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
230 (maybe-spam)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
231 (message-sender)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
232 (message-recipients)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
233 (message-subject)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
234 (message-content-type)
91846
5c746b9a3869 (rmail-spam-filter): Let-bind message-spam-status.
Glenn Morris <rgm@gnu.org>
parents: 91817
diff changeset
235 (message-spam-status)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
236 (num-spam-definition-elements)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
237 (num-element 0)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
238 (exit-while-loop nil)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
239 (saved-case-fold-search case-fold-search)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
240 (save-current-msg)
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
241 ;; make sure bbdb does not create entries for messages while spam
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
242 ;; filter is scanning the rmail file:
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
243 (bbdb/mail_auto_create_p nil)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
244 )
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
245
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
246 ;; Other things may wish to know if we are running (nothing uses
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
247 ;; this at present).
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
248 (setq rsf-scanning-messages-now t)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
249 (save-excursion
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
250 (save-restriction
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
251 (setq this-is-a-spam-email nil)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
252 ;; Narrow buffer to header of message and get Sender and
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
253 ;; Subject fields to be used below:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
254 (save-restriction
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
255 (goto-char (rmail-msgbeg msg))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
256 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
257 (setq message-sender (mail-fetch-field "From"))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
258 (setq message-recipients
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
259 (concat (mail-fetch-field "To")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
260 (if (mail-fetch-field "Cc")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
261 (concat ", " (mail-fetch-field "Cc")))))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
262 (setq message-subject (mail-fetch-field "Subject"))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
263 (setq message-content-type (mail-fetch-field "Content-Type"))
91817
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
264 (setq message-spam-status (mail-fetch-field "X-Spam-Status"))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
265 )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
266 ;; Find number of spam-definition elements in the list
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
267 ;; rsf-definitions-alist specified by user:
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
268 (setq num-spam-definition-elements (safe-length
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
269 rsf-definitions-alist))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
270
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
271 ;;; do we want to ignore case in spam definitions:
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
272 (setq case-fold-search rsf-ignore-case)
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
273
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
274 ;; Check for blind CC condition. Set vars such that while
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
275 ;; loop will be bypassed and spam condition will trigger
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
276 (if (and rsf-no-blind-cc
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
277 (null message-recipients))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
278 (setq exit-while-loop t
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
279 maybe-spam t
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
280 this-is-a-spam-email t))
53685
2d1c4cfccc4a Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 53665
diff changeset
281
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
282 ;; Check white list, and likewise cause while loop
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
283 ;; bypass.
58182
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
284 (if (and message-sender
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
285 (let ((white-list rsf-white-list)
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
286 (found nil))
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
287 (while (and (not found) white-list)
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
288 (if (string-match (car white-list) message-sender)
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
289 (setq found t)
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
290 (setq white-list (cdr white-list))))
875255640d7a (rmail-spam-filter): Only check white list if `message-sender' is non-nil.
Eli Zaretskii <eliz@gnu.org>
parents: 54018
diff changeset
291 found))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
292 (setq exit-while-loop t
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
293 maybe-spam nil
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
294 this-is-a-spam-email nil))
53685
2d1c4cfccc4a Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 53665
diff changeset
295
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
296 ;; maybe-spam is in the car, this-is-a-spam-email in cdr, this
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
297 ;; simplifies the call to rsf-check-field
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
298 (setq maybe-spam (cons maybe-spam this-is-a-spam-email))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
299
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
300 ;; scan all elements of the list rsf-definitions-alist
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
301 (while (and
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
302 (< num-element num-spam-definition-elements)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
303 (not exit-while-loop))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
304 (let ((definition (nth num-element rsf-definitions-alist)))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
305 ;; Initialize maybe-spam which is set to t in one of two
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
306 ;; cases: (1) unspecified definition-elements are found in
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
307 ;; rsf-definitions-alist, (2) empty field is found
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
308 ;; in the message being scanned (e.g. empty subject,
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
309 ;; sender, recipients, etc). The variable is set to nil
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
310 ;; if a non empty field of the scanned message does not
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
311 ;; match a specified field in
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
312 ;; rsf-definitions-alist.
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
313
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
314 ;; initialize this-is-a-spam-email to nil. This variable
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
315 ;; is set to t if one of the spam definitions matches a
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
316 ;; field in the scanned message.
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
317 (setq maybe-spam (cons t nil))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
318
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
319 ;; start scanning incoming message:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
320 ;;---------------------------------
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
321
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
322 ;; Maybe the different fields should also be done in a
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
323 ;; loop to make the whole thing more flexible
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
324 ;; if sender field is not specified in message being
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
325 ;; scanned, AND if "from" field does not appear in spam
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
326 ;; definitions for this element, this may still be spam
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
327 ;; due to another element...
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
328 (rsf-check-field 'from message-sender definition maybe-spam)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
329 ;; next, if spam was not ruled out already, check recipients:
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
330 (rsf-check-field 'to message-recipients definition maybe-spam)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
331 ;; next, if spam was not ruled out already, check subject:
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
332 (rsf-check-field 'subject message-subject definition maybe-spam)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
333 ;; next, if spam was not ruled out already, check content-type:
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
334 (rsf-check-field 'content-type message-content-type
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
335 definition maybe-spam)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
336 ;; next, if spam was not ruled out already, check
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
337 ;; contents: if contents field is not specified, this may
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
338 ;; still be spam due to another element...
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
339 (rsf-check-field 'contents
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
340 (buffer-substring
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
341 (rmail-msgbeg msg) (rmail-msgend msg))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
342 definition maybe-spam)
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
343
91817
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
344 ;; finally, check the X-Spam-Status header. You will typically
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
345 ;; look for the "Yes" string in this header field
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
346 (rsf-check-field 'x-spam-status message-spam-status
91817
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
347 definition maybe-spam)
f0b22bbb77fb ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents: 79712
diff changeset
348
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
349 ;; if the search in rsf-definitions-alist found
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
350 ;; that this email is spam, output the email to the spam
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
351 ;; rmail file, mark the email for deletion, leave the
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
352 ;; while loop and return nil so that an rmail summary line
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
353 ;; wont be displayed for this message:
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
354 (if (and (car maybe-spam) (cdr maybe-spam))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
355 ;; found that this is spam, no need to look at the
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
356 ;; rest of the rsf-definitions-alist, exit
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
357 ;; loop:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
358 (setq exit-while-loop t)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
359 ;; else, spam was not yet found, increment number of
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
360 ;; element in rsf-definitions-alist and proceed
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
361 ;; to next element:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
362 (setq num-element (+ num-element 1)))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
363 )
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
364 )
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
365
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
366 ;; (BK) re-set originally used variables
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
367 (setq this-is-a-spam-email (cdr maybe-spam)
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
368 maybe-spam (car maybe-spam))
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
369
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
370 (if (and this-is-a-spam-email maybe-spam)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
371 (progn
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
372 ;;(message "Found spam!")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
373 ;;(ding 1) (sleep-for 2)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
374
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
375 ;; temprarily set rmail-current-message in order to
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
376 ;; output and delete the spam msg if needed:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
377 (setq save-current-msg rmail-current-message)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
378 (setq rmail-current-message msg)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
379 ;; check action item and rsf-definitions-alist
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
380 ;; and do it:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
381 (cond
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
382 ((equal (cdr (assoc 'action
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
383 (nth num-element rsf-definitions-alist)))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
384 'output-and-delete)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
385 (progn
101540
5389a1f33e22 Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
386 (rmail-output rsf-file)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
387 ;; Don't delete if automatic deletion after output
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
388 ;; is turned on
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
389 (unless rmail-delete-after-output (rmail-delete-message))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
390 ))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
391 ((equal (cdr (assoc 'action
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
392 (nth num-element rsf-definitions-alist)))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
393 'delete-spam)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
394 (progn
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
395 (rmail-delete-message)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
396 ))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
397 )
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
398 (setq rmail-current-message save-current-msg)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
399 ;; set return value. These lines must be last in the
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
400 ;; function, so that they will determine the value
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
401 ;; returned by rmail-spam-filter:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
402 (setq return-value nil))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
403 (setq return-value t))))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
404 (setq case-fold-search saved-case-fold-search)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
405 (setq rsf-scanning-messages-now nil)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
406 return-value))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
407
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
408
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
409 ;; define functions for interactively adding sender/subject of a
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
410 ;; specific message to the spam definitions while reading it, using
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
411 ;; the menubar:
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
412 (defun rsf-add-subject-to-spam-list ()
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
413 (interactive)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
414 (set-buffer rmail-buffer)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
415 (let ((message-subject))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
416 (setq message-subject (mail-fetch-field "Subject"))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
417 ;; note the use of a backquote and comma on the subject line here,
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
418 ;; to make sure message-subject is actually evaluated and its value
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
419 ;; substituted:
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
420 (add-to-list 'rsf-definitions-alist
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
421 (list '(from . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
422 '(to . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
423 `(subject . ,message-subject)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
424 '(content-type . "")
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
425 '(contents . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
426 '(action . output-and-delete))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
427 t)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
428 (customize-mark-to-save 'rsf-definitions-alist)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
429 (if rsf-autosave-newly-added-definitions
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
430 (progn
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
431 (custom-save-all)
65587
4e6c5e8ae4e9 Message format spec fixes (commit 6)
Deepak Goel <deego@gnufans.org>
parents: 65209
diff changeset
432 (message "%s" (concat "added subject \n <<< \n" message-subject
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
433 " \n >>> \n to list of spam definitions. \n"
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
434 "and saved the spam definitions to file.")))
65587
4e6c5e8ae4e9 Message format spec fixes (commit 6)
Deepak Goel <deego@gnufans.org>
parents: 65209
diff changeset
435 (message "%s" (concat "added subject \n <<< \n" message-subject
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
436 " \n >>> \n to list of spam definitions. \n"
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
437 "Don't forget to save the spam definitions to file using the spam
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
438 menu"))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
439 )))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
440
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
441 (defun rsf-add-sender-to-spam-list ()
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
442 (interactive)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
443 (set-buffer rmail-buffer)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
444 (let ((message-sender))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
445 (setq message-sender (mail-fetch-field "From"))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
446 ;; note the use of a backquote and comma on the "from" line here,
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
447 ;; to make sure message-sender is actually evaluated and its value
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
448 ;; substituted:
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
449 (add-to-list 'rsf-definitions-alist
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
450 (list `(from . ,message-sender)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
451 '(to . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
452 '(subject . "")
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
453 '(content-type . "")
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
454 '(contents . "")
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
455 '(action . output-and-delete))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
456 t)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
457 (customize-mark-to-save 'rsf-definitions-alist)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
458 (if rsf-autosave-newly-added-definitions
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
459 (progn
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
460 (custom-save-all)
65587
4e6c5e8ae4e9 Message format spec fixes (commit 6)
Deepak Goel <deego@gnufans.org>
parents: 65209
diff changeset
461 (message "%s" (concat "added sender \n <<< \n" message-sender
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
462 " \n >>> \n to list of spam definitions. \n"
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
463 "and saved the spam definitions to file.")))
65587
4e6c5e8ae4e9 Message format spec fixes (commit 6)
Deepak Goel <deego@gnufans.org>
parents: 65209
diff changeset
464 (message "%s" (concat "added sender \n <<< \n " message-sender
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
465 " \n >>> \n to list of spam definitions."
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
466 "Don't forget to save the spam definitions to file using the spam
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
467 menu"))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
468 )))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
469
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
470
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
471 (defun rsf-add-region-to-spam-list ()
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
472 "Add the region makred by user in the rmail buffer to spam list.
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
473 Added to spam definitions as a contents field."
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
474 (interactive)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
475 (set-buffer rmail-buffer)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
476 (let ((region-to-spam-list))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
477 ;; check if region is inactive or has zero size:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
478 (if (not (and mark-active (not (= (region-beginning) (region-end)))))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
479 ;; if inactive, print error message:
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
480 (message "you need to first highlight some text in the rmail buffer")
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
481 (if (< (- (region-end) (region-beginning)) rsf-min-region-to-spam-list)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
482 (message
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
483 (concat "highlighted region is too small; min length set by variable \n"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
484 "rsf-min-region-to-spam-list"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
485 " is " (number-to-string rsf-min-region-to-spam-list)))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
486 ;; if region active and long enough, add to list of spam definisions:
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
487 (progn
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
488 (setq region-to-spam-list (buffer-substring (region-beginning) (region-end)))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
489 ;; note the use of a backquote and comma on the "from" line here,
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
490 ;; to make sure message-sender is actually evaluated and its value
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
491 ;; substituted:
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
492 (add-to-list 'rsf-definitions-alist
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
493 (list '(from . "")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
494 '(to . "")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
495 '(subject . "")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
496 '(content-type . "")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
497 `(contents . ,region-to-spam-list)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
498 '(action . output-and-delete))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
499 t)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
500 (customize-mark-to-save 'rsf-definitions-alist)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
501 (if rsf-autosave-newly-added-definitions
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
502 (progn
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
503 (custom-save-all)
65587
4e6c5e8ae4e9 Message format spec fixes (commit 6)
Deepak Goel <deego@gnufans.org>
parents: 65209
diff changeset
504 (message "%s" (concat "added highlighted text \n <<< \n" region-to-spam-list
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
505 " \n >>> \n to list of spam definitions. \n"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
506 "and saved the spam definitions to file.")))
65587
4e6c5e8ae4e9 Message format spec fixes (commit 6)
Deepak Goel <deego@gnufans.org>
parents: 65209
diff changeset
507 (message "%s" (concat "added highlighted text \n <<< \n " region-to-spam-list
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
508 " \n >>> \n to list of spam definitions."
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
509 "Don't forget to save the spam definitions to file using the
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
510 spam menu"))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
511 ))))))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
512
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
513
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
514 (defun rsf-customize-spam-definitions ()
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
515 (interactive)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
516 (customize-variable (quote rsf-definitions-alist)))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
517
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
518 (defun rsf-customize-group ()
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
519 (interactive)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
520 (customize-group (quote rmail-spam-filter)))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
521
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
522 (defun rsf-custom-save-all ()
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
523 (interactive)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
524 (custom-save-all))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
525
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
526 ;; add the actual menu items and keyboard shortcuts to both rmail and
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
527 ;; rmail-summary menu-bars::
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
528 (define-key rmail-summary-mode-map [menu-bar spam]
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
529 (cons "Spam" (make-sparse-keymap "Spam")))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
530 (define-key rmail-mode-map [menu-bar spam]
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
531 (cons "Spam" (make-sparse-keymap "Spam")))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
532
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
533 (define-key rmail-summary-mode-map [menu-bar spam customize-group]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
534 '("Browse customizations of rmail spam filter" . rsf-customize-group))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
535 (define-key rmail-mode-map [menu-bar spam customize-group]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
536 '("Browse customizations of rmail spam filter" . rsf-customize-group))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
537 (define-key rmail-summary-mode-map "\C-cSg" 'rsf-customize-group)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
538 (define-key rmail-mode-map "\C-cSg" 'rsf-customize-group)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
539
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
540 (define-key rmail-summary-mode-map [menu-bar spam customize-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
541 '("Customize list of spam definitions" . rsf-customize-spam-definitions))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
542 (define-key rmail-mode-map [menu-bar spam customize-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
543 '("Customize list of spam definitions" . rsf-customize-spam-definitions))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
544 (define-key rmail-summary-mode-map "\C-cSd" 'rsf-customize-spam-definitions)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
545 (define-key rmail-mode-map "\C-cSd" 'rsf-customize-spam-definitions)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
546
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
547 (define-key rmail-summary-mode-map [menu-bar spam lambda] '("----"))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
548 (define-key rmail-mode-map [menu-bar spam lambda] '("----"))
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
549
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
550 (define-key rmail-summary-mode-map [menu-bar spam my-custom-save-all]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
551 '("save newly added spam definitions to customization file" . rsf-custom-save-all))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
552 (define-key rmail-mode-map [menu-bar spam my-custom-save-all]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
553 '("save newly added spam definitions to customization file" . rsf-custom-save-all))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
554 (define-key rmail-summary-mode-map "\C-cSa" 'rsf-custom-save-all)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
555 (define-key rmail-mode-map "\C-cSa" 'rsf-custom-save-all)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
556
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
557 (define-key rmail-summary-mode-map [menu-bar spam add-region-to-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
558 '("add region to spam list" . rsf-add-region-to-spam-list))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
559 (define-key rmail-mode-map [menu-bar spam add-region-to-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
560 '("add region to spam list" . rsf-add-region-to-spam-list))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
561 (define-key rmail-summary-mode-map "\C-cSn" 'rsf-add-region-to-spam-list)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
562 (define-key rmail-mode-map "\C-cSn" 'rsf-add-region-to-spam-list)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
563
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
564 (define-key rmail-summary-mode-map [menu-bar spam add-sender-to-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
565 '("add sender to spam list" . rsf-add-sender-to-spam-list))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
566 (define-key rmail-mode-map [menu-bar spam add-sender-to-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
567 '("add sender to spam list" . rsf-add-sender-to-spam-list))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
568 (define-key rmail-summary-mode-map "\C-cSr" 'rsf-add-sender-to-spam-list)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
569 (define-key rmail-mode-map "\C-cSr" 'rsf-add-sender-to-spam-list)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
570
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
571 (define-key rmail-summary-mode-map [menu-bar spam add-subject-to-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
572 '("add subject to spam list" . rsf-add-subject-to-spam-list))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
573 (define-key rmail-mode-map [menu-bar spam add-subject-to-spam-list]
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
574 '("add subject to spam list" . rsf-add-subject-to-spam-list))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
575 (define-key rmail-summary-mode-map "\C-cSt" 'rsf-add-subject-to-spam-list)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
576 (define-key rmail-mode-map "\C-cSt" 'rsf-add-subject-to-spam-list)
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
577
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
578 (defun rsf-add-content-type-field ()
72643
27b1d7466c09 (rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
579 "Maintain backward compatibility for `rmail-spam-filter'.
27b1d7466c09 (rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
580 The most recent version of `rmail-spam-filter' checks the contents
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
581 field of the incoming mail to see if it spam. The format of
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
582 `rsf-definitions-alist' has therefore changed. This function
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
583 checks to see if old format is used, and if it is, it converts
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
584 `rsf-definitions-alist' to the new format. Invoked
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
585 automatically, no user input is required."
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
586 (interactive)
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
587 (if (and rsf-definitions-alist
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
588 (not (assoc 'content-type (car rsf-definitions-alist))))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
589 (let ((result nil)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
590 (current nil)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
591 (definitions rsf-definitions-alist))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
592 (while definitions
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
593 (setq current (car definitions))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
594 (setq definitions (cdr definitions))
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
595 (setq result
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
596 (append result
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
597 (list
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
598 (list (assoc 'from current)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
599 (assoc 'to current)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
600 (assoc 'subject current)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
601 (cons 'content-type "")
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
602 (assoc 'contents current)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
603 (assoc 'action current))))))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
604 (setq rsf-definitions-alist result)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
605 (customize-mark-to-save 'rsf-definitions-alist)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
606 (if rsf-autosave-newly-added-definitions
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
607 (progn
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
608 (custom-save-all)
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
609 (message (concat "converted spam definitions to new format\n"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
610 "and saved the spam definitions to file.")))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
611 (message (concat "converted spam definitions to new format\n"
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
612 "Don't forget to save the spam definitions to file using the
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
613 spam menu"))
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
614 ))))
49862
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
615
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
616 (provide 'rmail-spam-filter)
22e7cf92fa43 Initial commit to the trunk.
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
617
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91846
diff changeset
618 ;; arch-tag: 03e1d45d-b72f-4dd7-8f04-e7fd78249746
53730
2a4fc5c14ddd Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents: 53685
diff changeset
619 ;;; rmail-spam-fitler ends here