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