- (when (and gnus-asynchronous
- (gnus-alive-p))
- (when next
- (gnus-async-get-semaphore 'gnus-async-article-semaphore)
- (pop gnus-async-fetch-list)
- (gnus-async-release-semaphore 'gnus-async-article-semaphore))
- (let ((do-fetch next))
- (when (and (gnus-group-asynchronous-p group)
- (gnus-buffer-live-p summary)
- (or (not next)
- gnus-async-fetch-list))
- (unwind-protect
- (progn
- (gnus-async-get-semaphore 'gnus-async-article-semaphore)
- (unless next
- (setq do-fetch (not gnus-async-fetch-list))
- ;; Nix out any outstanding requests.
- (setq gnus-async-fetch-list nil)
- ;; Fill in the new list.
- (let ((n gnus-use-article-prefetch)
- (data (gnus-data-find-list article))
- d)
- (while (and (setq d (pop data))
- (if (numberp n)
- (natnump (decf n))
- n))
- (unless (or (gnus-async-prefetched-article-entry
- group (setq article (gnus-data-number d)))
- (not (natnump article)))
- ;; Not already fetched -- so we add it to the list.
- (push article gnus-async-fetch-list)))
- (setq gnus-async-fetch-list (nreverse gnus-async-fetch-list))))
-
- (when do-fetch
- (setq article (pop gnus-async-fetch-list))))
-
- (gnus-async-release-semaphore 'gnus-async-article-semaphore))
-
- (when article
- ;; We want to fetch some more articles.
- (save-excursion
- (set-buffer summary)
- (let (mark)
- (gnus-async-set-buffer)
- (goto-char (point-max))
- (setq mark (point-marker))
- (let ((nnheader-callback-function
- (gnus-make-async-article-function
- group article mark summary next))
- (nntp-server-buffer (get-buffer
- gnus-async-prefetch-article-buffer)))
- (gnus-message 7 "Prefetching article %d in group %s"
- article group)
- (gnus-request-article article group)))))))))
+ (if (not (gnus-buffer-live-p summary))
+ (gnus-async-with-semaphore
+ (setq gnus-async-fetch-list nil))
+ (when (and gnus-asynchronous
+ (gnus-alive-p))
+ (when next
+ (gnus-async-with-semaphore
+ (pop gnus-async-fetch-list)))
+ (let ((do-fetch next)
+ (do-message t)) ;(eq major-mode 'gnus-summary-mode)))
+ (when (and (gnus-group-asynchronous-p group)
+ (gnus-buffer-live-p summary)
+ (or (not next)
+ gnus-async-fetch-list))
+ (gnus-async-with-semaphore
+ (unless next
+ (setq do-fetch (not gnus-async-fetch-list))
+ ;; Nix out any outstanding requests.
+ (setq gnus-async-fetch-list nil)
+ ;; Fill in the new list.
+ (let ((n gnus-use-article-prefetch)
+ (data (gnus-data-find-list article))
+ d)
+ (while (and (setq d (pop data))
+ (if (numberp n)
+ (natnump (decf n))
+ n))
+ (unless (or (gnus-async-prefetched-article-entry
+ group (setq article (gnus-data-number d)))
+ (not (natnump article))
+ (not (funcall gnus-async-prefetch-article-p d)))
+ ;; Not already fetched -- so we add it to the list.
+ (push article gnus-async-fetch-list)))
+ (setq gnus-async-fetch-list
+ (nreverse gnus-async-fetch-list))))
+
+ (when do-fetch
+ (setq article (car gnus-async-fetch-list))))
+
+ (when (and do-fetch article)
+ ;; We want to fetch some more articles.
+ (save-excursion
+ (set-buffer summary)
+ (let (mark)
+ (gnus-async-set-buffer)
+ (goto-char (point-max))
+ (setq mark (point-marker))
+ (let ((nnheader-callback-function
+ (gnus-make-async-article-function
+ group article mark summary next))
+ (nntp-server-buffer
+ (get-buffer gnus-async-prefetch-article-buffer)))
+ (when do-message
+ (gnus-message 9 "Prefetching article %d in group %s"
+ article group))
+ (setq gnus-async-current-prefetch-group group)
+ (setq gnus-async-current-prefetch-article article)
+ (gnus-request-article article group))))))))))