Mercurial > emacs
annotate lisp/mail/rmail-spam-filter.el @ 64812:0d6aa987778c
Replace `info' with upper-case `Info' where appropriate.
(info-title-1, info-title-2, info-title-3, info-title-4)
(info-menu-header): Move up face definitions.
(info-menu-star): Rename from `info-menu-5'.
(Info-fontify-node): Replace `info-menu-5' with `info-menu-star'.
(Info-fontify-visited-nodes): Fix docstring.
(Info-hide-note-references): Fix docstring.
(Info-up, Info-next-reference, Info-prev-reference): Put cursor on
menu items in the same way as on cross-references.
(info-apropos): Fix sorting order and formatting to be like in the
stand-alone Info browser. Display error messages for 1 sec.
(Info-mode-map): Move down `c' key binding. Bind `^' to `Info-up'.
(Info-mode-menu): Remove item for `Info-search-case-sensitively'
from the menu bar.
(Info-insert-dir): Restore point after calling `insert-buffer-substring'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 09 Aug 2005 08:43:02 +0000 |
parents | fafd692d1e40 |
children | afdca0591e8c 2d92f5c9d6ae |
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 |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 2002, 2003, 2004, 2005 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 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
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 | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64085 | 21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 ;; Boston, MA 02110-1301, USA. | |
49862 | 23 |
24 ;;; Commentary: | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
25 ;;; ----------- |
49862 | 26 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
27 ;;; 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
|
28 ;;; 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
|
29 ;;; specifying one or more of the sender, subject and contents. |
54002 | 30 ;;; URL: http://www.weizmann.ac.il/~eli/Downloads/rmail-spam-filter/ |
49862 | 31 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
32 ;;; Usage: |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
33 ;;; ------ |
49862 | 34 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
35 ;;; put in your .emacs: |
49862 | 36 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
37 ;;; (load "rmail-spam-filter.el") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
38 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
39 ;;; and use customize (in rmail-spam-filter group) to: |
49862 | 40 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
41 ;;; (*) turn on the variable rmail-use-spam-filter, |
49862 | 42 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
43 ;;; (*) 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
|
44 ;;; subject and contents make an email be considered spam. |
49862 | 45 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
46 ;;; in addition, you may: |
49862 | 47 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
48 ;;; (*) 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
|
49 ;;; 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
|
50 ;;; 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
|
51 ;;; 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
|
52 ;;; 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
|
53 ;;; 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
|
54 ;;; `rsf-autosave-newly-added-definitions'. |
49862 | 55 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
56 ;;; (*) 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
|
57 ;;; 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
|
58 ;;; 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
|
59 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
60 ;;; (*) 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
|
61 ;;; 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
|
62 ;;; Ethan Brown <ethan@gso.saic.com> for the suggestion). |
49862 | 63 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
64 ;;; (*) 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
|
65 ;;; 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
|
66 ;;; 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
|
67 ;;; Brown <ethan@gso.saic.com>). |
49862 | 68 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
69 ;;; (*) 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
|
70 ;;; 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
|
71 ;;; 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
|
72 ;;; 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
|
73 ;;; 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
|
74 ;;; rmail-spam-filter itself. |
49862 | 75 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
76 ;;; (*) 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
|
77 ;;; 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
|
78 ;;; "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
|
79 ;;; 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
|
80 ;;; 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
|
81 ;;; 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
|
82 ;;; sender's bbdb entry as well _if_ it was created at the same day. |
49862 | 83 |
84 (require 'rmail) | |
54002 | 85 (if (> emacs-major-version 20) |
86 (require 'rmailsum) | |
87 (if (not (fboundp 'rmail-make-summary-line)) (load-library "rmailsum"))) | |
49862 | 88 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
89 ;; 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
|
90 (eval-when-compile |
2d1c4cfccc4a
Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53665
diff
changeset
|
91 (require 'cl)) |
49862 | 92 |
93 (defgroup rmail-spam-filter nil | |
94 "Spam filter for RMAIL, the mail reader for Emacs." | |
95 :group 'rmail) | |
96 | |
97 (defcustom rmail-use-spam-filter nil | |
98 "*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
|
99 Specify `rsf-definitions-alist' to define what you consider spam |
49862 | 100 emails." |
101 :type 'boolean | |
102 :group 'rmail-spam-filter ) | |
103 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
104 (defcustom rsf-file "~/XRMAIL-SPAM" |
49862 | 105 "*Name of rmail file for optionally saving some of the spam. |
106 Spam may be either just deleted, or saved in a separate spam file to | |
107 be looked at at a later time. Whether the spam is just deleted or | |
108 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
|
109 spam, as one of the fields of `rsf-definitions-alist'" |
49862 | 110 :type 'string |
111 :group 'rmail-spam-filter ) | |
112 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
113 (defcustom rsf-no-blind-cc nil |
49862 | 114 "*Non-nil to treat blind CC (no To: header) as spam." |
115 :type 'boolean | |
116 :group 'rmail-spam-filter ) | |
117 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
118 (defcustom rsf-ignore-case nil |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
119 "*Non-nil to ignore case in `rsf-definitions-alist'." |
49862 | 120 :type 'boolean |
121 :group 'rmail-spam-filter ) | |
122 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
123 (defcustom rsf-beep nil |
49862 | 124 "*Non-nil to beep if spam is found." |
125 :type 'boolean | |
126 :group 'rmail-spam-filter ) | |
127 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
128 (defcustom rsf-sleep-after-message 2.0 |
49862 | 129 "*Seconds to wait after display of message that spam was found." |
130 :type 'number | |
131 :group 'rmail-spam-filter ) | |
53685
2d1c4cfccc4a
Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53665
diff
changeset
|
132 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
133 (defcustom rsf-min-region-to-spam-list 7 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
134 "*User may highlight a region in an incomming message and use |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
135 the menubar to add this region to the spam definitions. This |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
136 variable specifies the minimum size of region that may be added |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
137 to spam list, to avoid accidentally adding a too short region |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
138 which would result in false positive identification of spam |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
139 messages." |
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" "")) | |
202 (cons :format "%v" :value (action . output-and-delete) | |
203 (const :format "" action) | |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
204 (choice :tag "Action selection" |
49862 | 205 (const :tag "output to spam folder and delete" output-and-delete) |
206 (const :tag "delete spam" delete-spam) | |
207 )) | |
208 )) | |
209 :group 'rmail-spam-filter) | |
210 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
211 (defvar rsf-scanning-messages-now nil |
49862 | 212 "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
|
213 for interaction with `rsf-bbdb-auto-delete-spam-entries'") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
214 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
215 ;; 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
|
216 ;; of in-one-definition-elements |
54002 | 217 (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
|
218 "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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 field" |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
226 (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
|
227 (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
|
228 ;; 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
|
229 ;; ... 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
|
230 ;; 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
|
231 ;; is potentially a spam: |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
232 (if (and message-data |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
233 (string-match definition-field message-data)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
234 ;; 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
|
235 ;; spam |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
236 (setf (rest result) t) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
237 ;; 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
|
238 (setf (first result) nil))))) |
49862 | 239 |
240 (defun rmail-spam-filter (msg) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
241 "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
|
242 If spam, optionally output msg to a file `rsf-file' and delete |
49862 | 243 it from rmail file. Called for each new message retrieved by |
244 `rmail-get-new-mail'." | |
245 | |
246 (let ((old-message) | |
247 (return-value) | |
248 (this-is-a-spam-email) | |
249 (maybe-spam) | |
250 (message-sender) | |
251 (message-recipients) | |
252 (message-subject) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
253 (message-content-type) |
49862 | 254 (num-spam-definition-elements) |
255 (num-element 0) | |
256 (exit-while-loop nil) | |
257 (saved-case-fold-search case-fold-search) | |
258 (save-current-msg) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
259 (rsf-saved-bbdb/mail_auto_create_p nil) |
49862 | 260 ) |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
261 |
49862 | 262 ;; make sure bbdb does not create entries for messages while spam |
263 ;; 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
|
264 (setq rsf-saved-bbdb/mail_auto_create_p 'bbdb/mail_auto_create_p) |
49862 | 265 (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
|
266 ;; let `rsf-bbdb-auto-delete-spam-entries' know that rmail spam |
49862 | 267 ;; filter is running, so that deletion of rmail messages should be |
268 ;; ignored for now: | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
269 (setq rsf-scanning-messages-now t) |
49862 | 270 (save-excursion |
271 (save-restriction | |
272 (setq this-is-a-spam-email nil) | |
273 ;; Narrow buffer to header of message and get Sender and | |
274 ;; Subject fields to be used below: | |
275 (save-restriction | |
276 (goto-char (rmail-msgbeg msg)) | |
277 (narrow-to-region (point) (progn (search-forward "\n\n") (point))) | |
278 (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
|
279 (setq message-recipients |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
280 (concat (mail-fetch-field "To") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
281 (if (mail-fetch-field "Cc") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
282 (concat ", " (mail-fetch-field "Cc"))))) |
49862 | 283 (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
|
284 (setq message-content-type (mail-fetch-field "Content-Type")) |
49862 | 285 ) |
286 ;; 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
|
287 ;; rsf-definitions-alist specified by user: |
49862 | 288 (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
|
289 rsf-definitions-alist)) |
49862 | 290 |
291 ;;; 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
|
292 (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
|
293 |
49862 | 294 ;; 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
|
295 ;; 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
|
296 (if (and rsf-no-blind-cc |
49862 | 297 (null message-recipients)) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
298 (setq exit-while-loop t |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
299 maybe-spam t |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
300 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
|
301 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
302 ;; 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
|
303 ;; 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
|
304 (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
|
305 (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
|
306 (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
|
307 (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
|
308 (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
|
309 (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
|
310 (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
|
311 found)) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
312 (setq exit-while-loop t |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
313 maybe-spam nil |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
314 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
|
315 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
316 ;; maybe-spam is in first, this-is-a-spam-email in rest, this |
54002 | 317 ;; 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
|
318 (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
|
319 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
320 ;; scan all elements of the list rsf-definitions-alist |
49862 | 321 (while (and |
322 (< num-element num-spam-definition-elements) | |
323 (not exit-while-loop)) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
324 (let ((definition (nth num-element rsf-definitions-alist))) |
49862 | 325 ;; Initialize maybe-spam which is set to t in one of two |
326 ;; 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
|
327 ;; rsf-definitions-alist, (2) empty field is found |
49862 | 328 ;; in the message being scanned (e.g. empty subject, |
329 ;; sender, recipients, etc). The variable is set to nil | |
330 ;; if a non empty field of the scanned message does not | |
331 ;; match a specified field in | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
332 ;; rsf-definitions-alist. |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
333 |
49862 | 334 ;; initialize this-is-a-spam-email to nil. This variable |
335 ;; is set to t if one of the spam definitions matches a | |
336 ;; field in the scanned message. | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
337 (setq maybe-spam (cons t nil)) |
49862 | 338 |
339 ;; start scanning incoming message: | |
340 ;;--------------------------------- | |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
341 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
342 ;; 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
|
343 ;; 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
|
344 ;; if sender field is not specified in message being |
49862 | 345 ;; scanned, AND if "from" field does not appear in spam |
346 ;; definitions for this element, this may still be spam | |
347 ;; due to another element... | |
54002 | 348 (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
|
349 ;; next, if spam was not ruled out already, check recipients: |
54002 | 350 (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
|
351 ;; next, if spam was not ruled out already, check subject: |
54002 | 352 (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
|
353 ;; 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
|
354 (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
|
355 definition maybe-spam) |
49862 | 356 ;; next, if spam was not ruled out already, check |
357 ;; contents: if contents field is not specified, this may | |
358 ;; 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
|
359 (check-field 'contents |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
360 (buffer-substring |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
361 (rmail-msgbeg msg) (rmail-msgend msg)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
362 definition maybe-spam) |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
363 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
364 ;; if the search in rsf-definitions-alist found |
49862 | 365 ;; that this email is spam, output the email to the spam |
366 ;; rmail file, mark the email for deletion, leave the | |
367 ;; while loop and return nil so that an rmail summary line | |
368 ;; 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
|
369 (if (and (first maybe-spam) (rest maybe-spam)) |
49862 | 370 ;; 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
|
371 ;; rest of the rsf-definitions-alist, exit |
49862 | 372 ;; loop: |
373 (setq exit-while-loop t) | |
374 ;; 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
|
375 ;; element in rsf-definitions-alist and proceed |
49862 | 376 ;; to next element: |
377 (setq num-element (+ num-element 1))) | |
378 ) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
379 ) |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
380 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
381 ;; (BK) re-set originally used variables |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
382 (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
|
383 maybe-spam (first maybe-spam)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
384 |
49862 | 385 (if (and this-is-a-spam-email maybe-spam) |
386 (progn | |
387 ;;(message "Found spam!") | |
388 ;;(ding 1) (sleep-for 2) | |
389 | |
390 ;; temprarily set rmail-current-message in order to | |
391 ;; output and delete the spam msg if needed: | |
392 (setq save-current-msg rmail-current-message) | |
393 (setq rmail-current-message msg) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
394 ;; check action item and rsf-definitions-alist |
49862 | 395 ;; and do it: |
396 (cond | |
397 ((equal (cdr (assoc 'action | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
398 (nth num-element rsf-definitions-alist))) |
49862 | 399 'output-and-delete) |
400 (progn | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
401 (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
|
402 ;; 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
|
403 ;; is turned on |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
404 (unless rmail-delete-after-output (rmail-delete-message)) |
49862 | 405 )) |
406 ((equal (cdr (assoc 'action | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
407 (nth num-element rsf-definitions-alist))) |
49862 | 408 'delete-spam) |
409 (progn | |
410 (rmail-delete-message) | |
411 )) | |
412 ) | |
413 (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
|
414 (setq bbdb/mail_auto_create_p |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
415 'rsf-saved-bbdb/mail_auto_create_p) |
49862 | 416 ;; set return value. These lines must be last in the |
417 ;; function, so that they will determine the value | |
418 ;; returned by rmail-spam-filter: | |
419 (setq return-value nil)) | |
420 (setq return-value t)))) | |
421 (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
|
422 (setq rsf-scanning-messages-now nil) |
49862 | 423 return-value)) |
424 | |
425 | |
426 ;; define functions for interactively adding sender/subject of a | |
427 ;; specific message to the spam definitions while reading it, using | |
428 ;; the menubar: | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
429 (defun rsf-add-subject-to-spam-list () |
49862 | 430 (interactive) |
431 (set-buffer rmail-buffer) | |
432 (let ((message-subject)) | |
433 (setq message-subject (mail-fetch-field "Subject")) | |
434 ;; note the use of a backquote and comma on the subject line here, | |
435 ;; to make sure message-subject is actually evaluated and its value | |
436 ;; substituted: | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
437 (add-to-list 'rsf-definitions-alist |
49862 | 438 (list '(from . "") |
439 '(to . "") | |
440 `(subject . ,message-subject) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
441 '(content-type . "") |
49862 | 442 '(contents . "") |
443 '(action . output-and-delete)) | |
444 t) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
445 (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
|
446 (if rsf-autosave-newly-added-definitions |
49862 | 447 (progn |
448 (custom-save-all) | |
449 (message (concat "added subject \n <<< \n" message-subject | |
450 " \n >>> \n to list of spam definitions. \n" | |
451 "and saved the spam definitions to file."))) | |
452 (message (concat "added subject \n <<< \n" message-subject | |
453 " \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
|
454 "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
|
455 menu")) |
49862 | 456 ))) |
457 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
458 (defun rsf-add-sender-to-spam-list () |
49862 | 459 (interactive) |
460 (set-buffer rmail-buffer) | |
461 (let ((message-sender)) | |
462 (setq message-sender (mail-fetch-field "From")) | |
463 ;; note the use of a backquote and comma on the "from" line here, | |
464 ;; to make sure message-sender is actually evaluated and its value | |
465 ;; substituted: | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
466 (add-to-list 'rsf-definitions-alist |
49862 | 467 (list `(from . ,message-sender) |
468 '(to . "") | |
469 '(subject . "") | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
470 '(content-type . "") |
49862 | 471 '(contents . "") |
472 '(action . output-and-delete)) | |
473 t) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
474 (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
|
475 (if rsf-autosave-newly-added-definitions |
49862 | 476 (progn |
477 (custom-save-all) | |
478 (message (concat "added sender \n <<< \n" message-sender | |
479 " \n >>> \n to list of spam definitions. \n" | |
480 "and saved the spam definitions to file."))) | |
481 (message (concat "added sender \n <<< \n " message-sender | |
482 " \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
|
483 "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
|
484 menu")) |
49862 | 485 ))) |
486 | |
487 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
488 (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
|
489 "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
|
490 Added to spam definitions as a contents field." |
49862 | 491 (interactive) |
492 (set-buffer rmail-buffer) | |
493 (let ((region-to-spam-list)) | |
494 ;; check if region is inactive or has zero size: | |
495 (if (not (and mark-active (not (= (region-beginning) (region-end))))) | |
496 ;; if inactive, print error message: | |
497 (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
|
498 (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
|
499 (message |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
500 (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
|
501 "rsf-min-region-to-spam-list" |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
502 " 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
|
503 ;; 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
|
504 (progn |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
505 (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
|
506 ;; 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
|
507 ;; 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
|
508 ;; substituted: |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
509 (add-to-list 'rsf-definitions-alist |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
510 (list '(from . "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
511 '(to . "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
512 '(subject . "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
513 '(content-type . "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
514 `(contents . ,region-to-spam-list) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
515 '(action . output-and-delete)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
516 t) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
517 (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
|
518 (if rsf-autosave-newly-added-definitions |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
519 (progn |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
520 (custom-save-all) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
521 (message (concat "added highlighted text \n <<< \n" region-to-spam-list |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
522 " \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
|
523 "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
|
524 (message (concat "added highlighted text \n <<< \n " region-to-spam-list |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
525 " \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
|
526 "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
|
527 spam menu")) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
528 )))))) |
49862 | 529 |
530 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
531 (defun rsf-customize-spam-definitions () |
49862 | 532 (interactive) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
533 (customize-variable (quote rsf-definitions-alist))) |
49862 | 534 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
535 (defun rsf-customize-group () |
49862 | 536 (interactive) |
537 (customize-group (quote rmail-spam-filter))) | |
538 | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
539 (defun rsf-custom-save-all () |
49862 | 540 (interactive) |
541 (custom-save-all)) | |
542 | |
543 ;; add the actual menu items and keyboard shortcuts to both rmail and | |
544 ;; rmail-summary menu-bars:: | |
545 (define-key rmail-summary-mode-map [menu-bar spam] | |
546 (cons "Spam" (make-sparse-keymap "Spam"))) | |
547 (define-key rmail-mode-map [menu-bar spam] | |
548 (cons "Spam" (make-sparse-keymap "Spam"))) | |
549 | |
550 (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
|
551 '("Browse customizations of rmail spam filter" . rsf-customize-group)) |
49862 | 552 (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
|
553 '("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
|
554 (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
|
555 (define-key rmail-mode-map "\C-cSg" 'rsf-customize-group) |
49862 | 556 |
557 (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
|
558 '("Customize list of spam definitions" . rsf-customize-spam-definitions)) |
49862 | 559 (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
|
560 '("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
|
561 (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
|
562 (define-key rmail-mode-map "\C-cSd" 'rsf-customize-spam-definitions) |
49862 | 563 |
564 (define-key rmail-summary-mode-map [menu-bar spam lambda] '("----")) | |
565 (define-key rmail-mode-map [menu-bar spam lambda] '("----")) | |
566 | |
567 (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
|
568 '("save newly added spam definitions to customization file" . rsf-custom-save-all)) |
49862 | 569 (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
|
570 '("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
|
571 (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
|
572 (define-key rmail-mode-map "\C-cSa" 'rsf-custom-save-all) |
49862 | 573 |
574 (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
|
575 '("add region to spam list" . rsf-add-region-to-spam-list)) |
49862 | 576 (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
|
577 '("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
|
578 (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
|
579 (define-key rmail-mode-map "\C-cSn" 'rsf-add-region-to-spam-list) |
49862 | 580 |
581 (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
|
582 '("add sender to spam list" . rsf-add-sender-to-spam-list)) |
49862 | 583 (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
|
584 '("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
|
585 (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
|
586 (define-key rmail-mode-map "\C-cSr" 'rsf-add-sender-to-spam-list) |
49862 | 587 |
588 (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
|
589 '("add subject to spam list" . rsf-add-subject-to-spam-list)) |
49862 | 590 (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
|
591 '("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
|
592 (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
|
593 (define-key rmail-mode-map "\C-cSt" 'rsf-add-subject-to-spam-list) |
49862 | 594 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
595 (defun rsf-add-content-type-field () |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
596 "Maintain backward compatibility with previous versions of rmail-spam-filter. |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
597 The most recent version of rmai-spam-filter checks the contents |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
598 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
|
599 `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
|
600 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
|
601 `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
|
602 automatically, no user input is required." |
49862 | 603 (interactive) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
604 (if (and rsf-definitions-alist |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
605 (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
|
606 (let ((result nil) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
607 (current nil) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
608 (definitions rsf-definitions-alist)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
609 (while definitions |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
610 (setq current (car definitions)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
611 (setq definitions (cdr definitions)) |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
612 (setq result |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
613 (append result |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
614 (list |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
615 (list (assoc 'from current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
616 (assoc 'to current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
617 (assoc 'subject current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
618 (cons 'content-type "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
619 (assoc 'contents current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
620 (assoc 'action current)))))) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
621 (setq rsf-definitions-alist result) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
622 (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
|
623 (if rsf-autosave-newly-added-definitions |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
624 (progn |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
625 (custom-save-all) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
626 (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
|
627 "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
|
628 (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
|
629 "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
|
630 spam menu")) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
631 )))) |
49862 | 632 |
633 (provide 'rmail-spam-filter) | |
634 | |
54018 | 635 ;;; 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
|
636 ;;; rmail-spam-fitler ends here |