Mercurial > emacs
annotate lisp/mail/rmail-spam-filter.el @ 110328:5c41eafe6021
* xml.c (Fxml_parse_string, Fhtml_parse_string): Fix up the parameters
for the doc string.
From Leo <sdl.web@gmail.com> (tiny change)
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Tue, 14 Sep 2010 02:08:02 +0200 |
parents | a3e1f7134e6e |
children | 417b1e4d63cd |
rev | line source |
---|---|
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
1 ;;; rmail-spam-filter.el --- spam filter for Rmail, the Emacs mail reader |
49862 | 2 |
106815 | 3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
49862 | 5 ;; Keywords: email, spam, filter, rmail |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
6 ;; Author: Eli Tziperman <eli AT deas.harvard.edu> |
110016
a3e1f7134e6e
Add "Version:" and "Package:" Lisp file headers.
Chong Yidong <cyd@stupidchicken.com>
parents:
108933
diff
changeset
|
7 ;; Package: rmail |
49862 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
49862 | 12 ;; 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
|
13 ;; 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
|
14 ;; (at your option) any later version. |
49862 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; 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
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
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 |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
37 ;;; (require 'rmail-spam-filter) |
53730
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 |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
76 (require 'rmail) |
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
77 (require 'rmailsum) |
49862 | 78 |
79 (defgroup rmail-spam-filter nil | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
80 "Spam filter for Rmail, the Emacs mail reader." |
49862 | 81 :group 'rmail) |
82 | |
83 (defcustom rmail-use-spam-filter nil | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
84 "Non-nil to activate the Rmail spam filter. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
85 Set `rsf-definitions-alist' to define what you consider spam emails." |
49862 | 86 :type 'boolean |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
87 :group 'rmail-spam-filter) |
49862 | 88 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
89 (defcustom rsf-file "~/XRMAIL-SPAM" |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
90 "Name of Rmail file for optionally saving some of the spam. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
91 You can either just delete spam, or save it in this file for |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
92 later review. Which action to take for each spam definition is |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
93 specified by the \"action\" element of the definition." |
49862 | 94 :type 'string |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
95 :group 'rmail-spam-filter) |
49862 | 96 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
97 (defcustom rsf-no-blind-cc nil |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
98 "Non-nil means mail with no explicit To: or Cc: is spam." |
49862 | 99 :type 'boolean |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
100 :group 'rmail-spam-filter) |
49862 | 101 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
102 (defcustom rsf-ignore-case nil |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
103 "Non-nil means to ignore case in `rsf-definitions-alist'." |
49862 | 104 :type 'boolean |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
105 :group 'rmail-spam-filter) |
49862 | 106 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
107 (defcustom rsf-beep nil |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
108 "Non-nil means to beep if spam is found." |
49862 | 109 :type 'boolean |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
110 :group 'rmail-spam-filter) |
49862 | 111 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
112 (defcustom rsf-sleep-after-message 2.0 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
113 "Seconds to wait after displaying a message that spam was found." |
49862 | 114 :type 'number |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
115 :group 'rmail-spam-filter) |
53685
2d1c4cfccc4a
Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53665
diff
changeset
|
116 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
117 (defcustom rsf-min-region-to-spam-list 7 |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
118 "Minimum size of region that you can add to the spam list. |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
119 The aim is to avoid adding too short a region, which could result |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
120 in false positive identification of a valid message as spam." |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
121 :type 'integer |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
122 :group 'rmail-spam-filter) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
123 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
124 (defcustom rsf-autosave-newly-added-definitions nil |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
125 "Non-nil to auto-save new spam entries. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
126 Any time you add an entry via the \"Spam\" menu, immediately saves |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
127 the custom file." |
49862 | 128 :type 'boolean |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
129 :group 'rmail-spam-filter) |
49862 | 130 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
131 (defcustom rsf-white-list nil |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
132 "List of regexps to identify valid senders. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
133 If any element matches the \"From\" header, the message is |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
134 flagged as a valid, non-spam message. E.g., if your domain is |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
135 \"emacs.com\" then including \"emacs\\\\.com\" in this list would |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
136 flag all mail (purporting to be) from your colleagues as valid." |
49862 | 137 :type '(repeat string) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
138 :group 'rmail-spam-filter) |
49862 | 139 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
140 (defcustom rsf-definitions-alist nil |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
141 "A list of rules (definitions) matching spam messages. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
142 Each rule is an alist, with elements of the form (FIELD . REGEXP). |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
143 The recognized FIELDS are: from, to, subject, content-type, |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
144 x-spam-status, and contents. The \"contents\" element refers to |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
145 the entire text of the message; all the other elements refer to |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
146 message headers of the same name. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
147 |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
148 Using an empty-string for REGEXP is the same as omitting that |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
149 element altogether. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
150 |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
151 Each rule should contain one \"action\" element, saying what to do |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
152 if the rule is matched. This has the form (action . CHOICE), where |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
153 CHOICE may be either `output-and-delete' (save to `rsf-file', then delete), |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
154 or `delete-spam' (just delete). |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
155 |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
156 A rule matches only if all the specified elements match." |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
157 :type '(repeat |
49862 | 158 (list :format "%v" |
159 (cons :format "%v" :value (from . "") | |
160 (const :format "" from) | |
161 (string :tag "From" "")) | |
162 (cons :format "%v" :value (to . "") | |
163 (const :format "" to) | |
164 (string :tag "To" "")) | |
165 (cons :format "%v" :value (subject . "") | |
166 (const :format "" subject) | |
167 (string :tag "Subject" "")) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
168 (cons :format "%v" :value (content-type . "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
169 (const :format "" content-type) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
170 (string :tag "Content-Type" "")) |
49862 | 171 (cons :format "%v" :value (contents . "") |
172 (const :format "" contents) | |
173 (string :tag "Contents" "")) | |
91817
f0b22bbb77fb
;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
174 (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
|
175 (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
|
176 (string :tag "X-Spam-Status" "")) |
49862 | 177 (cons :format "%v" :value (action . output-and-delete) |
178 (const :format "" action) | |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
179 (choice :tag "Action selection" |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
180 (const :tag "Output and delete" output-and-delete) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
181 (const :tag "Delete" delete-spam) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
182 )))) |
49862 | 183 :group 'rmail-spam-filter) |
184 | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
185 ;; FIXME nothing uses this, and it could just be let-bound. |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
186 (defvar rsf-scanning-messages-now nil |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
187 "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
|
188 |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
189 ;; 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
|
190 ;; of in-one-definition-elements |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
191 (defun rsf-check-field (field-symbol message-data definition result) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
192 "Check if a message appears to be spam. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
193 FIELD-SYMBOL is one of the possible keys of a `rsf-definitions-alist' |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
194 rule; e.g. from, to. MESSAGE-DATA is a string giving the value of |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
195 FIELD-SYMBOL in the current message. DEFINITION is the element of |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
196 `rsf-definitions-alist' currently being checked. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
197 |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
198 RESULT is a cons of the form (MAYBE-SPAM . IS-SPAM). If the car |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
199 is nil, or if the entry for FIELD-SYMBOL in this DEFINITION is |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
200 absent or the empty string, this function does nothing. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
201 |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
202 Otherwise, if MESSAGE-DATA is non-nil and the entry matches it, |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
203 the cdr is set to t. Else, the car is set to nil." |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
204 (let ((definition-field (cdr (assoc field-symbol definition)))) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
205 ;; Only in this case can maybe-spam change from t to nil. |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
206 (if (and (car result) (> (length definition-field) 0)) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
207 ;; If FIELD-SYMBOL field appears in the message, and also in |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
208 ;; spam definition list, this is potentially a spam. |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
209 (if (and message-data |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
210 (string-match definition-field message-data)) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
211 ;; If we do not get a contradiction from another field, this is spam |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
212 (setcdr result t) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
213 ;; The message data contradicts the specification, this is not spam. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
214 ;; Note that the total absence of a header specified in the |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
215 ;; rule means this cannot be spam. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
216 (setcar result nil))))) |
49862 | 217 |
218 (defun rmail-spam-filter (msg) | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
219 "Return nil if message number MSG is spam based on `rsf-definitions-alist'. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
220 If spam, optionally output message to a file `rsf-file' and delete |
49862 | 221 it from rmail file. Called for each new message retrieved by |
222 `rmail-get-new-mail'." | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
223 (let ((return-value) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
224 ;; maybe-spam is in the car, this-is-a-spam-email in cdr. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
225 (maybe-spam '(nil . nil)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
226 message-sender message-to message-cc message-recipients |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
227 message-subject message-content-type message-spam-status |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
228 (num-spam-definition-elements (safe-length rsf-definitions-alist)) |
49862 | 229 (num-element 0) |
230 (exit-while-loop nil) | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
231 ;; Do we want to ignore case in spam definitions. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
232 (case-fold-search rsf-ignore-case) |
101540
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
233 ;; make sure bbdb does not create entries for messages while spam |
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
234 ;; filter is scanning the rmail file: |
5389a1f33e22
Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
235 (bbdb/mail_auto_create_p nil) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
236 ;; Other things may wish to know if we are running (nothing |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
237 ;; uses this at present). |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
238 (rsf-scanning-messages-now t)) |
49862 | 239 (save-excursion |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
240 ;; Narrow buffer to header of message and get Sender and |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
241 ;; Subject fields to be used below: |
49862 | 242 (save-restriction |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
243 (goto-char (rmail-msgbeg msg)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
244 (narrow-to-region (point) (progn (search-forward "\n\n") (point))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
245 (setq message-sender (mail-fetch-field "From")) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
246 (setq message-to (mail-fetch-field "To") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
247 message-cc (mail-fetch-field "Cc") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
248 message-recipients (or (and message-to message-cc |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
249 (concat message-to ", " message-cc)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
250 message-to |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
251 message-cc)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
252 (setq message-subject (mail-fetch-field "Subject")) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
253 (setq message-content-type (mail-fetch-field "Content-Type")) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
254 (setq message-spam-status (mail-fetch-field "X-Spam-Status"))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
255 ;; Check for blind CC condition. Set vars such that while |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
256 ;; loop will be bypassed and spam condition will trigger. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
257 (and rsf-no-blind-cc |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
258 (null message-recipients) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
259 (setq exit-while-loop t |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
260 maybe-spam '(t . t))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
261 ;; Check white list, and likewise cause while loop bypass. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
262 (and message-sender |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
263 (let ((white-list rsf-white-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
264 (found nil)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
265 (while (and (not found) white-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
266 (if (string-match (car white-list) message-sender) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
267 (setq found t) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
268 (setq white-list (cdr white-list)))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
269 found) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
270 (setq exit-while-loop t |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
271 maybe-spam '(nil . nil))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
272 ;; Scan all elements of the list rsf-definitions-alist. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
273 (while (and (< num-element num-spam-definition-elements) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
274 (not exit-while-loop)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
275 (let ((definition (nth num-element rsf-definitions-alist))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
276 ;; Initialize car, which is set to t in one of two cases: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
277 ;; (1) unspecified definition-elements are found in |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
278 ;; rsf-definitions-alist, (2) empty field is found in the |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
279 ;; message being scanned (e.g. empty subject, sender, |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
280 ;; recipients, etc). It is set to nil if a non-empty field |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
281 ;; of the scanned message does not match a specified field |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
282 ;; in rsf-definitions-alist. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
283 ;; FIXME the car is never set to t?! |
53685
2d1c4cfccc4a
Use two semicolons as Commentary line prefix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53665
diff
changeset
|
284 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
285 ;; Initialize cdr to nil. This is set to t if one of the |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
286 ;; spam definitions matches a field in the scanned message. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
287 (setq maybe-spam (cons t nil)) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
288 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
289 ;; Maybe the different fields should also be done in a |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
290 ;; loop to make the whole thing more flexible. |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
291 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
292 ;; If sender field is not specified in message being |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
293 ;; scanned, AND if "from" field does not appear in spam |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
294 ;; definitions for this element, this may still be spam due |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
295 ;; to another element... |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
296 (rsf-check-field 'from message-sender definition maybe-spam) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
297 ;; Next, if spam was not ruled out already, check recipients: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
298 (rsf-check-field 'to message-recipients definition maybe-spam) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
299 ;; Next, if spam was not ruled out already, check subject: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
300 (rsf-check-field 'subject message-subject definition maybe-spam) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
301 ;; Next, if spam was not ruled out already, check content-type: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
302 (rsf-check-field 'content-type message-content-type |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
303 definition maybe-spam) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
304 ;; Next, if spam was not ruled out already, check contents: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
305 ;; If contents field is not specified, this may still be |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
306 ;; spam due to another element... |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
307 (rsf-check-field 'contents |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
308 (buffer-substring-no-properties |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
309 (rmail-msgbeg msg) (rmail-msgend msg)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
310 definition maybe-spam) |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
311 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
312 ;; Finally, check the X-Spam-Status header. You will typically |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
313 ;; look for the "Yes" string in this header field. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
314 (rsf-check-field 'x-spam-status message-spam-status |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
315 definition maybe-spam) |
91817
f0b22bbb77fb
;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
Bastien Guerry <bzg@altern.org>
parents:
79712
diff
changeset
|
316 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
317 ;; If the search in rsf-definitions-alist found |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
318 ;; that this email is spam, output the email to the spam |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
319 ;; rmail file, mark the email for deletion, leave the |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
320 ;; while loop and return nil so that an rmail summary line |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
321 ;; wont be displayed for this message: (FIXME ?) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
322 (if (and (car maybe-spam) (cdr maybe-spam)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
323 (setq exit-while-loop t) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
324 ;; Else, spam was not yet found, proceed to next element |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
325 ;; in rsf-definitions-alist: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
326 (setq num-element (1+ num-element))))) |
49862 | 327 |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
328 (if (and (car maybe-spam) (cdr maybe-spam)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
329 ;; Temporarily set rmail-current-message in order to output |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
330 ;; and delete the spam msg if needed: |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
331 (let ((rmail-current-message msg) ; FIXME does this do anything? |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
332 (action (cdr (assq 'action |
102096
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
333 (nth num-element rsf-definitions-alist)))) |
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
334 (newfile (not (file-exists-p rsf-file)))) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
335 ;; Check action item in rsf-definitions-alist and do it. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
336 (cond |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
337 ((eq action 'output-and-delete) |
102096
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
338 ;; Else the prompt to write a new file leaves the raw |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
339 ;; mbox buffer visible. |
102096
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
340 (and newfile |
102112
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
341 (rmail-show-message (rmail-first-unseen-message) t)) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
342 (rmail-output rsf-file) |
102096
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
343 ;; Swap back, else rmail-get-new-mail-1 gets confused. |
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
344 (when newfile |
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
345 (rmail-swap-buffers-maybe) |
7053d753a548
(rmail-spam-filter): Show a message rather than the raw mbox while prompting.
Glenn Morris <rgm@gnu.org>
parents:
102087
diff
changeset
|
346 (widen)) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
347 ;; Don't delete if automatic deletion after output is on. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
348 (or rmail-delete-after-output (rmail-delete-message))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
349 ((eq action 'delete-spam) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
350 (rmail-delete-message))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
351 (setq return-value nil)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
352 (setq return-value t))) |
49862 | 353 return-value)) |
354 | |
102110
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
355 (defun rmail-get-new-mail-filter-spam (nnew) |
102112
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
356 "Check the most NNEW recent messages for spam. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
357 This is called at the end of `rmail-get-new-mail-1' if there is new mail." |
102110
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
358 (let* ((nold (- rmail-total-messages nnew)) |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
359 (nspam 0) |
102112
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
360 (nscan (1+ nold)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
361 ;; Save the original deleted state of all the messages. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
362 (rdv-old rmail-deleted-vector) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
363 errflag) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
364 ;; Set all messages undeleted so that the expunge only affects spam. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
365 (setq rmail-deleted-vector (make-string (1+ rmail-total-messages) ?\s)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
366 (while (and (not errflag) (<= nscan rmail-total-messages)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
367 (condition-case nil |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
368 (or (rmail-spam-filter nscan) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
369 (setq nspam (1+ nspam))) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
370 (error (setq errflag nscan))) |
102110
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
371 (setq nscan (1+ nscan))) |
102112
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
372 (unwind-protect |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
373 (if errflag |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
374 (progn |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
375 (setq rmail-use-spam-filter nil) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
376 (if rsf-beep (ding t)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
377 (message "Spam filter error for new message %d, disabled" errflag) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
378 (sleep-for rsf-sleep-after-message)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
379 (when (> nspam 0) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
380 ;; Otherwise sleep or expunge prompt leaves raw mbox buffer showing. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
381 (rmail-show-message (or (rmail-first-unseen-message) 1) t) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
382 (unwind-protect |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
383 (progn |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
384 (if rsf-beep (ding t)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
385 (message "Rmail spam-filter detected and deleted %d spam \ |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
386 message%s" |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
387 nspam (if (= 1 nspam) "" "s")) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
388 (sleep-for rsf-sleep-after-message) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
389 (if (rmail-expunge-confirmed) (rmail-only-expunge t))) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
390 ;; Swap back, else get-new-mail-1 gets confused. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
391 (rmail-swap-buffers-maybe) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
392 (widen)))) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
393 ;; Restore the original deleted state. Character N refers to message N. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
394 (setq rmail-deleted-vector |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
395 (concat (substring rdv-old 0 (1+ nold)) |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
396 ;; This still works if we deleted all the new mail. |
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
397 (substring rmail-deleted-vector (1+ nold))))) |
102110
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
398 ;; Return a message based on the number of spam messages found. |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
399 (cond |
102112
c9da83f185a6
(rmail-get-new-mail-filter-spam): Be more careful about error-handling.
Glenn Morris <rgm@gnu.org>
parents:
102110
diff
changeset
|
400 (errflag ", error in spam filter") |
102110
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
401 ((zerop nspam) "") |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
402 ((= 1 nnew) ", and it appears to be spam") |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
403 ((= nspam nnew) ", and all appear to be spam") |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
404 (t (format ", and %d appear%s to be spam" nspam |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
405 (if (= 1 nspam) "s" "")))))) |
4df6195e1d5e
(rmail-get-new-mail-filter-spam): Move here from rmail.el.
Glenn Morris <rgm@gnu.org>
parents:
102096
diff
changeset
|
406 |
49862 | 407 ;; define functions for interactively adding sender/subject of a |
408 ;; specific message to the spam definitions while reading it, using | |
409 ;; the menubar: | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
410 (defun rsf-add-subject-to-spam-list () |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
411 "Add the \"Subject\" header to the spam list." |
49862 | 412 (interactive) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
413 (let ((message-subject (regexp-quote (rmail-get-header "Subject")))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
414 ;; Note the use of a backquote and comma on the subject line here, |
49862 | 415 ;; to make sure message-subject is actually evaluated and its value |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
416 ;; substituted. |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
417 (add-to-list 'rsf-definitions-alist |
108933 | 418 ;; Note that an empty element is treated the same as |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
419 ;; an absent one, so why does it bother to add them? |
49862 | 420 (list '(from . "") |
421 '(to . "") | |
422 `(subject . ,message-subject) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
423 '(content-type . "") |
49862 | 424 '(contents . "") |
425 '(action . output-and-delete)) | |
426 t) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
427 (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
|
428 (if rsf-autosave-newly-added-definitions |
49862 | 429 (progn |
430 (custom-save-all) | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
431 (message "Added subject `%s' to spam list, and saved it" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
432 message-subject)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
433 (message "Added subject `%s' to spam list (remember to save it)" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
434 message-subject)))) |
49862 | 435 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
436 (defun rsf-add-sender-to-spam-list () |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
437 "Add the \"From\" address to the spam list." |
49862 | 438 (interactive) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
439 (let ((message-sender (regexp-quote (rmail-get-header "From")))) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
440 (add-to-list 'rsf-definitions-alist |
49862 | 441 (list `(from . ,message-sender) |
442 '(to . "") | |
443 '(subject . "") | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
444 '(content-type . "") |
49862 | 445 '(contents . "") |
446 '(action . output-and-delete)) | |
447 t) | |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
448 (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
|
449 (if rsf-autosave-newly-added-definitions |
49862 | 450 (progn |
451 (custom-save-all) | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
452 (message "Added sender `%s' to spam list, and saved it" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
453 message-sender)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
454 (message "Added sender `%s' to spam list (remember to save it)" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
455 message-sender)))) |
49862 | 456 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
457 (defun rsf-add-region-to-spam-list () |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
458 "Add the marked region in the Rmail buffer to the spam list. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
459 Adds to spam definitions as a \"contents\" field." |
49862 | 460 (interactive) |
461 (set-buffer rmail-buffer) | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
462 ;; Check if region is inactive or has zero size. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
463 (if (not (and mark-active (not (= (region-beginning) (region-end))))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
464 ;; If inactive, print error message. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
465 (message "You must highlight some text in the Rmail buffer") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
466 (if (< (- (region-end) (region-beginning)) rsf-min-region-to-spam-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
467 (message "Region is too small (minimum %d characters)" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
468 rsf-min-region-to-spam-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
469 ;; If region active and long enough, add to list of spam definitions. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
470 (let ((region-to-spam-list (regexp-quote |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
471 (buffer-substring-no-properties |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
472 (region-beginning) (region-end))))) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
473 (add-to-list 'rsf-definitions-alist |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
474 (list '(from . "") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
475 '(to . "") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
476 '(subject . "") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
477 '(content-type . "") |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
478 `(contents . ,region-to-spam-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
479 '(action . output-and-delete)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
480 t) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
481 (customize-mark-to-save 'rsf-definitions-alist) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
482 (if rsf-autosave-newly-added-definitions |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
483 (progn |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
484 (custom-save-all) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
485 (message "Added highlighted text:\n%s\n\ |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
486 to the spam list, and saved it" region-to-spam-list)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
487 (message "Added highlighted text:\n%s\n\ |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
488 to the spam list (remember to save it)" region-to-spam-list)))))) |
49862 | 489 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
490 (defun rsf-customize-spam-definitions () |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
491 "Customize `rsf-definitions-alist'." |
49862 | 492 (interactive) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
493 (customize-variable 'rsf-definitions-alist)) |
49862 | 494 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
495 (defun rsf-customize-group () |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
496 "Customize the rmail-spam-filter group." |
49862 | 497 (interactive) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
498 (customize-group 'rmail-spam-filter)) |
49862 | 499 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
500 (defun rsf-custom-save-all () |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
501 "Interactive version of `custom-save-all'." |
49862 | 502 (interactive) |
503 (custom-save-all)) | |
504 | |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
505 ;; Add menu items (and keyboard shortcuts) to both rmail and rmail-summary. |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
506 (dolist (map (list rmail-summary-mode-map rmail-mode-map)) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
507 (easy-menu-define nil map nil |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
508 '("Spam" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
509 ["Add subject to spam list" rsf-add-subject-to-spam-list] |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
510 ["Add sender to spam list" rsf-add-sender-to-spam-list] |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
511 ["Add region to spam list" rsf-add-region-to-spam-list] |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
512 ["Save spam definitions" rsf-custom-save-all] |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
513 "--" |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
514 ["Customize spam definitions" rsf-customize-spam-definitions] |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
515 ["Browse spam customizations" rsf-customize-group] |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
516 )) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
517 (define-key map "\C-cSt" 'rsf-add-subject-to-spam-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
518 (define-key map "\C-cSr" 'rsf-add-sender-to-spam-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
519 (define-key map "\C-cSn" 'rsf-add-region-to-spam-list) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
520 (define-key map "\C-cSa" 'rsf-custom-save-all) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
521 (define-key map "\C-cSd" 'rsf-customize-spam-definitions) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
522 (define-key map "\C-cSg" 'rsf-customize-group)) |
49862 | 523 |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
524 (defun rsf-add-content-type-field () |
72643
27b1d7466c09
(rsf-scanning-messages-now): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
68648
diff
changeset
|
525 "Maintain backward compatibility for `rmail-spam-filter'. |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
526 The most recent version of `rmail-spam-filter' checks the content-type |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
527 field of the incoming mail to see if it is spam. The format of |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
528 `rsf-definitions-alist' has therefore changed. This function |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
529 checks to see if the old format is used, and updates it if necessary." |
49862 | 530 (interactive) |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
531 (if (and rsf-definitions-alist |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
532 (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
|
533 (let ((result nil) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
534 (current nil) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
535 (definitions rsf-definitions-alist)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
536 (while definitions |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
537 (setq current (car definitions)) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
538 (setq definitions (cdr definitions)) |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
539 (setq result |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
540 (append result |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
541 (list |
53730
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
542 (list (assoc 'from current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
543 (assoc 'to current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
544 (assoc 'subject current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
545 (cons 'content-type "") |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
546 (assoc 'contents current) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
547 (assoc 'action current)))))) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
548 (setq rsf-definitions-alist result) |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
549 (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
|
550 (if rsf-autosave-newly-added-definitions |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
551 (progn |
2a4fc5c14ddd
Change rmail-spam-filter- or spam-filter-
Richard M. Stallman <rms@gnu.org>
parents:
53685
diff
changeset
|
552 (custom-save-all) |
102087
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
553 (message "Spam definitions converted to new format, and saved")) |
d6de2e3c19e8
(rmail-summary-mode-map): Remove unneeded declaration.
Glenn Morris <rgm@gnu.org>
parents:
101540
diff
changeset
|
554 (message "Spam definitions converted to new format (remember to save)"))))) |
49862 | 555 |
556 (provide 'rmail-spam-filter) | |
557 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91846
diff
changeset
|
558 ;; 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
|
559 ;;; rmail-spam-fitler ends here |