Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / gnus-agent.el
index 3c1da2f..c8b7792 100644 (file)
@@ -365,15 +365,17 @@ last form in your `.gnus.el' file:
 
 \(gnus-agentize)
 
-This will modify the `gnus-before-startup-hook', `gnus-post-method',
-and `message-send-mail-function' variables, and install the Gnus
-agent minor mode in all Gnus buffers."
+This will modify the `gnus-setup-news-hook', and
+`message-send-mail-real-function' variables, and install the Gnus agent
+minor mode in all Gnus buffers."
   (interactive)
   (gnus-open-agent)
   (add-hook 'gnus-setup-news-hook 'gnus-agent-queue-setup)
   (unless gnus-agent-send-mail-function
-    (setq gnus-agent-send-mail-function message-send-mail-function
-         message-send-mail-function 'gnus-agent-send-mail))
+    (setq gnus-agent-send-mail-function (or 
+                                         message-send-mail-real-function
+                                         message-send-mail-function)
+         message-send-mail-real-function 'gnus-agent-send-mail))
   (unless gnus-agent-covered-methods
     (setq gnus-agent-covered-methods (list gnus-select-method))))
 
@@ -655,23 +657,18 @@ the actual number of articles toggled is returned."
               (gnus-agent-method-p gnus-command-method))
       (gnus-agent-load-alist gnus-newsgroup-name)
       ;; First mark all undownloaded articles as undownloaded.
-      (let ((articles (append gnus-newsgroup-unreads
-                             gnus-newsgroup-marked
-                             gnus-newsgroup-dormant))
-           article)
-       (while (setq article (pop articles))
-         (unless (or (cdr (assq article gnus-agent-article-alist))
-                     (memq article gnus-newsgroup-downloadable)
-                     (memq article gnus-newsgroup-cached))
-           (push article gnus-newsgroup-undownloaded))))
+      (dolist (article (mapcar (lambda (header) (mail-header-number header))
+                              gnus-newsgroup-headers))
+       (unless (or (cdr (assq article gnus-agent-article-alist))
+                   (memq article gnus-newsgroup-downloadable)
+                   (memq article gnus-newsgroup-cached))
+         (push article gnus-newsgroup-undownloaded)))
       ;; Then mark downloaded downloadable as not-downloadable,
       ;; if you get my drift.
-      (let ((articles gnus-newsgroup-downloadable)
-           article)
-       (while (setq article (pop articles))
-         (when (cdr (assq article gnus-agent-article-alist))
-           (setq gnus-newsgroup-downloadable
-                 (delq article gnus-newsgroup-downloadable))))))))
+      (dolist (article gnus-newsgroup-downloadable)
+       (when (cdr (assq article gnus-agent-article-alist))
+         (setq gnus-newsgroup-downloadable
+               (delq article gnus-newsgroup-downloadable)))))))
 
 (defun gnus-agent-catchup ()
   "Mark all undownloaded articles as read."
@@ -1074,7 +1071,8 @@ the actual number of articles toggled is returned."
 (defun gnus-agent-save-alist (group &optional articles state dir)
   "Save the article-state alist for GROUP."
   (let ((file-name-coding-system nnmail-pathname-coding-system)
-       (pathname-coding-system nnmail-pathname-coding-system))
+       (pathname-coding-system nnmail-pathname-coding-system)
+       print-level print-length)
     (with-temp-file (if dir
                        (expand-file-name ".agentview" dir)
                      (gnus-agent-article-name ".agentview" group))