Synch with Oort Gnus.
authoryamaoka <yamaoka>
Sun, 17 Nov 2002 05:12:08 +0000 (05:12 +0000)
committeryamaoka <yamaoka>
Sun, 17 Nov 2002 05:12:08 +0000 (05:12 +0000)
lisp/ChangeLog
lisp/nnimap.el

index 4b2628f..e184189 100644 (file)
@@ -1,3 +1,12 @@
+2002-11-16  Simon Josefsson  <jas@extundo.com>
+
+       * nnimap.el (nnimap-callback-callback-function):
+       (nnimap-callback-buffer): Removed, these cannot be global but must
+       be embedded into the callback.
+       (nnimap-make-callback): New.  Embedd article number, callback and
+       buffer in function.
+       (nnimap-callback, nnimap-request-article-part): Update.
+
 2002-11-15  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * mml.el (mml-preview): Bind message-this-is-mail if it is mail.
index ba0f5d5..a6530b8 100644 (file)
@@ -394,10 +394,6 @@ For example: (setq nnimap-debug \"*nnimap-debug*\")")
 (defvar nnimap-progress-chars '(?| ?/ ?- ?\\))
 (defvar nnimap-progress-how-often 20)
 (defvar nnimap-counter)
-(defvar nnimap-callback-callback-function nil
-  "Gnus callback the nnimap asynchronous callback should call.")
-(defvar nnimap-callback-buffer nil
-  "Which buffer the asynchronous article prefetch callback should work in.")
 (defvar nnimap-server-buffer-alist nil)        ;; Map server name to buffers.
 (defvar nnimap-current-server nil)     ;; Current server
 (defvar nnimap-server-buffer nil)      ;; Current servers' buffer
@@ -786,18 +782,25 @@ function is generally only called when Gnus is shutting down."
             'identity)
           (or string "")))
 
-(defun nnimap-callback ()
-  (remove-hook 'imap-fetch-data-hook 'nnimap-callback)
-  (with-current-buffer nnimap-callback-buffer
-    (insert
-     (with-current-buffer nnimap-server-buffer
-       (if (imap-capability 'IMAP4rev1)
-          ;; xxx don't just use car? alist doesn't contain
-          ;; anything else now, but it might...
-          (nth 2 (car (imap-message-get (imap-current-message) 'BODYDETAIL)))
-        (imap-message-get (imap-current-message) 'RFC822))))
-    (nnheader-ms-strip-cr)
-    (funcall nnimap-callback-callback-function t)))
+(defun nnimap-make-callback (article gnus-callback buffer)
+  "Return a callback function."
+  `(lambda ()
+     (nnimap-callback ,article ,gnus-callback ,buffer)))
+
+(defun nnimap-callback (article gnus-callback buffer)
+  (when (eq article (imap-current-message))
+    (remove-hook 'imap-fetch-data-hook
+                (nnimap-make-callback article gnus-callback buffer))
+    (with-current-buffer buffer
+      (insert
+       (with-current-buffer nnimap-server-buffer
+        (if (imap-capability 'IMAP4rev1)
+            ;; xxx don't just use car? alist doesn't contain
+            ;; anything else now, but it might...
+            (nth 2 (car (imap-message-get article 'BODYDETAIL)))
+          (imap-message-get article 'RFC822))))
+      (nnheader-ms-strip-cr)
+      (funcall gnus-callback t))))
 
 (defun nnimap-request-article-part (article part prop &optional
                                            group server to-buffer detail)
@@ -828,9 +831,10 @@ function is generally only called when Gnus is shutting down."
                                                   gnus-newsgroup-name)
                                       (imap-error-text nnimap-server-buffer))
                    (cons group article)))))
-         (add-hook 'imap-fetch-data-hook 'nnimap-callback)
-         (setq nnimap-callback-callback-function nnheader-callback-function
-               nnimap-callback-buffer nntp-server-buffer)
+         (add-hook 'imap-fetch-data-hook
+                   (nnimap-make-callback article
+                                         nnheader-callback-function
+                                         nntp-server-buffer))
          (imap-fetch-asynch article part nil nnimap-server-buffer)
          (cons group article))))))