1 ;;; gnus-agent.el --- unplugged support for Gnus
2 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
34 (if (featurep 'xemacs)
40 (autoload 'gnus-server-update-server "gnus-srvr"))
42 (defcustom gnus-agent-directory (nnheader-concat gnus-directory "agent/")
43 "Where the Gnus agent will store its files."
47 (defcustom gnus-agent-plugged-hook nil
48 "Hook run when plugging into the network."
52 (defcustom gnus-agent-unplugged-hook nil
53 "Hook run when unplugging from the network."
57 (defcustom gnus-agent-handle-level gnus-level-subscribed
58 "Groups on levels higher than this variable will be ignored by the Agent."
62 (defcustom gnus-agent-expire-days 7
63 "Read articles older than this will be expired.
64 This can also be a list of regexp/day pairs. The regexps will
65 be matched against group names."
69 (defcustom gnus-agent-expire-all nil
70 "If non-nil, also expire unread, ticked and dormant articles.
71 If nil, only read articles will be expired."
75 (defcustom gnus-agent-group-mode-hook nil
76 "Hook run in Agent group minor modes."
80 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
81 (when (featurep 'xemacs)
82 (add-hook 'gnus-agent-group-mode-hook 'gnus-xmas-agent-group-menu-add))
84 (defcustom gnus-agent-summary-mode-hook nil
85 "Hook run in Agent summary minor modes."
89 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
90 (when (featurep 'xemacs)
91 (add-hook 'gnus-agent-summary-mode-hook 'gnus-xmas-agent-summary-menu-add))
93 (defcustom gnus-agent-server-mode-hook nil
94 "Hook run in Agent summary minor modes."
98 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
99 (when (featurep 'xemacs)
100 (add-hook 'gnus-agent-server-mode-hook 'gnus-xmas-agent-server-menu-add))
102 (defcustom gnus-agent-confirmation-function 'y-or-n-p
103 "Function to confirm when error happens."
108 (defcustom gnus-agent-synchronize-flags 'ask
109 "Indicate if flags are synchronized when you plug in.
110 If this is `ask' the hook will query the user."
112 :type '(choice (const :tag "Always" t)
113 (const :tag "Never" nil)
114 (const :tag "Ask" ask))
117 (defcustom gnus-agent-go-online 'ask
118 "Indicate if offline servers go online when you plug in.
119 If this is `ask' the hook will query the user."
121 :type '(choice (const :tag "Always" t)
122 (const :tag "Never" nil)
123 (const :tag "Ask" ask))
126 (defcustom gnus-agent-mark-unread-after-downloaded t
127 "Indicate whether to mark articles unread after downloaded."
132 (defcustom gnus-agent-download-marks '(download)
133 "Marks for downloading."
135 :type '(repeat (symbol :tag "Mark"))
138 (defcustom gnus-agent-consider-all-articles nil
139 "If non-nil, consider also the read articles for downloading."
144 (defcustom gnus-agent-max-fetch-size 10000000 ;; 10 Mb
145 "gnus-agent-fetch-session is required to split its article fetches into chunks smaller than this limit."
149 ;;; Internal variables
151 (defvar gnus-agent-history-buffers nil)
152 (defvar gnus-agent-buffer-alist nil)
153 (defvar gnus-agent-article-alist nil
154 "An assoc list identifying the articles whose headers have been fetched.
155 If successfully fetched, these headers will be stored in the group's overview file.
156 The key of each assoc pair is the article ID.
157 The value of each assoc pair is a flag indicating
158 whether the identified article has been downloaded (gnus-agent-fetch-articles
159 sets the value to the day of the download).
161 1) The last element of this list can not be expired as some
162 routines (for example, get-agent-fetch-headers) use the last
163 value to track which articles have had their headers retrieved.
164 2) The gnus-agent-regenerate may destructively modify the value.
166 (defvar gnus-agent-group-alist nil)
167 (defvar gnus-category-alist nil)
168 (defvar gnus-agent-current-history nil)
169 (defvar gnus-agent-overview-buffer nil)
170 (defvar gnus-category-predicate-cache nil)
171 (defvar gnus-category-group-cache nil)
172 (defvar gnus-agent-spam-hashtb nil)
173 (defvar gnus-agent-file-name nil)
174 (defvar gnus-agent-send-mail-function nil)
175 (defvar gnus-agent-file-coding-system 'raw-text)
176 (defvar gnus-agent-file-loading-cache nil)
177 (defvar gnus-agent-file-header-cache nil)
179 (defvar gnus-agent-auto-agentize-methods '(nntp nnimap)
180 "Initially, all servers from these methods are agentized.
181 The user may remove or add servers using the Server buffer. See Info
182 node `(gnus)Server Buffer'.")
185 (defvar gnus-headers)
192 (defun gnus-open-agent ()
194 (gnus-agent-read-servers)
196 (gnus-agent-create-buffer)
197 (add-hook 'gnus-group-mode-hook 'gnus-agent-mode)
198 (add-hook 'gnus-summary-mode-hook 'gnus-agent-mode)
199 (add-hook 'gnus-server-mode-hook 'gnus-agent-mode))
201 (defun gnus-agent-create-buffer ()
202 (if (gnus-buffer-live-p gnus-agent-overview-buffer)
204 (setq gnus-agent-overview-buffer
205 (gnus-get-buffer-create " *Gnus agent overview*"))
206 (with-current-buffer gnus-agent-overview-buffer
207 (mm-enable-multibyte))
210 (gnus-add-shutdown 'gnus-close-agent 'gnus)
212 (defun gnus-close-agent ()
213 (setq gnus-category-predicate-cache nil
214 gnus-category-group-cache nil
215 gnus-agent-spam-hashtb nil)
216 (gnus-kill-buffer gnus-agent-overview-buffer))
219 ;;; Utility functions
222 (defun gnus-agent-read-file (file)
223 "Load FILE and do a `read' there."
226 (nnheader-insert-file-contents file)
227 (goto-char (point-min))
228 (read (current-buffer)))))
230 (defsubst gnus-agent-method ()
231 (concat (symbol-name (car gnus-command-method)) "/"
232 (if (equal (cadr gnus-command-method) "")
234 (cadr gnus-command-method))))
236 (defsubst gnus-agent-directory ()
237 "The name of the Gnus agent directory."
238 (nnheader-concat gnus-agent-directory
239 (nnheader-translate-file-chars (gnus-agent-method)) "/"))
241 (defun gnus-agent-lib-file (file)
242 "The full name of the Gnus agent library FILE."
243 (expand-file-name file
244 (file-name-as-directory
245 (expand-file-name "agent.lib" (gnus-agent-directory)))))
247 ;;; Fetching setup functions.
249 (defun gnus-agent-start-fetch ()
250 "Initialize data structures for efficient fetching."
251 (gnus-agent-create-buffer))
253 (defun gnus-agent-stop-fetch ()
254 "Save all data structures and clean up."
255 (setq gnus-agent-spam-hashtb nil)
257 (set-buffer nntp-server-buffer)
260 (defmacro gnus-agent-with-fetch (&rest forms)
263 (let ((gnus-agent-fetching t))
264 (gnus-agent-start-fetch)
266 (gnus-agent-stop-fetch)))
268 (put 'gnus-agent-with-fetch 'lisp-indent-function 0)
269 (put 'gnus-agent-with-fetch 'edebug-form-spec '(body))
271 (defmacro gnus-agent-append-to-list (tail value)
272 `(setq ,tail (setcdr ,tail (cons ,value nil))))
278 (defvar gnus-agent-mode-hook nil
279 "Hook run when installing agent mode.")
281 (defvar gnus-agent-mode nil)
282 (defvar gnus-agent-mode-status '(gnus-agent-mode " Plugged"))
284 (defun gnus-agent-mode ()
285 "Minor mode for providing a agent support in Gnus buffers."
286 (let* ((buffer (progn (string-match "^gnus-\\(.*\\)-mode$"
287 (symbol-name major-mode))
288 (match-string 1 (symbol-name major-mode))))
289 (mode (intern (format "gnus-agent-%s-mode" buffer))))
290 (set (make-local-variable 'gnus-agent-mode) t)
292 (set (make-local-variable mode) t)
294 (when (gnus-visual-p 'agent-menu 'menu)
295 (funcall (intern (format "gnus-agent-%s-make-menu-bar" buffer))))
296 (unless (assq 'gnus-agent-mode minor-mode-alist)
297 (push gnus-agent-mode-status minor-mode-alist))
298 (unless (assq mode minor-mode-map-alist)
299 (push (cons mode (symbol-value (intern (format "gnus-agent-%s-mode-map"
301 minor-mode-map-alist))
302 (when (eq major-mode 'gnus-group-mode)
303 (gnus-agent-toggle-plugged gnus-plugged))
304 (gnus-run-hooks 'gnus-agent-mode-hook
305 (intern (format "gnus-agent-%s-mode-hook" buffer)))))
307 (defvar gnus-agent-group-mode-map (make-sparse-keymap))
308 (gnus-define-keys gnus-agent-group-mode-map
309 "Ju" gnus-agent-fetch-groups
310 "Jc" gnus-enter-category-buffer
311 "Jj" gnus-agent-toggle-plugged
312 "Js" gnus-agent-fetch-session
313 "JY" gnus-agent-synchronize-flags
314 "JS" gnus-group-send-queue
315 "Ja" gnus-agent-add-group
316 "Jr" gnus-agent-remove-group
317 "Jo" gnus-agent-toggle-group-plugged)
319 (defun gnus-agent-group-make-menu-bar ()
320 (unless (boundp 'gnus-agent-group-menu)
322 gnus-agent-group-menu gnus-agent-group-mode-map ""
324 ["Toggle plugged" gnus-agent-toggle-plugged t]
325 ["Toggle group plugged" gnus-agent-toggle-group-plugged t]
326 ["List categories" gnus-enter-category-buffer t]
327 ["Send queue" gnus-group-send-queue gnus-plugged]
329 ["All" gnus-agent-fetch-session gnus-plugged]
330 ["Group" gnus-agent-fetch-group gnus-plugged])))))
332 (defvar gnus-agent-summary-mode-map (make-sparse-keymap))
333 (gnus-define-keys gnus-agent-summary-mode-map
334 "Jj" gnus-agent-toggle-plugged
335 "Ju" gnus-agent-summary-fetch-group
336 "JS" gnus-agent-fetch-group
337 "Js" gnus-agent-summary-fetch-series
338 "J#" gnus-agent-mark-article
339 "J\M-#" gnus-agent-unmark-article
340 "@" gnus-agent-toggle-mark
341 "Jc" gnus-agent-catchup)
343 (defun gnus-agent-summary-make-menu-bar ()
344 (unless (boundp 'gnus-agent-summary-menu)
346 gnus-agent-summary-menu gnus-agent-summary-mode-map ""
348 ["Toggle plugged" gnus-agent-toggle-plugged t]
349 ["Mark as downloadable" gnus-agent-mark-article t]
350 ["Unmark as downloadable" gnus-agent-unmark-article t]
351 ["Toggle mark" gnus-agent-toggle-mark t]
352 ["Fetch downloadable" gnus-agent-summary-fetch-group t]
353 ["Catchup undownloaded" gnus-agent-catchup t]))))
355 (defvar gnus-agent-server-mode-map (make-sparse-keymap))
356 (gnus-define-keys gnus-agent-server-mode-map
357 "Jj" gnus-agent-toggle-plugged
358 "Ja" gnus-agent-add-server
359 "Jr" gnus-agent-remove-server)
361 (defun gnus-agent-server-make-menu-bar ()
362 (unless (boundp 'gnus-agent-server-menu)
364 gnus-agent-server-menu gnus-agent-server-mode-map ""
366 ["Toggle plugged" gnus-agent-toggle-plugged t]
367 ["Add" gnus-agent-add-server t]
368 ["Remove" gnus-agent-remove-server t]))))
370 (defun gnus-agent-make-mode-line-string (string mouse-button mouse-func)
371 (if (and (fboundp 'propertize)
372 (fboundp 'make-mode-line-mouse-map))
373 (propertize string 'local-map
374 (make-mode-line-mouse-map mouse-button mouse-func))
377 (defun gnus-agent-toggle-plugged (plugged)
378 "Toggle whether Gnus is unplugged or not."
379 (interactive (list (not gnus-plugged)))
382 (setq gnus-plugged plugged)
383 (gnus-run-hooks 'gnus-agent-plugged-hook)
384 (setcar (cdr gnus-agent-mode-status)
385 (gnus-agent-make-mode-line-string " Plugged"
387 'gnus-agent-toggle-plugged))
388 (gnus-agent-go-online gnus-agent-go-online)
389 (gnus-agent-possibly-synchronize-flags))
390 (gnus-agent-close-connections)
391 (setq gnus-plugged plugged)
392 (gnus-run-hooks 'gnus-agent-unplugged-hook)
393 (setcar (cdr gnus-agent-mode-status)
394 (gnus-agent-make-mode-line-string " Unplugged"
396 'gnus-agent-toggle-plugged)))
397 (set-buffer-modified-p t))
399 (defun gnus-agent-close-connections ()
400 "Close all methods covered by the Gnus agent."
401 (let ((methods gnus-agent-covered-methods))
403 (gnus-close-server (pop methods)))))
406 (defun gnus-unplugged ()
407 "Start Gnus unplugged."
409 (setq gnus-plugged nil)
413 (defun gnus-plugged ()
414 "Start Gnus plugged."
416 (setq gnus-plugged t)
420 (defun gnus-slave-unplugged (&optional arg)
421 "Read news as a slave unplugged."
423 (setq gnus-plugged nil)
424 (gnus arg nil 'slave))
427 (defun gnus-agentize ()
428 "Allow Gnus to be an offline newsreader.
429 The normal usage of this command is to put the following as the
430 last form in your `.gnus.el' file:
434 This will modify the `gnus-setup-news-hook', and
435 `message-send-mail-real-function' variables, and install the Gnus agent
436 minor mode in all Gnus buffers."
439 (add-hook 'gnus-setup-news-hook 'gnus-agent-queue-setup)
440 (unless gnus-agent-send-mail-function
441 (setq gnus-agent-send-mail-function (or
442 message-send-mail-real-function
443 message-send-mail-function)
444 message-send-mail-real-function 'gnus-agent-send-mail))
445 (unless gnus-agent-covered-methods
448 (if (memq (car (gnus-server-to-method server))
449 gnus-agent-auto-agentize-methods)
450 (setq gnus-agent-covered-methods
451 (cons (gnus-server-to-method server)
452 gnus-agent-covered-methods ))))
453 (append (list gnus-select-method) gnus-secondary-select-methods))))
455 (defun gnus-agent-queue-setup ()
456 "Make sure the queue group exists."
457 (unless (gnus-gethash "nndraft:queue" gnus-newsrc-hashtb)
458 (gnus-request-create-group "queue" '(nndraft ""))
459 (let ((gnus-level-default-subscribed 1))
460 (gnus-subscribe-group "nndraft:queue" nil '(nndraft "")))
461 (gnus-group-set-parameter
462 "nndraft:queue" 'gnus-dummy '((gnus-draft-mode)))))
464 (defun gnus-agent-send-mail ()
466 (funcall gnus-agent-send-mail-function)
467 (goto-char (point-min))
469 (concat "^" (regexp-quote mail-header-separator) "\n"))
471 (gnus-agent-insert-meta-information 'mail)
472 (gnus-request-accept-article "nndraft:queue" nil t t)))
474 (defun gnus-agent-insert-meta-information (type &optional method)
475 "Insert meta-information into the message that says how it's to be posted.
476 TYPE can be either `mail' or `news'. If the latter, then METHOD can
479 (message-remove-header gnus-agent-meta-information-header)
480 (goto-char (point-min))
481 (insert gnus-agent-meta-information-header ": "
482 (symbol-name type) " " (format "%S" method)
485 (while (search-backward "\n" nil t)
486 (replace-match "\\n" t t))))
488 (defun gnus-agent-restore-gcc ()
489 "Restore GCC field from saved header."
491 (goto-char (point-min))
492 (while (re-search-forward (concat gnus-agent-gcc-header ":") nil t)
493 (replace-match "Gcc:" 'fixedcase))))
495 (defun gnus-agent-any-covered-gcc ()
497 (message-narrow-to-headers)
498 (let* ((gcc (mail-fetch-field "gcc" nil t))
500 (mapcar 'gnus-inews-group-method
501 (message-unquote-tokens
502 (message-tokenize-header
505 (while (and (not covered) methods)
506 (setq covered (gnus-agent-method-p (car methods))
507 methods (cdr methods)))
511 (defun gnus-agent-possibly-save-gcc ()
512 "Save GCC if Gnus is unplugged."
513 (when (and (not gnus-plugged) (gnus-agent-any-covered-gcc))
515 (goto-char (point-min))
516 (let ((case-fold-search t))
517 (while (re-search-forward "^gcc:" nil t)
518 (replace-match (concat gnus-agent-gcc-header ":") 'fixedcase))))))
520 (defun gnus-agent-possibly-do-gcc ()
521 "Do GCC if Gnus is plugged."
522 (when (or gnus-plugged (not (gnus-agent-any-covered-gcc)))
523 (gnus-inews-do-gcc)))
526 ;;; Group mode commands
529 (defun gnus-agent-fetch-groups (n)
530 "Put all new articles in the current groups into the Agent."
533 (error "Groups can't be fetched when Gnus is unplugged"))
534 (gnus-group-iterate n 'gnus-agent-fetch-group))
536 (defun gnus-agent-fetch-group (&optional group)
537 "Put all new articles in GROUP into the Agent."
538 (interactive (list (gnus-group-group-name)))
539 (let ((state gnus-plugged))
542 (setq group (or group gnus-newsgroup-name))
544 (error "No group on the current line"))
546 (gnus-agent-toggle-plugged gnus-plugged))
547 (let ((gnus-command-method (gnus-find-method-for-group group)))
548 (gnus-agent-with-fetch
549 (gnus-agent-fetch-group-1 group gnus-command-method)
550 (gnus-message 5 "Fetching %s...done" group))))
551 (when (and (not state)
553 (gnus-agent-toggle-plugged gnus-plugged)))))
555 (defun gnus-agent-add-group (category arg)
556 "Add the current group to an agent category."
562 (mapcar (lambda (cat) (list (symbol-name (car cat))))
566 (let ((cat (assq category gnus-category-alist))
568 (gnus-group-iterate arg
570 (when (cadddr (setq c (gnus-group-category group)))
571 (setf (cadddr c) (delete group (cadddr c))))
572 (push group groups)))
573 (setf (cadddr cat) (nconc (cadddr cat) groups))
574 (gnus-category-write)))
576 (defun gnus-agent-remove-group (arg)
577 "Remove the current group from its agent category, if any."
580 (gnus-group-iterate arg
582 (when (cadddr (setq c (gnus-group-category group)))
583 (setf (cadddr c) (delete group (cadddr c))))))
584 (gnus-category-write)))
586 (defun gnus-agent-synchronize-flags ()
587 "Synchronize unplugged flags with servers."
590 (dolist (gnus-command-method gnus-agent-covered-methods)
591 (when (file-exists-p (gnus-agent-lib-file "flags"))
592 (gnus-agent-synchronize-flags-server gnus-command-method)))))
594 (defun gnus-agent-possibly-synchronize-flags ()
595 "Synchronize flags according to `gnus-agent-synchronize-flags'."
598 (dolist (gnus-command-method gnus-agent-covered-methods)
599 (when (file-exists-p (gnus-agent-lib-file "flags"))
600 (gnus-agent-possibly-synchronize-flags-server gnus-command-method)))))
602 (defun gnus-agent-synchronize-flags-server (method)
603 "Synchronize flags set when unplugged for server."
604 (let ((gnus-command-method method))
605 (when (file-exists-p (gnus-agent-lib-file "flags"))
606 (set-buffer (get-buffer-create " *Gnus Agent flag synchronize*"))
608 (nnheader-insert-file-contents (gnus-agent-lib-file "flags"))
609 (if (null (gnus-check-server gnus-command-method))
610 (gnus-message 1 "Couldn't open server %s" (nth 1 gnus-command-method))
612 (if (null (eval (read (current-buffer))))
613 (progn (forward-line)
615 (write-file (gnus-agent-lib-file "flags"))
616 (error "Couldn't set flags from file %s"
617 (gnus-agent-lib-file "flags"))))
618 (delete-file (gnus-agent-lib-file "flags")))
621 (defun gnus-agent-possibly-synchronize-flags-server (method)
622 "Synchronize flags for server according to `gnus-agent-synchronize-flags'."
623 (when (or (and gnus-agent-synchronize-flags
624 (not (eq gnus-agent-synchronize-flags 'ask)))
625 (and (eq gnus-agent-synchronize-flags 'ask)
626 (gnus-y-or-n-p (format "Synchronize flags on server `%s'? "
628 (gnus-agent-synchronize-flags-server method)))
631 ;;; Server mode commands
634 (defun gnus-agent-add-server (server)
635 "Enroll SERVER in the agent program."
636 (interactive (list (gnus-server-server-name)))
638 (error "No server on the current line"))
639 (let ((method (gnus-server-get-method nil (gnus-server-server-name))))
640 (when (gnus-agent-method-p method)
641 (error "Server already in the agent program"))
642 (push method gnus-agent-covered-methods)
643 (gnus-server-update-server server)
644 (gnus-agent-write-servers)
645 (gnus-message 1 "Entered %s into the Agent" server)))
647 (defun gnus-agent-remove-server (server)
648 "Remove SERVER from the agent program."
649 (interactive (list (gnus-server-server-name)))
651 (error "No server on the current line"))
652 (let ((method (gnus-server-get-method nil (gnus-server-server-name))))
653 (unless (gnus-agent-method-p method)
654 (error "Server not in the agent program"))
655 (setq gnus-agent-covered-methods
656 (delete method gnus-agent-covered-methods))
657 (gnus-server-update-server server)
658 (gnus-agent-write-servers)
659 (gnus-message 1 "Removed %s from the agent" server)))
661 (defun gnus-agent-read-servers ()
662 "Read the alist of covered servers."
664 (let ((method (gnus-server-get-method
668 (unless (member method gnus-agent-covered-methods)
669 (push method gnus-agent-covered-methods))
670 (gnus-message 1 "Ignoring disappeared server `%s'" m)
672 (gnus-agent-read-file
673 (nnheader-concat gnus-agent-directory "lib/servers"))))
675 (defun gnus-agent-write-servers ()
676 "Write the alist of covered servers."
677 (gnus-make-directory (nnheader-concat gnus-agent-directory "lib"))
678 (let ((coding-system-for-write nnheader-file-coding-system)
679 (file-name-coding-system nnmail-pathname-coding-system))
680 (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
681 (prin1 (mapcar 'gnus-method-simplify gnus-agent-covered-methods)
688 (defun gnus-agent-mark-article (n &optional unmark)
689 "Mark the next N articles as downloadable.
690 If N is negative, mark backward instead. If UNMARK is non-nil, remove
691 the mark instead. The difference between N and the actual number of
692 articles marked is returned."
694 (let ((backward (< n 0))
699 (gnus-summary-set-agent-mark
700 (gnus-summary-article-number) unmark)
701 (zerop (gnus-summary-next-subject (if backward -1 1) nil t))))
704 (gnus-message 7 "No more articles"))
705 (gnus-summary-recenter)
706 (gnus-summary-position-point)
709 (defun gnus-agent-unmark-article (n)
710 "Remove the downloadable mark from the next N articles.
711 If N is negative, unmark backward instead. The difference between N and
712 the actual number of articles unmarked is returned."
714 (gnus-agent-mark-article n t))
716 (defun gnus-agent-toggle-mark (n)
717 "Toggle the downloadable mark from the next N articles.
718 If N is negative, toggle backward instead. The difference between N and
719 the actual number of articles toggled is returned."
721 (gnus-agent-mark-article n 'toggle))
723 (defun gnus-summary-set-agent-mark (article &optional unmark)
724 "Mark ARTICLE as downloadable. If UNMARK is nil, article is marked.
725 When UNMARK is t, the article is unmarked. For any other value, the
726 article's mark is toggled."
727 (let ((unmark (cond ((eq nil unmark)
732 (memq article gnus-newsgroup-downloadable)))))
733 (gnus-summary-update-mark
736 (setq gnus-newsgroup-downloadable
737 (delq article gnus-newsgroup-downloadable))
738 (gnus-article-mark article))
740 (setq gnus-newsgroup-downloadable
741 (gnus-add-to-sorted-list gnus-newsgroup-downloadable article))
742 gnus-downloadable-mark)
746 (defun gnus-agent-get-undownloaded-list ()
747 "Construct list of articles that have not been downloaded."
748 (let ((gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name)))
749 (when (set (make-local-variable 'gnus-newsgroup-agentized) (gnus-agent-method-p gnus-command-method))
750 (let* ((alist (gnus-agent-load-alist gnus-newsgroup-name))
751 (headers gnus-newsgroup-headers)
752 (undownloaded (list nil))
754 (while (and alist headers)
755 (let ((a (caar alist))
756 (h (mail-header-number (car headers))))
758 (pop alist)) ; ignore IDs in the alist that are not being displayed in the summary
760 ;; headers that are not in the alist should be
761 ;; fictious (see nnagent-retrieve-headers); they
762 ;; imply that this article isn't in the agent.
763 (gnus-agent-append-to-list tail h)
768 nil; ignore already downloaded
773 (gnus-agent-append-to-list tail a)))))
776 (gnus-agent-append-to-list tail (mail-header-number (pop headers))))
777 (setq gnus-newsgroup-undownloaded (cdr undownloaded))))))
779 (defun gnus-agent-catchup ()
780 "Mark all articles as read that are neither cached, downloaded, nor downloadable."
783 (let ((articles gnus-newsgroup-undownloaded))
784 (when (or gnus-newsgroup-downloadable
785 gnus-newsgroup-cached)
786 (setq articles (gnus-sorted-ndifference (gnus-sorted-ndifference (copy-sequence articles) gnus-newsgroup-downloadable) gnus-newsgroup-cached)))
789 (gnus-summary-mark-article
790 (pop articles) gnus-catchup-mark)))
791 (gnus-summary-position-point)))
793 (defun gnus-agent-summary-fetch-series ()
795 (when gnus-newsgroup-processable
796 (setq gnus-newsgroup-downloadable
797 (let* ((dl gnus-newsgroup-downloadable)
798 (gnus-newsgroup-downloadable (sort (copy-sequence gnus-newsgroup-processable) '<))
799 (fetched-articles (gnus-agent-summary-fetch-group)))
800 ;; The preceeding call to (gnus-agent-summary-fetch-group)
801 ;; updated gnus-newsgroup-downloadable to remove each
802 ;; article successfully fetched.
804 ;; For each article that I processed, remove its
805 ;; processable mark IF the article is no longer
806 ;; downloadable (i.e. it's already downloaded)
807 (dolist (article gnus-newsgroup-processable)
808 (unless (memq article gnus-newsgroup-downloadable)
809 (gnus-summary-remove-process-mark article)))
810 (gnus-sorted-ndifference dl fetched-articles)))))
812 (defun gnus-agent-summary-fetch-group (&optional all)
813 "Fetch the downloadable articles in the group.
814 Optional arg ALL, if non-nil, means to fetch all articles."
817 (if all gnus-newsgroup-articles
818 gnus-newsgroup-downloadable))
819 (gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name))
825 (gnus-agent-toggle-plugged t))
827 (error "No articles to download"))
828 (gnus-agent-with-fetch
829 (setq gnus-newsgroup-undownloaded
830 (gnus-sorted-ndifference gnus-newsgroup-undownloaded
831 (setq fetched-articles (gnus-agent-fetch-articles gnus-newsgroup-name articles)))))
834 (dolist (article articles)
835 (setq gnus-newsgroup-downloadable
836 (delq article gnus-newsgroup-downloadable))
837 (if gnus-agent-mark-unread-after-downloaded
838 (gnus-summary-mark-article article gnus-unread-mark))
839 (when (gnus-summary-goto-subject article nil t)
840 (gnus-summary-update-download-mark article)))))
841 (when (and (not state)
843 (gnus-agent-toggle-plugged nil)))
846 (defun gnus-agent-fetch-selected-article ()
847 "Fetch the current article as it is selected.
848 This can be added to `gnus-select-article-hook' or
849 `gnus-mark-article-hook'."
850 (let ((gnus-command-method gnus-current-select-method))
851 (when (and gnus-plugged (gnus-agent-method-p gnus-command-method))
852 (when (gnus-agent-fetch-articles
854 (list gnus-current-article))
855 (setq gnus-newsgroup-undownloaded
856 (delq gnus-current-article gnus-newsgroup-undownloaded))
857 (gnus-summary-update-article-line
859 (gnus-summary-article-header gnus-current-article))))))
862 ;;; Internal functions
865 (defun gnus-agent-save-active (method)
866 (gnus-agent-save-active-1 method 'gnus-active-to-gnus-format))
868 (defun gnus-agent-save-active-1 (method function)
869 (when (gnus-agent-method-p method)
870 (let* ((gnus-command-method method)
871 (new (gnus-make-hashtable (count-lines (point-min) (point-max))))
872 (file (gnus-agent-lib-file "active")))
873 (funcall function nil new)
874 (gnus-agent-write-active file new)
876 (nnheader-insert-file-contents file))))
878 (defun gnus-agent-write-active (file new)
879 (let ((orig (gnus-make-hashtable (count-lines (point-min) (point-max))))
880 (file (gnus-agent-lib-file "active"))
882 (when (file-exists-p file)
884 (nnheader-insert-file-contents file)
885 (gnus-active-to-gnus-format nil orig))
888 (when (and sym (boundp sym))
889 (if (and (boundp (setq osym (intern (symbol-name sym) orig)))
890 (setq elem (symbol-value osym)))
892 (if (and (integerp (car (symbol-value sym)))
893 (> (car elem) (car (symbol-value sym))))
894 (setcar elem (car (symbol-value sym))))
895 (if (integerp (cdr (symbol-value sym)))
896 (setcdr elem (cdr (symbol-value sym)))))
897 (set (intern (symbol-name sym) orig) (symbol-value sym)))))
899 (gnus-make-directory (file-name-directory file))
900 (let ((nnmail-active-file-coding-system gnus-agent-file-coding-system))
901 ;; The hashtable contains real names of groups, no more prefix
902 ;; removing, so set `full' to `t'.
903 (gnus-write-active-file file orig t))))
905 (defun gnus-agent-save-groups (method)
906 (gnus-agent-save-active-1 method 'gnus-groups-to-gnus-format))
908 (defun gnus-agent-save-group-info (method group active)
909 (when (gnus-agent-method-p method)
910 (let* ((gnus-command-method method)
911 (coding-system-for-write nnheader-file-coding-system)
912 (file-name-coding-system nnmail-pathname-coding-system)
913 (file (gnus-agent-lib-file "active"))
915 (gnus-make-directory (file-name-directory file))
917 ;; Emacs got problem to match non-ASCII group in multibyte buffer.
918 (mm-disable-multibyte)
919 (when (file-exists-p file)
920 (nnheader-insert-file-contents file))
921 (goto-char (point-min))
922 (when (re-search-forward
923 (concat "^" (regexp-quote group) " ") nil t)
925 (read (current-buffer)) ;; max
926 (setq oactive-min (read (current-buffer)))) ;; min
928 (insert (format "%S %d %d y\n" (intern group)
930 (or oactive-min (car active))))
931 (goto-char (point-max))
932 (while (search-backward "\\." nil t)
935 (defun gnus-agent-group-path (group)
936 "Translate GROUP into a file name."
937 (if nnmail-use-long-file-names
938 (gnus-group-real-name group)
939 (nnheader-translate-file-chars
940 (nnheader-replace-chars-in-string
941 (nnheader-replace-duplicate-chars-in-string
942 (nnheader-replace-chars-in-string
943 (gnus-group-real-name group)
948 (defun gnus-agent-get-function (method)
949 (if (gnus-online method)
954 ;;; History functions
956 (defun gnus-agent-history-buffer ()
957 (cdr (assoc (gnus-agent-method) gnus-agent-history-buffers)))
959 (defun gnus-agent-open-history ()
961 (push (cons (gnus-agent-method)
962 (set-buffer (gnus-get-buffer-create
963 (format " *Gnus agent %s history*"
964 (gnus-agent-method)))))
965 gnus-agent-history-buffers)
966 (mm-disable-multibyte) ;; everything is binary
969 (let ((file (gnus-agent-lib-file "history")))
970 (when (file-exists-p file)
971 (nnheader-insert-file-contents file))
972 (set (make-local-variable 'gnus-agent-file-name) file))))
974 (defun gnus-agent-close-history ()
975 (when (gnus-buffer-live-p gnus-agent-current-history)
976 (kill-buffer gnus-agent-current-history)
977 (setq gnus-agent-history-buffers
978 (delq (assoc (gnus-agent-method) gnus-agent-history-buffers)
979 gnus-agent-history-buffers))))
985 (defun gnus-agent-fetch-articles (group articles)
986 "Fetch ARTICLES from GROUP and put them into the Agent."
988 (gnus-agent-load-alist group)
989 (let* ((alist gnus-agent-article-alist)
990 (headers (if (< (length articles) 2) nil gnus-newsgroup-headers))
991 (selected-sets (list nil))
995 ;; Check each article
996 (while (setq article (pop articles))
997 ;; Skip alist entries preceeding this article
998 (while (> article (or (caar alist) (1+ article)))
999 (setq alist (cdr alist)))
1001 ;; Prune off articles that we have already fetched.
1002 (unless (and (eq article (caar alist))
1004 ;; Skip headers preceeding this article
1007 (let* ((header (car headers)))
1009 (mail-header-number header)
1011 (setq headers (cdr headers)))
1013 ;; Add this article to the current set
1014 (setcar selected-sets (cons article (car selected-sets)))
1016 ;; Update the set size, when the set is too large start a
1017 ;; new one. I do this after adding the article as I want at
1018 ;; least one article in each set.
1019 (when (< gnus-agent-max-fetch-size
1020 (setq current-set-size (+ current-set-size (if (= header-number article)
1021 (mail-header-chars (car headers))
1023 (setcar selected-sets (nreverse (car selected-sets)))
1024 (setq selected-sets (cons nil selected-sets)
1025 current-set-size 0))))
1027 (when (or (cdr selected-sets) (car selected-sets))
1028 (let* ((fetched-articles (list nil))
1029 (tail-fetched-articles fetched-articles)
1031 (gnus-agent-directory)
1032 (gnus-agent-group-path group) "/"))
1033 (date (time-to-days (current-time)))
1034 (case-fold-search t)
1037 (setcar selected-sets (nreverse (car selected-sets)))
1038 (setq selected-sets (nreverse selected-sets))
1040 (gnus-make-directory dir)
1041 (gnus-message 7 "Fetching articles for %s..." group)
1044 (while (setq articles (pop selected-sets))
1045 ;; Fetch the articles from the backend.
1046 (if (gnus-check-backend-function 'retrieve-articles group)
1047 (setq pos (gnus-retrieve-articles articles group))
1050 (while (setq article (pop articles))
1051 (gnus-message 10 "Fetching article %s for %s..."
1054 (gnus-backlog-request-article group article
1056 (gnus-request-article article group))
1057 (goto-char (point-max))
1058 (push (cons article (point)) pos)
1059 (insert-buffer-substring nntp-server-buffer)))
1060 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
1061 (setq pos (nreverse pos)))))
1062 ;; Then save these articles into the Agent.
1064 (set-buffer nntp-server-buffer)
1066 (narrow-to-region (cdar pos) (or (cdadr pos) (point-max)))
1067 (goto-char (point-min))
1068 (unless (eobp) ;; Don't save empty articles.
1069 (when (search-forward "\n\n" nil t)
1070 (when (search-backward "\nXrefs: " nil t)
1071 ;; Handle cross posting.
1072 (goto-char (match-end 0)) ; move to end of header name
1073 (skip-chars-forward "^ ") ; skip server name
1074 (skip-chars-forward " ")
1076 (while (looking-at "\\([^: \n]+\\):\\([0-9]+\\) *")
1077 (push (cons (buffer-substring (match-beginning 1)
1079 (string-to-int (buffer-substring (match-beginning 2)
1082 (goto-char (match-end 0)))
1083 (gnus-agent-crosspost crosses (caar pos) date)))
1084 (goto-char (point-min))
1085 (if (not (re-search-forward
1086 "^Message-ID: *<\\([^>\n]+\\)>" nil t))
1087 (setq id "No-Message-ID-in-article")
1088 (setq id (buffer-substring (match-beginning 1) (match-end 1))))
1089 (let ((coding-system-for-write
1090 gnus-agent-file-coding-system))
1091 (write-region (point-min) (point-max)
1092 (concat dir (number-to-string (caar pos)))
1095 (gnus-agent-append-to-list tail-fetched-articles (caar pos)))
1099 (gnus-agent-save-alist group (cdr fetched-articles) date))
1100 (cdr fetched-articles))))))
1102 (defun gnus-agent-crosspost (crosses article &optional date)
1103 (setq date (or date t))
1105 (let (gnus-agent-article-alist group alist beg end)
1107 (set-buffer gnus-agent-overview-buffer)
1108 (when (nnheader-find-nov-line article)
1111 (setq end (progn (forward-line 1) (point)))))
1113 (setq group (caar crosses))
1114 (unless (setq alist (assoc group gnus-agent-group-alist))
1115 (push (setq alist (list group (gnus-agent-load-alist (caar crosses))))
1116 gnus-agent-group-alist))
1117 (setcdr alist (cons (cons (cdar crosses) date) (cdr alist)))
1119 (set-buffer (gnus-get-buffer-create (format " *Gnus agent overview %s*"
1121 (when (= (point-max) (point-min))
1122 (push (cons group (current-buffer)) gnus-agent-buffer-alist)
1124 (nnheader-insert-file-contents
1125 (gnus-agent-article-name ".overview" group))))
1126 (nnheader-find-nov-line (string-to-number (cdar crosses)))
1127 (insert (string-to-number (cdar crosses)))
1128 (insert-buffer-substring gnus-agent-overview-buffer beg end)
1129 (gnus-agent-check-overview-buffer))
1132 (defun gnus-agent-backup-overview-buffer ()
1133 (when gnus-newsgroup-name
1134 (let ((root (gnus-agent-article-name ".overview" gnus-newsgroup-name))
1137 (while (file-exists-p (setq name (concat root "~" (int-to-string (setq cnt (1+ cnt))) "~"))))
1138 (write-region (point-min) (point-max) name nil 'no-msg)
1139 (gnus-message 1 "Created backup copy of overview in %s." name)
1144 (defun gnus-agent-check-overview-buffer (&optional buffer)
1145 "Check the overview file given for sanity.
1146 In particular, checks that the file is sorted by article number
1147 and that there are no duplicates."
1152 (set-buffer buffer))
1155 (goto-char (point-min))
1157 (while (< (point) (point-max))
1159 (cur (condition-case nil
1160 (read (current-buffer))
1163 ((or (not (integerp cur))
1164 (not (eq (char-after) ?\t)))
1166 (setq backed-up (gnus-agent-backup-overview-buffer)))
1168 "Overview buffer contains garbage '%s'."
1170 p (gnus-point-at-eol))))
1173 (setq backed-up (gnus-agent-backup-overview-buffer)))
1175 "Duplicate overview line for %d" cur)
1176 (delete-region (point) (progn (forward-line 1) (point))))
1179 (setq backed-up (gnus-agent-backup-overview-buffer)))
1180 (gnus-message 1 "Overview buffer not sorted!")
1181 (sort-numeric-fields 1 (point-min) (point-max))
1182 (goto-char (point-min))
1185 (setq prev-num cur)))
1186 (forward-line 1)))))))
1188 (defun gnus-agent-flush-cache ()
1190 (while gnus-agent-buffer-alist
1191 (set-buffer (cdar gnus-agent-buffer-alist))
1192 (let ((coding-system-for-write
1193 gnus-agent-file-coding-system))
1194 (write-region (point-min) (point-max)
1195 (gnus-agent-article-name ".overview"
1196 (caar gnus-agent-buffer-alist))
1198 (pop gnus-agent-buffer-alist))
1199 (while gnus-agent-group-alist
1200 (with-temp-file (gnus-agent-article-name ".agentview" (caar gnus-agent-group-alist))
1201 (princ (cdar gnus-agent-group-alist))
1203 (princ 1 (current-buffer))
1205 (pop gnus-agent-group-alist))))
1207 (defun gnus-agent-fetch-headers (group &optional force)
1208 "Fetch interesting headers into the agent. The group's overview
1209 file will be updated to include the headers while a list of available
1210 article numbers will be returned."
1211 (let* ((fetch-all (and gnus-agent-consider-all-articles
1212 ;; Do not fetch all headers if the predicate
1213 ;; implies that we only consider unread articles.
1214 (not (gnus-predicate-implies-unread
1215 (or (gnus-group-find-parameter
1216 group 'agent-predicate t)
1217 (cadr (gnus-group-category group)))))))
1218 (articles (if fetch-all
1219 (gnus-uncompress-range (gnus-active group))
1220 (gnus-list-of-unread-articles group)))
1221 (gnus-decode-encoded-word-function 'identity)
1222 (file (gnus-agent-article-name ".overview" group))
1226 ;; Add articles with marks to the list of article headers we want to
1227 ;; fetch. Don't fetch articles solely on the basis of a recent or seen
1228 ;; mark, but do fetch recent or seen articles if they have other, more
1229 ;; interesting marks. (We have to fetch articles with boring marks
1230 ;; because otherwise the agent will remove their marks.)
1231 (dolist (arts (gnus-info-marks (gnus-get-info group)))
1232 (unless (memq (car arts) '(seen recent killed cache))
1233 (setq articles (gnus-range-add articles (cdr arts)))))
1234 (setq articles (sort (gnus-uncompress-sequence articles) '<)))
1236 ;; At this point, I have the list of articles to consider for fetching.
1237 ;; This is the list that I'll return to my caller. Some of these articles may have already
1238 ;; been fetched. That's OK as the fetch article code will filter those out.
1239 ;; Internally, I'll filter this list to just those articles whose headers need to be fetched.
1240 (let ((articles articles))
1241 ;; Remove known articles.
1242 (when (gnus-agent-load-alist group)
1243 ;; Remove articles marked as downloaded.
1245 ;; I want to fetch all headers in the active range.
1246 ;; Therefore, exclude only those headers that are in the article alist.
1247 ;; NOTE: This is probably NOT what I want to do after agent expiration in this group.
1248 (setq articles (gnus-agent-uncached-articles articles group))
1250 ;; I want to only fetch those headers that have never been fetched.
1251 ;; Therefore, exclude all headers that are, or WERE, in the article alist.
1252 (let ((low (1+ (caar (last gnus-agent-article-alist))))
1253 (high (cdr (gnus-active group))))
1254 ;; Low can be greater than High when the same group is fetched twice
1255 ;; in the same session {The first fetch will fill the article alist
1256 ;; such that (last gnus-agent-article-alist) equals (cdr (gnus-active group))}.
1257 ;; The addition of one(the 1+ above) then forces Low to be greater than High.
1258 ;; When this happens, gnus-list-range-intersection returns nil which indicates
1259 ;; that no headers need to be fetched. -- Kevin
1260 (setq articles (gnus-list-range-intersection
1261 articles (list (cons low high)))))))
1263 (gnus-message 10 "gnus-agent-fetch-headers: undownloaded articles are '%s'" (gnus-compress-sequence articles t))
1266 (set-buffer nntp-server-buffer)
1270 (gnus-message 7 "Fetching headers for %s..." group)
1273 (gnus-make-directory (nnheader-translate-file-chars
1274 (file-name-directory file) t))
1276 (unless (eq 'nov (gnus-retrieve-headers articles group))
1277 (nnvirtual-convert-headers))
1278 (gnus-agent-check-overview-buffer)
1279 ;; Move these headers to the overview buffer so that gnus-agent-braid-nov can merge them
1280 ;; with the contents of FILE.
1281 (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
1282 (when (file-exists-p file)
1283 (gnus-agent-braid-nov group articles file))
1284 (let ((coding-system-for-write
1285 gnus-agent-file-coding-system))
1286 (gnus-agent-check-overview-buffer)
1287 (write-region (point-min) (point-max) file nil 'silent))
1288 (gnus-agent-save-alist group articles nil)
1292 (nnheader-insert-file-contents file))))
1296 (defsubst gnus-agent-copy-nov-line (article)
1298 (set-buffer gnus-agent-overview-buffer)
1299 (while (and (not (eobp))
1300 (< (setq art (read (current-buffer))) article))
1304 (not (eq article art)))
1305 (set-buffer nntp-server-buffer)
1307 (setq e (progn (forward-line 1) (point)))
1308 (set-buffer nntp-server-buffer)
1309 (insert-buffer-substring gnus-agent-overview-buffer b e))))
1311 (defun gnus-agent-braid-nov (group articles file)
1312 "Merges the article headers identified by ARTICLES from gnus-agent-overview-buffer with the contents
1313 of FILE placing the combined headers in nntp-server-buffer."
1315 (set-buffer gnus-agent-overview-buffer)
1316 (goto-char (point-min))
1317 (set-buffer nntp-server-buffer)
1319 (nnheader-insert-file-contents file)
1320 (goto-char (point-max))
1322 (unless (looking-at "[0-9]+\t")
1323 ;; Remove corrupted lines
1324 (gnus-message 1 "Overview %s is corrupted. Removing corrupted lines..." file)
1325 (goto-char (point-min))
1327 (if (looking-at "[0-9]+\t")
1329 (delete-region (point) (progn (forward-line 1) (point)))))
1331 (unless (or (= (point-min) (point-max))
1332 (< (setq last (read (current-buffer))) (car articles)))
1333 ;; We do it the hard way.
1334 (when (nnheader-find-nov-line (car articles))
1335 ;; Replacing existing NOV entry
1336 (delete-region (point) (progn (forward-line 1) (point))))
1337 (gnus-agent-copy-nov-line (pop articles))
1341 (while (let ((art (read (current-buffer))))
1342 (cond ((< art (car articles))
1345 ((= art (car articles))
1347 (delete-region (point) (progn (forward-line 1) (point)))
1353 (gnus-agent-copy-nov-line (pop articles)))))
1355 ;; Copy the rest lines
1356 (set-buffer nntp-server-buffer)
1357 (goto-char (point-max))
1360 (set-buffer gnus-agent-overview-buffer)
1362 (while (<= (read (current-buffer)) last)
1365 (setq start (point))
1366 (set-buffer nntp-server-buffer))
1367 (insert-buffer-substring gnus-agent-overview-buffer start))))
1369 (eval-when-compile ; Keeps the compiler from warning about the free variable in gnus-agent-read-agentview
1370 (defvar gnus-agent-read-agentview))
1372 (defun gnus-agent-load-alist (group)
1373 (let ((gnus-agent-read-agentview group)) ; Binds free variable that's used in gnus-agent-read-agentview
1374 "Load the article-state alist for GROUP."
1375 (setq gnus-agent-article-alist
1376 (gnus-cache-file-contents
1377 (gnus-agent-article-name ".agentview" group)
1378 'gnus-agent-file-loading-cache
1379 'gnus-agent-read-agentview))))
1381 ;; Save format may be either 1 or 2. Two is the new, compressed format that is still being tested. Format 1 is uncompressed but known to be reliable.
1382 (defconst gnus-agent-article-alist-save-format 2)
1384 (defun gnus-agent-read-agentview (file)
1385 "Load FILE and do a `read' there."
1388 (nnheader-insert-file-contents file)
1389 (goto-char (point-min))
1390 (let ((alist (read (current-buffer)))
1391 (version (condition-case nil (read (current-buffer))
1395 (cond ((= version 0)
1396 (let ((inhibit-quit t)
1398 (gnus-agent-open-history)
1399 (set-buffer (gnus-agent-history-buffer))
1400 (goto-char (point-min))
1402 (if (and (looking-at
1403 "[^\t\n]+\t\\([0-9]+\\)\t\\([^ \n]+\\) \\([0-9]+\\)")
1404 (string= (match-string 2)
1405 gnus-agent-read-agentview)
1406 (setq entry (assoc (string-to-number (match-string 3)) alist)))
1407 (setcdr entry (string-to-number (match-string 1))))
1409 (gnus-agent-close-history)
1410 (setq changed-version t)))
1412 (setq changed-version (not (= 1 gnus-agent-article-alist-save-format))))
1415 (mapcar (lambda (comp-list)
1416 (let ((state (car comp-list))
1417 (sequence (gnus-uncompress-sequence (cdr comp-list))))
1418 (mapcar (lambda (article-id)
1419 (setq uncomp (cons (cons article-id state) uncomp))) sequence))) alist)
1420 (setq alist (sort uncomp (lambda (first second) (< (car first) (car second)))))
1423 (when changed-version
1424 (let ((gnus-agent-article-alist alist))
1425 (gnus-agent-save-alist gnus-agent-read-agentview)))
1428 (defun gnus-agent-save-alist (group &optional articles state dir)
1429 "Save the article-state alist for GROUP."
1430 (let* ((file-name-coding-system nnmail-pathname-coding-system)
1431 (prev (cons nil gnus-agent-article-alist))
1433 print-level print-length item article)
1434 (while (setq article (pop articles))
1435 (while (and (cdr prev)
1436 (< (caadr prev) article))
1437 (setq prev (cdr prev)))
1440 (setcdr prev (list (cons article state))))
1441 ((> (caadr prev) article)
1442 (setcdr prev (cons (cons article state) (cdr prev))))
1443 ((= (caadr prev) article)
1444 (setcdr (cadr prev) state)))
1445 (setq prev (cdr prev)))
1446 (setq gnus-agent-article-alist (cdr all))
1448 (gnus-make-directory dir)
1449 (gnus-make-directory (gnus-agent-article-name "" group)))
1450 (with-temp-file (if dir
1451 (expand-file-name ".agentview" dir)
1452 (gnus-agent-article-name ".agentview" group))
1453 (cond ((eq gnus-agent-article-alist-save-format 1)
1454 (princ gnus-agent-article-alist (current-buffer)))
1455 ((eq gnus-agent-article-alist-save-format 2)
1456 (let ((compressed nil))
1457 (mapcar (lambda (pair)
1458 (let* ((article-id (car pair))
1459 (day-of-download (cdr pair))
1460 (comp-list (assq day-of-download compressed)))
1462 (setcdr comp-list (cons article-id (cdr comp-list)))
1463 (setq compressed (cons (list day-of-download article-id) compressed)))
1464 nil)) gnus-agent-article-alist)
1465 (mapcar (lambda (comp-list) (setcdr comp-list (gnus-compress-sequence (nreverse (cdr comp-list))))) compressed)
1466 (princ compressed (current-buffer))
1471 (princ gnus-agent-article-alist-save-format (current-buffer))
1474 (defun gnus-agent-article-name (article group)
1475 (expand-file-name (if (stringp article) article (string-to-number article))
1476 (file-name-as-directory
1477 (expand-file-name (gnus-agent-group-path group)
1478 (gnus-agent-directory)))))
1480 (defun gnus-agent-batch-confirmation (msg)
1481 "Show error message and return t."
1482 (gnus-message 1 msg)
1486 (defun gnus-agent-batch-fetch ()
1487 "Start Gnus and fetch session."
1490 (let ((gnus-agent-confirmation-function 'gnus-agent-batch-confirmation))
1491 (gnus-agent-fetch-session))
1494 (defun gnus-agent-fetch-session ()
1495 "Fetch all articles and headers that are eligible for fetching."
1497 (unless gnus-agent-covered-methods
1498 (error "No servers are covered by the Gnus agent"))
1499 (unless gnus-plugged
1500 (error "Can't fetch articles while Gnus is unplugged"))
1501 (let ((methods gnus-agent-covered-methods)
1502 groups group gnus-command-method)
1507 (setq gnus-command-method (car methods))
1508 (when (and (or (gnus-server-opened gnus-command-method)
1509 (gnus-open-server gnus-command-method))
1510 (gnus-online gnus-command-method))
1511 (setq groups (gnus-groups-from-server (car methods)))
1512 (gnus-agent-with-fetch
1513 (while (setq group (pop groups))
1514 (when (<= (gnus-group-level group) gnus-agent-handle-level)
1515 (gnus-agent-fetch-group-1 group gnus-command-method))))))
1517 (unless (funcall gnus-agent-confirmation-function
1518 (format "Error %s. Continue? " (cdr err)))
1519 (error "Cannot fetch articles into the Gnus agent")))
1521 (unless (funcall gnus-agent-confirmation-function
1522 (format "Quit fetching session %s. Continue? "
1524 (signal 'quit "Cannot fetch articles into the Gnus agent"))))
1526 (run-hooks 'gnus-agent-fetch-hook)
1527 (gnus-message 6 "Finished fetching articles into the Gnus agent"))))
1529 (defun gnus-agent-fetch-group-1 (group method)
1531 (let ((gnus-command-method method)
1532 (gnus-newsgroup-name group)
1533 (gnus-newsgroup-dependencies gnus-newsgroup-dependencies)
1534 (gnus-newsgroup-headers gnus-newsgroup-headers)
1535 (gnus-newsgroup-scored gnus-newsgroup-scored)
1536 (gnus-use-cache gnus-use-cache)
1537 (gnus-summary-expunge-below gnus-summary-expunge-below)
1538 (gnus-summary-mark-below gnus-summary-mark-below)
1539 (gnus-orphan-score gnus-orphan-score)
1540 ;; Maybe some other gnus-summary local variables should also
1546 category predicate info marks score-param
1548 (unless (gnus-check-group group)
1549 (error "Can't open server for %s" group))
1552 (when (or gnus-newsgroup-active
1554 (gnus-activate-group group))
1555 (let ((marked-articles gnus-newsgroup-downloadable))
1556 ;; Identify the articles marked for download
1557 (unless gnus-newsgroup-active ;; This needs to be a
1558 ;; gnus-summary local variable
1559 ;; that is NOT bound to any
1560 ;; value above (It's global
1561 ;; value should default to nil).
1562 (dolist (mark gnus-agent-download-marks)
1563 (let ((arts (cdr (assq mark (gnus-info-marks
1564 (setq info (gnus-get-info group)))))))
1566 (setq marked-articles (nconc (gnus-uncompress-range arts)
1569 (setq marked-articles (sort marked-articles '<))
1571 ;; Fetch any new articles from the server
1572 (setq articles (gnus-agent-fetch-headers group))
1574 ;; Merge new articles with marked
1575 (setq articles (sort (append marked-articles articles) '<))
1578 ;; Parse them and see which articles we want to fetch.
1579 (setq gnus-newsgroup-dependencies
1580 (or gnus-newsgroup-dependencies
1581 (make-vector (length articles) 0)))
1582 (setq gnus-newsgroup-headers
1583 (or gnus-newsgroup-headers
1584 (gnus-get-newsgroup-headers-xover articles nil nil
1586 ;; `gnus-agent-overview-buffer' may be killed for
1587 ;; timeout reason. If so, recreate it.
1588 (gnus-agent-create-buffer)
1590 ;; Figure out how to select articles in this group
1591 (setq category (gnus-group-category group))
1595 (or (gnus-group-find-parameter group 'agent-predicate t)
1598 ;; If the selection predicate requires scoring, score each header
1599 (unless (memq predicate '(gnus-agent-true gnus-agent-false))
1601 (or (gnus-group-get-parameter group 'agent-score t)
1603 ;; Translate score-param into real one
1606 ((eq score-param 'file)
1607 (setq score-param (gnus-all-score-files group)))
1608 ((stringp (car score-param)))
1610 (setq score-param (list (list score-param)))))
1612 (gnus-score-headers score-param))))
1614 (unless (and (eq predicate 'gnus-agent-false)
1615 (not marked-articles))
1616 (let ((arts (list nil)))
1617 (let ((arts-tail arts)
1618 (alist (gnus-agent-load-alist group))
1619 (marked-articles marked-articles)
1620 (gnus-newsgroup-headers gnus-newsgroup-headers))
1621 (while (setq gnus-headers (pop gnus-newsgroup-headers))
1622 (let ((num (mail-header-number gnus-headers)))
1623 ;; Determine if this article is already in the cache
1625 (> num (caar alist)))
1626 (setq alist (cdr alist)))
1628 (unless (and (eq num (caar alist))
1631 ;; Determine if this article was marked for download.
1632 (while (and marked-articles
1633 (> num (car marked-articles)))
1634 (setq marked-articles
1635 (cdr marked-articles)))
1637 ;; When this article is marked, or selected by the
1638 ;; predicate, add it to the download list
1639 (when (or (eq num (car marked-articles))
1641 (or (cdr (assq num gnus-newsgroup-scored))
1642 gnus-summary-default-score)))
1643 (funcall predicate)))
1644 (gnus-agent-append-to-list arts-tail num))))))
1646 (let (fetched-articles)
1647 ;; Fetch all selected articles
1648 (setq gnus-newsgroup-undownloaded
1649 (gnus-sorted-ndifference gnus-newsgroup-undownloaded
1650 (setq fetched-articles (if (cdr arts) (gnus-agent-fetch-articles group (cdr arts)) nil))))
1652 (let ((unfetched-articles (gnus-sorted-ndifference (cdr arts) fetched-articles)))
1653 (if gnus-newsgroup-active
1654 ;; Update the summary buffer
1656 (dolist (article marked-articles)
1657 (when (gnus-summary-goto-subject article nil t)
1658 (gnus-summary-set-agent-mark article t)))
1659 (dolist (article fetched-articles)
1660 (if gnus-agent-mark-unread-after-downloaded
1661 (gnus-summary-mark-article article gnus-unread-mark))
1662 (when (gnus-summary-goto-subject article nil t)
1663 (gnus-summary-update-download-mark article)))
1664 (dolist (article unfetched-articles)
1665 (gnus-summary-mark-article article gnus-canceled-mark)))
1667 ;; Update the group buffer.
1669 ;; When some, or all, of the marked articles came
1670 ;; from the download mark. Remove that mark. I
1671 ;; didn't do this earlier as I only want to remove
1672 ;; the marks after the fetch is completed.
1674 (dolist (mark gnus-agent-download-marks)
1675 (when (eq mark 'download)
1676 (let ((marked-arts (assq mark (gnus-info-marks
1677 (setq info (gnus-get-info group))))))
1678 (when (cdr marked-arts)
1679 (setq marks (delq marked-arts (gnus-info-marks info)))
1680 (gnus-info-set-marks info marks)))))
1681 (let ((read (gnus-info-read (or info (setq info (gnus-get-info group))))))
1682 (gnus-info-set-read info (gnus-add-to-range read unfetched-articles)))
1684 (gnus-group-update-group group t)
1688 (concat "(gnus-group-set-info '"
1689 (gnus-prin1-to-string info)
1693 ;;; Agent Category Mode
1696 (defvar gnus-category-mode-hook nil
1697 "Hook run in `gnus-category-mode' buffers.")
1699 (defvar gnus-category-line-format " %(%20c%): %g\n"
1700 "Format of category lines.
1702 Valid specifiers include:
1703 %c Topic name (string)
1704 %g The number of groups in the topic (integer)
1706 General format specifiers can also be used. See Info node
1707 `(gnus)Formatting Variables'.")
1709 (defvar gnus-category-mode-line-format "Gnus: %%b"
1710 "The format specification for the category mode line.")
1712 (defvar gnus-agent-short-article 100
1713 "Articles that have fewer lines than this are short.")
1715 (defvar gnus-agent-long-article 200
1716 "Articles that have more lines than this are long.")
1718 (defvar gnus-agent-low-score 0
1719 "Articles that have a score lower than this have a low score.")
1721 (defvar gnus-agent-high-score 0
1722 "Articles that have a score higher than this have a high score.")
1725 ;;; Internal variables.
1727 (defvar gnus-category-buffer "*Agent Category*")
1729 (defvar gnus-category-line-format-alist
1730 `((?c gnus-tmp-name ?s)
1731 (?g gnus-tmp-groups ?d)))
1733 (defvar gnus-category-mode-line-format-alist
1734 `((?u user-defined ?s)))
1736 (defvar gnus-category-line-format-spec nil)
1737 (defvar gnus-category-mode-line-format-spec nil)
1739 (defvar gnus-category-mode-map nil)
1740 (put 'gnus-category-mode 'mode-class 'special)
1742 (unless gnus-category-mode-map
1743 (setq gnus-category-mode-map (make-sparse-keymap))
1744 (suppress-keymap gnus-category-mode-map)
1746 (gnus-define-keys gnus-category-mode-map
1747 "q" gnus-category-exit
1748 "k" gnus-category-kill
1749 "c" gnus-category-copy
1750 "a" gnus-category-add
1751 "p" gnus-category-edit-predicate
1752 "g" gnus-category-edit-groups
1753 "s" gnus-category-edit-score
1754 "l" gnus-category-list
1756 "\C-c\C-i" gnus-info-find-node
1757 "\C-c\C-b" gnus-bug))
1759 (defvar gnus-category-menu-hook nil
1760 "*Hook run after the creation of the menu.")
1762 (defun gnus-category-make-menu-bar ()
1763 (gnus-turn-off-edit-menu 'category)
1764 (unless (boundp 'gnus-category-menu)
1766 gnus-category-menu gnus-category-mode-map ""
1768 ["Add" gnus-category-add t]
1769 ["Kill" gnus-category-kill t]
1770 ["Copy" gnus-category-copy t]
1771 ["Edit predicate" gnus-category-edit-predicate t]
1772 ["Edit score" gnus-category-edit-score t]
1773 ["Edit groups" gnus-category-edit-groups t]
1774 ["Exit" gnus-category-exit t]))
1776 (gnus-run-hooks 'gnus-category-menu-hook)))
1778 (defun gnus-category-mode ()
1779 "Major mode for listing and editing agent categories.
1781 All normal editing commands are switched off.
1782 \\<gnus-category-mode-map>
1783 For more in-depth information on this mode, read the manual
1784 \(`\\[gnus-info-find-node]').
1786 The following commands are available:
1788 \\{gnus-category-mode-map}"
1790 (when (gnus-visual-p 'category-menu 'menu)
1791 (gnus-category-make-menu-bar))
1792 (kill-all-local-variables)
1793 (gnus-simplify-mode-line)
1794 (setq major-mode 'gnus-category-mode)
1795 (setq mode-name "Category")
1796 (gnus-set-default-directory)
1797 (setq mode-line-process nil)
1798 (use-local-map gnus-category-mode-map)
1799 (buffer-disable-undo)
1800 (setq truncate-lines t)
1801 (setq buffer-read-only t)
1802 (gnus-run-hooks 'gnus-category-mode-hook))
1804 (defalias 'gnus-category-position-point 'gnus-goto-colon)
1806 (defun gnus-category-insert-line (category)
1807 (let* ((gnus-tmp-name (format "%s" (car category)))
1808 (gnus-tmp-groups (length (cadddr category))))
1810 (gnus-add-text-properties
1814 (eval gnus-category-line-format-spec))
1815 (list 'gnus-category gnus-tmp-name))))
1817 (defun gnus-enter-category-buffer ()
1818 "Go to the Category buffer."
1820 (gnus-category-setup-buffer)
1821 (gnus-configure-windows 'category)
1822 (gnus-category-prepare))
1824 (defun gnus-category-setup-buffer ()
1825 (unless (get-buffer gnus-category-buffer)
1827 (set-buffer (gnus-get-buffer-create gnus-category-buffer))
1828 (gnus-category-mode))))
1830 (defun gnus-category-prepare ()
1831 (gnus-set-format 'category-mode)
1832 (gnus-set-format 'category t)
1833 (let ((alist gnus-category-alist)
1834 (buffer-read-only nil))
1837 (gnus-category-insert-line (pop alist)))
1838 (goto-char (point-min))
1839 (gnus-category-position-point)))
1841 (defun gnus-category-name ()
1842 (or (intern (get-text-property (gnus-point-at-bol) 'gnus-category))
1843 (error "No category on the current line")))
1845 (defun gnus-category-read ()
1846 "Read the category alist."
1847 (setq gnus-category-alist
1848 (or (gnus-agent-read-file
1849 (nnheader-concat gnus-agent-directory "lib/categories"))
1850 (list (list 'default 'short nil nil)))))
1852 (defun gnus-category-write ()
1853 "Write the category alist."
1854 (setq gnus-category-predicate-cache nil
1855 gnus-category-group-cache nil)
1856 (gnus-make-directory (nnheader-concat gnus-agent-directory "lib"))
1857 (with-temp-file (nnheader-concat gnus-agent-directory "lib/categories")
1858 (prin1 gnus-category-alist (current-buffer))))
1860 (defun gnus-category-edit-predicate (category)
1861 "Edit the predicate for CATEGORY."
1862 (interactive (list (gnus-category-name)))
1863 (let ((info (assq category gnus-category-alist)))
1865 (cadr info) (format "Editing the predicate for category %s" category)
1866 `(lambda (predicate)
1867 (setcar (cdr (assq ',category gnus-category-alist)) predicate)
1868 (gnus-category-write)
1869 (gnus-category-list)))))
1871 (defun gnus-category-edit-score (category)
1872 "Edit the score expression for CATEGORY."
1873 (interactive (list (gnus-category-name)))
1874 (let ((info (assq category gnus-category-alist)))
1877 (format "Editing the score expression for category %s" category)
1879 (setcar (cddr (assq ',category gnus-category-alist)) groups)
1880 (gnus-category-write)
1881 (gnus-category-list)))))
1883 (defun gnus-category-edit-groups (category)
1884 "Edit the group list for CATEGORY."
1885 (interactive (list (gnus-category-name)))
1886 (let ((info (assq category gnus-category-alist)))
1888 (cadddr info) (format "Editing the group list for category %s" category)
1890 (setcar (nthcdr 3 (assq ',category gnus-category-alist)) groups)
1891 (gnus-category-write)
1892 (gnus-category-list)))))
1894 (defun gnus-category-kill (category)
1895 "Kill the current category."
1896 (interactive (list (gnus-category-name)))
1897 (let ((info (assq category gnus-category-alist))
1898 (buffer-read-only nil))
1900 (setq gnus-category-alist (delq info gnus-category-alist))
1901 (gnus-category-write)))
1903 (defun gnus-category-copy (category to)
1904 "Copy the current category."
1905 (interactive (list (gnus-category-name) (intern (read-string "New name: "))))
1906 (let ((info (assq category gnus-category-alist)))
1907 (push (list to (gnus-copy-sequence (cadr info))
1908 (gnus-copy-sequence (caddr info)) nil)
1909 gnus-category-alist)
1910 (gnus-category-write)
1911 (gnus-category-list)))
1913 (defun gnus-category-add (category)
1914 "Create a new category."
1915 (interactive "SCategory name: ")
1916 (when (assq category gnus-category-alist)
1917 (error "Category %s already exists" category))
1918 (push (list category 'false nil nil)
1919 gnus-category-alist)
1920 (gnus-category-write)
1921 (gnus-category-list))
1923 (defun gnus-category-list ()
1924 "List all categories."
1926 (gnus-category-prepare))
1928 (defun gnus-category-exit ()
1929 "Return to the group buffer."
1931 (kill-buffer (current-buffer))
1932 (gnus-configure-windows 'group t))
1934 ;; To avoid having 8-bit characters in the source file.
1935 (defvar gnus-category-not (list '! 'not (intern (format "%c" 172))))
1937 (defvar gnus-category-predicate-alist
1938 '((spam . gnus-agent-spam-p)
1939 (short . gnus-agent-short-p)
1940 (long . gnus-agent-long-p)
1941 (low . gnus-agent-low-scored-p)
1942 (high . gnus-agent-high-scored-p)
1943 (read . gnus-agent-read-p)
1944 (true . gnus-agent-true)
1945 (false . gnus-agent-false))
1946 "Mapping from short score predicate symbols to predicate functions.")
1948 (defun gnus-agent-spam-p ()
1949 "Say whether an article is spam or not."
1950 (unless gnus-agent-spam-hashtb
1951 (setq gnus-agent-spam-hashtb (gnus-make-hashtable 1000)))
1952 (if (not (equal (mail-header-references gnus-headers) ""))
1954 (let ((string (gnus-simplify-subject (mail-header-subject gnus-headers))))
1956 (gnus-gethash string gnus-agent-spam-hashtb)
1957 (gnus-sethash string t gnus-agent-spam-hashtb)))))
1959 (defun gnus-agent-short-p ()
1960 "Say whether an article is short or not."
1961 (< (mail-header-lines gnus-headers) gnus-agent-short-article))
1963 (defun gnus-agent-long-p ()
1964 "Say whether an article is long or not."
1965 (> (mail-header-lines gnus-headers) gnus-agent-long-article))
1967 (defun gnus-agent-low-scored-p ()
1968 "Say whether an article has a low score or not."
1969 (< gnus-score gnus-agent-low-score))
1971 (defun gnus-agent-high-scored-p ()
1972 "Say whether an article has a high score or not."
1973 (> gnus-score gnus-agent-high-score))
1975 (defun gnus-agent-read-p ()
1976 "Say whether an article is read or not."
1977 (gnus-member-of-range (mail-header-number gnus-headers)
1978 (gnus-info-read (gnus-get-info gnus-newsgroup-name))))
1980 (defun gnus-category-make-function (cat)
1981 "Make a function from category CAT."
1982 (let ((func (gnus-category-make-function-1 cat)))
1983 (if (and (= (length func) 1)
1984 (symbolp (car func)))
1986 (gnus-byte-compile `(lambda () ,func)))))
1988 (defun gnus-agent-true ()
1992 (defun gnus-agent-false ()
1996 (defun gnus-category-make-function-1 (cat)
1997 "Make a function from category CAT."
1999 ;; Functions are just returned as is.
2001 (gnus-functionp cat))
2002 `(,(or (cdr (assq cat gnus-category-predicate-alist))
2004 ;; More complex category.
2007 ((memq (car cat) '(& and))
2009 ((memq (car cat) '(| or))
2011 ((memq (car cat) gnus-category-not)
2013 ,@(mapcar 'gnus-category-make-function-1 (cdr cat))))
2015 (error "Unknown category type: %s" cat))))
2017 (defun gnus-get-predicate (predicate)
2018 "Return the predicate for CATEGORY."
2019 (or (cdr (assoc predicate gnus-category-predicate-cache))
2020 (let ((func (gnus-category-make-function predicate)))
2021 (setq gnus-category-predicate-cache
2022 (nconc gnus-category-predicate-cache
2023 (list (cons predicate func))))
2026 (defun gnus-predicate-implies-unread (predicate)
2027 "Say whether PREDICATE implies unread articles only.
2028 It is okay to miss some cases, but there must be no false positives.
2029 That is, if this function returns true, then indeed the predicate must
2030 return only unread articles."
2031 ;; Todo: make this work in more cases.
2032 (equal predicate '(not read)))
2034 (defun gnus-group-category (group)
2035 "Return the category GROUP belongs to."
2036 (unless gnus-category-group-cache
2037 (setq gnus-category-group-cache (gnus-make-hashtable 1000))
2038 (let ((cs gnus-category-alist)
2040 (while (setq cat (pop cs))
2041 (setq groups (cadddr cat))
2043 (gnus-sethash (pop groups) cat gnus-category-group-cache)))))
2044 (or (gnus-gethash group gnus-category-group-cache)
2045 (assq 'default gnus-category-alist)))
2047 (defun gnus-agent-expire (&optional articles group force)
2048 "Expire all old articles.
2049 If you want to force expiring of certain articles, this function can
2050 take ARTICLES, GROUP and FORCE parameters as well.
2052 The articles on which the expiration process runs are selected as follows:
2053 if ARTICLES is null, all read and unmarked articles.
2054 if ARTICLES is t, all articles.
2055 if ARTICLES is a list, just those articles.
2056 Setting GROUP will limit expiration to that group.
2057 FORCE is equivalent to setting gnus-agent-expire-days to zero(0)."
2060 (if (or (not (eq articles t))
2061 (yes-or-no-p (concat "Are you sure that you want to expire all articles in " (if group group "every agentized group") ".")))
2062 (let ((methods (if group
2063 (list (gnus-find-method-for-group group))
2064 gnus-agent-covered-methods))
2065 (day (if (numberp gnus-agent-expire-days)
2066 (- (time-to-days (current-time)) gnus-agent-expire-days)
2068 gnus-command-method sym arts pos
2069 history overview file histories elem art nov-file low info
2070 unreads marked article orig lowest highest found days)
2072 (setq overview (gnus-get-buffer-create " *expire overview*"))
2074 (while (setq gnus-command-method (pop methods))
2075 (when (file-exists-p (gnus-agent-lib-file "active"))
2077 (nnheader-insert-file-contents (gnus-agent-lib-file "active"))
2078 (gnus-active-to-gnus-format
2080 (setq orig (gnus-make-hashtable
2081 (count-lines (point-min) (point-max))))))
2082 (dolist (expiring-group (gnus-groups-from-server gnus-command-method))
2084 (equal group expiring-group))
2086 (gnus-agent-directory)
2087 (gnus-agent-group-path expiring-group) "/"))
2089 (gnus-gethash-safe expiring-group orig))
2090 (day (if (numberp day)
2093 (days gnus-agent-expire-days))
2095 (while (and (not found)
2097 (when (eq 0 (string-match (caar days) expiring-group))
2098 (throw 'found (- (time-to-days (current-time)) (cadar days))))
2100 ;; No regexp matched so set a limit that will block expiration in this group
2104 (gnus-agent-load-alist expiring-group)
2105 (gnus-message 5 "Expiring articles in %s" expiring-group)
2106 (let* ((info (gnus-get-info expiring-group))
2107 (alist gnus-agent-article-alist)
2109 (list (caar (last alist)))))
2110 (unreads ;; Articles that are excluded from the expiration process
2111 (cond (gnus-agent-expire-all
2112 ;; All articles are marked read by global decree
2115 ;; All articles are marked read by function parameter
2118 ;; Unread articles are marked protected from expiration
2119 ;; Don't call gnus-list-of-unread-articles as it returns articles that have not been fetched into the agent.
2120 (ignore-errors (gnus-agent-unread-articles expiring-group)))
2122 ;; All articles EXCEPT those named by the caller are protected from expiration
2123 (gnus-sorted-difference (gnus-uncompress-range (cons (caar alist) (caar (last alist)))) (sort articles '<)))))
2124 (marked ;; More articles that are exluded from the expiration process
2125 (cond (gnus-agent-expire-all
2126 ;; All articles are unmarked by global decree
2129 ;; All articles are unmarked by function parameter
2132 ;; All articles may as well be unmarked as the unreads list already names the articles we are going to keep
2135 ;; Ticked and/or dormant articles are excluded from expiration
2137 (gnus-uncompress-range
2138 (cdr (assq 'tick (gnus-info-marks info))))
2139 (gnus-uncompress-range
2141 (gnus-info-marks info))))))))
2142 (nov-file (concat dir ".overview"))
2148 ;; The normal article alist contains elements that look like (article# . fetch_date)
2149 ;; I need to combine other information with this list. For example, a flag indicating that a particular article MUST BE KEPT.
2150 ;; To do this, I'm going to transform the elements to look like (article# fetch_date keep_flag NOV_entry_marker)
2151 ;; Later, I'll reverse the process to generate the expired article alist.
2153 ;; Convert the alist elements to (article# fetch_date nil nil).
2154 (setq dlist (mapcar (lambda (e) (list (car e) (cdr e) nil nil)) alist))
2156 ;; Convert the keep lists to elements that look like (article# nil keep_flag nil) then append it to the expanded dlist
2157 ;; These statements are sorted by ascending precidence of the keep_flag.
2158 (setq dlist (nconc dlist
2159 (mapcar (lambda (e) (list e nil 'unread nil)) unreads)))
2160 (setq dlist (nconc dlist
2161 (mapcar (lambda (e) (list e nil 'marked nil)) marked)))
2162 (setq dlist (nconc dlist
2163 (mapcar (lambda (e) (list e nil 'special nil)) specials)))
2165 (set-buffer overview)
2167 (when (file-exists-p nov-file)
2168 (gnus-message 7 "gnus-agent-expire: Loading overview...")
2169 (nnheader-insert-file-contents nov-file)
2170 (goto-char (point-min))
2173 (while (< (setq p (point)) (point-max))
2175 ;; If I successfully read an integer (the plus zero ensures a numeric type), prepend a marker entry to the list
2176 (push (list (+ 0 (read (current-buffer))) nil nil (set-marker (make-marker) p)) dlist)
2178 (gnus-message 1 "gnus-agent-expire: read error occurred when reading expression at %s in %s. Skipping to next line." (point) nov-file)))
2179 ;; Whether I succeeded, or failed, it doesn't matter. Move to the next line then try again.
2181 (gnus-message 7 "gnus-agent-expire: Loading overview... Done"))
2182 (set-buffer-modified-p nil)
2184 ;; At this point, all of the information is in dlist. The only problem is that much of it is spread across multiple entries. Sort then MERGE!!
2185 (gnus-message 7 "gnus-agent-expire: Sorting entries... ")
2186 (let ((special 0) ; If two entries have the same article-number then sort by ascending keep_flag.
2192 (cond ((< (nth 0 a) (nth 0 b))
2194 ((> (nth 0 a) (nth 0 b))
2197 (let ((a (or (symbol-value (nth 2 a)) 3))
2198 (b (or (symbol-value (nth 2 b)) 3)))
2200 (gnus-message 7 "gnus-agent-expire: Sorting entries... Done")
2201 (gnus-message 7 "gnus-agent-expire: Merging entries... ")
2202 (let ((dlist dlist))
2203 (while (cdr dlist) ; I'm not at the end-of-list
2204 (if (eq (caar dlist) (caadr dlist))
2205 (let ((first (cdr (car dlist)))
2206 (secnd (cdr (cadr dlist))))
2207 (setcar first (or (car first) (car secnd))) ; fetch_date
2208 (setq first (cdr first)
2210 (setcar first (or (car first) (car secnd))) ; Keep_flag
2211 (setq first (cdr first)
2213 (setcar first (or (car first) (car secnd))) ; NOV_entry_marker
2215 (setcdr dlist (cddr dlist)))
2216 (setq dlist (cdr dlist)))))
2217 (gnus-message 7 "gnus-agent-expire: Merging entries... Done")
2219 (let* ((len (float (length dlist)))
2223 (let ((new-completed (truncate (* 100.0 (/ (setq cnt (1+ cnt)) len)))))
2224 (when (> new-completed completed)
2225 (setq completed new-completed)
2226 (gnus-message 9 "%3d%% completed..." completed)))
2227 (let* ((entry (car dlist))
2228 (article-number (nth 0 entry))
2229 (fetch-date (nth 1 entry))
2230 (keep (nth 2 entry))
2231 (marker (nth 3 entry)))
2234 ;; Kept articles are unread, marked, or special.
2237 (unless (file-exists-p (concat dir (number-to-string article-number)))
2238 (setf (nth 1 entry) nil)
2239 (gnus-message 3 "gnus-agent-expire cleared download flag on article %d as the cached article file is missing." (caar dlist)))
2241 (gnus-message 1 "gnus-agent-expire detected a missing NOV entry. Run gnus-agent-regenerate-group to restore it.")))
2242 (gnus-agent-append-to-list tail-alist (cons article-number fetch-date)))
2244 ;; The following articles are READ, UNMARKED, and ORDINARY.
2245 ;; See if they can be EXPIRED!!!
2248 ((not (integerp fetch-date))
2249 'read) ;; never fetched article (may expire right now)
2250 ((not (file-exists-p (concat dir (number-to-string article-number))))
2251 (setf (nth 1 entry) nil)
2252 'externally-expired) ;; Can't find the cached article. Handle case as though this article was never fetched.
2254 ;; We now have the arrival day, so we see
2255 ;; whether it's old enough to be expired.
2261 ;; I found some reason to expire this entry.
2263 (let ((actions nil))
2264 (when (memq type '(forced expired))
2265 (ignore-errors ; Just being paranoid.
2266 (delete-file (concat dir (number-to-string article-number)))
2267 (push "expired cached article" actions))
2268 (setf (nth 1 entry) nil)
2272 (push "NOV entry removed" actions)
2276 ;; If considering all articles is set, I can only expire article IDs that are no longer in the active range.
2277 (if (and gnus-agent-consider-all-articles
2278 (>= article-number (car active)))
2279 ;; I have to keep this ID in the alist
2280 (gnus-agent-append-to-list tail-alist (cons article-number fetch-date))
2281 (push (format "Removed %s article number from article alist" type) actions))
2283 (gnus-message 7 "gnus-agent-expire: Article %d: %s" article-number (mapconcat 'identity actions ", "))))
2285 (gnus-agent-append-to-list tail-alist (cons article-number fetch-date)))
2288 ;; Clean up markers as I want to recycle this buffer over several groups.
2290 (set-marker marker nil))
2292 (setq dlist (cdr dlist))))
2294 (setq alist (cdr alist))
2296 (let ((inhibit-quit t))
2297 (unless (equal alist gnus-agent-article-alist)
2298 (setq gnus-agent-article-alist alist)
2299 (gnus-agent-save-alist expiring-group))
2301 (when (buffer-modified-p)
2302 (let ((coding-system-for-write
2303 gnus-agent-file-coding-system))
2304 (gnus-make-directory dir)
2305 (write-region (point-min) (point-max) nov-file nil 'silent)
2306 ;; clear the modified flag as that I'm not confused by its status on the next pass through this routine.
2307 (set-buffer-modified-p nil)))
2309 (when (eq articles t)
2310 (gnus-summary-update-info)))))))))))
2311 (kill-buffer overview)))))
2312 (gnus-message 4 "Expiry...done"))
2315 (defun gnus-agent-batch ()
2316 "Start Gnus, send queue and fetch session."
2318 (let ((init-file-user "")
2319 (gnus-always-read-dribble-file t))
2321 (let ((gnus-agent-confirmation-function 'gnus-agent-batch-confirmation))
2322 (gnus-group-send-queue)
2323 (gnus-agent-fetch-session)))
2325 (defun gnus-agent-unread-articles (group)
2326 (let* ((read (gnus-info-read (gnus-get-info group)))
2327 (known (gnus-agent-load-alist group))
2329 (tail-unread unread))
2330 (while (and known read)
2331 (let ((candidate (car (pop known))))
2332 (while (let* ((range (car read))
2333 (min (if (numberp range) range (car range)))
2334 (max (if (numberp range) range (cdr range))))
2335 (cond ((or (not min)
2337 (gnus-agent-append-to-list tail-unread candidate)
2342 (gnus-agent-append-to-list tail-unread (car (pop known))))
2345 (defun gnus-agent-uncached-articles (articles group &optional cached-header)
2346 "Constructs sublist of ARTICLES that excludes those articles ids in GROUP that have already been fetched.
2347 If CACHED-HEADER is nil, articles are only excluded if the article itself has been fetched."
2349 ;; Logically equivalent to: (gnus-sorted-difference articles (mapcar 'car gnus-agent-article-alist))
2350 ;; Functionally, I don't need to construct a temp list using mapcar.
2352 (if (gnus-agent-load-alist group)
2353 (let* ((ref gnus-agent-article-alist)
2355 (uncached (list nil))
2356 (tail-uncached uncached))
2357 (while (and ref arts)
2358 (let ((v1 (car arts))
2360 (cond ((< v1 v2) ; the article (v1) does not appear in the reference list
2361 (gnus-agent-append-to-list tail-uncached v1)
2364 (unless (or cached-header (cdar ref)) ; the article (v1) is already cached
2365 (gnus-agent-append-to-list tail-uncached v1))
2368 (t ; the reference article (v2) preceeds the list being filtered
2371 (gnus-agent-append-to-list tail-uncached (pop arts)))
2373 ;; if gnus-agent-load-alist fails, no articles are cached.
2376 (defun gnus-agent-retrieve-headers (articles group &optional fetch-old)
2378 (gnus-agent-create-buffer)
2379 (let ((gnus-decode-encoded-word-function 'identity)
2380 (file (gnus-agent-article-name ".overview" group))
2381 cached-articles uncached-articles)
2382 (gnus-make-directory (nnheader-translate-file-chars
2383 (file-name-directory file) t))
2385 ;; Populate temp buffer with known headers
2386 (when (file-exists-p file)
2387 (with-current-buffer gnus-agent-overview-buffer
2389 (let ((nnheader-file-coding-system
2390 gnus-agent-file-coding-system))
2391 (nnheader-insert-nov-file file (car articles)))))
2393 (if (setq uncached-articles (gnus-agent-uncached-articles articles group t))
2395 ;; Populate nntp-server-buffer with uncached headers
2396 (set-buffer nntp-server-buffer)
2398 (let (gnus-agent-cache) ; Turn off agent cache
2399 (cond ((not (eq 'nov (gnus-retrieve-headers
2400 uncached-articles group fetch-old)))
2401 (nnvirtual-convert-headers))
2402 ((eq 'nntp (car gnus-current-select-method))
2403 ;; The author of gnus-get-newsgroup-headers-xover reports that the XOVER command
2404 ;; is commonly unreliable. The problem is that recently posted articles may not
2405 ;; be entered into the NOV database in time to respond to my XOVER query.
2407 ;; I'm going to use his assumption that the NOV database is updated in order
2408 ;; of ascending article ID. Therefore, a response containing article ID N
2409 ;; implies that all articles from 1 to N-1 are up-to-date. Therefore,
2410 ;; missing articles in that range have expired.
2412 (set-buffer nntp-server-buffer)
2413 (let* ((fetched-articles (list nil))
2414 (tail-fetched-articles fetched-articles)
2415 (min (cond ((numberp fetch-old)
2416 (max 1 (- (car articles) fetch-old)))
2421 (max (car (last articles))))
2423 ;; Get the list of articles that were fetched
2424 (goto-char (point-min))
2425 (let ((pm (point-max)))
2426 (while (< (point) pm)
2427 (when (looking-at "[0-9]+\t")
2428 (gnus-agent-append-to-list tail-fetched-articles (read (current-buffer))))
2431 ;; Clip this list to the headers that will actually be returned
2432 (setq fetched-articles (gnus-list-range-intersection
2433 (cdr fetched-articles)
2436 ;; Clip the uncached articles list to exclude IDs after the last FETCHED header.
2437 ;; The excluded IDs may be fetchable using HEAD.
2438 (if (car tail-fetched-articles)
2439 (setq uncached-articles (gnus-list-range-intersection
2441 (cons (car uncached-articles) (car tail-fetched-articles)))))
2443 ;; Create the list of articles that were "successfully" fetched. Success, in
2444 ;; this case, means that the ID should not be fetched again. In the case of
2445 ;; an expired article, the header will not be fetched.
2446 (setq uncached-articles (gnus-sorted-nunion fetched-articles uncached-articles))
2449 ;; Erase the temp buffer
2450 (set-buffer gnus-agent-overview-buffer)
2453 ;; Copy the nntp-server-buffer to the temp buffer
2454 (set-buffer nntp-server-buffer)
2455 (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
2457 ;; Merge the temp buffer with the known headers (found on disk in FILE) into the nntp-server-buffer
2458 (when (and uncached-articles (file-exists-p file))
2459 (gnus-agent-braid-nov group uncached-articles file))
2461 ;; Save the new set of known headers to FILE
2462 (set-buffer nntp-server-buffer)
2463 (let ((coding-system-for-write
2464 gnus-agent-file-coding-system))
2465 (gnus-agent-check-overview-buffer)
2466 (write-region (point-min) (point-max) file nil 'silent))
2468 ;; Update the group's article alist to include the newly fetched articles.
2469 (gnus-agent-load-alist group)
2470 (gnus-agent-save-alist group uncached-articles nil)
2473 ;; Copy the temp buffer to the nntp-server-buffer
2474 (set-buffer nntp-server-buffer)
2476 (insert-buffer-substring gnus-agent-overview-buffer)))
2479 (not (numberp fetch-old)))
2480 t ; Don't remove anything.
2481 (nnheader-nov-delete-outside-range
2482 (if fetch-old (max 1 (- (car articles) fetch-old))
2484 (car (last articles)))
2489 (defun gnus-agent-request-article (article group)
2490 "Retrieve ARTICLE in GROUP from the agent cache."
2491 (let* ((gnus-command-method (gnus-find-method-for-group group))
2493 (gnus-agent-directory)
2494 (gnus-agent-group-path group) "/"
2495 (number-to-string article)))
2496 (buffer-read-only nil))
2497 (when (and (file-exists-p file)
2498 (> (nth 7 (file-attributes file)) 0))
2500 (gnus-kill-all-overlays)
2501 (let ((coding-system-for-read gnus-cache-coding-system))
2502 (insert-file-contents file))
2505 (defun gnus-agent-regenerate-group (group &optional reread)
2506 "Regenerate GROUP. If REREAD is t, all articles in the .overview are marked as unread. If REREAD is not nil, downloaded articles are marked as unread."
2507 (interactive (list (let ((def (or (gnus-group-group-name)
2508 gnus-newsgroup-name)))
2509 (let ((select (read-string (if def (concat "Group Name (" def "): ")
2511 (if (and (equal "" select)
2515 (intern-soft (read-string "Reread (nil)? (t=>all, nil=>none, some=>all downloaded): "))))
2516 (gnus-message 5 "Regenerating in %s" group)
2517 (let* ((gnus-command-method (or gnus-command-method
2518 (gnus-find-method-for-group group)))
2519 (file (gnus-agent-article-name ".overview" group))
2520 (dir (file-name-directory file))
2522 (downloaded (if (file-exists-p dir)
2523 (sort (mapcar (lambda (name) (string-to-int name))
2524 (directory-files dir nil "^[0-9]+$" t))
2526 (progn (gnus-make-directory dir) nil)))
2531 (mm-with-unibyte-buffer
2532 (if (file-exists-p file)
2533 (let ((nnheader-file-coding-system
2534 gnus-agent-file-coding-system))
2535 (nnheader-insert-file-contents file)))
2536 (set-buffer-modified-p nil)
2538 ;; Load the article IDs found in the overview file. As a side-effect, validate the file contents.
2542 (goto-char (point-min))
2543 (while (< (point) (point-max))
2544 (cond ((looking-at "[0-9]+\t")
2545 (push (read (current-buffer)) nov-arts)
2547 (let ((l1 (car nov-arts))
2548 (l2 (cadr nov-arts)))
2552 (gnus-message 3 "gnus-agent-regenerate-group: NOV entries are NOT in ascending order.")
2553 ;; Don't sort now as I haven't verified that every line begins with a number
2557 (gnus-message 4 "gnus-agent-regenerate-group: NOV entries contained duplicate of article %s. Duplicate deleted." l1)
2561 (gnus-message 1 "gnus-agent-regenerate-group: NOV entries contained line that did not begin with an article number. Deleted line.")
2562 (gnus-delete-line))))
2565 (gnus-message 5 "gnus-agent-regenerate-group: Sorting NOV entries into ascending order.")
2566 (sort-numeric-fields 1 (point-min) (point-max))
2567 (setq nov-arts nil)))))
2568 (gnus-agent-check-overview-buffer)
2570 ;; Construct a new article alist whose nodes match every header in the .overview file.
2571 ;; As a side-effect, missing headers are reconstructed from the downloaded article file.
2572 (while (or downloaded nov-arts)
2573 (cond ((and downloaded
2575 (> (car downloaded) (car nov-arts))))
2576 ;; This entry is missing from the overview file
2577 (gnus-message 3 "Regenerating NOV %s %d..." group (car downloaded))
2578 (let ((file (concat dir (number-to-string (car downloaded)))))
2579 (mm-with-unibyte-buffer
2580 (nnheader-insert-file-contents file)
2581 (nnheader-remove-body)
2582 (setq header (nnheader-parse-naked-head)))
2583 (mail-header-set-number header (car downloaded))
2585 (let ((key (concat "^" (int-to-string (car nov-arts)) "\t")))
2586 (or (re-search-backward key nil t)
2587 (re-search-forward key))
2589 (goto-char (point-min)))
2590 (nnheader-insert-nov header))
2591 (setq nov-arts (cons (car downloaded) nov-arts)))
2592 ((eq (car downloaded) (car nov-arts))
2593 ;; This entry in the overview has been downloaded
2594 (push (cons (car downloaded) (time-to-days (nth 5 (file-attributes (concat dir (number-to-string (car downloaded))))))) alist)
2598 ;; This entry in the overview has not been downloaded
2599 (push (cons (car nov-arts) nil) alist)
2602 ;; When gnus-agent-consider-all-articles is set, gnus-agent-regenerate-group should NOT remove article IDs
2603 ;; from the alist. Those IDs serve as markers to indicate that an attempt has been made to fetch that
2604 ;; article's header.
2606 ;; When gnus-agent-consider-all-articles is NOT set, gnus-agent-regenerate-group can remove the article
2607 ;; ID of every article (with the exception of the last ID in the list - it's special) that no longer appears in the overview.
2608 ;; In this situtation, the last article ID in the list implies that it, and every article ID preceeding it,
2609 ;; have been fetched from the server.
2610 (if gnus-agent-consider-all-articles
2611 ;; Restore all article IDs that were not found in the overview file.
2612 (let* ((n (cons nil alist))
2614 (o (gnus-agent-load-alist group)))
2616 (let ((nID (caadr n))
2619 (setq n (setcdr n (list (list oID))))
2622 (setcdr n (cons (list oID) (cdr n)))
2629 (setq alist (cdr merged)))
2630 ;; Restore the last article ID if it is not already in the new alist
2631 (let ((n (last alist))
2632 (o (last (gnus-agent-load-alist group))))
2635 (push (cons (caar o) nil) alist)))
2636 ((< (caar n) (caar o))
2637 (setcdr n (list (car o)))))))
2639 (let ((inhibit-quit t))
2640 (if (setq regenerated (buffer-modified-p))
2641 (let ((coding-system-for-write gnus-agent-file-coding-system))
2642 (write-region (point-min) (point-max) file nil 'silent)))
2644 (setq regenerated (or regenerated
2645 (and reread gnus-agent-article-alist)
2646 (not (equal alist gnus-agent-article-alist)))
2649 (setq gnus-agent-article-alist alist)
2652 (gnus-agent-save-alist group)))
2655 (when (and reread gnus-agent-article-alist)
2656 (gnus-make-ascending-articles-unread
2658 (delq nil (mapcar (function (lambda (c)
2659 (cond ((eq reread t)
2663 gnus-agent-article-alist)))
2665 (when (gnus-buffer-live-p gnus-group-buffer)
2666 (gnus-group-update-group group t)
2673 (defun gnus-agent-regenerate (&optional clean reread)
2674 "Regenerate all agent covered files.
2675 If CLEAN, don't read existing active files."
2678 (gnus-message 4 "Regenerating Gnus agent files...")
2679 (dolist (gnus-command-method gnus-agent-covered-methods)
2680 (let ((active-file (gnus-agent-lib-file "active"))
2681 active-hashtb active-changed
2683 (gnus-make-directory (file-name-directory active-file))
2685 (setq active-hashtb (gnus-make-hashtable 1000))
2686 (mm-with-unibyte-buffer
2687 (if (file-exists-p active-file)
2688 (let ((nnheader-file-coding-system
2689 gnus-agent-file-coding-system))
2690 (nnheader-insert-file-contents active-file))
2691 (setq active-changed t))
2692 (gnus-active-to-gnus-format
2693 nil (setq active-hashtb
2694 (gnus-make-hashtable
2695 (count-lines (point-min) (point-max)))))))
2696 (dolist (group (gnus-groups-from-server gnus-command-method))
2697 (setq regenerated (or (gnus-agent-regenerate-group group reread)
2699 (let ((min (or (caar gnus-agent-article-alist) 1))
2700 (max (or (caar (last gnus-agent-article-alist)) 0))
2701 (active (gnus-gethash-safe (gnus-group-real-name group)
2703 (read (gnus-info-read (gnus-get-info group))))
2706 (setq active (cons min max)
2708 (gnus-sethash group active active-hashtb))
2709 (when (> (car active) min)
2711 (setq active-changed t))
2712 (when (< (cdr active) max)
2714 (setq active-changed t)))))
2715 (when active-changed
2716 (setq regenerated t)
2717 (gnus-message 4 "Regenerate %s" active-file)
2718 (let ((nnmail-active-file-coding-system gnus-agent-file-coding-system))
2719 (gnus-write-active-file active-file active-hashtb)))))
2720 (gnus-message 4 "Regenerating Gnus agent files...done")
2723 (defun gnus-agent-go-online (&optional force)
2724 "Switch servers into online status."
2725 (interactive (list t))
2726 (dolist (server gnus-opened-servers)
2727 (when (eq (nth 1 server) 'offline)
2728 (if (if (eq force 'ask)
2730 (format "Switch %s:%s into online status? "
2731 (caar server) (cadar server)))
2733 (setcar (nthcdr 1 server) 'close)))))
2735 (defun gnus-agent-toggle-group-plugged (group)
2736 "Toggle the status of the server of the current group."
2737 (interactive (list (gnus-group-group-name)))
2738 (let* ((method (gnus-find-method-for-group group))
2739 (status (cadr (assoc method gnus-opened-servers))))
2740 (if (eq status 'offline)
2741 (gnus-server-set-status method 'closed)
2742 (gnus-close-server method)
2743 (gnus-server-set-status method 'offline))
2744 (message "Turn %s:%s from %s to %s." (car method) (cadr method)
2745 (if (eq status 'offline) 'offline 'online)
2746 (if (eq status 'offline) 'online 'offline))))
2748 (defun gnus-agent-group-covered-p (group)
2749 (member (gnus-group-method group)
2750 gnus-agent-covered-methods))
2752 (provide 'gnus-agent)
2754 ;;; gnus-agent.el ends here