Mercurial > emacs
annotate lisp/gnus/gnus-agent.el @ 32155:d218ef159e45
(icon-mode): Don't gratuitously override the default for comment-column.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 05 Oct 2000 01:58:16 +0000 |
parents | 9968f55ad26e |
children | 2e19cd4c5909 |
rev | line source |
---|---|
24358 | 1 ;;; gnus-agent.el --- unplugged support for Gnus |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
2 ;; Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
24358 | 3 |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
9 ;; the Free Software Foundation; either version 2, or (at your option) | |
10 ;; any later version. | |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 ;; Boston, MA 02111-1307, USA. | |
21 | |
22 ;;; Commentary: | |
23 | |
24 ;;; Code: | |
25 | |
26 (require 'gnus) | |
27 (require 'gnus-cache) | |
28 (require 'nnvirtual) | |
29 (require 'gnus-sum) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
30 (eval-when-compile |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
31 (require 'timer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
32 (require 'cl) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
33 (require 'gnus-score)) |
24358 | 34 |
35 (defcustom gnus-agent-directory (nnheader-concat gnus-directory "agent/") | |
36 "Where the Gnus agent will store its files." | |
37 :group 'gnus-agent | |
38 :type 'directory) | |
39 | |
40 (defcustom gnus-agent-plugged-hook nil | |
41 "Hook run when plugging into the network." | |
42 :group 'gnus-agent | |
43 :type 'hook) | |
44 | |
45 (defcustom gnus-agent-unplugged-hook nil | |
46 "Hook run when unplugging from the network." | |
47 :group 'gnus-agent | |
48 :type 'hook) | |
49 | |
50 (defcustom gnus-agent-handle-level gnus-level-subscribed | |
51 "Groups on levels higher than this variable will be ignored by the Agent." | |
52 :group 'gnus-agent | |
53 :type 'integer) | |
54 | |
55 (defcustom gnus-agent-expire-days 7 | |
56 "Read articles older than this will be expired." | |
57 :group 'gnus-agent | |
58 :type 'integer) | |
59 | |
60 (defcustom gnus-agent-expire-all nil | |
61 "If non-nil, also expire unread, ticked and dormant articles. | |
62 If nil, only read articles will be expired." | |
63 :group 'gnus-agent | |
64 :type 'boolean) | |
65 | |
66 (defcustom gnus-agent-group-mode-hook nil | |
67 "Hook run in Agent group minor modes." | |
68 :group 'gnus-agent | |
69 :type 'hook) | |
70 | |
71 (defcustom gnus-agent-summary-mode-hook nil | |
72 "Hook run in Agent summary minor modes." | |
73 :group 'gnus-agent | |
74 :type 'hook) | |
75 | |
76 (defcustom gnus-agent-server-mode-hook nil | |
77 "Hook run in Agent summary minor modes." | |
78 :group 'gnus-agent | |
79 :type 'hook) | |
80 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
81 (defcustom gnus-agent-confirmation-function 'y-or-n-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
82 "Function to confirm when error happens." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
83 :group 'gnus-agent |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
84 :type 'function) |
24358 | 85 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
86 ;;; Internal variables |
24358 | 87 |
88 (defvar gnus-agent-history-buffers nil) | |
89 (defvar gnus-agent-buffer-alist nil) | |
90 (defvar gnus-agent-article-alist nil) | |
91 (defvar gnus-agent-group-alist nil) | |
92 (defvar gnus-agent-covered-methods nil) | |
93 (defvar gnus-category-alist nil) | |
94 (defvar gnus-agent-current-history nil) | |
95 (defvar gnus-agent-overview-buffer nil) | |
96 (defvar gnus-category-predicate-cache nil) | |
97 (defvar gnus-category-group-cache nil) | |
98 (defvar gnus-agent-spam-hashtb nil) | |
99 (defvar gnus-agent-file-name nil) | |
100 (defvar gnus-agent-send-mail-function nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
101 (defvar gnus-agent-file-coding-system 'raw-text) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
102 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
103 (defconst gnus-agent-scoreable-headers |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
104 '("subject" "from" "date" "message-id" "references" "chars" "lines" "xref") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
105 "Headers that are considered when scoring articles for download via the Agent.") |
24358 | 106 |
107 ;; Dynamic variables | |
108 (defvar gnus-headers) | |
109 (defvar gnus-score) | |
110 | |
111 ;;; | |
112 ;;; Setup | |
113 ;;; | |
114 | |
115 (defun gnus-open-agent () | |
116 (setq gnus-agent t) | |
117 (gnus-agent-read-servers) | |
118 (gnus-category-read) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
119 (gnus-agent-create-buffer) |
24358 | 120 (add-hook 'gnus-group-mode-hook 'gnus-agent-mode) |
121 (add-hook 'gnus-summary-mode-hook 'gnus-agent-mode) | |
122 (add-hook 'gnus-server-mode-hook 'gnus-agent-mode)) | |
123 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
124 (defun gnus-agent-create-buffer () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
125 (if (gnus-buffer-live-p gnus-agent-overview-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
126 t |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
127 (setq gnus-agent-overview-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
128 (gnus-get-buffer-create " *Gnus agent overview*")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
129 (with-current-buffer gnus-agent-overview-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
130 (mm-enable-multibyte)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
131 nil)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
132 |
24358 | 133 (gnus-add-shutdown 'gnus-close-agent 'gnus) |
134 | |
135 (defun gnus-close-agent () | |
136 (setq gnus-agent-covered-methods nil | |
137 gnus-category-predicate-cache nil | |
138 gnus-category-group-cache nil | |
139 gnus-agent-spam-hashtb nil) | |
140 (gnus-kill-buffer gnus-agent-overview-buffer)) | |
141 | |
142 ;;; | |
143 ;;; Utility functions | |
144 ;;; | |
145 | |
146 (defun gnus-agent-read-file (file) | |
147 "Load FILE and do a `read' there." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
148 (with-temp-buffer |
24358 | 149 (ignore-errors |
150 (nnheader-insert-file-contents file) | |
151 (goto-char (point-min)) | |
152 (read (current-buffer))))) | |
153 | |
154 (defsubst gnus-agent-method () | |
155 (concat (symbol-name (car gnus-command-method)) "/" | |
156 (if (equal (cadr gnus-command-method) "") | |
157 "unnamed" | |
158 (cadr gnus-command-method)))) | |
159 | |
160 (defsubst gnus-agent-directory () | |
161 "Path of the Gnus agent directory." | |
162 (nnheader-concat gnus-agent-directory | |
163 (nnheader-translate-file-chars (gnus-agent-method)) "/")) | |
164 | |
165 (defun gnus-agent-lib-file (file) | |
166 "The full path of the Gnus agent library FILE." | |
167 (concat (gnus-agent-directory) "agent.lib/" file)) | |
168 | |
169 ;;; Fetching setup functions. | |
170 | |
171 (defun gnus-agent-start-fetch () | |
172 "Initialize data structures for efficient fetching." | |
173 (gnus-agent-open-history) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
174 (setq gnus-agent-current-history (gnus-agent-history-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
175 (gnus-agent-create-buffer)) |
24358 | 176 |
177 (defun gnus-agent-stop-fetch () | |
178 "Save all data structures and clean up." | |
179 (gnus-agent-save-history) | |
180 (gnus-agent-close-history) | |
181 (setq gnus-agent-spam-hashtb nil) | |
182 (save-excursion | |
183 (set-buffer nntp-server-buffer) | |
184 (widen))) | |
185 | |
186 (defmacro gnus-agent-with-fetch (&rest forms) | |
187 "Do FORMS safely." | |
188 `(unwind-protect | |
189 (progn | |
190 (gnus-agent-start-fetch) | |
191 ,@forms) | |
192 (gnus-agent-stop-fetch))) | |
193 | |
194 (put 'gnus-agent-with-fetch 'lisp-indent-function 0) | |
195 (put 'gnus-agent-with-fetch 'edebug-form-spec '(body)) | |
196 | |
197 ;;; | |
198 ;;; Mode infestation | |
199 ;;; | |
200 | |
201 (defvar gnus-agent-mode-hook nil | |
202 "Hook run when installing agent mode.") | |
203 | |
204 (defvar gnus-agent-mode nil) | |
205 (defvar gnus-agent-mode-status '(gnus-agent-mode " Plugged")) | |
206 | |
207 (defun gnus-agent-mode () | |
208 "Minor mode for providing a agent support in Gnus buffers." | |
209 (let* ((buffer (progn (string-match "^gnus-\\(.*\\)-mode$" | |
210 (symbol-name major-mode)) | |
211 (match-string 1 (symbol-name major-mode)))) | |
212 (mode (intern (format "gnus-agent-%s-mode" buffer)))) | |
213 (set (make-local-variable 'gnus-agent-mode) t) | |
214 (set mode nil) | |
215 (set (make-local-variable mode) t) | |
216 ;; Set up the menu. | |
217 (when (gnus-visual-p 'agent-menu 'menu) | |
218 (funcall (intern (format "gnus-agent-%s-make-menu-bar" buffer)))) | |
219 (unless (assq 'gnus-agent-mode minor-mode-alist) | |
220 (push gnus-agent-mode-status minor-mode-alist)) | |
221 (unless (assq mode minor-mode-map-alist) | |
222 (push (cons mode (symbol-value (intern (format "gnus-agent-%s-mode-map" | |
223 buffer)))) | |
224 minor-mode-map-alist)) | |
225 (when (eq major-mode 'gnus-group-mode) | |
226 (gnus-agent-toggle-plugged gnus-plugged)) | |
227 (gnus-run-hooks 'gnus-agent-mode-hook | |
228 (intern (format "gnus-agent-%s-mode-hook" buffer))))) | |
229 | |
230 (defvar gnus-agent-group-mode-map (make-sparse-keymap)) | |
231 (gnus-define-keys gnus-agent-group-mode-map | |
232 "Ju" gnus-agent-fetch-groups | |
233 "Jc" gnus-enter-category-buffer | |
234 "Jj" gnus-agent-toggle-plugged | |
235 "Js" gnus-agent-fetch-session | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
236 "JY" gnus-agent-synchronize |
24358 | 237 "JS" gnus-group-send-drafts |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
238 "Ja" gnus-agent-add-group |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
239 "Jr" gnus-agent-remove-group) |
24358 | 240 |
241 (defun gnus-agent-group-make-menu-bar () | |
242 (unless (boundp 'gnus-agent-group-menu) | |
243 (easy-menu-define | |
244 gnus-agent-group-menu gnus-agent-group-mode-map "" | |
245 '("Agent" | |
246 ["Toggle plugged" gnus-agent-toggle-plugged t] | |
247 ["List categories" gnus-enter-category-buffer t] | |
248 ["Send drafts" gnus-group-send-drafts gnus-plugged] | |
249 ("Fetch" | |
250 ["All" gnus-agent-fetch-session gnus-plugged] | |
251 ["Group" gnus-agent-fetch-group gnus-plugged]))))) | |
252 | |
253 (defvar gnus-agent-summary-mode-map (make-sparse-keymap)) | |
254 (gnus-define-keys gnus-agent-summary-mode-map | |
255 "Jj" gnus-agent-toggle-plugged | |
256 "J#" gnus-agent-mark-article | |
257 "J\M-#" gnus-agent-unmark-article | |
258 "@" gnus-agent-toggle-mark | |
259 "Jc" gnus-agent-catchup) | |
260 | |
261 (defun gnus-agent-summary-make-menu-bar () | |
262 (unless (boundp 'gnus-agent-summary-menu) | |
263 (easy-menu-define | |
264 gnus-agent-summary-menu gnus-agent-summary-mode-map "" | |
265 '("Agent" | |
266 ["Toggle plugged" gnus-agent-toggle-plugged t] | |
267 ["Mark as downloadable" gnus-agent-mark-article t] | |
268 ["Unmark as downloadable" gnus-agent-unmark-article t] | |
269 ["Toggle mark" gnus-agent-toggle-mark t] | |
270 ["Catchup undownloaded" gnus-agent-catchup t])))) | |
271 | |
272 (defvar gnus-agent-server-mode-map (make-sparse-keymap)) | |
273 (gnus-define-keys gnus-agent-server-mode-map | |
274 "Jj" gnus-agent-toggle-plugged | |
275 "Ja" gnus-agent-add-server | |
276 "Jr" gnus-agent-remove-server) | |
277 | |
278 (defun gnus-agent-server-make-menu-bar () | |
279 (unless (boundp 'gnus-agent-server-menu) | |
280 (easy-menu-define | |
281 gnus-agent-server-menu gnus-agent-server-mode-map "" | |
282 '("Agent" | |
283 ["Toggle plugged" gnus-agent-toggle-plugged t] | |
284 ["Add" gnus-agent-add-server t] | |
285 ["Remove" gnus-agent-remove-server t])))) | |
286 | |
287 (defun gnus-agent-toggle-plugged (plugged) | |
288 "Toggle whether Gnus is unplugged or not." | |
289 (interactive (list (not gnus-plugged))) | |
290 (if plugged | |
291 (progn | |
292 (setq gnus-plugged plugged) | |
293 (gnus-run-hooks 'gnus-agent-plugged-hook) | |
294 (setcar (cdr gnus-agent-mode-status) " Plugged")) | |
295 (gnus-agent-close-connections) | |
296 (setq gnus-plugged plugged) | |
297 (gnus-run-hooks 'gnus-agent-unplugged-hook) | |
298 (setcar (cdr gnus-agent-mode-status) " Unplugged")) | |
299 (set-buffer-modified-p t)) | |
300 | |
301 (defun gnus-agent-close-connections () | |
302 "Close all methods covered by the Gnus agent." | |
303 (let ((methods gnus-agent-covered-methods)) | |
304 (while methods | |
305 (gnus-close-server (pop methods))))) | |
306 | |
307 ;;;###autoload | |
308 (defun gnus-unplugged () | |
309 "Start Gnus unplugged." | |
310 (interactive) | |
311 (setq gnus-plugged nil) | |
312 (gnus)) | |
313 | |
314 ;;;###autoload | |
315 (defun gnus-plugged () | |
316 "Start Gnus plugged." | |
317 (interactive) | |
318 (setq gnus-plugged t) | |
319 (gnus)) | |
320 | |
321 ;;;###autoload | |
322 (defun gnus-agentize () | |
323 "Allow Gnus to be an offline newsreader. | |
324 The normal usage of this command is to put the following as the | |
325 last form in your `.gnus.el' file: | |
326 | |
327 \(gnus-agentize) | |
328 | |
329 This will modify the `gnus-before-startup-hook', `gnus-post-method', | |
330 and `message-send-mail-function' variables, and install the Gnus | |
331 agent minor mode in all Gnus buffers." | |
332 (interactive) | |
333 (gnus-open-agent) | |
334 (add-hook 'gnus-setup-news-hook 'gnus-agent-queue-setup) | |
335 (unless gnus-agent-send-mail-function | |
336 (setq gnus-agent-send-mail-function message-send-mail-function | |
337 message-send-mail-function 'gnus-agent-send-mail)) | |
338 (unless gnus-agent-covered-methods | |
339 (setq gnus-agent-covered-methods (list gnus-select-method)))) | |
340 | |
341 (defun gnus-agent-queue-setup () | |
342 "Make sure the queue group exists." | |
343 (unless (gnus-gethash "nndraft:queue" gnus-newsrc-hashtb) | |
344 (gnus-request-create-group "queue" '(nndraft "")) | |
345 (let ((gnus-level-default-subscribed 1)) | |
346 (gnus-subscribe-group "nndraft:queue" nil '(nndraft ""))) | |
347 (gnus-group-set-parameter | |
348 "nndraft:queue" 'gnus-dummy '((gnus-draft-mode))))) | |
349 | |
350 (defun gnus-agent-send-mail () | |
351 (if gnus-plugged | |
352 (funcall gnus-agent-send-mail-function) | |
353 (goto-char (point-min)) | |
354 (re-search-forward | |
355 (concat "^" (regexp-quote mail-header-separator) "\n")) | |
356 (replace-match "\n") | |
357 (gnus-agent-insert-meta-information 'mail) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
358 (gnus-request-accept-article "nndraft:queue" nil t t))) |
24358 | 359 |
360 (defun gnus-agent-insert-meta-information (type &optional method) | |
361 "Insert meta-information into the message that says how it's to be posted. | |
362 TYPE can be either `mail' or `news'. If the latter METHOD can | |
363 be a select method." | |
364 (save-excursion | |
365 (message-remove-header gnus-agent-meta-information-header) | |
366 (goto-char (point-min)) | |
367 (insert gnus-agent-meta-information-header ": " | |
368 (symbol-name type) " " (format "%S" method) | |
369 "\n") | |
370 (forward-char -1) | |
371 (while (search-backward "\n" nil t) | |
372 (replace-match "\\n" t t)))) | |
373 | |
374 ;;; | |
375 ;;; Group mode commands | |
376 ;;; | |
377 | |
378 (defun gnus-agent-fetch-groups (n) | |
379 "Put all new articles in the current groups into the Agent." | |
380 (interactive "P") | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
381 (unless gnus-plugged |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
382 (error "Groups can't be fetched when Gnus is unplugged")) |
24358 | 383 (gnus-group-iterate n 'gnus-agent-fetch-group)) |
384 | |
385 (defun gnus-agent-fetch-group (group) | |
386 "Put all new articles in GROUP into the Agent." | |
387 (interactive (list (gnus-group-group-name))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
388 (unless gnus-plugged |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
389 (error "Groups can't be fetched when Gnus is unplugged")) |
24358 | 390 (unless group |
391 (error "No group on the current line")) | |
392 (let ((gnus-command-method (gnus-find-method-for-group group))) | |
393 (gnus-agent-with-fetch | |
394 (gnus-agent-fetch-group-1 group gnus-command-method) | |
395 (gnus-message 5 "Fetching %s...done" group)))) | |
396 | |
397 (defun gnus-agent-add-group (category arg) | |
398 "Add the current group to an agent category." | |
399 (interactive | |
400 (list | |
401 (intern | |
402 (completing-read | |
403 "Add to category: " | |
404 (mapcar (lambda (cat) (list (symbol-name (car cat)))) | |
405 gnus-category-alist) | |
406 nil t)) | |
407 current-prefix-arg)) | |
408 (let ((cat (assq category gnus-category-alist)) | |
409 c groups) | |
410 (gnus-group-iterate arg | |
411 (lambda (group) | |
412 (when (cadddr (setq c (gnus-group-category group))) | |
413 (setf (cadddr c) (delete group (cadddr c)))) | |
414 (push group groups))) | |
415 (setf (cadddr cat) (nconc (cadddr cat) groups)) | |
416 (gnus-category-write))) | |
417 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
418 (defun gnus-agent-remove-group (arg) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
419 "Remove the current group from its agent category, if any." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
420 (interactive "P") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
421 (let (c) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
422 (gnus-group-iterate arg |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
423 (lambda (group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
424 (when (cadddr (setq c (gnus-group-category group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
425 (setf (cadddr c) (delete group (cadddr c)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
426 (gnus-category-write))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
427 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
428 (defun gnus-agent-synchronize () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
429 "Synchronize local, unplugged, data with backend. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
430 Currently sends flag setting requests, if any." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
431 (interactive) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
432 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
433 (dolist (gnus-command-method gnus-agent-covered-methods) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
434 (when (file-exists-p (gnus-agent-lib-file "flags")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
435 (set-buffer (get-buffer-create " *Gnus Agent flag synchronize*")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
436 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
437 (nnheader-insert-file-contents (gnus-agent-lib-file "flags")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
438 (if (null (gnus-check-server gnus-command-method)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
439 (message "Couldn't open server %s" (nth 1 gnus-command-method)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
440 (while (not (eobp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
441 (if (null (eval (read (current-buffer)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
442 (progn (forward-line) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
443 (kill-line -1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
444 (write-file (gnus-agent-lib-file "flags")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
445 (error "Couldn't set flags from file %s" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
446 (gnus-agent-lib-file "flags")))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
447 (write-file (gnus-agent-lib-file "flags"))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
448 (kill-buffer nil))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
449 |
24358 | 450 ;;; |
451 ;;; Server mode commands | |
452 ;;; | |
453 | |
454 (defun gnus-agent-add-server (server) | |
455 "Enroll SERVER in the agent program." | |
456 (interactive (list (gnus-server-server-name))) | |
457 (unless server | |
458 (error "No server on the current line")) | |
459 (let ((method (gnus-server-get-method nil (gnus-server-server-name)))) | |
460 (when (member method gnus-agent-covered-methods) | |
461 (error "Server already in the agent program")) | |
462 (push method gnus-agent-covered-methods) | |
463 (gnus-agent-write-servers) | |
464 (message "Entered %s into the Agent" server))) | |
465 | |
466 (defun gnus-agent-remove-server (server) | |
467 "Remove SERVER from the agent program." | |
468 (interactive (list (gnus-server-server-name))) | |
469 (unless server | |
470 (error "No server on the current line")) | |
471 (let ((method (gnus-server-get-method nil (gnus-server-server-name)))) | |
472 (unless (member method gnus-agent-covered-methods) | |
473 (error "Server not in the agent program")) | |
474 (setq gnus-agent-covered-methods | |
475 (delete method gnus-agent-covered-methods)) | |
476 (gnus-agent-write-servers) | |
477 (message "Removed %s from the agent" server))) | |
478 | |
479 (defun gnus-agent-read-servers () | |
480 "Read the alist of covered servers." | |
481 (setq gnus-agent-covered-methods | |
482 (gnus-agent-read-file | |
483 (nnheader-concat gnus-agent-directory "lib/servers")))) | |
484 | |
485 (defun gnus-agent-write-servers () | |
486 "Write the alist of covered servers." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
487 (gnus-make-directory (nnheader-concat gnus-agent-directory "lib")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
488 (let ((coding-system-for-write nnheader-file-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
489 (file-name-coding-system nnmail-pathname-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
490 (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
491 (prin1 gnus-agent-covered-methods (current-buffer))))) |
24358 | 492 |
493 ;;; | |
494 ;;; Summary commands | |
495 ;;; | |
496 | |
497 (defun gnus-agent-mark-article (n &optional unmark) | |
498 "Mark the next N articles as downloadable. | |
499 If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
500 the mark instead. The difference between N and the actual number of | |
501 articles marked is returned." | |
502 (interactive "p") | |
503 (let ((backward (< n 0)) | |
504 (n (abs n))) | |
505 (while (and | |
506 (> n 0) | |
507 (progn | |
508 (gnus-summary-set-agent-mark | |
509 (gnus-summary-article-number) unmark) | |
510 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))) | |
511 (setq n (1- n))) | |
512 (when (/= 0 n) | |
513 (gnus-message 7 "No more articles")) | |
514 (gnus-summary-recenter) | |
515 (gnus-summary-position-point) | |
516 n)) | |
517 | |
518 (defun gnus-agent-unmark-article (n) | |
519 "Remove the downloadable mark from the next N articles. | |
520 If N is negative, unmark backward instead. The difference between N and | |
521 the actual number of articles unmarked is returned." | |
522 (interactive "p") | |
523 (gnus-agent-mark-article n t)) | |
524 | |
525 (defun gnus-agent-toggle-mark (n) | |
526 "Toggle the downloadable mark from the next N articles. | |
527 If N is negative, toggle backward instead. The difference between N and | |
528 the actual number of articles toggled is returned." | |
529 (interactive "p") | |
530 (gnus-agent-mark-article n 'toggle)) | |
531 | |
532 (defun gnus-summary-set-agent-mark (article &optional unmark) | |
533 "Mark ARTICLE as downloadable." | |
534 (let ((unmark (if (and (not (null unmark)) (not (eq t unmark))) | |
535 (memq article gnus-newsgroup-downloadable) | |
536 unmark))) | |
537 (if unmark | |
538 (progn | |
539 (setq gnus-newsgroup-downloadable | |
540 (delq article gnus-newsgroup-downloadable)) | |
541 (push article gnus-newsgroup-undownloaded)) | |
542 (setq gnus-newsgroup-undownloaded | |
543 (delq article gnus-newsgroup-undownloaded)) | |
544 (push article gnus-newsgroup-downloadable)) | |
545 (gnus-summary-update-mark | |
546 (if unmark gnus-undownloaded-mark gnus-downloadable-mark) | |
547 'unread))) | |
548 | |
549 (defun gnus-agent-get-undownloaded-list () | |
550 "Mark all unfetched articles as read." | |
551 (let ((gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name))) | |
552 (when (and (not gnus-plugged) | |
553 (gnus-agent-method-p gnus-command-method)) | |
554 (gnus-agent-load-alist gnus-newsgroup-name) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
555 ;; First mark all undownloaded articles as undownloaded. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
556 (let ((articles (append gnus-newsgroup-unreads |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
557 gnus-newsgroup-marked |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
558 gnus-newsgroup-dormant)) |
24358 | 559 article) |
560 (while (setq article (pop articles)) | |
561 (unless (or (cdr (assq article gnus-agent-article-alist)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
562 (memq article gnus-newsgroup-downloadable) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
563 (memq article gnus-newsgroup-cached)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
564 (push article gnus-newsgroup-undownloaded)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
565 ;; Then mark downloaded downloadable as not-downloadable, |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
566 ;; if you get my drift. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
567 (let ((articles gnus-newsgroup-downloadable) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
568 article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
569 (while (setq article (pop articles)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
570 (when (cdr (assq article gnus-agent-article-alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
571 (setq gnus-newsgroup-downloadable |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
572 (delq article gnus-newsgroup-downloadable)))))))) |
24358 | 573 |
574 (defun gnus-agent-catchup () | |
575 "Mark all undownloaded articles as read." | |
576 (interactive) | |
577 (save-excursion | |
578 (while gnus-newsgroup-undownloaded | |
579 (gnus-summary-mark-article | |
580 (pop gnus-newsgroup-undownloaded) gnus-catchup-mark))) | |
581 (gnus-summary-position-point)) | |
582 | |
583 ;;; | |
584 ;;; Internal functions | |
585 ;;; | |
586 | |
587 (defun gnus-agent-save-active (method) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
588 (gnus-agent-save-active-1 method 'gnus-active-to-gnus-format)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
589 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
590 (defun gnus-agent-save-active-1 (method function) |
24358 | 591 (when (gnus-agent-method-p method) |
592 (let* ((gnus-command-method method) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
593 (new (gnus-make-hashtable (count-lines (point-min) (point-max)))) |
24358 | 594 (file (gnus-agent-lib-file "active"))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
595 (funcall function nil new) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
596 (gnus-agent-write-active file new) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
597 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
598 (nnheader-insert-file-contents file)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
599 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
600 (defun gnus-agent-write-active (file new) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
601 (let ((orig (gnus-make-hashtable (count-lines (point-min) (point-max)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
602 (file (gnus-agent-lib-file "active")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
603 elem osym) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
604 (when (file-exists-p file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
605 (with-temp-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
606 (nnheader-insert-file-contents file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
607 (gnus-active-to-gnus-format nil orig)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
608 (mapatoms |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
609 (lambda (sym) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
610 (when (and sym (boundp sym)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
611 (if (and (boundp (setq osym (intern (symbol-name sym) orig))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
612 (setq elem (symbol-value osym))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
613 (setcdr elem (cdr (symbol-value sym))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
614 (set (intern (symbol-name sym) orig) (symbol-value sym))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
615 new)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
616 (gnus-make-directory (file-name-directory file)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
617 (let ((coding-system-for-write gnus-agent-file-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
618 ;; The hashtable contains real names of groups, no more prefix |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
619 ;; removing, so set `full' to `t'. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
620 (gnus-write-active-file file orig t)))) |
24358 | 621 |
622 (defun gnus-agent-save-groups (method) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
623 (gnus-agent-save-active-1 method 'gnus-groups-to-gnus-format)) |
24358 | 624 |
625 (defun gnus-agent-save-group-info (method group active) | |
626 (when (gnus-agent-method-p method) | |
627 (let* ((gnus-command-method method) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
628 (coding-system-for-write nnheader-file-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
629 (file-name-coding-system nnmail-pathname-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
630 (file (gnus-agent-lib-file "active")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
631 oactive) |
24358 | 632 (gnus-make-directory (file-name-directory file)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
633 (with-temp-file file |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
634 ;; Emacs got problem to match non-ASCII group in multibyte buffer. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
635 (mm-disable-multibyte) |
24358 | 636 (when (file-exists-p file) |
637 (nnheader-insert-file-contents file)) | |
638 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
639 (when (re-search-forward |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
640 (concat "^" (regexp-quote group) " ") nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
641 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
642 (save-restriction |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
643 (narrow-to-region (match-beginning 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
644 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
645 (forward-line 1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
646 (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
647 (setq oactive (car (nnmail-parse-active))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
648 (gnus-delete-line)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
649 (insert (format "%S %d %d y\n" (intern group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
650 (cdr active) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
651 (or (car oactive) (car active)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
652 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
653 (while (search-backward "\\." nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
654 (delete-char 1)))))) |
24358 | 655 |
656 (defun gnus-agent-group-path (group) | |
657 "Translate GROUP into a path." | |
658 (if nnmail-use-long-file-names | |
659 (gnus-group-real-name group) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
660 (nnheader-translate-file-chars |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
661 (nnheader-replace-chars-in-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
662 (nnheader-replace-duplicate-chars-in-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
663 (nnheader-replace-chars-in-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
664 (gnus-group-real-name group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
665 ?/ ?_) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
666 ?. ?_) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
667 ?. ?/)))) |
24358 | 668 |
669 | |
670 | |
671 (defun gnus-agent-method-p (method) | |
672 "Say whether METHOD is covered by the agent." | |
673 (member method gnus-agent-covered-methods)) | |
674 | |
675 (defun gnus-agent-get-function (method) | |
676 (if (and (not gnus-plugged) | |
677 (gnus-agent-method-p method)) | |
678 (progn | |
679 (require 'nnagent) | |
680 'nnagent) | |
681 (car method))) | |
682 | |
683 ;;; History functions | |
684 | |
685 (defun gnus-agent-history-buffer () | |
686 (cdr (assoc (gnus-agent-method) gnus-agent-history-buffers))) | |
687 | |
688 (defun gnus-agent-open-history () | |
689 (save-excursion | |
690 (push (cons (gnus-agent-method) | |
691 (set-buffer (gnus-get-buffer-create | |
692 (format " *Gnus agent %s history*" | |
693 (gnus-agent-method))))) | |
694 gnus-agent-history-buffers) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
695 (mm-disable-multibyte) ;; everything is binary |
24358 | 696 (erase-buffer) |
697 (insert "\n") | |
698 (let ((file (gnus-agent-lib-file "history"))) | |
699 (when (file-exists-p file) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
700 (nnheader-insert-file-contents file)) |
24358 | 701 (set (make-local-variable 'gnus-agent-file-name) file)))) |
702 | |
703 (defun gnus-agent-save-history () | |
704 (save-excursion | |
705 (set-buffer gnus-agent-current-history) | |
706 (gnus-make-directory (file-name-directory gnus-agent-file-name)) | |
707 (let ((coding-system-for-write gnus-agent-file-coding-system)) | |
708 (write-region (1+ (point-min)) (point-max) | |
709 gnus-agent-file-name nil 'silent)))) | |
710 | |
711 (defun gnus-agent-close-history () | |
712 (when (gnus-buffer-live-p gnus-agent-current-history) | |
713 (kill-buffer gnus-agent-current-history) | |
714 (setq gnus-agent-history-buffers | |
715 (delq (assoc (gnus-agent-method) gnus-agent-history-buffers) | |
716 gnus-agent-history-buffers)))) | |
717 | |
718 (defun gnus-agent-enter-history (id group-arts date) | |
719 (save-excursion | |
720 (set-buffer gnus-agent-current-history) | |
721 (goto-char (point-max)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
722 (let ((p (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
723 (insert id "\t" (number-to-string date) "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
724 (while group-arts |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
725 (insert (format "%S" (intern (caar group-arts))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
726 " " (number-to-string (cdr (pop group-arts))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
727 " ")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
728 (insert "\n") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
729 (while (search-backward "\\." p t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
730 (delete-char 1))))) |
24358 | 731 |
732 (defun gnus-agent-article-in-history-p (id) | |
733 (save-excursion | |
734 (set-buffer (gnus-agent-history-buffer)) | |
735 (goto-char (point-min)) | |
736 (search-forward (concat "\n" id "\t") nil t))) | |
737 | |
738 (defun gnus-agent-history-path (id) | |
739 (save-excursion | |
740 (set-buffer (gnus-agent-history-buffer)) | |
741 (goto-char (point-min)) | |
742 (when (search-forward (concat "\n" id "\t") nil t) | |
743 (let ((method (gnus-agent-method))) | |
744 (let (paths group) | |
745 (while (not (numberp (setq group (read (current-buffer))))) | |
746 (push (concat method "/" group) paths)) | |
747 (nreverse paths)))))) | |
748 | |
749 ;;; | |
750 ;;; Fetching | |
751 ;;; | |
752 | |
753 (defun gnus-agent-fetch-articles (group articles) | |
754 "Fetch ARTICLES from GROUP and put them into the Agent." | |
755 (when articles | |
756 ;; Prune off articles that we have already fetched. | |
757 (while (and articles | |
758 (cdr (assq (car articles) gnus-agent-article-alist))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
759 (pop articles)) |
24358 | 760 (let ((arts articles)) |
761 (while (cdr arts) | |
762 (if (cdr (assq (cadr arts) gnus-agent-article-alist)) | |
763 (setcdr arts (cddr arts)) | |
764 (setq arts (cdr arts))))) | |
765 (when articles | |
766 (let ((dir (concat | |
767 (gnus-agent-directory) | |
768 (gnus-agent-group-path group) "/")) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
769 (date (time-to-days (current-time))) |
24358 | 770 (case-fold-search t) |
771 pos crosses id elem) | |
772 (gnus-make-directory dir) | |
773 (gnus-message 7 "Fetching articles for %s..." group) | |
774 ;; Fetch the articles from the backend. | |
775 (if (gnus-check-backend-function 'retrieve-articles group) | |
776 (setq pos (gnus-retrieve-articles articles group)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
777 (with-temp-buffer |
24358 | 778 (let (article) |
779 (while (setq article (pop articles)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
780 (when (or |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
781 (gnus-backlog-request-article group article |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
782 nntp-server-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
783 (gnus-request-article article group)) |
24358 | 784 (goto-char (point-max)) |
785 (push (cons article (point)) pos) | |
786 (insert-buffer-substring nntp-server-buffer))) | |
787 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) | |
788 (setq pos (nreverse pos))))) | |
789 ;; Then save these articles into the Agent. | |
790 (save-excursion | |
791 (set-buffer nntp-server-buffer) | |
792 (while pos | |
793 (narrow-to-region (cdar pos) (or (cdadr pos) (point-max))) | |
794 (goto-char (point-min)) | |
795 (when (search-forward "\n\n" nil t) | |
796 (when (search-backward "\nXrefs: " nil t) | |
797 ;; Handle crossposting. | |
798 (skip-chars-forward "^ ") | |
799 (skip-chars-forward " ") | |
800 (setq crosses nil) | |
801 (while (looking-at "\\([^: \n]+\\):\\([0-9]+\\) +") | |
802 (push (cons (buffer-substring (match-beginning 1) | |
803 (match-end 1)) | |
804 (buffer-substring (match-beginning 2) | |
805 (match-end 2))) | |
806 crosses) | |
807 (goto-char (match-end 0))) | |
808 (gnus-agent-crosspost crosses (caar pos)))) | |
809 (goto-char (point-min)) | |
810 (if (not (re-search-forward "^Message-ID: *<\\([^>\n]+\\)>" nil t)) | |
811 (setq id "No-Message-ID-in-article") | |
812 (setq id (buffer-substring (match-beginning 1) (match-end 1)))) | |
813 (let ((coding-system-for-write | |
814 gnus-agent-file-coding-system)) | |
815 (write-region (point-min) (point-max) | |
816 (concat dir (number-to-string (caar pos))) | |
817 nil 'silent)) | |
818 (when (setq elem (assq (caar pos) gnus-agent-article-alist)) | |
819 (setcdr elem t)) | |
820 (gnus-agent-enter-history | |
821 id (or crosses (list (cons group (caar pos)))) date) | |
822 (widen) | |
823 (pop pos))) | |
824 (gnus-agent-save-alist group))))) | |
825 | |
826 (defun gnus-agent-crosspost (crosses article) | |
827 (let (gnus-agent-article-alist group alist beg end) | |
828 (save-excursion | |
829 (set-buffer gnus-agent-overview-buffer) | |
830 (when (nnheader-find-nov-line article) | |
831 (forward-word 1) | |
832 (setq beg (point)) | |
833 (setq end (progn (forward-line 1) (point))))) | |
834 (while crosses | |
835 (setq group (caar crosses)) | |
836 (unless (setq alist (assoc group gnus-agent-group-alist)) | |
837 (push (setq alist (list group (gnus-agent-load-alist (caar crosses)))) | |
838 gnus-agent-group-alist)) | |
839 (setcdr alist (cons (cons (cdar crosses) t) (cdr alist))) | |
840 (save-excursion | |
841 (set-buffer (gnus-get-buffer-create (format " *Gnus agent overview %s*" | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
842 group))) |
24358 | 843 (when (= (point-max) (point-min)) |
844 (push (cons group (current-buffer)) gnus-agent-buffer-alist) | |
845 (ignore-errors | |
846 (nnheader-insert-file-contents | |
847 (gnus-agent-article-name ".overview" group)))) | |
848 (nnheader-find-nov-line (string-to-number (cdar crosses))) | |
849 (insert (string-to-number (cdar crosses))) | |
850 (insert-buffer-substring gnus-agent-overview-buffer beg end)) | |
851 (pop crosses)))) | |
852 | |
853 (defun gnus-agent-flush-cache () | |
854 (save-excursion | |
855 (while gnus-agent-buffer-alist | |
856 (set-buffer (cdar gnus-agent-buffer-alist)) | |
857 (let ((coding-system-for-write | |
858 gnus-agent-file-coding-system)) | |
859 (write-region (point-min) (point-max) | |
860 (gnus-agent-article-name ".overview" | |
861 (caar gnus-agent-buffer-alist)) | |
862 nil 'silent)) | |
863 (pop gnus-agent-buffer-alist)) | |
864 (while gnus-agent-group-alist | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
865 (with-temp-file (caar gnus-agent-group-alist) |
24358 | 866 (princ (cdar gnus-agent-group-alist)) |
867 (insert "\n")) | |
868 (pop gnus-agent-group-alist)))) | |
869 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
870 (if (fboundp 'union) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
871 (defalias 'gnus-agent-union 'union) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
872 (defun gnus-agent-union (l1 l2) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
873 "Set union of lists L1 and L2." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
874 (cond ((null l1) l2) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
875 ((null l2) l1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
876 ((equal l1 l2) l1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
877 (t |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
878 (or (>= (length l1) (length l2)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
879 (setq l1 (prog1 l2 (setq l2 l1)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
880 (while l2 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
881 (or (memq (car l2) l1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
882 (push (car l2) l1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
883 (pop l2)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
884 l1)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
885 |
24358 | 886 (defun gnus-agent-fetch-headers (group &optional force) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
887 (let ((articles (gnus-list-of-unread-articles group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
888 (gnus-decode-encoded-word-function 'identity) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
889 (file (gnus-agent-article-name ".overview" group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
890 ;; Add article with marks to list of article headers we want to fetch. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
891 (dolist (arts (gnus-info-marks (gnus-get-info group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
892 (setq articles (gnus-agent-union (gnus-uncompress-sequence (cdr arts)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
893 articles))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
894 (setq articles (sort articles '<)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
895 ;; Remove known articles. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
896 (when (gnus-agent-load-alist group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
897 (setq articles (gnus-sorted-intersection |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
898 articles |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
899 (gnus-uncompress-range |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
900 (cons (1+ (caar (last gnus-agent-article-alist))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
901 (cdr (gnus-active group))))))) |
24358 | 902 ;; Fetch them. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
903 (gnus-make-directory (nnheader-translate-file-chars |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
904 (file-name-directory file) t)) |
24358 | 905 (when articles |
906 (gnus-message 7 "Fetching headers for %s..." group) | |
907 (save-excursion | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
908 (set-buffer nntp-server-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
909 (unless (eq 'nov (gnus-retrieve-headers articles group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
910 (nnvirtual-convert-headers)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
911 ;; Save these headers for later processing. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
912 (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
913 (when (file-exists-p file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
914 (gnus-agent-braid-nov group articles file)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
915 (let ((coding-system-for-write |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
916 gnus-agent-file-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
917 (write-region (point-min) (point-max) file nil 'silent)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
918 (gnus-agent-save-alist group articles nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
919 (gnus-agent-enter-history |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
920 "last-header-fetched-for-session" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
921 (list (cons group (nth (- (length articles) 1) articles))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
922 (time-to-days (current-time))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
923 articles)))) |
24358 | 924 |
925 (defsubst gnus-agent-copy-nov-line (article) | |
926 (let (b e) | |
927 (set-buffer gnus-agent-overview-buffer) | |
928 (setq b (point)) | |
929 (if (eq article (read (current-buffer))) | |
930 (setq e (progn (forward-line 1) (point))) | |
931 (progn | |
932 (beginning-of-line) | |
933 (setq e b))) | |
934 (set-buffer nntp-server-buffer) | |
935 (insert-buffer-substring gnus-agent-overview-buffer b e))) | |
936 | |
937 (defun gnus-agent-braid-nov (group articles file) | |
938 (set-buffer gnus-agent-overview-buffer) | |
939 (goto-char (point-min)) | |
940 (set-buffer nntp-server-buffer) | |
941 (erase-buffer) | |
942 (nnheader-insert-file-contents file) | |
943 (goto-char (point-max)) | |
944 (if (or (= (point-min) (point-max)) | |
945 (progn | |
946 (forward-line -1) | |
947 (< (read (current-buffer)) (car articles)))) | |
948 ;; We have only headers that are after the older headers, | |
949 ;; so we just append them. | |
950 (progn | |
951 (goto-char (point-max)) | |
952 (insert-buffer-substring gnus-agent-overview-buffer)) | |
953 ;; We do it the hard way. | |
954 (nnheader-find-nov-line (car articles)) | |
955 (gnus-agent-copy-nov-line (car articles)) | |
956 (pop articles) | |
957 (while (and articles | |
958 (not (eobp))) | |
959 (while (and (not (eobp)) | |
960 (< (read (current-buffer)) (car articles))) | |
961 (forward-line 1)) | |
962 (beginning-of-line) | |
963 (unless (eobp) | |
964 (gnus-agent-copy-nov-line (car articles)) | |
965 (setq articles (cdr articles)))) | |
966 (when articles | |
967 (let (b e) | |
968 (set-buffer gnus-agent-overview-buffer) | |
969 (setq b (point) | |
970 e (point-max)) | |
971 (set-buffer nntp-server-buffer) | |
972 (insert-buffer-substring gnus-agent-overview-buffer b e))))) | |
973 | |
974 (defun gnus-agent-load-alist (group &optional dir) | |
975 "Load the article-state alist for GROUP." | |
976 (setq gnus-agent-article-alist | |
977 (gnus-agent-read-file | |
978 (if dir | |
979 (concat dir ".agentview") | |
980 (gnus-agent-article-name ".agentview" group))))) | |
981 | |
982 (defun gnus-agent-save-alist (group &optional articles state dir) | |
983 "Save the article-state alist for GROUP." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
984 (let ((file-name-coding-system nnmail-pathname-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
985 (with-temp-file (if dir |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
986 (concat dir ".agentview") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
987 (gnus-agent-article-name ".agentview" group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
988 (princ (setq gnus-agent-article-alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
989 (nconc gnus-agent-article-alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
990 (mapcar (lambda (article) (cons article state)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
991 articles))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
992 (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
993 (insert "\n")))) |
24358 | 994 |
995 (defun gnus-agent-article-name (article group) | |
996 (concat (gnus-agent-directory) (gnus-agent-group-path group) "/" | |
997 (if (stringp article) article (string-to-number article)))) | |
998 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
999 (defun gnus-agent-batch-confirmation (msg) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1000 "Show error message and return t." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1001 (gnus-message 1 msg) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1002 t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1003 |
24358 | 1004 ;;;###autoload |
1005 (defun gnus-agent-batch-fetch () | |
1006 "Start Gnus and fetch session." | |
1007 (interactive) | |
1008 (gnus) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1009 (let ((gnus-agent-confirmation-function 'gnus-agent-batch-confirmation)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1010 (gnus-agent-fetch-session)) |
24358 | 1011 (gnus-group-exit)) |
1012 | |
1013 (defun gnus-agent-fetch-session () | |
1014 "Fetch all articles and headers that are eligible for fetching." | |
1015 (interactive) | |
1016 (unless gnus-agent-covered-methods | |
1017 (error "No servers are covered by the Gnus agent")) | |
1018 (unless gnus-plugged | |
1019 (error "Can't fetch articles while Gnus is unplugged")) | |
1020 (let ((methods gnus-agent-covered-methods) | |
1021 groups group gnus-command-method) | |
1022 (save-excursion | |
1023 (while methods | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1024 (condition-case err |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1025 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1026 (setq gnus-command-method (car methods)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1027 (when (or (gnus-server-opened gnus-command-method) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1028 (gnus-open-server gnus-command-method)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1029 (setq groups (gnus-groups-from-server (car methods))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1030 (gnus-agent-with-fetch |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1031 (while (setq group (pop groups)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1032 (when (<= (gnus-group-level group) gnus-agent-handle-level) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1033 (gnus-agent-fetch-group-1 group gnus-command-method)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1034 (error |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1035 (unless (funcall gnus-agent-confirmation-function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1036 (format "Error (%s). Continue? " err)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1037 (error "Cannot fetch articles into the Gnus agent.")))) |
24358 | 1038 (pop methods)) |
1039 (gnus-message 6 "Finished fetching articles into the Gnus agent")))) | |
1040 | |
1041 (defun gnus-agent-fetch-group-1 (group method) | |
1042 "Fetch GROUP." | |
1043 (let ((gnus-command-method method) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1044 (gnus-newsgroup-name group) |
24358 | 1045 gnus-newsgroup-dependencies gnus-newsgroup-headers |
1046 gnus-newsgroup-scored gnus-headers gnus-score | |
1047 gnus-use-cache articles arts | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1048 category predicate info marks score-param |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1049 (gnus-summary-expunge-below gnus-summary-expunge-below) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1050 (gnus-summary-mark-below gnus-summary-mark-below) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1051 (gnus-orphan-score gnus-orphan-score) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1052 ;; Maybe some other gnus-summary local variables should also |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1053 ;; be put here. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1054 ) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1055 (unless (gnus-check-group group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1056 (error "Can't open server for %s" group)) |
24358 | 1057 ;; Fetch headers. |
1058 (when (and (or (gnus-active group) (gnus-activate-group group)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1059 (setq articles (gnus-agent-fetch-headers group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1060 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1061 ;; Parse them and see which articles we want to fetch. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1062 (setq gnus-newsgroup-dependencies |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1063 (make-vector (length articles) 0)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1064 ;; No need to call `gnus-get-newsgroup-headers-xover' with |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1065 ;; the entire .overview for group as we still have the just |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1066 ;; downloaded headers in `gnus-agent-overview-buffer'. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1067 (let ((nntp-server-buffer gnus-agent-overview-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1068 (setq gnus-newsgroup-headers |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1069 (gnus-get-newsgroup-headers-xover articles nil nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1070 group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1071 ;; `gnus-agent-overview-buffer' may be killed for |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1072 ;; timeout reason. If so, recreate it. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1073 (gnus-agent-create-buffer))) |
24358 | 1074 (setq category (gnus-group-category group)) |
1075 (setq predicate | |
1076 (gnus-get-predicate | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1077 (or (gnus-group-find-parameter group 'agent-predicate t) |
24358 | 1078 (cadr category)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1079 ;; Do we want to download everything, or nothing? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1080 (if (or (eq (caaddr predicate) 'gnus-agent-true) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1081 (eq (caaddr predicate) 'gnus-agent-false)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1082 ;; Yes. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1083 (setq arts (symbol-value |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1084 (cadr (assoc (caaddr predicate) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1085 '((gnus-agent-true articles) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1086 (gnus-agent-false nil)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1087 ;; No, we need to decide what we want. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1088 (setq score-param |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1089 (let ((score-method |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1090 (or |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1091 (gnus-group-find-parameter group 'agent-score t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1092 (caddr category)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1093 (when score-method |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1094 (require 'gnus-score) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1095 (if (eq score-method 'file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1096 (let ((entries |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1097 (gnus-score-load-files |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1098 (gnus-all-score-files group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1099 list score-file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1100 (while (setq list (car entries)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1101 (push (car list) score-file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1102 (setq list (cdr list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1103 (while list |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1104 (when (member (caar list) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1105 gnus-agent-scoreable-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1106 (push (car list) score-file)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1107 (setq list (cdr list))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1108 (setq score-param |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1109 (append score-param (list (nreverse score-file))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1110 score-file nil entries (cdr entries))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1111 (list score-param)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1112 (if (stringp (car score-method)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1113 score-method |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1114 (list (list score-method))))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1115 (when score-param |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1116 (gnus-score-headers score-param)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1117 (setq arts nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1118 (while (setq gnus-headers (pop gnus-newsgroup-headers)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1119 (setq gnus-score |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1120 (or (cdr (assq (mail-header-number gnus-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1121 gnus-newsgroup-scored)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1122 gnus-summary-default-score)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1123 (when (funcall predicate) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1124 (push (mail-header-number gnus-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1125 arts)))) |
24358 | 1126 ;; Fetch the articles. |
1127 (when arts | |
1128 (gnus-agent-fetch-articles group arts))) | |
1129 ;; Perhaps we have some additional articles to fetch. | |
1130 (setq arts (assq 'download (gnus-info-marks | |
1131 (setq info (gnus-get-info group))))) | |
1132 (when (cdr arts) | |
1133 (gnus-agent-fetch-articles | |
1134 group (gnus-uncompress-range (cdr arts))) | |
1135 (setq marks (delq arts (gnus-info-marks info))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1136 (gnus-info-set-marks info marks) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1137 (gnus-dribble-enter |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1138 (concat "(gnus-group-set-info '" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1139 (gnus-prin1-to-string info) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1140 ")"))))) |
24358 | 1141 |
1142 ;;; | |
1143 ;;; Agent Category Mode | |
1144 ;;; | |
1145 | |
1146 (defvar gnus-category-mode-hook nil | |
1147 "Hook run in `gnus-category-mode' buffers.") | |
1148 | |
1149 (defvar gnus-category-line-format " %(%20c%): %g\n" | |
1150 "Format of category lines.") | |
1151 | |
1152 (defvar gnus-category-mode-line-format "Gnus: %%b" | |
1153 "The format specification for the category mode line.") | |
1154 | |
1155 (defvar gnus-agent-short-article 100 | |
1156 "Articles that have fewer lines than this are short.") | |
1157 | |
1158 (defvar gnus-agent-long-article 200 | |
1159 "Articles that have more lines than this are long.") | |
1160 | |
1161 (defvar gnus-agent-low-score 0 | |
1162 "Articles that have a score lower than this have a low score.") | |
1163 | |
1164 (defvar gnus-agent-high-score 0 | |
1165 "Articles that have a score higher than this have a high score.") | |
1166 | |
1167 | |
1168 ;;; Internal variables. | |
1169 | |
1170 (defvar gnus-category-buffer "*Agent Category*") | |
1171 | |
1172 (defvar gnus-category-line-format-alist | |
1173 `((?c gnus-tmp-name ?s) | |
1174 (?g gnus-tmp-groups ?d))) | |
1175 | |
1176 (defvar gnus-category-mode-line-format-alist | |
1177 `((?u user-defined ?s))) | |
1178 | |
1179 (defvar gnus-category-line-format-spec nil) | |
1180 (defvar gnus-category-mode-line-format-spec nil) | |
1181 | |
1182 (defvar gnus-category-mode-map nil) | |
1183 (put 'gnus-category-mode 'mode-class 'special) | |
1184 | |
1185 (unless gnus-category-mode-map | |
1186 (setq gnus-category-mode-map (make-sparse-keymap)) | |
1187 (suppress-keymap gnus-category-mode-map) | |
1188 | |
1189 (gnus-define-keys gnus-category-mode-map | |
1190 "q" gnus-category-exit | |
1191 "k" gnus-category-kill | |
1192 "c" gnus-category-copy | |
1193 "a" gnus-category-add | |
1194 "p" gnus-category-edit-predicate | |
1195 "g" gnus-category-edit-groups | |
1196 "s" gnus-category-edit-score | |
1197 "l" gnus-category-list | |
1198 | |
1199 "\C-c\C-i" gnus-info-find-node | |
1200 "\C-c\C-b" gnus-bug)) | |
1201 | |
1202 (defvar gnus-category-menu-hook nil | |
1203 "*Hook run after the creation of the menu.") | |
1204 | |
1205 (defun gnus-category-make-menu-bar () | |
1206 (gnus-turn-off-edit-menu 'category) | |
1207 (unless (boundp 'gnus-category-menu) | |
1208 (easy-menu-define | |
1209 gnus-category-menu gnus-category-mode-map "" | |
1210 '("Categories" | |
1211 ["Add" gnus-category-add t] | |
1212 ["Kill" gnus-category-kill t] | |
1213 ["Copy" gnus-category-copy t] | |
1214 ["Edit predicate" gnus-category-edit-predicate t] | |
1215 ["Edit score" gnus-category-edit-score t] | |
1216 ["Edit groups" gnus-category-edit-groups t] | |
1217 ["Exit" gnus-category-exit t])) | |
1218 | |
1219 (gnus-run-hooks 'gnus-category-menu-hook))) | |
1220 | |
1221 (defun gnus-category-mode () | |
1222 "Major mode for listing and editing agent categories. | |
1223 | |
1224 All normal editing commands are switched off. | |
1225 \\<gnus-category-mode-map> | |
1226 For more in-depth information on this mode, read the manual | |
1227 (`\\[gnus-info-find-node]'). | |
1228 | |
1229 The following commands are available: | |
1230 | |
1231 \\{gnus-category-mode-map}" | |
1232 (interactive) | |
1233 (when (gnus-visual-p 'category-menu 'menu) | |
1234 (gnus-category-make-menu-bar)) | |
1235 (kill-all-local-variables) | |
1236 (gnus-simplify-mode-line) | |
1237 (setq major-mode 'gnus-category-mode) | |
1238 (setq mode-name "Category") | |
1239 (gnus-set-default-directory) | |
1240 (setq mode-line-process nil) | |
1241 (use-local-map gnus-category-mode-map) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1242 (buffer-disable-undo) |
24358 | 1243 (setq truncate-lines t) |
1244 (setq buffer-read-only t) | |
1245 (gnus-run-hooks 'gnus-category-mode-hook)) | |
1246 | |
1247 (defalias 'gnus-category-position-point 'gnus-goto-colon) | |
1248 | |
1249 (defun gnus-category-insert-line (category) | |
1250 (let* ((gnus-tmp-name (car category)) | |
1251 (gnus-tmp-groups (length (cadddr category)))) | |
1252 (beginning-of-line) | |
1253 (gnus-add-text-properties | |
1254 (point) | |
1255 (prog1 (1+ (point)) | |
1256 ;; Insert the text. | |
1257 (eval gnus-category-line-format-spec)) | |
1258 (list 'gnus-category gnus-tmp-name)))) | |
1259 | |
1260 (defun gnus-enter-category-buffer () | |
1261 "Go to the Category buffer." | |
1262 (interactive) | |
1263 (gnus-category-setup-buffer) | |
1264 (gnus-configure-windows 'category) | |
1265 (gnus-category-prepare)) | |
1266 | |
1267 (defun gnus-category-setup-buffer () | |
1268 (unless (get-buffer gnus-category-buffer) | |
1269 (save-excursion | |
1270 (set-buffer (gnus-get-buffer-create gnus-category-buffer)) | |
1271 (gnus-category-mode)))) | |
1272 | |
1273 (defun gnus-category-prepare () | |
1274 (gnus-set-format 'category-mode) | |
1275 (gnus-set-format 'category t) | |
1276 (let ((alist gnus-category-alist) | |
1277 (buffer-read-only nil)) | |
1278 (erase-buffer) | |
1279 (while alist | |
1280 (gnus-category-insert-line (pop alist))) | |
1281 (goto-char (point-min)) | |
1282 (gnus-category-position-point))) | |
1283 | |
1284 (defun gnus-category-name () | |
1285 (or (get-text-property (gnus-point-at-bol) 'gnus-category) | |
1286 (error "No category on the current line"))) | |
1287 | |
1288 (defun gnus-category-read () | |
1289 "Read the category alist." | |
1290 (setq gnus-category-alist | |
1291 (or (gnus-agent-read-file | |
1292 (nnheader-concat gnus-agent-directory "lib/categories")) | |
1293 (list (list 'default 'short nil nil))))) | |
1294 | |
1295 (defun gnus-category-write () | |
1296 "Write the category alist." | |
1297 (setq gnus-category-predicate-cache nil | |
1298 gnus-category-group-cache nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1299 (gnus-make-directory (nnheader-concat gnus-agent-directory "lib")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1300 (with-temp-file (nnheader-concat gnus-agent-directory "lib/categories") |
24358 | 1301 (prin1 gnus-category-alist (current-buffer)))) |
1302 | |
1303 (defun gnus-category-edit-predicate (category) | |
1304 "Edit the predicate for CATEGORY." | |
1305 (interactive (list (gnus-category-name))) | |
1306 (let ((info (assq category gnus-category-alist))) | |
1307 (gnus-edit-form | |
1308 (cadr info) (format "Editing the predicate for category %s" category) | |
1309 `(lambda (predicate) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1310 (setcar (cdr (assq ',category gnus-category-alist)) predicate) |
24358 | 1311 (gnus-category-write) |
1312 (gnus-category-list))))) | |
1313 | |
1314 (defun gnus-category-edit-score (category) | |
1315 "Edit the score expression for CATEGORY." | |
1316 (interactive (list (gnus-category-name))) | |
1317 (let ((info (assq category gnus-category-alist))) | |
1318 (gnus-edit-form | |
1319 (caddr info) | |
1320 (format "Editing the score expression for category %s" category) | |
1321 `(lambda (groups) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1322 (setcar (cddr (assq ',category gnus-category-alist)) groups) |
24358 | 1323 (gnus-category-write) |
1324 (gnus-category-list))))) | |
1325 | |
1326 (defun gnus-category-edit-groups (category) | |
1327 "Edit the group list for CATEGORY." | |
1328 (interactive (list (gnus-category-name))) | |
1329 (let ((info (assq category gnus-category-alist))) | |
1330 (gnus-edit-form | |
1331 (cadddr info) (format "Editing the group list for category %s" category) | |
1332 `(lambda (groups) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1333 (setcar (nthcdr 3 (assq ',category gnus-category-alist)) groups) |
24358 | 1334 (gnus-category-write) |
1335 (gnus-category-list))))) | |
1336 | |
1337 (defun gnus-category-kill (category) | |
1338 "Kill the current category." | |
1339 (interactive (list (gnus-category-name))) | |
1340 (let ((info (assq category gnus-category-alist)) | |
1341 (buffer-read-only nil)) | |
1342 (gnus-delete-line) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1343 (setq gnus-category-alist (delq info gnus-category-alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1344 (gnus-category-write))) |
24358 | 1345 |
1346 (defun gnus-category-copy (category to) | |
1347 "Copy the current category." | |
1348 (interactive (list (gnus-category-name) (intern (read-string "New name: ")))) | |
1349 (let ((info (assq category gnus-category-alist))) | |
1350 (push (list to (gnus-copy-sequence (cadr info)) | |
1351 (gnus-copy-sequence (caddr info)) nil) | |
1352 gnus-category-alist) | |
1353 (gnus-category-write) | |
1354 (gnus-category-list))) | |
1355 | |
1356 (defun gnus-category-add (category) | |
1357 "Create a new category." | |
1358 (interactive "SCategory name: ") | |
1359 (when (assq category gnus-category-alist) | |
1360 (error "Category %s already exists" category)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1361 (push (list category 'false nil nil) |
24358 | 1362 gnus-category-alist) |
1363 (gnus-category-write) | |
1364 (gnus-category-list)) | |
1365 | |
1366 (defun gnus-category-list () | |
1367 "List all categories." | |
1368 (interactive) | |
1369 (gnus-category-prepare)) | |
1370 | |
1371 (defun gnus-category-exit () | |
1372 "Return to the group buffer." | |
1373 (interactive) | |
1374 (kill-buffer (current-buffer)) | |
1375 (gnus-configure-windows 'group t)) | |
1376 | |
1377 ;; To avoid having 8-bit characters in the source file. | |
1378 (defvar gnus-category-not (list '! 'not (intern (format "%c" 172)))) | |
1379 | |
1380 (defvar gnus-category-predicate-alist | |
1381 '((spam . gnus-agent-spam-p) | |
1382 (short . gnus-agent-short-p) | |
1383 (long . gnus-agent-long-p) | |
1384 (low . gnus-agent-low-scored-p) | |
1385 (high . gnus-agent-high-scored-p) | |
1386 (true . gnus-agent-true) | |
1387 (false . gnus-agent-false)) | |
1388 "Mapping from short score predicate symbols to predicate functions.") | |
1389 | |
1390 (defun gnus-agent-spam-p () | |
1391 "Say whether an article is spam or not." | |
1392 (unless gnus-agent-spam-hashtb | |
1393 (setq gnus-agent-spam-hashtb (gnus-make-hashtable 1000))) | |
1394 (if (not (equal (mail-header-references gnus-headers) "")) | |
1395 nil | |
1396 (let ((string (gnus-simplify-subject (mail-header-subject gnus-headers)))) | |
1397 (prog1 | |
1398 (gnus-gethash string gnus-agent-spam-hashtb) | |
1399 (gnus-sethash string t gnus-agent-spam-hashtb))))) | |
1400 | |
1401 (defun gnus-agent-short-p () | |
1402 "Say whether an article is short or not." | |
1403 (< (mail-header-lines gnus-headers) gnus-agent-short-article)) | |
1404 | |
1405 (defun gnus-agent-long-p () | |
1406 "Say whether an article is long or not." | |
1407 (> (mail-header-lines gnus-headers) gnus-agent-long-article)) | |
1408 | |
1409 (defun gnus-agent-low-scored-p () | |
1410 "Say whether an article has a low score or not." | |
1411 (< gnus-score gnus-agent-low-score)) | |
1412 | |
1413 (defun gnus-agent-high-scored-p () | |
1414 "Say whether an article has a high score or not." | |
1415 (> gnus-score gnus-agent-high-score)) | |
1416 | |
1417 (defun gnus-category-make-function (cat) | |
1418 "Make a function from category CAT." | |
1419 `(lambda () ,(gnus-category-make-function-1 cat))) | |
1420 | |
1421 (defun gnus-agent-true () | |
1422 "Return t." | |
1423 t) | |
1424 | |
1425 (defun gnus-agent-false () | |
1426 "Return nil." | |
1427 nil) | |
1428 | |
1429 (defun gnus-category-make-function-1 (cat) | |
1430 "Make a function from category CAT." | |
1431 (cond | |
1432 ;; Functions are just returned as is. | |
1433 ((or (symbolp cat) | |
1434 (gnus-functionp cat)) | |
1435 `(,(or (cdr (assq cat gnus-category-predicate-alist)) | |
1436 cat))) | |
1437 ;; More complex category. | |
1438 ((consp cat) | |
1439 `(,(cond | |
1440 ((memq (car cat) '(& and)) | |
1441 'and) | |
1442 ((memq (car cat) '(| or)) | |
1443 'or) | |
1444 ((memq (car cat) gnus-category-not) | |
1445 'not)) | |
1446 ,@(mapcar 'gnus-category-make-function-1 (cdr cat)))) | |
1447 (t | |
1448 (error "Unknown category type: %s" cat)))) | |
1449 | |
1450 (defun gnus-get-predicate (predicate) | |
1451 "Return the predicate for CATEGORY." | |
1452 (or (cdr (assoc predicate gnus-category-predicate-cache)) | |
1453 (cdar (push (cons predicate | |
1454 (gnus-category-make-function predicate)) | |
1455 gnus-category-predicate-cache)))) | |
1456 | |
1457 (defun gnus-group-category (group) | |
1458 "Return the category GROUP belongs to." | |
1459 (unless gnus-category-group-cache | |
1460 (setq gnus-category-group-cache (gnus-make-hashtable 1000)) | |
1461 (let ((cs gnus-category-alist) | |
1462 groups cat) | |
1463 (while (setq cat (pop cs)) | |
1464 (setq groups (cadddr cat)) | |
1465 (while groups | |
1466 (gnus-sethash (pop groups) cat gnus-category-group-cache))))) | |
1467 (or (gnus-gethash group gnus-category-group-cache) | |
1468 (assq 'default gnus-category-alist))) | |
1469 | |
1470 (defun gnus-agent-expire () | |
1471 "Expire all old articles." | |
1472 (interactive) | |
1473 (let ((methods gnus-agent-covered-methods) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1474 (day (- (time-to-days (current-time)) gnus-agent-expire-days)) |
24358 | 1475 gnus-command-method sym group articles |
1476 history overview file histories elem art nov-file low info | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1477 unreads marked article orig lowest highest) |
24358 | 1478 (save-excursion |
1479 (setq overview (gnus-get-buffer-create " *expire overview*")) | |
1480 (while (setq gnus-command-method (pop methods)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1481 (when (file-exists-p (gnus-agent-lib-file "active")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1482 (with-temp-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1483 (nnheader-insert-file-contents (gnus-agent-lib-file "active")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1484 (gnus-active-to-gnus-format |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1485 gnus-command-method |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1486 (setq orig (gnus-make-hashtable |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1487 (count-lines (point-min) (point-max)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1488 (let ((expiry-hashtb (gnus-make-hashtable 1023))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1489 (gnus-agent-open-history) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1490 (set-buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1491 (setq gnus-agent-current-history |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1492 (setq history (gnus-agent-history-buffer)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1493 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1494 (when (> (buffer-size) 1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1495 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1496 (while (not (eobp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1497 (skip-chars-forward "^\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1498 (if (> (read (current-buffer)) day) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1499 ;; New article; we don't expire it. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1500 (forward-line 1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1501 ;; Old article. Schedule it for possible nuking. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1502 (while (not (eolp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1503 (setq sym (let ((obarray expiry-hashtb) s) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1504 (setq s (read (current-buffer))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1505 (if (stringp s) (intern s) s))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1506 (if (boundp sym) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1507 (set sym (cons (cons (read (current-buffer)) (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1508 (symbol-value sym))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1509 (set sym (list (cons (read (current-buffer)) (point))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1510 (skip-chars-forward " ")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1511 (forward-line 1))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1512 ;; We now have all articles that can possibly be expired. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1513 (mapatoms |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1514 (lambda (sym) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1515 (setq group (symbol-name sym) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1516 articles (sort (symbol-value sym) 'car-less-than-car) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1517 low (car (gnus-active group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1518 info (gnus-get-info group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1519 unreads (ignore-errors |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1520 (gnus-list-of-unread-articles group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1521 marked (nconc |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1522 (gnus-uncompress-range |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1523 (cdr (assq 'tick (gnus-info-marks info)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1524 (gnus-uncompress-range |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1525 (cdr (assq 'dormant |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1526 (gnus-info-marks info))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1527 nov-file (gnus-agent-article-name ".overview" group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1528 lowest nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1529 highest nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1530 (gnus-agent-load-alist group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1531 (gnus-message 5 "Expiring articles in %s" group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1532 (set-buffer overview) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1533 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1534 (when (file-exists-p nov-file) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1535 (nnheader-insert-file-contents nov-file)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1536 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1537 (setq article 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1538 (while (setq elem (pop articles)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1539 (setq article (car elem)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1540 (when (or (null low) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1541 (< article low) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1542 gnus-agent-expire-all |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1543 (and (not (memq article unreads)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1544 (not (memq article marked)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1545 ;; Find and nuke the NOV line. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1546 (while (and (not (eobp)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1547 (or (not (numberp |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1548 (setq art (read (current-buffer))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1549 (< art article))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1550 (if (and (numberp art) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1551 (file-exists-p |
24358 | 1552 (gnus-agent-article-name |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1553 (number-to-string art) group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1554 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1555 (unless lowest |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1556 (setq lowest art)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1557 (setq highest art) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1558 (forward-line 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1559 ;; Remove old NOV lines that have no articles. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1560 (gnus-delete-line))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1561 (if (or (eobp) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1562 (/= art article)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1563 (beginning-of-line) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1564 (gnus-delete-line)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1565 ;; Nuke the article. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1566 (when (file-exists-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1567 (setq file (gnus-agent-article-name |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1568 (number-to-string article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1569 group))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1570 (delete-file file)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1571 ;; Schedule the history line for nuking. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1572 (push (cdr elem) histories))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1573 (gnus-make-directory (file-name-directory nov-file)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1574 (let ((coding-system-for-write |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1575 gnus-agent-file-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1576 (write-region (point-min) (point-max) nov-file nil 'silent)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1577 ;; Delete the unwanted entries in the alist. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1578 (setq gnus-agent-article-alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1579 (sort gnus-agent-article-alist 'car-less-than-car)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1580 (let* ((alist gnus-agent-article-alist) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1581 (prev (cons nil alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1582 (first prev) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1583 expired) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1584 (while (and alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1585 (<= (caar alist) article)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1586 (if (or (not (cdar alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1587 (not (file-exists-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1588 (gnus-agent-article-name |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1589 (number-to-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1590 (caar alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1591 group)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1592 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1593 (push (caar alist) expired) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1594 (setcdr prev (setq alist (cdr alist)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1595 (setq prev alist |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1596 alist (cdr alist)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1597 (setq gnus-agent-article-alist (cdr first)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1598 (gnus-agent-save-alist group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1599 ;; Mark all articles up to the first article |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1600 ;; in `gnus-article-alist' as read. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1601 (when (and info (caar gnus-agent-article-alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1602 (setcar (nthcdr 2 info) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1603 (gnus-range-add |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1604 (nth 2 info) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1605 (cons 1 (- (caar gnus-agent-article-alist) 1))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1606 ;; Maybe everything has been expired from `gnus-article-alist' |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1607 ;; and so the above marking as read could not be conducted, |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1608 ;; or there are expired article within the range of the alist. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1609 (when (and info |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1610 expired |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1611 (or (not (caar gnus-agent-article-alist)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1612 (> (car expired) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1613 (caar gnus-agent-article-alist)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1614 (setcar (nthcdr 2 info) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1615 (gnus-add-to-range |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1616 (nth 2 info) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1617 (nreverse expired)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1618 (gnus-dribble-enter |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1619 (concat "(gnus-group-set-info '" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1620 (gnus-prin1-to-string info) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1621 ")"))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1622 (when lowest |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1623 (if (gnus-gethash group orig) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1624 (setcar (gnus-gethash group orig) lowest) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1625 (gnus-sethash group (cons lowest highest) orig)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1626 expiry-hashtb) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1627 (set-buffer history) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1628 (setq histories (nreverse (sort histories '<))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1629 (while histories |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1630 (goto-char (pop histories)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1631 (gnus-delete-line)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1632 (gnus-agent-save-history) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1633 (gnus-agent-close-history) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1634 (gnus-write-active-file |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1635 (gnus-agent-lib-file "active") orig)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
1636 (gnus-message 4 "Expiry...done"))))))) |
24358 | 1637 |
1638 ;;;###autoload | |
1639 (defun gnus-agent-batch () | |
1640 (interactive) | |
1641 (let ((init-file-user "") | |
1642 (gnus-always-read-dribble-file t)) | |
1643 (gnus)) | |
1644 (gnus-group-send-drafts) | |
1645 (gnus-agent-fetch-session)) | |
1646 | |
1647 (provide 'gnus-agent) | |
1648 | |
1649 ;;; gnus-agent.el ends here |