(gnus-button-prefer-mid-or-mail): Fixed typo in doc-string.
[gnus] / lisp / gnus-kill.el
1 ;;; gnus-kill.el --- kill commands for Gnus
2 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;;        Free Software Foundation, Inc.
4
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;;      Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
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
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus)
33 (require 'gnus-art)
34 (require 'gnus-range)
35
36 (defcustom gnus-kill-file-mode-hook nil
37   "Hook for Gnus kill file mode."
38   :group 'gnus-score-kill
39   :type 'hook)
40
41 (defcustom gnus-kill-expiry-days 7
42   "*Number of days before expiring unused kill file entries."
43   :group 'gnus-score-kill
44   :group 'gnus-score-expire
45   :type 'integer)
46
47 (defcustom gnus-kill-save-kill-file nil
48   "*If non-nil, will save kill files after processing them."
49   :group 'gnus-score-kill
50   :type 'boolean)
51
52 (defcustom gnus-winconf-kill-file nil
53   "What does this do, Lars?
54 I don't know, Per."
55   :group 'gnus-score-kill
56   :type 'sexp)
57
58 (defcustom gnus-kill-killed t
59   "*If non-nil, Gnus will apply kill files to already killed articles.
60 If it is nil, Gnus will never apply kill files to articles that have
61 already been through the scoring process, which might very well save lots
62 of time."
63   :group 'gnus-score-kill
64   :type 'boolean)
65
66 \f
67
68 (defmacro gnus-raise (field expression level)
69   `(gnus-kill ,field ,expression
70               (function (gnus-summary-raise-score ,level)) t))
71
72 (defmacro gnus-lower (field expression level)
73   `(gnus-kill ,field ,expression
74               (function (gnus-summary-raise-score (- ,level))) t))
75
76 ;;;
77 ;;; Gnus Kill File Mode
78 ;;;
79
80 (defvar gnus-kill-file-mode-map nil)
81
82 (unless gnus-kill-file-mode-map
83   (gnus-define-keymap (setq gnus-kill-file-mode-map
84                             (copy-keymap emacs-lisp-mode-map))
85     "\C-c\C-k\C-s" gnus-kill-file-kill-by-subject
86     "\C-c\C-k\C-a" gnus-kill-file-kill-by-author
87     "\C-c\C-k\C-t" gnus-kill-file-kill-by-thread
88     "\C-c\C-k\C-x" gnus-kill-file-kill-by-xref
89     "\C-c\C-a" gnus-kill-file-apply-buffer
90     "\C-c\C-e" gnus-kill-file-apply-last-sexp
91     "\C-c\C-c" gnus-kill-file-exit))
92
93 (defun gnus-kill-file-mode ()
94   "Major mode for editing kill files.
95
96 If you are using this mode - you probably shouldn't.  Kill files
97 perform badly and paint with a pretty broad brush.  Score files, on
98 the other hand, are vastly faster (40x speedup) and give you more
99 control over what to do.
100
101 In addition to Emacs-Lisp Mode, the following commands are available:
102
103 \\{gnus-kill-file-mode-map}
104
105   A kill file contains Lisp expressions to be applied to a selected
106 newsgroup.  The purpose is to mark articles as read on the basis of
107 some set of regexps.  A global kill file is applied to every newsgroup,
108 and a local kill file is applied to a specified newsgroup.  Since a
109 global kill file is applied to every newsgroup, for better performance
110 use a local one.
111
112   A kill file can contain any kind of Emacs Lisp expressions expected
113 to be evaluated in the Summary buffer.  Writing Lisp programs for this
114 purpose is not so easy because the internal working of Gnus must be
115 well-known.  For this reason, Gnus provides a general function which
116 does this easily for non-Lisp programmers.
117
118   The `gnus-kill' function executes commands available in Summary Mode
119 by their key sequences.  `gnus-kill' should be called with FIELD,
120 REGEXP and optional COMMAND and ALL.  FIELD is a string representing
121 the header field or an empty string.  If FIELD is an empty string, the
122 entire article body is searched for.  REGEXP is a string which is