Import No Gnus v0.3.
[elisp/gnus.git-] / lisp / gnus-async.el
index f3a43c9..1b0074d 100644 (file)
 (require 'gnus-sum)
 (require 'nntp)
 
+(eval-when-compile
+  (when (featurep 'xemacs)
+    (require 'timer-funcs)))
+
 (defgroup gnus-asynchronous nil
   "Support for asynchronous operations."
   :group 'gnus)
@@ -269,28 +273,29 @@ It should return non-nil if the article is to be prefetched."
          (nntp-server-buffer (current-buffer))
          (nntp-have-messaged nil)
          (tries 0))
-      (condition-case nil
-         ;; FIXME: we could stop waiting after some
-         ;; timeout, but this is the wrong place to do it.
-         ;; rather than checking time-spent-waiting, we
-         ;; should check time-since-last-output, which
-         ;; needs to be done in nntp.el.
-         (while (eq article gnus-async-current-prefetch-article)
-           (incf tries)
-           (when (nntp-accept-process-output proc)
-             (setq tries 0))
-           (when (and (not nntp-have-messaged)
-                      (= tries 3))
-             (gnus-message 5 "Waiting for async article...")
-             (setq nntp-have-messaged t)))
-       (quit
-        ;; if the user interrupted on a slow/hung connection,
-        ;; do something friendly.
-        (when (> tries 3)
-          (setq gnus-async-current-prefetch-article nil))
-        (signal 'quit nil)))
-      (when nntp-have-messaged
-       (gnus-message 5 "")))))
+      (when proc
+       (condition-case nil
+           ;; FIXME: we could stop waiting after some
+           ;; timeout, but this is the wrong place to do it.
+           ;; rather than checking time-spent-waiting, we
+           ;; should check time-since-last-output, which
+           ;; needs to be done in nntp.el.
+           (while (eq article gnus-async-current-prefetch-article)
+             (incf tries)
+             (when (nntp-accept-process-output proc)
+               (setq tries 0))
+             (when (and (not nntp-have-messaged)
+                        (= tries 3))
+               (gnus-message 5 "Waiting for async article...")
+               (setq nntp-have-messaged t)))
+         (quit
+          ;; if the user interrupted on a slow/hung connection,
+          ;; do something friendly.
+          (when (> tries 3)
+            (setq gnus-async-current-prefetch-article nil))
+          (signal 'quit nil)))
+       (when nntp-have-messaged
+         (gnus-message 5 ""))))))
 
 (defun gnus-async-delete-prefetched-entry (entry)
   "Delete ENTRY from buffer and alist."
@@ -306,13 +311,11 @@ It should return non-nil if the article is to be prefetched."
   "Remove all articles belonging to GROUP from the prefetch buffer."
   (when (and (gnus-group-asynchronous-p group)
             (memq 'exit gnus-prefetched-article-deletion-strategy))
-    (let ((alist gnus-async-article-alist))
-      (save-excursion
-       (gnus-async-set-buffer)
-       (while alist
-         (when (equal group (nth 3 (car alist)))
-           (gnus-async-delete-prefetched-entry (car alist)))
-         (pop alist))))))
+    (save-excursion
+      (gnus-async-set-buffer)
+      (dolist (entry gnus-async-article-alist)
+       (when (equal group (nth 3 entry))
+         (gnus-async-delete-prefetched-entry entry))))))
 
 (defun gnus-async-prefetched-article-entry (group article)
   "Return the entry for ARTICLE in GROUP iff it has been prefetched."
@@ -374,4 +377,5 @@ It should return non-nil if the article is to be prefetched."
 
 (provide 'gnus-async)
 
+;;; arch-tag: fee61de5-3ea2-4de6-8578-2f90ce89391d
 ;;; gnus-async.el ends here