*** empty log message ***
[gnus] / lisp / gnus-async.el
index ee3fb8d..e880fa4 100644 (file)
@@ -1,7 +1,7 @@
 ;;; gnus-async.el --- asynchronous support for Gnus
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
 
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
 
 ;; This file is part of GNU Emacs.
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
 (require 'gnus)
 (require 'gnus-sum)
 (require 'nntp)
@@ -50,7 +52,7 @@ if t, prefetch as many articles as possible."
 
 (defcustom gnus-prefetched-article-deletion-strategy '(read exit)
   "List of symbols that say when to remove articles from the prefetch buffer.
-Possible values in this list are `read', which means that 
+Possible values in this list are `read', which means that
 articles are removed as they are read, and `exit', which means
 that all articles belonging to a group are removed on exit
 from that group."
@@ -75,6 +77,9 @@ It should return non-nil if the article is to be prefetched."
 (defvar gnus-async-article-alist nil)
 (defvar gnus-async-article-semaphore '(nil))
 (defvar gnus-async-fetch-list nil)
+(defvar gnus-async-hashtb nil)
+(defvar gnus-async-current-prefetch-group nil)
+(defvar gnus-async-current-prefetch-article nil)
 
 (defvar gnus-async-prefetch-headers-buffer " *Async Prefetch Headers*")
 (defvar gnus-async-header-prefetched nil)
@@ -104,9 +109,8 @@ It should return non-nil if the article is to be prefetched."
      (gnus-async-release-semaphore 'gnus-async-article-semaphore)))
 
 (put 'gnus-asynch-with-semaphore 'lisp-indent-function 0)
-(put 'gnus-asynch-with-semaphore 'lisp-indent-hook 0)
 (put 'gnus-asynch-with-semaphore 'edebug-form-spec '(body))
-       
+
 ;;;
 ;;; Article prefetch
 ;;;
@@ -115,11 +119,18 @@ It should return non-nil if the article is to be prefetched."
 (defun gnus-async-close ()
   (gnus-kill-buffer gnus-async-prefetch-article-buffer)
   (gnus-kill-buffer gnus-async-prefetch-headers-buffer)
-  (setq gnus-async-article-alist nil
+  (setq gnus-async-hashtb nil
+       gnus-async-article-alist nil
        gnus-async-header-prefetched nil))
 
 (defun gnus-async-set-buffer ()
-  (nnheader-set-temp-buffer gnus-async-prefetch-article-buffer t))
+  (nnheader-set-temp-buffer gnus-async-prefetch-article-buffer t)
+  (unless gnus-async-hashtb
+    (setq gnus-async-hashtb (gnus-make-hashtable 1023))))
+
+(defun gnus-async-halt-prefetch ()
+  "Stop prefetching."
+  (setq gnus-async-fetch-list nil))
 
 (defun gnus-async-prefetch-next (group article summary)
   "Possibly prefetch several articles starting with the article after ARTICLE."
@@ -135,7 +146,7 @@ It should return non-nil if the article is to be prefetched."
              ;; do this, which leads to slightly slower article
              ;; buffer display.
              (gnus-async-prefetch-article group next summary)
-           (run-with-idle-timer 
+           (run-with-idle-timer
             0.1 nil 'gnus-async-prefetch-article group next summary)))))))
 
 (defun gnus-async-prefetch-article (group article summary &optional next)
@@ -148,7 +159,8 @@ It should return non-nil if the article is to be prefetched."
       (when next
        (gnus-async-with-semaphore
         (pop gnus-async-fetch-list)))
-      (let ((do-fetch next))
+      (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)
@@ -177,7 +189,7 @@ It should return non-nil if the article is to be prefetched."
 
           (when do-fetch
             (setq article (car gnus-async-fetch-list))))
-    
+
          (when (and do-fetch article)
            ;; We want to fetch some more articles.
            (save-excursion
@@