annotate lisp/gnus/gnus-kill.el @ 140:585fb297b004 r20-2b4

Import from CVS: tag r20-2b4
author cvs
date Mon, 13 Aug 2007 09:32:43 +0200
parents 360340f9fd5f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; gnus-kill.el --- kill commands for Gnus
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'gnus)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
30 (require 'gnus-art)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
31 (require 'gnus-range)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
33 (defcustom gnus-kill-file-mode-hook nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
34 "Hook for Gnus kill file mode."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
35 :group 'gnus-score-kill
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
36 :type 'hook)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
37
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
38 (defcustom gnus-kill-expiry-days 7
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
39 "*Number of days before expiring unused kill file entries."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
40 :group 'gnus-score-kill
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
41 :group 'gnus-score-expire
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
42 :type 'integer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
44 (defcustom gnus-kill-save-kill-file nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
45 "*If non-nil, will save kill files after processing them."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
46 :group 'gnus-score-kill
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
47 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
49 (defcustom gnus-winconf-kill-file nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
50 "What does this do, Lars?"
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
51 :group 'gnus-score-kill
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
52 :type 'sexp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
54 (defcustom gnus-kill-killed t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
55 "*If non-nil, Gnus will apply kill files to already killed articles.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
56 If it is nil, Gnus will never apply kill files to articles that have
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
57 already been through the scoring process, which might very well save lots
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
58 of time."
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
59 :group 'gnus-score-kill
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
60 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defmacro gnus-raise (field expression level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 `(gnus-kill ,field ,expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (function (gnus-summary-raise-score ,level)) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defmacro gnus-lower (field expression level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 `(gnus-kill ,field ,expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (function (gnus-summary-raise-score (- ,level))) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; Gnus Kill File Mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defvar gnus-kill-file-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (unless gnus-kill-file-mode-map
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
79 (gnus-define-keymap (setq gnus-kill-file-mode-map
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
80 (copy-keymap emacs-lisp-mode-map))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
81 "\C-c\C-k\C-s" gnus-kill-file-kill-by-subject
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
82 "\C-c\C-k\C-a" gnus-kill-file-kill-by-author
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
83 "\C-c\C-k\C-t" gnus-kill-file-kill-by-thread
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
84 "\C-c\C-k\C-x" gnus-kill-file-kill-by-xref
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
85 "\C-c\C-a" gnus-kill-file-apply-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
86 "\C-c\C-e" gnus-kill-file-apply-last-sexp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
87 "\C-c\C-c" gnus-kill-file-exit))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defun gnus-kill-file-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "Major mode for editing kill files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 If you are using this mode - you probably shouldn't. Kill files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 perform badly and paint with a pretty broad brush. Score files, on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 the other hand, are vastly faster (40x speedup) and give you more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 control over what to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 In addition to Emacs-Lisp Mode, the following commands are available:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 \\{gnus-kill-file-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 A kill file contains Lisp expressions to be applied to a selected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 newsgroup. The purpose is to mark articles as read on the basis of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 some set of regexps. A global kill file is applied to every newsgroup,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 and a local kill file is applied to a specified newsgroup. Since a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 global kill file is applied to every newsgroup, for better performance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 use a local one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 A kill file can contain any kind of Emacs Lisp expressions expected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 to be evaluated in the Summary buffer. Writing Lisp programs for this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 purpose is not so easy because the internal working of Gnus must be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 well-known. For this reason, Gnus provides a general function which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 does this easily for non-Lisp programmers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 The `gnus-kill' function executes commands available in Summary Mode
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
115 by their key sequences. `gnus-kill' should be called with FIELD,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 REGEXP and optional COMMAND and ALL. FIELD is a string representing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 the header field or an empty string. If FIELD is an empty string, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 entire article body is searched for. REGEXP is a string which is
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
119 compared with FIELD value. COMMAND is a string representing a valid
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
120 key sequence in Summary mode or Lisp expression. COMMAND defaults to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 '(gnus-summary-mark-as-read nil \"X\"). Make sure that COMMAND is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 executed in the Summary buffer. If the second optional argument ALL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 is non-nil, the COMMAND is applied to articles which are already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 marked as read or unread. Articles which are marked are skipped over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 For example, if you want to mark articles of which subjects contain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 the string `AI' as read, a possible kill file may look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (gnus-kill \"Subject\" \"AI\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 If you want to mark articles with `D' instead of `X', you can use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 the following expression:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (gnus-kill \"Subject\" \"AI\" \"d\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 In this example it is assumed that the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 `gnus-summary-mark-as-read-forward' is assigned to `d' in Summary Mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 It is possible to delete unnecessary headers which are marked with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 `X' in a kill file as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (gnus-expunge \"X\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 If the Summary buffer is empty after applying kill files, Gnus will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 exit the selected newsgroup normally. If headers which are marked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 with `D' are deleted in a kill file, it is impossible to read articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 which are marked as read in the previous Gnus sessions. Marks other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 than `D' should be used for articles which should really be deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Entry to this mode calls emacs-lisp-mode-hook and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 gnus-kill-file-mode-hook with no arguments, if that value is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (use-local-map gnus-kill-file-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (set-syntax-table emacs-lisp-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq major-mode 'gnus-kill-file-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq mode-name "Kill")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (lisp-mode-variables nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (run-hooks 'emacs-lisp-mode-hook 'gnus-kill-file-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defun gnus-kill-file-edit-file (newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "Begin editing a kill file for NEWSGROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 If NEWSGROUP is nil, the global kill file is selected."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (interactive "sNewsgroup: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((file (gnus-newsgroup-kill-file newsgroup)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (gnus-make-directory (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; Save current window configuration if this is first invocation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (or (and (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (get-buffer-window (get-file-buffer file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq gnus-winconf-kill-file (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; Hack windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (let ((buffer (find-file-noselect file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (cond ((get-buffer-window buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (pop-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ((eq major-mode 'gnus-group-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (gnus-configure-windows 'group) ;Take all windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (pop-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ((eq major-mode 'gnus-summary-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (gnus-configure-windows 'article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (pop-to-buffer gnus-article-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (bury-buffer gnus-article-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (switch-to-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (t ;No good rules.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (find-file-other-window file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (gnus-kill-file-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun gnus-kill-set-kill-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (let* ((file (gnus-newsgroup-kill-file gnus-newsgroup-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (buffer (find-file-noselect file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (gnus-kill-file-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (bury-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (defun gnus-kill-file-enter-kill (field regexp &optional dont-move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; Enter kill file entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;; FIELD: String containing the name of the header field to kill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; REGEXP: The string to kill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let (string)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
202 (unless (eq major-mode 'gnus-kill-file-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
203 (gnus-kill-set-kill-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (unless dont-move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (insert (setq string (format "(gnus-kill %S %S)\n" field regexp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (gnus-kill-file-apply-string string))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
208
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defun gnus-kill-file-kill-by-subject ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "Kill by subject."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (gnus-kill-file-enter-kill
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
213 "Subject"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if (vectorp gnus-current-headers)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
215 (regexp-quote
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (gnus-simplify-subject (mail-header-subject gnus-current-headers)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
217 "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
218 t))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
219
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defun gnus-kill-file-kill-by-author ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "Kill by author."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (gnus-kill-file-enter-kill
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
224 "From"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if (vectorp gnus-current-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (regexp-quote (mail-header-from gnus-current-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "") t))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
228
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defun gnus-kill-file-kill-by-thread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "Kill by author."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (gnus-kill-file-enter-kill
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
233 "References"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (vectorp gnus-current-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (regexp-quote (mail-header-id gnus-current-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 "")))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
237
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun gnus-kill-file-kill-by-xref ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Kill by Xref."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (interactive)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
241 (let ((xref (and (vectorp gnus-current-headers)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (mail-header-xref gnus-current-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (start 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if xref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (while (string-match " \\([^ \t]+\\):" xref start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq start (match-end 0))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
248 (when (not (string=
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
249 (setq group
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
250 (substring xref (match-beginning 1) (match-end 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
251 gnus-newsgroup-name))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
252 (gnus-kill-file-enter-kill
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
253 "Xref" (concat " " (regexp-quote group) ":") t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (gnus-kill-file-enter-kill "Xref" "" t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defun gnus-kill-file-raise-followups-to-author (level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Raise score for all followups to the current author."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (let ((name (mail-header-from gnus-current-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (gnus-kill-set-kill-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (setq name (read-string (concat "Add " level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 " to followup articles to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (regexp-quote name)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
267 (setq
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "(gnus-kill %S %S '(gnus-summary-temporarily-raise-by-thread %S))\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "From" name level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (gnus-kill-file-apply-string string))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
274 (gnus-message
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 6 "Added temporary score file entry for followups to %s." name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defun gnus-kill-file-apply-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 "Apply current buffer to current newsgroup."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (if (and gnus-current-kill-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (get-buffer gnus-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; Assume newsgroup is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (gnus-kill-file-apply-string (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (ding) (gnus-message 2 "No newsgroup is selected.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun gnus-kill-file-apply-string (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "Apply STRING to current newsgroup."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (let ((string (concat "(progn \n" string "\n)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (pop-to-buffer gnus-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (eval (car (read-from-string string)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defun gnus-kill-file-apply-last-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "Apply sexp before point in current buffer to current newsgroup."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (if (and gnus-current-kill-article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (get-buffer gnus-summary-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; Assume newsgroup is selected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let ((string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (save-excursion (forward-sexp -1) (point)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (pop-to-buffer gnus-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (eval (car (read-from-string string))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (ding) (gnus-message 2 "No newsgroup is selected.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defun gnus-kill-file-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "Save a kill file, then return to the previous buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let ((killbuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; We don't want to return to article buffer.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
316 (when (get-buffer gnus-article-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
317 (bury-buffer gnus-article-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;; Delete the KILL file windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (delete-windows-on killbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; Restore last window configuration if available.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
321 (when gnus-winconf-kill-file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
322 (set-window-configuration gnus-winconf-kill-file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq gnus-winconf-kill-file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; Kill the KILL file buffer. Suggested by tale@pawl.rpi.edu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (kill-buffer killbuf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; For kill files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defun gnus-Newsgroup-kill-file (newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 "Return the name of a kill file for NEWSGROUP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 If NEWSGROUP is nil, return the global kill file instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (cond ((or (null newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (string-equal newsgroup ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; The global kill file is placed at top of the directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (expand-file-name gnus-kill-file-name gnus-kill-files-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (gnus-use-long-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; Append ".KILL" to capitalized newsgroup name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (expand-file-name (concat (gnus-capitalize-newsgroup newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 "." gnus-kill-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 gnus-kill-files-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; Place "KILL" under the hierarchical directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "/" gnus-kill-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 gnus-kill-files-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun gnus-expunge (marks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Remove lines marked with MARKS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (set-buffer gnus-summary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (gnus-summary-limit-to-marks marks 'reverse)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defun gnus-apply-kill-file-unless-scored ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "Apply .KILL file, unless a .SCORE file for the same newsgroup exists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (cond ((file-exists-p (gnus-score-file-name gnus-newsgroup-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; Ignores global KILL.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
357 (when (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
358 (gnus-message 3 "Note: Ignoring %s.KILL; preferring .SCORE"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
359 gnus-newsgroup-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ((or (file-exists-p (gnus-newsgroup-kill-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (gnus-apply-kill-file-internal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defun gnus-apply-kill-file-internal ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "Apply a kill file to the current newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 Returns the number of articles marked as read."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (let* ((kill-files (list (gnus-newsgroup-kill-file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (gnus-newsgroup-kill-file gnus-newsgroup-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (unreads (length gnus-newsgroup-unreads))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (gnus-summary-inhibit-highlight t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq gnus-newsgroup-kill-headers nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; If there are any previously scored articles, we remove these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; from the `gnus-newsgroup-headers' list that the score functions
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
378 ;; will see. This is probably pretty wasteful when it comes to
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; conses, but is, I think, faster than having to assq in every
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; single score function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (let ((files kill-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (while files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if (file-exists-p (car files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (let ((headers gnus-newsgroup-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if gnus-kill-killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (setq gnus-newsgroup-kill-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (mapcar (lambda (header) (mail-header-number header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (while headers
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
390 (unless (gnus-member-of-range
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
391 (mail-header-number (car headers))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
392 gnus-newsgroup-killed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
393 (push (mail-header-number (car headers))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
394 gnus-newsgroup-kill-headers))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (setq headers (cdr headers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (setq files nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (setq files (cdr files)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if (not gnus-newsgroup-kill-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (while kill-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (if (not (file-exists-p (car kill-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (gnus-message 6 "Processing kill file %s..." (car kill-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (find-file (car kill-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (gnus-add-current-to-buffer-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
410 (if (consp (ignore-errors (read (current-buffer))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (gnus-kill-parse-gnus-kill-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (gnus-kill-parse-rn-kill-file))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
413
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
414 (gnus-message
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 6 "Processing kill file %s...done" (car kill-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (setq kill-files (cdr kill-files)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (gnus-set-mode-line 'summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (if beg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (let ((nunreads (- unreads (length gnus-newsgroup-unreads))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (or (eq nunreads 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (gnus-message 6 "Marked %d articles as read" nunreads))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 nunreads)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ;; Parse a Gnus killfile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun gnus-score-insert-help (string alist idx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (pop-to-buffer "*Score Help*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (insert string ":\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (insert (format " %c: %s\n" (caar alist) (nth idx (car alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (setq alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (defun gnus-kill-parse-gnus-kill-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (gnus-kill-file-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (let (beg form)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
442 (while (progn
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setq beg (point))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
444 (setq form (ignore-errors (read (current-buffer)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
445 (unless (listp form)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
446 (error "Illegal kill entry (possibly rn kill file?): %s" form))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (if (or (eq (car form) 'gnus-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (eq (car form) 'gnus-raise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (eq (car form) 'gnus-lower))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (insert (or (eval form) "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (set-buffer gnus-summary-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
455 (ignore-errors (eval form)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
456 (and (buffer-modified-p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 gnus-kill-save-kill-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (set-buffer-modified-p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;; Parse an rn killfile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun gnus-kill-parse-rn-kill-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (gnus-kill-file-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (let ((mod-to-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 '((?a . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (?h . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (?f . "from")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (?: . "subject")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (com-to-com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 '((?m . " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (?j . "X")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 pattern modifier commands)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if (not (looking-at "[ \t]*/\\([^/]*\\)/\\([ahfcH]\\)?:\\([a-z=:]*\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq pattern (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (setq modifier (if (match-beginning 2) (char-after (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ?s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq commands (buffer-substring (match-beginning 3) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; The "f:+" command marks everything *but* the matches as read,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; so we simply first match everything as read, and then unmark
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
484 ;; PATTERN later.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
485 (when (string-match "\\+" commands)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
486 (gnus-kill "from" ".")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
487 (setq commands "m"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
489 (gnus-kill
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (or (cdr (assq modifier mod-to-header)) "subject")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
491 pattern
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
492 (if (string-match "m" commands)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 '(gnus-summary-mark-as-unread nil " ")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
494 '(gnus-summary-mark-as-read nil "X"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; Kill changes and new format by suggested by JWZ and Sudish Joseph
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
499 ;; <joseph@cis.ohio-state.edu>.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (defun gnus-kill (field regexp &optional exe-command all silent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 "If FIELD of an article matches REGEXP, execute COMMAND.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 Optional 1st argument COMMAND is default to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (gnus-summary-mark-as-read nil \"X\").
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 If optional 2nd argument ALL is non-nil, articles marked are also applied to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 If FIELD is an empty string (or nil), entire article body is searched for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 COMMAND must be a lisp expression or a string representing a key sequence."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; We don't want to change current point nor window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (let ((old-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; Selected window must be summary buffer to execute keyboard
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
512 ;; macros correctly. See command_loop_1.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (switch-to-buffer gnus-summary-buffer 'norecord)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (goto-char (point-min)) ;From the beginning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (let ((kill-list regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (date (current-time-string))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
517 (command (or exe-command '(gnus-summary-mark-as-read
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 nil gnus-kill-file-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 kill kdate prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (if (listp kill-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; It is a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (if (not (consp (cdr kill-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; It's on the form (regexp . date).
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
524 (if (zerop (gnus-execute field (car kill-list)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 command nil (not all)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
526 (when (> (gnus-days-between date (cdr kill-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
527 gnus-kill-expiry-days)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
528 (setq regexp nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setcdr kill-list date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (while (setq kill (car kill-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (if (consp kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; It's a temporary kill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (setq kdate (cdr kill))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
535 (if (zerop (gnus-execute
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 field (car kill) command nil (not all)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
537 (when (> (gnus-days-between date kdate)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
538 gnus-kill-expiry-days)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
539 ;; Time limit has been exceeded, so we
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
540 ;; remove the match.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
541 (if prev
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
542 (setcdr prev (cdr kill-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
543 (setq regexp (cdr regexp))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
544 ;; Successful kill. Set the date to today.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (setcdr kill date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; It's a permanent kill.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (gnus-execute field kill command nil (not all)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq prev kill-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (setq kill-list (cdr kill-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (gnus-execute field kill-list command nil (not all))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (switch-to-buffer old-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
552 (when (and (eq major-mode 'gnus-kill-file-mode) regexp (not silent))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
553 (gnus-pp-gnus-kill
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
554 (nconc (list 'gnus-kill field
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
555 (if (consp regexp) (list 'quote regexp) regexp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
556 (when (or exe-command all)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
557 (list (list 'quote exe-command)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
558 (if all (list t) nil))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (defun gnus-pp-gnus-kill (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (if (or (not (consp (nth 2 object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (not (consp (cdr (nth 2 object))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (and (eq 'quote (car (nth 2 object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (not (consp (cdadr (nth 2 object))))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
565 (concat "\n" (gnus-prin1-to-string object))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (set-buffer (get-buffer-create "*Gnus PP*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (insert (format "\n(%S %S\n '(" (nth 0 object) (nth 1 object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (let ((klist (cadr (nth 2 object)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (first t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (while klist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (insert (if first (progn (setq first nil) "") "\n ")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
575 (gnus-prin1-to-string (car klist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (setq klist (cdr klist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (insert ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (and (nth 3 object)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
579 (insert "\n "
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (if (and (consp (nth 3 object))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
581 (not (eq 'quote (car (nth 3 object)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "'" "")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
583 (gnus-prin1-to-string (nth 3 object))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
584 (when (nth 4 object)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
585 (insert "\n t"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (insert ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (buffer-substring (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun gnus-execute-1 (function regexp form header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (let (did-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (if (null header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 nil ;Nothing to do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (if function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; Compare with header field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (let (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (and header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (setq value (funcall function header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; Number (Lines:) or symbol must be converted to string.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
603 (unless (stringp value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
604 (setq value (gnus-prin1-to-string value)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (setq did-kill (string-match regexp value)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
606 (cond ((stringp form) ;Keyboard macro.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (execute-kbd-macro form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ((gnus-functionp form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (funcall form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (eval form)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; Search article body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (let ((gnus-current-article nil) ;Save article pointer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (gnus-last-article nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (gnus-break-pages nil) ;No need to break pages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (gnus-mark-article-hook nil)) ;Inhibit marking as read.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
617 (gnus-message
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 6 "Searching for article: %d..." (mail-header-number header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (gnus-article-setup-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (gnus-article-prepare (mail-header-number header) t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
621 (when (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
622 (set-buffer gnus-article-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
623 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
624 (setq did-kill (re-search-forward regexp nil t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
625 (cond ((stringp form) ;Keyboard macro.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
626 (execute-kbd-macro form))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
627 ((gnus-functionp form)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
628 (funcall form))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
629 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
630 (eval form)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 did-kill)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
633 (defun gnus-execute (field regexp form &optional backward unread)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "If FIELD of article header matches REGEXP, execute lisp FORM (or a string).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 If FIELD is an empty string (or nil), entire article body is searched for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 If optional 1st argument BACKWARD is non-nil, do backward instead.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
637 If optional 2nd argument UNREAD is non-nil, articles which are
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 marked as read or ticked are ignored."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (let ((killed-no 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 function article header)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
642 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; Search body.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
644 ((or (null field)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (string-equal field ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (setq function nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;; Get access function of header field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ((fboundp
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
649 (setq function
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
650 (intern-soft
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (concat "mail-header-" (downcase field)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (setq function `(lambda (h) (,function h))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; Signal error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (error "Unknown header field: \"%s\"" field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ;; Starting from the current article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (while (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;; First article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (and (not article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (setq article (gnus-summary-article-number)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;; Find later articles.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
662 (setq article
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
663 (gnus-summary-search-forward unread nil backward)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (and (or (null gnus-newsgroup-kill-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (memq article gnus-newsgroup-kill-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (vectorp (setq header (gnus-summary-article-header article)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (gnus-execute-1 function regexp form header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (setq killed-no (1+ killed-no))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ;; Return the number of killed articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 killed-no)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
672 ;;;###autoload
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
673 (defalias 'gnus-batch-kill 'gnus-batch-score)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
674 ;;;###autoload
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
675 (defun gnus-batch-score ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
676 "Run batched scoring.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
677 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
678 Newsgroups is a list of strings in Bnews format. If you want to score
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
679 the comp hierarchy, you'd say \"comp.all\". If you would not like to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
680 score the alt hierarchy, you'd say \"!alt.all\"."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
681 (interactive)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
682 (let* ((gnus-newsrc-options-n
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
683 (gnus-newsrc-parse-options
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
684 (concat "options -n "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
685 (mapconcat 'identity command-line-args-left " "))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
686 (gnus-expert-user t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
687 (nnmail-spool-file nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
688 (gnus-use-dribble-file nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
689 (gnus-batch-mode t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
690 group newsrc entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
691 ;; Disable verbose message.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
692 gnus-novice-user gnus-large-newsgroup
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
693 gnus-options-subscribe gnus-auto-subscribed-groups
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
694 gnus-options-not-subscribe)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
695 ;; Eat all arguments.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
696 (setq command-line-args-left nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
697 (gnus-slave)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
698 ;; Apply kills to specified newsgroups in command line arguments.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
699 (setq newsrc (cdr gnus-newsrc-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
700 (while (setq group (car (pop newsrc)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
701 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
702 (when (and (<= (gnus-info-level (car newsrc)) gnus-level-subscribed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
703 (and (car entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
704 (or (eq (car entry) t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
705 (not (zerop (car entry)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
706 ;;(eq (gnus-matches-options-n group) 'subscribe)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
707 )
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
708 (gnus-summary-read-group group nil t nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
709 (when (eq (current-buffer) (get-buffer gnus-summary-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
710 (gnus-summary-exit))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
711 ;; Exit Emacs.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
712 (switch-to-buffer gnus-group-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
713 (gnus-group-save-newsrc)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
714
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (provide 'gnus-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ;;; gnus-kill.el ends here