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