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-fetched-hook nil
58 "Hook run after finishing fetching articles."
62 (defcustom gnus-agent-handle-level gnus-level-subscribed
63 "Groups on levels higher than this variable will be ignored by the Agent."
67 (defcustom gnus-agent-expire-days 7
68 "Read articles older than this will be expired.
69 This can also be a list of regexp/day pairs. The regexps will
70 be matched against group names."
74 (defcustom gnus-agent-expire-all nil
75 "If non-nil, also expire unread, ticked and dormant articles.
76 If nil, only read articles will be expired."
80 (defcustom gnus-agent-group-mode-hook nil
81 "Hook run in Agent group minor modes."
85 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
86 (when (featurep 'xemacs)
87 (add-hook 'gnus-agent-group-mode-hook 'gnus-xmas-agent-group-menu-add))
89 (defcustom gnus-agent-summary-mode-hook nil
90 "Hook run in Agent summary minor modes."
94 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
95 (when (featurep 'xemacs)
96 (add-hook 'gnus-agent-summary-mode-hook 'gnus-xmas-agent-summary-menu-add))
98 (defcustom gnus-agent-server-mode-hook nil
99 "Hook run in Agent summary minor modes."
103 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
104 (when (featurep 'xemacs)
105 (add-hook 'gnus-agent-server-mode-hook 'gnus-xmas-agent-server-menu-add))
107 (defcustom gnus-agent-confirmation-function 'y-or-n-p
108 "Function to confirm when error happens."
113 (defcustom gnus-agent-synchronize-flags 'ask
114 "Indicate if flags are synchronized when you plug in.
115 If this is `ask' the hook will query the user."
117 :type '(choice (const :tag "Always" t)
118 (const :tag "Never" nil)
119 (const :tag "Ask" ask))
122 (defcustom gnus-agent-go-online 'ask
123 "Indicate if offline servers go online when you plug in.
124 If this is `ask' the hook will query the user."
126 :type '(choice (const :tag "Always" t)
127 (const :tag "Never" nil)
128 (const :tag "Ask" ask))
131 ;;; Internal variables
133 (defvar gnus-agent-history-buffers nil)
134 (defvar gnus-agent-buffer-alist nil)
135 (defvar gnus-agent-article-alist nil)
136 (defvar gnus-agent-group-alist nil)
137 (defvar gnus-category-alist nil)
138 (defvar gnus-agent-current-history nil)
139 (defvar gnus-agent-overview-buffer nil)
140 (defvar gnus-category-predicate-cache nil)
141 (defvar gnus-category-group-cache nil)
142 (defvar gnus-agent-spam-hashtb nil)
143 (defvar gnus-agent-file-name nil)
144 (defvar gnus-agent-send-mail-function nil)
145 (defvar gnus-agent-file-coding-system 'raw-text)
148 (defvar gnus-headers)
155 (defun gnus-open-agent ()
157 (gnus-agent-read-servers)
159 (gnus-agent-create-buffer)
160 (add-hook 'gnus-group-mode-hook 'gnus-agent-mode)
161 (add-hook 'gnus-summary-mode-hook 'gnus-agent-mode)
162 (add-hook 'gnus-server-mode-hook 'gnus-agent-mode))
164 (defun gnus-agent-create-buffer ()
165 (if (gnus-buffer-live-p gnus-agent-overview-buffer)
167 (setq gnus-agent-overview-buffer
168 (gnus-get-buffer-create " *Gnus agent overview*"))
169 (with-current-buffer gnus-agent-overview-buffer
170 (mm-enable-multibyte))
173 (gnus-add-shutdown 'gnus-close-agent 'gnus)
175 (defun gnus-close-agent ()
176 (setq gnus-agent-covered-methods nil
177 gnus-category-predicate-cache nil
178 gnus-category-group-cache nil
179 gnus-agent-spam-hashtb nil)
180 (gnus-kill-buffer gnus-agent-overview-buffer))
183 ;;; Utility functions
186 (defun gnus-agent-read-file (file)
187 "Load FILE and do a `read' there."
190 (nnheader-insert-file-contents file)
191 (goto-char (point-min))
192 (read (current-buffer)))))
194 (defsubst gnus-agent-method ()
195 (concat (symbol-name (car gnus-command-method)) "/"
196 (if (equal (cadr gnus-command-method) "")
198 (cadr gnus-command-method))))
200 (defsubst gnus-agent-directory ()
201 "Path of the Gnus agent directory."
202 (nnheader-concat gnus-agent-directory
203 (nnheader-translate-file-chars (gnus-agent-method)) "/"))
205 (defun gnus-agent-lib-file (file)
206 "The full path of the Gnus agent library FILE."
207 (expand-file-name file
208 (file-name-as-directory
209 (expand-file-name "agent.lib" (gnus-agent-directory)))))
211 ;;; Fetching setup functions.
213 (defun gnus-agent-start-fetch ()
214 "Initialize data structures for efficient fetching."
215 (gnus-agent-open-history)
216 (setq gnus-agent-current-history (gnus-agent-history-buffer))
217 (gnus-agent-create-buffer))
219 (defun gnus-agent-stop-fetch ()
220 "Save all data structures and clean up."
221 (gnus-agent-save-history)
222 (gnus-agent-close-history)
223 (setq gnus-agent-spam-hashtb nil)
225 (set-buffer nntp-server-buffer)
228 (defmacro gnus-agent-with-fetch (&rest forms)
231 (let ((gnus-agent-fetching t))
232 (gnus-agent-start-fetch)
234 (gnus-agent-stop-fetch)))
236 (put 'gnus-agent-with-fetch 'lisp-indent-function 0)
237 (put 'gnus-agent-with-fetch 'edebug-form-spec '(body))
243 (defvar gnus-agent-mode-hook nil
244 "Hook run when installing agent mode.")
246 (defvar gnus-agent-mode nil)
247 (defvar gnus-agent-mode-status '(gnus-agent-mode " Plugged"))
249 (defun gnus-agent-mode ()
250 "Minor mode for providing a agent support in Gnus buffers."
251 (let* ((buffer (progn (string-match "^gnus-\\(.*\\)-mode$"
252 (symbol-name major-mode))
253 (match-string 1 (symbol-name major-mode))))
254 (mode (intern (format "gnus-agent-%s-mode" buffer))))
255 (set (make-local-variable 'gnus-agent-mode) t)
257 (set (make-local-variable mode) t)
259 (when (gnus-visual-p 'agent-menu 'menu)
260 (funcall (intern (format "gnus-agent-%s-make-menu-bar" buffer))))
261 (unless (assq 'gnus-agent-mode minor-mode-alist)
262 (push gnus-agent-mode-status minor-mode-alist))
263 (unless (assq mode minor-mode-map-alist)
264 (push (cons mode (symbol-value (intern (format "gnus-agent-%s-mode-map"
266 minor-mode-map-alist))
267 (when (eq major-mode 'gnus-group-mode)
268 (gnus-agent-toggle-plugged gnus-plugged))
269 (gnus-run-hooks 'gnus-agent-mode-hook
270 (intern (format "gnus-agent-%s-mode-hook" buffer)))))
272 (defvar gnus-agent-group-mode-map (make-sparse-keymap))
273 (gnus-define-keys gnus-agent-group-mode-map
274 "Ju" gnus-agent-fetch-groups
275 "Jc" gnus-enter-category-buffer
276 "Jj" gnus-agent-toggle-plugged
277 "Js" gnus-agent-fetch-session
278 "JY" gnus-agent-synchronize-flags
279 "JS" gnus-group-send-queue
280 "Ja" gnus-agent-add-group
281 "Jr" gnus-agent-remove-group
282 "Jo" gnus-agent-toggle-group-plugged)
284 (defun gnus-agent-group-make-menu-bar ()
285 (unless (boundp 'gnus-agent-group-menu)
287 gnus-agent-group-menu gnus-agent-group-mode-map ""
289 ["Toggle plugged" gnus-agent-toggle-plugged t]
290 ["Toggle group plugged" gnus-agent-toggle-group-plugged t]
291 ["List categories" gnus-enter-category-buffer t]
292 ["Send queue" gnus-group-send-queue gnus-plugged]
294 ["All" gnus-agent-fetch-session gnus-plugged]
295 ["Group" gnus-agent-fetch-group gnus-plugged])))))
297 (defvar gnus-agent-summary-mode-map (make-sparse-keymap))
298 (gnus-define-keys gnus-agent-summary-mode-map
299 "Jj" gnus-agent-toggle-plugged
300 "Ju" gnus-agent-summary-fetch-group
301 "J#" gnus-agent-mark-article
302 "J\M-#" gnus-agent-unmark-article
303 "@" gnus-agent-toggle-mark
304 "Jc" gnus-agent-catchup)
306 (defun gnus-agent-summary-make-menu-bar ()
307 (unless (boundp 'gnus-agent-summary-menu)
309 gnus-agent-summary-menu gnus-agent-summary-mode-map ""
311 ["Toggle plugged" gnus-agent-toggle-plugged t]
312 ["Mark as downloadable" gnus-agent-mark-article t]
313 ["Unmark as downloadable" gnus-agent-unmark-article t]
314 ["Toggle mark" gnus-agent-toggle-mark t]
315 ["Fetch downloadable" gnus-aget-summary-fetch-group t]
316 ["Catchup undownloaded" gnus-agent-catchup t]))))
318 (defvar gnus-agent-server-mode-map (make-sparse-keymap))
319 (gnus-define-keys gnus-agent-server-mode-map
320 "Jj" gnus-agent-toggle-plugged
321 "Ja" gnus-agent-add-server
322 "Jr" gnus-agent-remove-server)
324 (defun gnus-agent-server-make-menu-bar ()
325 (unless (boundp 'gnus-agent-server-menu)
327 gnus-agent-server-menu gnus-agent-server-mode-map ""
329 ["Toggle plugged" gnus-agent-toggle-plugged t]
330 ["Add" gnus-agent-add-server t]
331 ["Remove" gnus-agent-remove-server t]))))
333 (defun gnus-agent-make-mode-line-string (string mouse-button mouse-func)
334 (if (and (fboundp 'propertize)
335 (fboundp 'make-mode-line-mouse-map))
336 (propertize string 'local-map
337 (make-mode-line-mouse-map mouse-button mouse-func))
340 (defun gnus-agent-toggle-plugged (plugged)
341 "Toggle whether Gnus is unplugged or not."
342 (interactive (list (not gnus-plugged)))
345 (setq gnus-plugged plugged)
346 (gnus-run-hooks 'gnus-agent-plugged-hook)
347 (setcar (cdr gnus-agent-mode-status)
348 (gnus-agent-make-mode-line-string " Plugged"
350 'gnus-agent-toggle-plugged))
351 (gnus-agent-go-online gnus-agent-go-online)
352 (gnus-agent-possibly-synchronize-flags))
353 (gnus-agent-close-connections)
354 (setq gnus-plugged plugged)
355 (gnus-run-hooks 'gnus-agent-unplugged-hook)
356 (setcar (cdr gnus-agent-mode-status)
357 (gnus-agent-make-mode-line-string " Unplugged"
359 'gnus-agent-toggle-plugged)))
360 (set-buffer-modified-p t))
362 (defun gnus-agent-close-connections ()
363 "Close all methods covered by the Gnus agent."
364 (let ((methods gnus-agent-covered-methods))
366 (gnus-close-server (pop methods)))))
369 (defun gnus-unplugged ()
370 "Start Gnus unplugged."
372 (setq gnus-plugged nil)
376 (defun gnus-plugged ()
377 "Start Gnus plugged."
379 (setq gnus-plugged t)
383 (defun gnus-agentize ()
384 "Allow Gnus to be an offline newsreader.
385 The normal usage of this command is to put the following as the
386 last form in your `.gnus.el' file:
390 This will modify the `gnus-setup-news-hook', and
391 `message-send-mail-real-function' variables, and install the Gnus agent
392 minor mode in all Gnus buffers."
395 (add-hook 'gnus-setup-news-hook 'gnus-agent-queue-setup)
396 (unless gnus-agent-send-mail-function
397 (setq gnus-agent-send-mail-function (or
398 message-send-mail-real-function
399 message-send-mail-function)
400 message-send-mail-real-function 'gnus-agent-send-mail))
401 (unless gnus-agent-covered-methods
402 (setq gnus-agent-covered-methods (list gnus-select-method))))
404 (defun gnus-agent-queue-setup ()
405 "Make sure the queue group exists."
406 (unless (gnus-gethash "nndraft:queue" gnus-newsrc-hashtb)
407 (gnus-request-create-group "queue" '(nndraft ""))
408 (let ((gnus-level-default-subscribed 1))
409 (gnus-subscribe-group "nndraft:queue" nil '(nndraft "")))
410 (gnus-group-set-parameter
411 "nndraft:queue" 'gnus-dummy '((gnus-draft-mode)))))
413 (defun gnus-agent-send-mail ()
415 (funcall gnus-agent-send-mail-function)
416 (goto-char (point-min))
418 (concat "^" (regexp-quote mail-header-separator) "\n"))
420 (gnus-agent-insert-meta-information 'mail)
421 (gnus-request-accept-article "nndraft:queue" nil t t)))
423 (defun gnus-agent-insert-meta-information (type &optional method)
424 "Insert meta-information into the message that says how it's to be posted.
425 TYPE can be either `mail' or `news'. If the latter, then METHOD can
428 (message-remove-header gnus-agent-meta-information-header)
429 (goto-char (point-min))
430 (insert gnus-agent-meta-information-header ": "
431 (symbol-name type) " " (format "%S" method)
434 (while (search-backward "\n" nil t)
435 (replace-match "\\n" t t))))
437 (defun gnus-agent-restore-gcc ()
438 "Restore GCC field from saved header."
440 (goto-char (point-min))
441 (while (re-search-forward (concat gnus-agent-gcc-header ":") nil t)
442 (replace-match "Gcc:" 'fixedcase))))
444 (defun gnus-agent-any-covered-gcc ()
446 (message-narrow-to-headers)
447 (let* ((gcc (mail-fetch-field "gcc" nil t))
449 (mapcar 'gnus-inews-group-method
450 (message-unquote-tokens
451 (message-tokenize-header
454 (while (and (not covered) methods)
455 (setq covered (gnus-agent-method-p (car methods))
456 methods (cdr methods)))
459 (defun gnus-agent-possibly-save-gcc ()
460 "Save GCC if Gnus is unplugged."
461 (when (and (not gnus-plugged) (gnus-agent-any-covered-gcc))
463 (goto-char (point-min))
464 (let ((case-fold-search t))
465 (while (re-search-forward "^gcc:" nil t)
466 (replace-match (concat gnus-agent-gcc-header ":") 'fixedcase))))))
468 (defun gnus-agent-possibly-do-gcc ()
469 "Do GCC if Gnus is plugged."
470 (when (or gnus-plugged (not (gnus-agent-any-covered-gcc)))
471 (gnus-inews-do-gcc)))
474 ;;; Group mode commands
477 (defun gnus-agent-fetch-groups (n)
478 "Put all new articles in the current groups into the Agent."
481 (error "Groups can't be fetched when Gnus is unplugged"))
482 (gnus-group-iterate n 'gnus-agent-fetch-group))
484 (defun gnus-agent-fetch-group (group)
485 "Put all new articles in GROUP into the Agent."
486 (interactive (list (gnus-group-group-name)))
487 (let ((state gnus-plugged))
491 (error "No group on the current line"))
493 (gnus-agent-toggle-plugged gnus-plugged))
494 (let ((gnus-command-method (gnus-find-method-for-group group)))
495 (gnus-agent-with-fetch
496 (gnus-agent-fetch-group-1 group gnus-command-method)
497 (gnus-message 5 "Fetching %s...done" group))))
498 (when (and (not state)
500 (gnus-agent-toggle-plugged gnus-plugged)))))
502 (defun gnus-agent-add-group (category arg)
503 "Add the current group to an agent category."
509 (mapcar (lambda (cat) (list (symbol-name (car cat))))
513 (let ((cat (assq category gnus-category-alist))
515 (gnus-group-iterate arg
517 (when (cadddr (setq c (gnus-group-category group)))
518 (setf (cadddr c) (delete group (cadddr c))))
519 (push group groups)))
520 (setf (cadddr cat) (nconc (cadddr cat) groups))
521 (gnus-category-write)))
523 (defun gnus-agent-remove-group (arg)
524 "Remove the current group from its agent category, if any."
527 (gnus-group-iterate arg
529 (when (cadddr (setq c (gnus-group-category group)))
530 (setf (cadddr c) (delete group (cadddr c))))))
531 (gnus-category-write)))
533 (defun gnus-agent-synchronize-flags ()
534 "Synchronize unplugged flags with servers."
537 (dolist (gnus-command-method gnus-agent-covered-methods)
538 (when (file-exists-p (gnus-agent-lib-file "flags"))
539 (gnus-agent-synchronize-flags-server gnus-command-method)))))
541 (defun gnus-agent-possibly-synchronize-flags ()
542 "Synchronize flags according to `gnus-agent-synchronize-flags'."
545 (dolist (gnus-command-method gnus-agent-covered-methods)
546 (when (file-exists-p (gnus-agent-lib-file "flags"))
547 (gnus-agent-possibly-synchronize-flags-server gnus-command-method)))))
549 (defun gnus-agent-synchronize-flags-server (method)
550 "Synchronize flags set when unplugged for server."
551 (let ((gnus-command-method method))
552 (when (file-exists-p (gnus-agent-lib-file "flags"))
553 (set-buffer (get-buffer-create " *Gnus Agent flag synchronize*"))
555 (nnheader-insert-file-contents (gnus-agent-lib-file "flags"))
556 (if (null (gnus-check-server gnus-command-method))
557 (message "Couldn't open server %s" (nth 1 gnus-command-method))
559 (if (null (eval (read (current-buffer))))
560 (progn (forward-line)
562 (write-file (gnus-agent-lib-file "flags"))
563 (error "Couldn't set flags from file %s"
564 (gnus-agent-lib-file "flags"))))
565 (delete-file (gnus-agent-lib-file "flags")))
568 (defun gnus-agent-possibly-synchronize-flags-server (method)
569 "Synchronize flags for server according to `gnus-agent-synchronize-flags'."
570 (when (or (and gnus-agent-synchronize-flags
571 (not (eq gnus-agent-synchronize-flags 'ask)))
572 (and (eq gnus-agent-synchronize-flags 'ask)
573 (gnus-y-or-n-p (format "Synchronize flags on server `%s'? "
575 (gnus-agent-synchronize-flags-server method)))
578 ;;; Server mode commands
581 (defun gnus-agent-add-server (server)
582 "Enroll SERVER in the agent program."
583 (interactive (list (gnus-server-server-name)))
585 (error "No server on the current line"))
586 (let ((method (gnus-server-get-method nil (gnus-server-server-name))))
587 (when (gnus-agent-method-p method)
588 (error "Server already in the agent program"))
589 (push method gnus-agent-covered-methods)
590 (gnus-server-update-server server)
591 (gnus-agent-write-servers)
592 (message "Entered %s into the Agent" server)))
594 (defun gnus-agent-remove-server (server)
595 "Remove SERVER from the agent program."
596 (interactive (list (gnus-server-server-name)))
598 (error "No server on the current line"))
599 (let ((method (gnus-server-get-method nil (gnus-server-server-name))))
600 (unless (gnus-agent-method-p method)
601 (error "Server not in the agent program"))
602 (setq gnus-agent-covered-methods
603 (delete method gnus-agent-covered-methods))
604 (gnus-server-update-server server)
605 (gnus-agent-write-servers)
606 (message "Removed %s from the agent" server)))
608 (defun gnus-agent-read-servers ()
609 "Read the alist of covered servers."
610 (setq gnus-agent-covered-methods
611 (gnus-agent-read-file
612 (nnheader-concat gnus-agent-directory "lib/servers"))))
614 (defun gnus-agent-write-servers ()
615 "Write the alist of covered servers."
616 (gnus-make-directory (nnheader-concat gnus-agent-directory "lib"))
617 (let ((coding-system-for-write nnheader-file-coding-system)
618 (file-name-coding-system nnmail-pathname-coding-system))
619 (with-temp-file (nnheader-concat gnus-agent-directory "lib/servers")
620 (prin1 gnus-agent-covered-methods (current-buffer)))))
626 (defun gnus-agent-mark-article (n &optional unmark)
627 "Mark the next N articles as downloadable.
628 If N is negative, mark backward instead. If UNMARK is non-nil, remove
629 the mark instead. The difference between N and the actual number of
630 articles marked is returned."
632 (let ((backward (< n 0))
637 (gnus-summary-set-agent-mark
638 (gnus-summary-article-number) unmark)
639 (zerop (gnus-summary-next-subject (if backward -1 1) nil t))))
642 (gnus-message 7 "No more articles"))
643 (gnus-summary-recenter)
644 (gnus-summary-position-point)
647 (defun gnus-agent-unmark-article (n)
648 "Remove the downloadable mark from the next N articles.
649 If N is negative, unmark backward instead. The difference between N and
650 the actual number of articles unmarked is returned."
652 (gnus-agent-mark-article n t))
654 (defun gnus-agent-toggle-mark (n)
655 "Toggle the downloadable mark from the next N articles.
656 If N is negative, toggle backward instead. The difference between N and
657 the actual number of articles toggled is returned."
659 (gnus-agent-mark-article n 'toggle))
661 (defun gnus-summary-set-agent-mark (article &optional unmark)
662 "Mark ARTICLE as downloadable."
663 (let ((unmark (if (and (not (null unmark)) (not (eq t unmark)))
664 (memq article gnus-newsgroup-downloadable)
668 (setq gnus-newsgroup-downloadable
669 (delq article gnus-newsgroup-downloadable))
670 (push article gnus-newsgroup-undownloaded))
671 (setq gnus-newsgroup-undownloaded
672 (delq article gnus-newsgroup-undownloaded))
673 (push article gnus-newsgroup-downloadable))
674 (gnus-summary-update-mark
675 (if unmark gnus-undownloaded-mark gnus-downloadable-mark)
678 (defun gnus-agent-get-undownloaded-list ()
679 "Mark all unfetched articles as read."
680 (let ((gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name)))
681 (when (and (not (gnus-online gnus-command-method))
682 (gnus-agent-method-p gnus-command-method))
683 (gnus-agent-load-alist gnus-newsgroup-name)
684 ;; First mark all undownloaded articles as undownloaded.
685 (dolist (article (mapcar (lambda (header) (mail-header-number header))
686 gnus-newsgroup-headers))
687 (unless (or (cdr (assq article gnus-agent-article-alist))
688 (memq article gnus-newsgroup-downloadable)
689 (memq article gnus-newsgroup-cached))
690 (push article gnus-newsgroup-undownloaded)))
691 ;; Then mark downloaded downloadable as not-downloadable,
692 ;; if you get my drift.
693 (dolist (article gnus-newsgroup-downloadable)
694 (when (cdr (assq article gnus-agent-article-alist))
695 (setq gnus-newsgroup-downloadable
696 (delq article gnus-newsgroup-downloadable)))))))
698 (defun gnus-agent-catchup ()
699 "Mark all undownloaded articles as read."
702 (while gnus-newsgroup-undownloaded
703 (gnus-summary-mark-article
704 (pop gnus-newsgroup-undownloaded) gnus-catchup-mark)))
705 (gnus-summary-position-point))
707 (defun gnus-agent-summary-fetch-group ()
708 "Fetch the downloadable articles in the group."
710 (let ((articles gnus-newsgroup-downloadable)
711 (gnus-command-method (gnus-find-method-for-group gnus-newsgroup-name))
712 (state gnus-plugged))
716 (gnus-agent-toggle-plugged t))
718 (error "No articles to download"))
719 (gnus-agent-with-fetch
720 (gnus-agent-fetch-articles gnus-newsgroup-name articles))
722 (dolist (article articles)
723 (setq gnus-newsgroup-downloadable
724 (delq article gnus-newsgroup-downloadable))
725 (gnus-summary-mark-article article gnus-unread-mark))))
726 (when (and (not state)
728 (gnus-agent-toggle-plugged nil)))))
731 ;;; Internal functions
734 (defun gnus-agent-save-active (method)
735 (gnus-agent-save-active-1 method 'gnus-active-to-gnus-format))
737 (defun gnus-agent-save-active-1 (method function)
738 (when (gnus-agent-method-p method)
739 (let* ((gnus-command-method method)
740 (new (gnus-make-hashtable (count-lines (point-min) (point-max))))
741 (file (gnus-agent-lib-file "active")))
742 (funcall function nil new)
743 (gnus-agent-write-active file new)
745 (nnheader-insert-file-contents file))))
747 (defun gnus-agent-write-active (file new)
748 (let ((orig (gnus-make-hashtable (count-lines (point-min) (point-max))))
749 (file (gnus-agent-lib-file "active"))
751 (when (file-exists-p file)
753 (nnheader-insert-file-contents file)
754 (gnus-active-to-gnus-format nil orig))
757 (when (and sym (boundp sym))
758 (if (and (boundp (setq osym (intern (symbol-name sym) orig)))
759 (setq elem (symbol-value osym)))
761 (if (and (integerp (car (symbol-value sym)))
762 (> (car elem) (car (symbol-value sym))))
763 (setcar elem (car (symbol-value sym))))
764 (if (integerp (cdr (symbol-value sym)))
765 (setcdr elem (cdr (symbol-value sym)))))
766 (set (intern (symbol-name sym) orig) (symbol-value sym)))))
768 (gnus-make-directory (file-name-directory file))
769 (let ((nnmail-active-file-coding-system gnus-agent-file-coding-system))
770 ;; The hashtable contains real names of groups, no more prefix
771 ;; removing, so set `full' to `t'.
772 (gnus-write-active-file file orig t))))
774 (defun gnus-agent-save-groups (method)
775 (gnus-agent-save-active-1 method 'gnus-groups-to-gnus-format))
777 (defun gnus-agent-save-group-info (method group active)
778 (when (gnus-agent-method-p method)
779 (let* ((gnus-command-method method)
780 (coding-system-for-write nnheader-file-coding-system)
781 (file-name-coding-system nnmail-pathname-coding-system)
782 (file (gnus-agent-lib-file "active"))
784 (gnus-make-directory (file-name-directory file))
786 ;; Emacs got problem to match non-ASCII group in multibyte buffer.
787 (mm-disable-multibyte)
788 (when (file-exists-p file)
789 (nnheader-insert-file-contents file))
790 (goto-char (point-min))
791 (when (re-search-forward
792 (concat "^" (regexp-quote group) " ") nil t)
794 (read (current-buffer)) ;; max
795 (setq oactive-min (read (current-buffer)))) ;; min
797 (insert (format "%S %d %d y\n" (intern group)
799 (or oactive-min (car active))))
800 (goto-char (point-max))
801 (while (search-backward "\\." nil t)
804 (defun gnus-agent-group-path (group)
805 "Translate GROUP into a path."
806 (if nnmail-use-long-file-names
807 (gnus-group-real-name group)
808 (nnheader-translate-file-chars
809 (nnheader-replace-chars-in-string
810 (nnheader-replace-duplicate-chars-in-string
811 (nnheader-replace-chars-in-string
812 (gnus-group-real-name group)
819 (defun gnus-agent-get-function (method)
820 (if (gnus-online method)
825 ;;; History functions
827 (defun gnus-agent-history-buffer ()
828 (cdr (assoc (gnus-agent-method) gnus-agent-history-buffers)))
830 (defun gnus-agent-open-history ()
832 (push (cons (gnus-agent-method)
833 (set-buffer (gnus-get-buffer-create
834 (format " *Gnus agent %s history*"
835 (gnus-agent-method)))))
836 gnus-agent-history-buffers)
837 (mm-disable-multibyte) ;; everything is binary
840 (let ((file (gnus-agent-lib-file "history")))
841 (when (file-exists-p file)
842 (nnheader-insert-file-contents file))
843 (set (make-local-variable 'gnus-agent-file-name) file))))
845 (defun gnus-agent-save-history ()
847 (set-buffer gnus-agent-current-history)
848 (gnus-make-directory (file-name-directory gnus-agent-file-name))
849 (let ((coding-system-for-write gnus-agent-file-coding-system))
850 (write-region (1+ (point-min)) (point-max)
851 gnus-agent-file-name nil 'silent))))
853 (defun gnus-agent-close-history ()
854 (when (gnus-buffer-live-p gnus-agent-current-history)
855 (kill-buffer gnus-agent-current-history)
856 (setq gnus-agent-history-buffers
857 (delq (assoc (gnus-agent-method) gnus-agent-history-buffers)
858 gnus-agent-history-buffers))))
860 (defun gnus-agent-enter-history (id group-arts date)
862 (set-buffer gnus-agent-current-history)
863 (goto-char (point-max))
865 (insert id "\t" (number-to-string date) "\t")
867 (insert (format "%S" (intern (caar group-arts)))
868 " " (number-to-string (cdr (pop group-arts)))
871 (while (search-backward "\\." p t)
874 (defun gnus-agent-article-in-history-p (id)
876 (set-buffer (gnus-agent-history-buffer))
877 (goto-char (point-min))
878 (search-forward (concat "\n" id "\t") nil t)))
880 (defun gnus-agent-history-path (id)
882 (set-buffer (gnus-agent-history-buffer))
883 (goto-char (point-min))
884 (when (search-forward (concat "\n" id "\t") nil t)
885 (let ((method (gnus-agent-method)))
887 (while (not (numberp (setq group (read (current-buffer)))))
888 (push (concat method "/" group) paths))
889 (nreverse paths))))))
895 (defun gnus-agent-fetch-articles (group articles)
896 "Fetch ARTICLES from GROUP and put them into the Agent."
898 ;; Prune off articles that we have already fetched.
900 (cdr (assq (car articles) gnus-agent-article-alist)))
902 (let ((arts articles))
904 (if (cdr (assq (cadr arts) gnus-agent-article-alist))
905 (setcdr arts (cddr arts))
906 (setq arts (cdr arts)))))
909 (gnus-agent-directory)
910 (gnus-agent-group-path group) "/"))
911 (date (time-to-days (current-time)))
914 (gnus-make-directory dir)
915 (gnus-message 7 "Fetching articles for %s..." group)
916 ;; Fetch the articles from the backend.
917 (if (gnus-check-backend-function 'retrieve-articles group)
918 (setq pos (gnus-retrieve-articles articles group))
921 (while (setq article (pop articles))
923 (gnus-backlog-request-article group article
925 (gnus-request-article article group))
926 (goto-char (point-max))
927 (push (cons article (point)) pos)
928 (insert-buffer-substring nntp-server-buffer)))
929 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
930 (setq pos (nreverse pos)))))
931 ;; Then save these articles into the Agent.
933 (set-buffer nntp-server-buffer)
935 (narrow-to-region (cdar pos) (or (cdadr pos) (point-max)))
936 (goto-char (point-min))
937 (when (search-forward "\n\n" nil t)
938 (when (search-backward "\nXrefs: " nil t)
939 ;; Handle crossposting.
940 (skip-chars-forward "^ ")
941 (skip-chars-forward " ")
943 (while (looking-at "\\([^: \n]+\\):\\([0-9]+\\) +")
944 (push (cons (buffer-substring (match-beginning 1)
946 (buffer-substring (match-beginning 2)
949 (goto-char (match-end 0)))
950 (gnus-agent-crosspost crosses (caar pos))))
951 (goto-char (point-min))
952 (if (not (re-search-forward "^Message-ID: *<\\([^>\n]+\\)>" nil t))
953 (setq id "No-Message-ID-in-article")
954 (setq id (buffer-substring (match-beginning 1) (match-end 1))))
955 (let ((coding-system-for-write
956 gnus-agent-file-coding-system))
957 (write-region (point-min) (point-max)
958 (concat dir (number-to-string (caar pos)))
960 (when (setq elem (assq (caar pos) gnus-agent-article-alist))
962 (gnus-agent-enter-history
963 id (or crosses (list (cons group (caar pos)))) date)
966 (gnus-agent-save-alist group)))))
968 (defun gnus-agent-crosspost (crosses article)
969 (let (gnus-agent-article-alist group alist beg end)
971 (set-buffer gnus-agent-overview-buffer)
972 (when (nnheader-find-nov-line article)
975 (setq end (progn (forward-line 1) (point)))))
977 (setq group (caar crosses))
978 (unless (setq alist (assoc group gnus-agent-group-alist))
979 (push (setq alist (list group (gnus-agent-load-alist (caar crosses))))
980 gnus-agent-group-alist))
981 (setcdr alist (cons (cons (cdar crosses) t) (cdr alist)))
983 (set-buffer (gnus-get-buffer-create (format " *Gnus agent overview %s*"
985 (when (= (point-max) (point-min))
986 (push (cons group (current-buffer)) gnus-agent-buffer-alist)
988 (nnheader-insert-file-contents
989 (gnus-agent-article-name ".overview" group))))
990 (nnheader-find-nov-line (string-to-number (cdar crosses)))
991 (insert (string-to-number (cdar crosses)))
992 (insert-buffer-substring gnus-agent-overview-buffer beg end))
995 (defun gnus-agent-flush-cache ()
997 (while gnus-agent-buffer-alist
998 (set-buffer (cdar gnus-agent-buffer-alist))
999 (let ((coding-system-for-write
1000 gnus-agent-file-coding-system))
1001 (write-region (point-min) (point-max)
1002 (gnus-agent-article-name ".overview"
1003 (caar gnus-agent-buffer-alist))
1005 (pop gnus-agent-buffer-alist))
1006 (while gnus-agent-group-alist
1007 (with-temp-file (caar gnus-agent-group-alist)
1008 (princ (cdar gnus-agent-group-alist))
1010 (pop gnus-agent-group-alist))))
1012 (defun gnus-agent-fetch-headers (group &optional force)
1013 (let ((articles (gnus-list-of-unread-articles group))
1014 (gnus-decode-encoded-word-function 'identity)
1015 (file (gnus-agent-article-name ".overview" group))
1017 ;; Add article with marks to list of article headers we want to fetch.
1018 (dolist (arts (gnus-info-marks (gnus-get-info group)))
1019 (unless (memq (car arts) '(seen recent))
1020 (setq articles (gnus-range-add articles (cdr arts)))))
1021 (setq articles (sort (gnus-uncompress-sequence articles) '<))
1022 ;; Remove known articles.
1023 (when (gnus-agent-load-alist group)
1024 (setq articles (gnus-sorted-intersection
1026 (gnus-uncompress-range
1027 (cons (1+ (caar (last gnus-agent-article-alist)))
1028 (cdr (gnus-active group)))))))
1030 (gnus-make-directory (nnheader-translate-file-chars
1031 (file-name-directory file) t))
1033 (gnus-message 7 "Fetching headers for %s..." group)
1035 (set-buffer nntp-server-buffer)
1036 (unless (eq 'nov (gnus-retrieve-headers articles group))
1037 (nnvirtual-convert-headers))
1038 ;; Save these headers for later processing.
1039 (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
1040 (when (file-exists-p file)
1041 (gnus-agent-braid-nov group articles file))
1042 (let ((coding-system-for-write
1043 gnus-agent-file-coding-system))
1044 (write-region (point-min) (point-max) file nil 'silent))
1045 (gnus-agent-save-alist group articles nil)
1046 (gnus-agent-enter-history
1047 "last-header-fetched-for-session"
1048 (list (cons group (nth (- (length articles) 1) articles)))
1049 (time-to-days (current-time)))
1052 (defsubst gnus-agent-copy-nov-line (article)
1054 (set-buffer gnus-agent-overview-buffer)
1057 (if (eq article (read (current-buffer)))
1058 (setq e (progn (forward-line 1) (point)))
1062 (set-buffer nntp-server-buffer)
1063 (insert-buffer-substring gnus-agent-overview-buffer b e))))
1065 (defun gnus-agent-braid-nov (group articles file)
1066 (set-buffer gnus-agent-overview-buffer)
1067 (goto-char (point-min))
1068 (set-buffer nntp-server-buffer)
1070 (nnheader-insert-file-contents file)
1071 (goto-char (point-max))
1072 (if (or (= (point-min) (point-max))
1075 (< (read (current-buffer)) (car articles))))
1076 ;; We have only headers that are after the older headers,
1077 ;; so we just append them.
1079 (goto-char (point-max))
1080 (insert-buffer-substring gnus-agent-overview-buffer))
1081 ;; We do it the hard way.
1082 (nnheader-find-nov-line (car articles))
1083 (gnus-agent-copy-nov-line (car articles))
1085 (while (and articles
1087 (while (and (not (eobp))
1088 (< (read (current-buffer)) (car articles)))
1092 (gnus-agent-copy-nov-line (car articles))
1093 (setq articles (cdr articles))))
1094 (set-buffer nntp-server-buffer)
1097 (set-buffer gnus-agent-overview-buffer)
1100 (while (and (not (eobp))
1101 (<= (read (current-buffer)) (car articles)))
1104 (set-buffer nntp-server-buffer)
1105 (insert-buffer-substring gnus-agent-overview-buffer b e)))))
1107 (defun gnus-agent-load-alist (group &optional dir)
1108 "Load the article-state alist for GROUP."
1109 (setq gnus-agent-article-alist
1110 (gnus-agent-read-file
1112 (expand-file-name ".agentview" dir)
1113 (gnus-agent-article-name ".agentview" group)))))
1115 (defun gnus-agent-save-alist (group &optional articles state dir)
1116 "Save the article-state alist for GROUP."
1117 (let ((file-name-coding-system nnmail-pathname-coding-system)
1118 print-level print-length item)
1119 (dolist (art articles)
1120 (if (setq item (memq art gnus-agent-article-alist))
1122 (push (cons art state) gnus-agent-article-alist)))
1123 (setq gnus-agent-article-alist
1124 (sort gnus-agent-article-alist 'car-less-than-car))
1125 (with-temp-file (if dir
1126 (expand-file-name ".agentview" dir)
1127 (gnus-agent-article-name ".agentview" group))
1128 (princ gnus-agent-article-alist (current-buffer))
1131 (defun gnus-agent-article-name (article group)
1132 (expand-file-name (if (stringp article) article (string-to-number article))
1133 (file-name-as-directory
1134 (expand-file-name (gnus-agent-group-path group)
1135 (gnus-agent-directory)))))
1137 (defun gnus-agent-batch-confirmation (msg)
1138 "Show error message and return t."
1139 (gnus-message 1 msg)
1143 (defun gnus-agent-batch-fetch ()
1144 "Start Gnus and fetch session."
1147 (let ((gnus-agent-confirmation-function 'gnus-agent-batch-confirmation))
1148 (gnus-agent-fetch-session))
1151 (defun gnus-agent-fetch-session ()
1152 "Fetch all articles and headers that are eligible for fetching."
1154 (unless gnus-agent-covered-methods
1155 (error "No servers are covered by the Gnus agent"))
1156 (unless gnus-plugged
1157 (error "Can't fetch articles while Gnus is unplugged"))
1158 (let ((methods gnus-agent-covered-methods)
1159 groups group gnus-command-method)
1164 (setq gnus-command-method (car methods))
1165 (when (and (or (gnus-server-opened gnus-command-method)
1166 (gnus-open-server gnus-command-method))
1167 (gnus-online gnus-command-method))
1168 (setq groups (gnus-groups-from-server (car methods)))
1169 (gnus-agent-with-fetch
1170 (while (setq group (pop groups))
1171 (when (<= (gnus-group-level group) gnus-agent-handle-level)
1172 (gnus-agent-fetch-group-1 group gnus-command-method))))))
1174 (unless (funcall gnus-agent-confirmation-function
1175 (format "Error (%s). Continue? " err))
1176 (error "Cannot fetch articles into the Gnus agent")))
1178 (unless (funcall gnus-agent-confirmation-function
1179 (format "Quit fetching session (%s). Continue? "
1181 (signal 'quit "Cannot fetch articles into the Gnus agent"))))
1183 (run-hooks 'gnus-agent-fetch-hook)
1184 (gnus-message 6 "Finished fetching articles into the Gnus agent"))))
1186 (defun gnus-agent-fetch-group-1 (group method)
1188 (let ((gnus-command-method method)
1189 (gnus-newsgroup-name group)
1190 gnus-newsgroup-dependencies gnus-newsgroup-headers
1191 gnus-newsgroup-scored gnus-headers gnus-score
1192 gnus-use-cache articles arts
1193 category predicate info marks score-param
1194 (gnus-summary-expunge-below gnus-summary-expunge-below)
1195 (gnus-summary-mark-below gnus-summary-mark-below)
1196 (gnus-orphan-score gnus-orphan-score)
1197 ;; Maybe some other gnus-summary local variables should also
1200 (unless (gnus-check-group group)
1201 (error "Can't open server for %s" group))
1203 (when (and (or (gnus-active group)
1204 (gnus-activate-group group))
1205 (setq articles (gnus-agent-fetch-headers group))
1206 (let ((nntp-server-buffer gnus-agent-overview-buffer))
1207 ;; Parse them and see which articles we want to fetch.
1208 (setq gnus-newsgroup-dependencies
1209 (make-vector (length articles) 0))
1210 (setq gnus-newsgroup-headers
1211 (gnus-get-newsgroup-headers-xover articles nil nil
1213 ;; `gnus-agent-overview-buffer' may be killed for
1214 ;; timeout reason. If so, recreate it.
1215 (gnus-agent-create-buffer)))
1216 (setq category (gnus-group-category group))
1219 (or (gnus-group-find-parameter group 'agent-predicate t)
1221 (if (memq predicate '(gnus-agent-true gnus-agent-false))
1222 ;; Simple implementation
1223 (setq arts (and (eq predicate 'gnus-agent-true) articles))
1226 (or (gnus-group-get-parameter group 'agent-score t)
1228 ;; Translate score-param into real one
1231 ((eq score-param 'file)
1232 (setq score-param (gnus-all-score-files group)))
1233 ((stringp (car score-param)))
1235 (setq score-param (list (list score-param)))))
1237 (gnus-score-headers score-param))
1238 (while (setq gnus-headers (pop gnus-newsgroup-headers))
1240 (or (cdr (assq (mail-header-number gnus-headers)
1241 gnus-newsgroup-scored))
1242 gnus-summary-default-score))
1243 (when (funcall predicate)
1244 (push (mail-header-number gnus-headers)
1246 ;; Fetch the articles.
1248 (gnus-agent-fetch-articles group arts)))
1249 ;; Perhaps we have some additional articles to fetch.
1250 (setq arts (assq 'download (gnus-info-marks
1251 (setq info (gnus-get-info group)))))
1253 (gnus-message 8 "Agent is downloading marked articles...")
1254 (gnus-agent-fetch-articles
1255 group (gnus-uncompress-range (cdr arts)))
1256 (setq marks (delq arts (gnus-info-marks info)))
1257 (gnus-info-set-marks info marks)
1259 (concat "(gnus-group-set-info '"
1260 (gnus-prin1-to-string info)
1264 ;;; Agent Category Mode
1267 (defvar gnus-category-mode-hook nil
1268 "Hook run in `gnus-category-mode' buffers.")
1270 (defvar gnus-category-line-format " %(%20c%): %g\n"
1271 "Format of category lines.
1273 Valid specifiers include:
1274 %c Topic name (string)
1275 %g The number of groups in the topic (integer)
1277 General format specifiers can also be used. See
1278 (gnus)Formatting Variables.")
1280 (defvar gnus-category-mode-line-format "Gnus: %%b"
1281 "The format specification for the category mode line.")
1283 (defvar gnus-agent-short-article 100
1284 "Articles that have fewer lines than this are short.")
1286 (defvar gnus-agent-long-article 200
1287 "Articles that have more lines than this are long.")
1289 (defvar gnus-agent-low-score 0
1290 "Articles that have a score lower than this have a low score.")
1292 (defvar gnus-agent-high-score 0
1293 "Articles that have a score higher than this have a high score.")
1296 ;;; Internal variables.
1298 (defvar gnus-category-buffer "*Agent Category*")
1300 (defvar gnus-category-line-format-alist
1301 `((?c gnus-tmp-name ?s)
1302 (?g gnus-tmp-groups ?d)))
1304 (defvar gnus-category-mode-line-format-alist
1305 `((?u user-defined ?s)))
1307 (defvar gnus-category-line-format-spec nil)
1308 (defvar gnus-category-mode-line-format-spec nil)
1310 (defvar gnus-category-mode-map nil)
1311 (put 'gnus-category-mode 'mode-class 'special)
1313 (unless gnus-category-mode-map
1314 (setq gnus-category-mode-map (make-sparse-keymap))
1315 (suppress-keymap gnus-category-mode-map)
1317 (gnus-define-keys gnus-category-mode-map
1318 "q" gnus-category-exit
1319 "k" gnus-category-kill
1320 "c" gnus-category-copy
1321 "a" gnus-category-add
1322 "p" gnus-category-edit-predicate
1323 "g" gnus-category-edit-groups
1324 "s" gnus-category-edit-score
1325 "l" gnus-category-list
1327 "\C-c\C-i" gnus-info-find-node
1328 "\C-c\C-b" gnus-bug))
1330 (defvar gnus-category-menu-hook nil
1331 "*Hook run after the creation of the menu.")
1333 (defun gnus-category-make-menu-bar ()
1334 (gnus-turn-off-edit-menu 'category)
1335 (unless (boundp 'gnus-category-menu)
1337 gnus-category-menu gnus-category-mode-map ""
1339 ["Add" gnus-category-add t]
1340 ["Kill" gnus-category-kill t]
1341 ["Copy" gnus-category-copy t]
1342 ["Edit predicate" gnus-category-edit-predicate t]
1343 ["Edit score" gnus-category-edit-score t]
1344 ["Edit groups" gnus-category-edit-groups t]
1345 ["Exit" gnus-category-exit t]))
1347 (gnus-run-hooks 'gnus-category-menu-hook)))
1349 (defun gnus-category-mode ()
1350 "Major mode for listing and editing agent categories.
1352 All normal editing commands are switched off.
1353 \\<gnus-category-mode-map>
1354 For more in-depth information on this mode, read the manual
1355 (`\\[gnus-info-find-node]').
1357 The following commands are available:
1359 \\{gnus-category-mode-map}"
1361 (when (gnus-visual-p 'category-menu 'menu)
1362 (gnus-category-make-menu-bar))
1363 (kill-all-local-variables)
1364 (gnus-simplify-mode-line)
1365 (setq major-mode 'gnus-category-mode)
1366 (setq mode-name "Category")
1367 (gnus-set-default-directory)
1368 (setq mode-line-process nil)
1369 (use-local-map gnus-category-mode-map)
1370 (buffer-disable-undo)
1371 (setq truncate-lines t)
1372 (setq buffer-read-only t)
1373 (gnus-run-hooks 'gnus-category-mode-hook))
1375 (defalias 'gnus-category-position-point 'gnus-goto-colon)
1377 (defun gnus-category-insert-line (category)
1378 (let* ((gnus-tmp-name (format "%s" (car category)))
1379 (gnus-tmp-groups (length (cadddr category))))
1381 (gnus-add-text-properties
1385 (eval gnus-category-line-format-spec))
1386 (list 'gnus-category gnus-tmp-name))))
1388 (defun gnus-enter-category-buffer ()
1389 "Go to the Category buffer."
1391 (gnus-category-setup-buffer)
1392 (gnus-configure-windows 'category)
1393 (gnus-category-prepare))
1395 (defun gnus-category-setup-buffer ()
1396 (unless (get-buffer gnus-category-buffer)
1398 (set-buffer (gnus-get-buffer-create gnus-category-buffer))
1399 (gnus-category-mode))))
1401 (defun gnus-category-prepare ()
1402 (gnus-set-format 'category-mode)
1403 (gnus-set-format 'category t)
1404 (let ((alist gnus-category-alist)
1405 (buffer-read-only nil))
1408 (gnus-category-insert-line (pop alist)))
1409 (goto-char (point-min))
1410 (gnus-category-position-point)))
1412 (defun gnus-category-name ()
1413 (or (intern (get-text-property (gnus-point-at-bol) 'gnus-category))
1414 (error "No category on the current line")))
1416 (defun gnus-category-read ()
1417 "Read the category alist."
1418 (setq gnus-category-alist
1419 (or (gnus-agent-read-file
1420 (nnheader-concat gnus-agent-directory "lib/categories"))
1421 (list (list 'default 'short nil nil)))))
1423 (defun gnus-category-write ()
1424 "Write the category alist."
1425 (setq gnus-category-predicate-cache nil
1426 gnus-category-group-cache nil)
1427 (gnus-make-directory (nnheader-concat gnus-agent-directory "lib"))
1428 (with-temp-file (nnheader-concat gnus-agent-directory "lib/categories")
1429 (prin1 gnus-category-alist (current-buffer))))
1431 (defun gnus-category-edit-predicate (category)
1432 "Edit the predicate for CATEGORY."
1433 (interactive (list (gnus-category-name)))
1434 (let ((info (assq category gnus-category-alist)))
1436 (cadr info) (format "Editing the predicate for category %s" category)
1437 `(lambda (predicate)
1438 (setcar (cdr (assq ',category gnus-category-alist)) predicate)
1439 (gnus-category-write)
1440 (gnus-category-list)))))
1442 (defun gnus-category-edit-score (category)
1443 "Edit the score expression for CATEGORY."
1444 (interactive (list (gnus-category-name)))
1445 (let ((info (assq category gnus-category-alist)))
1448 (format "Editing the score expression for category %s" category)
1450 (setcar (cddr (assq ',category gnus-category-alist)) groups)
1451 (gnus-category-write)
1452 (gnus-category-list)))))
1454 (defun gnus-category-edit-groups (category)
1455 "Edit the group list for CATEGORY."
1456 (interactive (list (gnus-category-name)))
1457 (let ((info (assq category gnus-category-alist)))
1459 (cadddr info) (format "Editing the group list for category %s" category)
1461 (setcar (nthcdr 3 (assq ',category gnus-category-alist)) groups)
1462 (gnus-category-write)
1463 (gnus-category-list)))))
1465 (defun gnus-category-kill (category)
1466 "Kill the current category."
1467 (interactive (list (gnus-category-name)))
1468 (let ((info (assq category gnus-category-alist))
1469 (buffer-read-only nil))
1471 (setq gnus-category-alist (delq info gnus-category-alist))
1472 (gnus-category-write)))
1474 (defun gnus-category-copy (category to)
1475 "Copy the current category."
1476 (interactive (list (gnus-category-name) (intern (read-string "New name: "))))
1477 (let ((info (assq category gnus-category-alist)))
1478 (push (list to (gnus-copy-sequence (cadr info))
1479 (gnus-copy-sequence (caddr info)) nil)
1480 gnus-category-alist)
1481 (gnus-category-write)
1482 (gnus-category-list)))
1484 (defun gnus-category-add (category)
1485 "Create a new category."
1486 (interactive "SCategory name: ")
1487 (when (assq category gnus-category-alist)
1488 (error "Category %s already exists" category))
1489 (push (list category 'false nil nil)
1490 gnus-category-alist)
1491 (gnus-category-write)
1492 (gnus-category-list))
1494 (defun gnus-category-list ()
1495 "List all categories."
1497 (gnus-category-prepare))
1499 (defun gnus-category-exit ()
1500 "Return to the group buffer."
1502 (kill-buffer (current-buffer))
1503 (gnus-configure-windows 'group t))
1505 ;; To avoid having 8-bit characters in the source file.
1506 (defvar gnus-category-not (list '! 'not (intern (format "%c" 172))))
1508 (defvar gnus-category-predicate-alist
1509 '((spam . gnus-agent-spam-p)
1510 (short . gnus-agent-short-p)
1511 (long . gnus-agent-long-p)
1512 (low . gnus-agent-low-scored-p)
1513 (high . gnus-agent-high-scored-p)
1514 (true . gnus-agent-true)
1515 (false . gnus-agent-false))
1516 "Mapping from short score predicate symbols to predicate functions.")
1518 (defun gnus-agent-spam-p ()
1519 "Say whether an article is spam or not."
1520 (unless gnus-agent-spam-hashtb
1521 (setq gnus-agent-spam-hashtb (gnus-make-hashtable 1000)))
1522 (if (not (equal (mail-header-references gnus-headers) ""))
1524 (let ((string (gnus-simplify-subject (mail-header-subject gnus-headers))))
1526 (gnus-gethash string gnus-agent-spam-hashtb)
1527 (gnus-sethash string t gnus-agent-spam-hashtb)))))
1529 (defun gnus-agent-short-p ()
1530 "Say whether an article is short or not."
1531 (< (mail-header-lines gnus-headers) gnus-agent-short-article))
1533 (defun gnus-agent-long-p ()
1534 "Say whether an article is long or not."
1535 (> (mail-header-lines gnus-headers) gnus-agent-long-article))
1537 (defun gnus-agent-low-scored-p ()
1538 "Say whether an article has a low score or not."
1539 (< gnus-score gnus-agent-low-score))
1541 (defun gnus-agent-high-scored-p ()
1542 "Say whether an article has a high score or not."
1543 (> gnus-score gnus-agent-high-score))
1545 (defun gnus-category-make-function (cat)
1546 "Make a function from category CAT."
1547 (let ((func (gnus-category-make-function-1 cat)))
1548 (if (and (= (length func) 1)
1549 (symbolp (car func)))
1551 (gnus-byte-compile `(lambda () ,func)))))
1553 (defun gnus-agent-true ()
1557 (defun gnus-agent-false ()
1561 (defun gnus-category-make-function-1 (cat)
1562 "Make a function from category CAT."
1564 ;; Functions are just returned as is.
1566 (gnus-functionp cat))
1567 `(,(or (cdr (assq cat gnus-category-predicate-alist))
1569 ;; More complex category.
1572 ((memq (car cat) '(& and))
1574 ((memq (car cat) '(| or))
1576 ((memq (car cat) gnus-category-not)
1578 ,@(mapcar 'gnus-category-make-function-1 (cdr cat))))
1580 (error "Unknown category type: %s" cat))))
1582 (defun gnus-get-predicate (predicate)
1583 "Return the predicate for CATEGORY."
1584 (or (cdr (assoc predicate gnus-category-predicate-cache))
1585 (cdar (push (cons predicate
1586 (gnus-category-make-function predicate))
1587 gnus-category-predicate-cache))))
1589 (defun gnus-group-category (group)
1590 "Return the category GROUP belongs to."
1591 (unless gnus-category-group-cache
1592 (setq gnus-category-group-cache (gnus-make-hashtable 1000))
1593 (let ((cs gnus-category-alist)
1595 (while (setq cat (pop cs))
1596 (setq groups (cadddr cat))
1598 (gnus-sethash (pop groups) cat gnus-category-group-cache)))))
1599 (or (gnus-gethash group gnus-category-group-cache)
1600 (assq 'default gnus-category-alist)))
1602 (defun gnus-agent-expire ()
1603 "Expire all old articles."
1605 (let ((methods gnus-agent-covered-methods)
1606 (day (if (numberp gnus-agent-expire-days)
1607 (- (time-to-days (current-time)) gnus-agent-expire-days)
1609 (current-day (time-to-days (current-time)))
1610 gnus-command-method sym group articles
1611 history overview file histories elem art nov-file low info
1612 unreads marked article orig lowest highest found days)
1614 (setq overview (gnus-get-buffer-create " *expire overview*"))
1615 (while (setq gnus-command-method (pop methods))
1616 (when (file-exists-p (gnus-agent-lib-file "active"))
1618 (nnheader-insert-file-contents (gnus-agent-lib-file "active"))
1619 (gnus-active-to-gnus-format
1621 (setq orig (gnus-make-hashtable
1622 (count-lines (point-min) (point-max))))))
1623 (let ((expiry-hashtb (gnus-make-hashtable 1023)))
1624 (gnus-agent-open-history)
1626 (setq gnus-agent-current-history
1627 (setq history (gnus-agent-history-buffer))))
1628 (goto-char (point-min))
1629 (when (> (buffer-size) 1)
1630 (goto-char (point-min))
1632 (skip-chars-forward "^\t")
1633 (if (let ((fetch-date (read (current-buffer))))
1634 (if (numberp fetch-date)
1635 ;; We now have the arrival day, so we see
1636 ;; whether it's old enough to be expired.
1639 (skip-chars-forward "\t")
1641 days gnus-agent-expire-days)
1642 (while (and (not found)
1644 (when (looking-at (caar days))
1645 (setq found (cadar days)))
1647 (> fetch-date (- current-day found)))
1648 ;; History file is corrupted.
1651 (format "File %s is corrupted!"
1652 (gnus-agent-lib-file "history")))
1656 ;; New article; we don't expire it.
1658 ;; Old article. Schedule it for possible nuking.
1660 (setq sym (let ((obarray expiry-hashtb) s)
1661 (setq s (read (current-buffer)))
1662 (if (stringp s) (intern s) s)))
1664 (set sym (cons (cons (read (current-buffer)) (point))
1665 (symbol-value sym)))
1666 (set sym (list (cons (read (current-buffer)) (point)))))
1667 (skip-chars-forward " "))
1669 ;; We now have all articles that can possibly be expired.
1672 (setq group (symbol-name sym)
1673 articles (sort (symbol-value sym) 'car-less-than-car)
1674 low (car (gnus-active group))
1675 info (gnus-get-info group)
1676 unreads (ignore-errors
1677 (gnus-list-of-unread-articles group))
1679 (gnus-uncompress-range
1680 (cdr (assq 'tick (gnus-info-marks info))))
1681 (gnus-uncompress-range
1683 (gnus-info-marks info)))))
1684 nov-file (gnus-agent-article-name ".overview" group)
1687 (gnus-agent-load-alist group)
1688 (gnus-message 5 "Expiring articles in %s" group)
1689 (set-buffer overview)
1691 (when (file-exists-p nov-file)
1692 (nnheader-insert-file-contents nov-file))
1693 (goto-char (point-min))
1695 (while (setq elem (pop articles))
1696 (setq article (car elem))
1697 (when (or (null low)
1699 gnus-agent-expire-all
1700 (and (not (memq article unreads))
1701 (not (memq article marked))))
1702 ;; Find and nuke the NOV line.
1703 (while (and (not (eobp))
1705 (setq art (read (current-buffer)))))
1707 (if (and (numberp art)
1709 (gnus-agent-article-name
1710 (number-to-string art) group)))
1716 ;; Remove old NOV lines that have no articles.
1717 (gnus-delete-line)))
1722 ;; Nuke the article.
1723 (when (file-exists-p
1724 (setq file (gnus-agent-article-name
1725 (number-to-string article)
1728 ;; Schedule the history line for nuking.
1729 (push (cdr elem) histories)))
1730 (gnus-make-directory (file-name-directory nov-file))
1731 (let ((coding-system-for-write
1732 gnus-agent-file-coding-system))
1733 (write-region (point-min) (point-max) nov-file nil 'silent))
1734 ;; Delete the unwanted entries in the alist.
1735 (setq gnus-agent-article-alist
1736 (sort gnus-agent-article-alist 'car-less-than-car))
1737 (let* ((alist gnus-agent-article-alist)
1738 (prev (cons nil alist))
1742 (<= (caar alist) article))
1743 (if (or (not (cdar alist))
1745 (gnus-agent-article-name
1750 (push (caar alist) expired)
1751 (setcdr prev (setq alist (cdr alist))))
1753 alist (cdr alist))))
1754 (setq gnus-agent-article-alist (cdr first))
1755 (gnus-agent-save-alist group)
1756 ;; Mark all articles up to the first article
1757 ;; in `gnus-article-alist' as read.
1758 (when (and info (caar gnus-agent-article-alist))
1759 (setcar (nthcdr 2 info)
1762 (cons 1 (- (caar gnus-agent-article-alist) 1)))))
1763 ;; Maybe everything has been expired from
1764 ;; `gnus-article-alist' and so the above marking as
1765 ;; read could not be conducted, or there are
1766 ;; expired article within the range of the alist.
1769 (or (not (caar gnus-agent-article-alist))
1771 (caar gnus-agent-article-alist))))
1772 (setcar (nthcdr 2 info)
1775 (nreverse expired))))
1777 (concat "(gnus-group-set-info '"
1778 (gnus-prin1-to-string info)
1781 (if (gnus-gethash group orig)
1782 (setcar (gnus-gethash group orig) lowest)
1783 (gnus-sethash group (cons lowest highest) orig))))
1785 (set-buffer history)
1786 (setq histories (nreverse (sort histories '<)))
1788 (goto-char (pop histories))
1790 (gnus-agent-save-history)
1791 (gnus-agent-close-history)
1792 (gnus-write-active-file
1793 (gnus-agent-lib-file "active") orig))
1794 (gnus-message 4 "Expiry...done")))))))
1797 (defun gnus-agent-batch ()
1799 (let ((init-file-user "")
1800 (gnus-always-read-dribble-file t))
1802 (let ((gnus-agent-confirmation-function 'gnus-agent-batch-confirmation))
1803 (gnus-group-send-queue)
1804 (gnus-agent-fetch-session)))
1806 (defun gnus-agent-retrieve-headers (articles group &optional fetch-old)
1808 (gnus-agent-create-buffer)
1809 (let ((gnus-decode-encoded-word-function 'identity)
1810 (file (gnus-agent-article-name ".overview" group))
1811 cached-articles uncached-articles)
1812 (gnus-make-directory (nnheader-translate-file-chars
1813 (file-name-directory file) t))
1814 (when (file-exists-p file)
1815 (with-current-buffer gnus-agent-overview-buffer
1817 (let ((nnheader-file-coding-system
1818 gnus-agent-file-coding-system))
1819 (nnheader-insert-file-contents file))
1820 (goto-char (point-min))
1822 (when (looking-at "[0-9]")
1823 (push (read (current-buffer)) cached-articles))
1825 (setq cached-articles (sort cached-articles '<))))
1826 (if (setq uncached-articles
1827 (gnus-set-difference articles cached-articles))
1829 (set-buffer nntp-server-buffer)
1831 (let (gnus-agent-cache)
1833 (gnus-retrieve-headers
1834 uncached-articles group fetch-old))
1835 (nnvirtual-convert-headers)))
1836 (set-buffer gnus-agent-overview-buffer)
1838 (set-buffer nntp-server-buffer)
1839 (copy-to-buffer gnus-agent-overview-buffer (point-min) (point-max))
1840 (when (and uncached-articles (file-exists-p file))
1841 (gnus-agent-braid-nov group uncached-articles file))
1842 (set-buffer nntp-server-buffer)
1843 (let ((coding-system-for-write
1844 gnus-agent-file-coding-system))
1845 (write-region (point-min) (point-max) file nil 'silent))
1846 (gnus-agent-load-alist group)
1847 (gnus-agent-save-alist group uncached-articles nil)
1848 (gnus-agent-open-history)
1849 (setq gnus-agent-current-history (gnus-agent-history-buffer))
1850 (gnus-agent-enter-history
1851 "last-header-fetched-for-session"
1852 (list (cons group (nth (- (length articles) 1) articles)))
1853 (time-to-days (current-time)))
1854 (gnus-agent-save-history))
1855 (set-buffer nntp-server-buffer)
1857 (insert-buffer-substring gnus-agent-overview-buffer)))
1859 (not (numberp fetch-old)))
1860 t ; Don't remove anything.
1861 (nnheader-nov-delete-outside-range
1862 (if fetch-old (max 1 (- (car articles) fetch-old))
1864 (car (last articles)))
1868 (defun gnus-agent-request-article (article group)
1869 "Retrieve ARTICLE in GROUP from the agent cache."
1870 (let* ((gnus-command-method (gnus-find-method-for-group group))
1872 (gnus-agent-directory)
1873 (gnus-agent-group-path group) "/"
1874 (number-to-string article)))
1875 (buffer-read-only nil))
1876 (when (and (file-exists-p file)
1877 (> (nth 7 (file-attributes file)) 0))
1879 (gnus-kill-all-overlays)
1880 (let ((coding-system-for-read gnus-cache-coding-system))
1881 (insert-file-contents file))
1884 (defun gnus-agent-regenerate-group (group &optional clean)
1886 (let ((dir (concat (gnus-agent-directory)
1887 (gnus-agent-group-path group) "/"))
1888 (file (gnus-agent-article-name ".overview" group))
1889 n point arts alist header new-alist changed)
1890 (when (file-exists-p dir)
1892 (sort (mapcar (lambda (name) (string-to-int name))
1893 (directory-files dir nil "^[0-9]+$" t))
1895 (gnus-make-directory (nnheader-translate-file-chars
1896 (file-name-directory file) t))
1897 (mm-with-unibyte-buffer
1898 (if (file-exists-p file)
1899 (let ((nnheader-file-coding-system
1900 gnus-agent-file-coding-system))
1901 (nnheader-insert-file-contents file)))
1902 (goto-char (point-min))
1904 (while (not (or (eobp) (looking-at "[0-9]")))
1905 (setq point (point))
1907 (delete-region point (point)))
1909 (setq n (read (current-buffer)))
1910 (when (and arts (> n (car arts)))
1912 (while (and arts (> n (car arts)))
1913 (message "Regenerating NOV %s %d..." group (car arts))
1914 (mm-with-unibyte-buffer
1915 (nnheader-insert-file-contents
1916 (concat dir (number-to-string (car arts))))
1917 (goto-char (point-min))
1918 (if (search-forward "\n\n" nil t)
1919 (delete-region (point) (point-max))
1920 (goto-char (point-max)))
1921 (setq header (nnheader-parse-head t)))
1922 (mail-header-set-number header (car arts))
1923 (nnheader-insert-nov header)
1925 (push (cons (car arts) t) alist)
1927 (if (and arts (= n (car arts)))
1929 (push (cons n t) alist)
1931 (push (cons n nil) alist))
1934 (let ((coding-system-for-write gnus-agent-file-coding-system))
1935 (write-region (point-min) (point-max) file nil 'silent))))
1936 (setq gnus-agent-article-alist nil)
1938 (gnus-agent-load-alist group))
1939 (setq alist (sort alist 'car-less-than-car))
1940 (setq gnus-agent-article-alist (sort gnus-agent-article-alist
1941 'car-less-than-car))
1942 (while (and alist gnus-agent-article-alist)
1944 ((< (caar alist) (caar gnus-agent-article-alist))
1945 (push (pop alist) new-alist))
1946 ((> (caar alist) (caar gnus-agent-article-alist))
1947 (push (list (car (pop gnus-agent-article-alist))) new-alist))
1949 (pop gnus-agent-article-alist)
1950 (while (and gnus-agent-article-alist
1951 (= (caar alist) (caar gnus-agent-article-alist)))
1952 (pop gnus-agent-article-alist))
1953 (push (pop alist) new-alist))))
1955 (push (pop alist) new-alist))
1956 (while gnus-agent-article-alist
1957 (push (list (car (pop gnus-agent-article-alist))) new-alist))
1958 (setq gnus-agent-article-alist (nreverse new-alist))
1959 (gnus-agent-save-alist group)))
1961 (defun gnus-agent-regenerate-history (group article)
1962 (let ((file (concat (gnus-agent-directory)
1963 (gnus-agent-group-path group) "/"
1964 (number-to-string article))) id)
1965 (mm-with-unibyte-buffer
1966 (nnheader-insert-file-contents file)
1967 (message-narrow-to-head)
1968 (goto-char (point-min))
1969 (if (not (re-search-forward "^Message-ID: *<\\([^>\n]+\\)>" nil t))
1970 (setq id "No-Message-ID-in-article")
1971 (setq id (buffer-substring (match-beginning 1) (match-end 1))))
1972 (gnus-agent-enter-history
1973 id (list (cons group article))
1974 (time-to-days (nth 5 (file-attributes file)))))))
1977 (defun gnus-agent-regenerate (&optional clean)
1978 "Regenerate all agent covered files.
1979 If CLEAN, don't read existing active and agentview files."
1981 (message "Regenerating Gnus agent files...")
1982 (dolist (gnus-command-method gnus-agent-covered-methods)
1983 (let ((active-file (gnus-agent-lib-file "active"))
1984 history-hashtb active-hashtb active-changed
1985 history-changed point)
1986 (gnus-make-directory (file-name-directory active-file))
1988 (setq active-hashtb (gnus-make-hashtable 1000))
1989 (mm-with-unibyte-buffer
1990 (if (file-exists-p active-file)
1991 (let ((nnheader-file-coding-system
1992 gnus-agent-file-coding-system))
1993 (nnheader-insert-file-contents active-file))
1994 (setq active-changed t))
1995 (gnus-active-to-gnus-format
1996 nil (setq active-hashtb
1997 (gnus-make-hashtable
1998 (count-lines (point-min) (point-max)))))))
1999 (gnus-agent-open-history)
2000 (setq history-hashtb (gnus-make-hashtable 1000))
2001 (with-current-buffer
2002 (setq gnus-agent-current-history (gnus-agent-history-buffer))
2003 (goto-char (point-min))
2007 "\\([^\t\n]+\\)\t[0-9]+\t\\([^ \n]+\\) \\([0-9]+\\)")
2009 (unless (string= (match-string 1)
2010 "last-header-fetched-for-session")
2011 (gnus-sethash (match-string 2)
2012 (cons (string-to-number (match-string 3))
2013 (gnus-gethash-safe (match-string 2)
2017 (setq point (point))
2019 (delete-region point (point))
2020 (setq history-changed t))))
2021 (dolist (group (gnus-groups-from-server gnus-command-method))
2022 (gnus-agent-regenerate-group group clean)
2023 (let ((min (or (caar gnus-agent-article-alist) 1))
2024 (max (or (caar (last gnus-agent-article-alist)) 0))
2025 (active (gnus-gethash-safe (gnus-group-real-name group)
2029 (setq active (cons min max)
2031 (gnus-sethash group active active-hashtb))
2032 (when (> (car active) min)
2034 (setq active-changed t))
2035 (when (< (cdr active) max)
2037 (setq active-changed t))))
2038 (let ((arts (sort (gnus-gethash-safe group history-hashtb) '<))
2040 (gnus-sethash group arts history-hashtb)
2041 (while (and arts gnus-agent-article-alist)
2043 ((> (car arts) (caar gnus-agent-article-alist))
2044 (when (cdar gnus-agent-article-alist)
2045 (gnus-agent-regenerate-history
2046 group (caar gnus-agent-article-alist))
2047 (setq history-changed t))
2048 (setq n (car (pop gnus-agent-article-alist)))
2049 (while (and gnus-agent-article-alist
2050 (= n (caar gnus-agent-article-alist)))
2051 (pop gnus-agent-article-alist)))
2052 ((< (car arts) (caar gnus-agent-article-alist))
2054 (while (and arts (= n (car arts)))
2057 (setq n (car (pop gnus-agent-article-alist)))
2058 (while (and gnus-agent-article-alist
2059 (= n (caar gnus-agent-article-alist)))
2060 (pop gnus-agent-article-alist))
2062 (while (and arts (= n (car arts)))
2064 (while gnus-agent-article-alist
2065 (when (cdar gnus-agent-article-alist)
2066 (gnus-agent-regenerate-history
2067 group (caar gnus-agent-article-alist))
2068 (setq history-changed t))
2069 (pop gnus-agent-article-alist))))
2070 (when history-changed
2071 (message "Regenerate the history file of %s:%s"
2072 (car gnus-command-method)
2073 (cadr gnus-command-method))
2074 (gnus-agent-save-history))
2075 (gnus-agent-close-history)
2076 (when active-changed
2077 (message "Regenerate %s" active-file)
2078 (let ((nnmail-active-file-coding-system gnus-agent-file-coding-system))
2079 (gnus-write-active-file active-file active-hashtb)))))
2080 (message "Regenerating Gnus agent files...done"))
2082 (defun gnus-agent-go-online (&optional force)
2083 "Switch servers into online status."
2084 (interactive (list t))
2085 (dolist (server gnus-opened-servers)
2086 (when (eq (nth 1 server) 'offline)
2087 (if (if (eq force 'ask)
2089 (format "Switch %s:%s into online status? "
2090 (caar server) (cadar server)))
2092 (setcar (nthcdr 1 server) 'close)))))
2094 (defun gnus-agent-toggle-group-plugged (group)
2095 "Toggle the status of the server of the current group."
2096 (interactive (list (gnus-group-group-name)))
2097 (let* ((method (gnus-find-method-for-group group))
2098 (status (cadr (assoc method gnus-opened-servers))))
2099 (if (eq status 'offline)
2100 (gnus-server-set-status method 'closed)
2101 (gnus-close-server method)
2102 (gnus-server-set-status method 'offline))
2103 (message "Turn %s:%s from %s to %s." (car method) (cadr method)
2104 (if (eq status 'offline) 'offline 'online)
2105 (if (eq status 'offline) 'online 'offline))))
2107 (provide 'gnus-agent)
2109 ;;; gnus-agent.el ends here