(spam-split): (save-excursion) around (widen)
[gnus] / lisp / spam.el
1 ;;; spam.el --- Identifying spam
2 ;; Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: network
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
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; This module addresses a few aspects of spam control under Gnus.  Page
27 ;;; breaks are used for grouping declarations and documentation relating to
28 ;;; each particular aspect.
29
30 ;;; The integration with Gnus is not yet complete.  See various `FIXME'
31 ;;; comments, below, for supplementary explanations or discussions.
32
33 ;;; Several TODO items are marked as such
34
35 ;;; Code:
36
37 (require 'gnus-sum)
38
39 (require 'gnus-uu)                      ; because of key prefix issues
40 (require 'gnus) ; for the definitions of group content classification and spam processors
41 (require 'message)                      ;for the message-fetch-field functions
42
43 ;; for nnimap-split-download-body-default
44 (eval-when-compile (require 'nnimap))
45
46 ;; autoload executable-find
47 (eval-and-compile
48   ;; executable-find is not autoloaded in Emacs 20
49   (autoload 'executable-find "executable"))
50
51 ;; autoload query-dig
52 (eval-and-compile
53   (autoload 'query-dig "dig"))
54
55 ;; autoload query-dns
56 (eval-and-compile
57   (autoload 'query-dns "dns"))
58
59 ;;; Main parameters.
60
61 (defgroup spam nil
62   "Spam configuration.")
63
64 (defcustom spam-directory "~/News/spam/"
65   "Directory for spam whitelists and blacklists."
66   :type 'directory
67   :group 'spam)
68
69 (defcustom spam-move-spam-nonspam-groups-only t
70   "Whether spam should be moved in non-spam groups only.
71 When nil, only ham and unclassified groups will have their spam moved
72 to the spam-process-destination.  When t, spam will also be moved from
73 spam groups."
74   :type 'boolean
75   :group 'spam)
76
77 (defcustom spam-mark-ham-unread-before-move-from-spam-group nil
78   "Whether ham should be marked unread before it's moved out of a spam
79 group according to ham-process-destination.  This variable is an
80 official entry in the international Longest Variable Name
81 Competition."
82   :type 'boolean
83   :group 'spam)
84
85 (defcustom spam-whitelist (expand-file-name "whitelist" spam-directory)
86   "The location of the whitelist.
87 The file format is one regular expression per line.
88 The regular expression is matched against the address."
89   :type 'file
90   :group 'spam)
91
92 (defcustom spam-blacklist (expand-file-name "blacklist" spam-directory)
93   "The location of the blacklist.
94 The file format is one regular expression per line.
95 The regular expression is matched against the address."
96   :type 'file
97   :group 'spam)
98
99 (defcustom spam-use-dig t
100   "Whether query-dig should be used instead of query-dns."
101   :type 'boolean
102   :group 'spam)
103
104 (defcustom spam-use-blacklist nil
105   "Whether the blacklist should be used by spam-split."
106   :type 'boolean
107   :group 'spam)
108
109 (defcustom spam-use-whitelist nil
110   "Whether the whitelist should be used by spam-split."
111   :type 'boolean
112   :group 'spam)
113
114 (defcustom spam-use-whitelist-exclusive nil
115   "Whether whitelist-exclusive should be used by spam-split.
116 Exclusive whitelisting means that all messages from senders not in the whitelist
117 are considered spam."
118   :type 'boolean
119   :group 'spam)
120
121 (defcustom spam-use-blackholes nil
122   "Whether blackholes should be used by spam-split."
123   :type 'boolean
124   :group 'spam)
125
126 (defcustom spam-use-hashcash nil
127   "Whether hashcash payments should be detected by spam-split."
128   :type 'boolean
129   :group 'spam)
130
131 (defcustom spam-use-regex-headers nil
132   "Whether a header regular expression match should be used by spam-split.
133 Also see the variable `spam-spam-regex-headers' and `spam-ham-regex-headers'."
134   :type 'boolean
135   :group 'spam)
136
137 (defcustom spam-use-bogofilter-headers nil
138   "Whether bogofilter headers should be used by spam-split.
139 Enable this if you pre-process messages with Bogofilter BEFORE Gnus sees them."
140   :type 'boolean
141   :group 'spam)
142
143 (defcustom spam-use-bogofilter nil
144   "Whether bogofilter should be invoked by spam-split.
145 Enable this if you want Gnus to invoke Bogofilter on new messages."
146   :type 'boolean
147   :group 'spam)
148
149 (defcustom spam-use-BBDB nil
150   "Whether BBDB should be used by spam-split."
151   :type 'boolean
152   :group 'spam)
153
154 (defcustom spam-use-BBDB-exclusive nil
155   "Whether BBDB-exclusive should be used by spam-split.
156 Exclusive BBDB means that all messages from send