* wl-message.el (wl-message-buffer-prefetch-clear-timer): New function.
authorokada <okada>
Tue, 22 Jan 2002 09:57:00 +0000 (09:57 +0000)
committerokada <okada>
Tue, 22 Jan 2002 09:57:00 +0000 (09:57 +0000)
(wl-message-buffer-prefetch-set-timer): New function.
(wl-message-buffer-prefetch-get-next): New function.
(wl-message-buffer-prefetch): New function.
(wl-message-buffer-prefetch-next): Rewrite.
(wl-message-buffer-prefetch-subr): Rewrite.
* wl-vars.el (wl-auto-prefetch-first): New variable.
* wl-summary.el (wl-summary-goto-folder-subr): Call
`wl-message-buffer-prefetch' if `wl-auto-prefetch-first' is non-nil.

wl/ChangeLog
wl/wl-message.el
wl/wl-summary.el
wl/wl-vars.el

index 6e19e9c..d37ce6f 100644 (file)
@@ -1,5 +1,17 @@
 2002-01-22  Kenichi OKADA  <okada@opaopa.org>
 
+       * wl-message.el (wl-message-buffer-prefetch-clear-timer): New function.
+       (wl-message-buffer-prefetch-set-timer): New function.
+       (wl-message-buffer-prefetch-get-next): New function.
+       (wl-message-buffer-prefetch): New function.
+       (wl-message-buffer-prefetch-next): Rewrite.
+       (wl-message-buffer-prefetch-subr): Rewrite.
+       * wl-vars.el (wl-auto-prefetch-first): New variable.
+       * wl-summary.el (wl-summary-goto-folder-subr): Call
+       `wl-message-buffer-prefetch' if `wl-auto-prefetch-first' is non-nil.
+
+2002-01-22  Kenichi OKADA  <okada@opaopa.org>
+
        * wl-score.el (wl-summary-score-update-all-lines): Do not call
        `wl-summary-unread-message-hook'.
 
index 05dc75a..53b36f5 100644 (file)
@@ -549,96 +549,138 @@ Returns non-nil if bottom of message."
                                wl-message-buffer-prefetch-folder-list))
        (t wl-message-buffer-prefetch-folder-list))))
 
-(defun wl-message-buffer-prefetch-next (folder number &optional
-                                              count summary charset)
-  (if (wl-message-buffer-prefetch-p folder)
-      (if (not (fboundp 'run-with-idle-timer))
-         (when (sit-for wl-message-buffer-prefetch-idle-time)
-           (wl-message-buffer-prefetch-subr
-            folder number (or count 1) summary charset))
+(defsubst wl-message-buffer-prefetch-clear-timer ()
 ;;;     cannot use for the bug of fsf-compat package (1.09).
 ;;;    (cancel-function-timers 'wl-message-buffer-prefetch-subr)
-       (if (featurep 'xemacs)
-           (let ((p itimer-list))
-             (while (car p)
-               (if (eq 'wl-message-buffer-prefetch-subr
-                       (itimer-function (car p)))
-                   (delete-itimer (car p)))
-               (setq p (cdr p))))
-         ;; FSF Emacs is correct
-         (cancel-function-timers 'wl-message-buffer-prefetch-subr))
-       (run-with-idle-timer
-        wl-message-buffer-prefetch-idle-time
-        nil
-        'wl-message-buffer-prefetch-subr
-        folder number (or count 1) summary charset))))
-
-(defun wl-message-buffer-prefetch-subr (folder number count summary charset)
+  (if (fboundp 'run-with-idle-timer)
+      (if (featurep 'xemacs)
+         (let ((p itimer-list))
+           (while (car p)
+             (if (eq 'wl-message-buffer-prefetch-subr
+                     (itimer-function (car p)))
+                 (delete-itimer (car p)))
+             (setq p (cdr p))))
+       ;; FSF Emacs is correct
+       (cancel-function-timers 'wl-message-buffer-prefetch-subr))))
+
+(defsubst wl-message-buffer-prefetch-set-timer (folder number count
+                                                      summary charset)
+  (if (not (fboundp 'run-with-idle-timer))
+      (when (sit-for wl-message-buffer-prefetch-idle-time)
+       (wl-message-buffer-prefetch-subr
+        folder number count summary charset))
+    (run-with-idle-timer
+     wl-message-buffer-prefetch-idle-time
+     nil
+     'wl-message-buffer-prefetch-subr
+     folder number count summary charset)))
+
+(defun wl-message-buffer-prefetch-get-next (folder number summary)
   (if (buffer-live-p summary)
       (with-current-buffer summary
-       ;(set-buffer summary)
        (let ((next (funcall wl-message-buffer-prefetch-get-next-function
                             number)))
-         (if (and next (not (wl-message-buffer-prefetch-p folder next)))
-             ;; for Multi folder
-             (wl-message-buffer-prefetch-subr folder next count summary charset)
-           (if (and next
-                    (numberp count)
-                    (>= (setq count (- count 1)) 0)
-                    (string= (elmo-folder-name-internal folder)
-                             (wl-summary-buffer-folder-name)))
-               (let* ((wl-mime-charset      charset)
-                      (default-mime-charset charset)
-                      (message-id (elmo-message-field folder next 'message-id))
-                      (key (list (elmo-folder-name-internal folder)
-                                 next message-id))
-                      (hit (wl-message-buffer-cache-hit key)))
-                 (when wl-message-buffer-prefetch-debug
-                   (message "%S: count %S, hit %S" next count hit))
-                 (if (and hit (buffer-live-p hit))
-                     (progn
-                       (wl-message-buffer-cache-sort
-                        (wl-message-buffer-cache-entry-make key hit))
-                       (wl-message-buffer-prefetch-subr folder next count summary charset))
-                   (let* ((size (elmo-message-field folder next 'size))
-                          result time1 time2 sec micro)
-                     (when (or (elmo-message-file-p folder next)
-                               (not (and (integerp size)
-                                         elmo-message-fetch-threshold
-                                         (>= size
-                                             elmo-message-fetch-threshold))))
-                       (when wl-message-buffer-prefetch-debug
-                         (setq time1 (current-time))
-                         (message "Prefetching %d..." next))
-                       (setq result (wl-message-buffer-display folder next
-                                                               'mime nil 'unread))
-                       (when wl-message-buffer-prefetch-debug
-                         (setq time2 (current-time))
-                         (setq sec  (- (nth 1 time2)(nth 1 time1)))
-                         (setq micro (- (nth 2 time2)(nth 2 time1)))
-                         (setq micro (+ micro (* 1000000 sec)))
-                         (message "Prefetching %d...done(%f msec)."
-                                  next
-                                  (/ micro 1000.0))
-                         (sit-for 0))
-                       ;; set next prefetch
-                       (wl-message-buffer-prefetch-next
-                        folder next count summary charset)
-                       (sit-for 0)
-                       ;; success prefetch
-                       ))))))
-         ;; finish prefetch
-         (when wl-message-buffer-prefetch-debug
-           (message "Buffer Cached Messages: %s"
-                    (mapconcat
-                     '(lambda (cache)
-                        (if (string=
-                             (nth 0 (car cache))
-                             (elmo-folder-name-internal folder))
-                            (format "%d"
-                                    (nth 1 (car cache)))
-                          (format "*%d" (nth 1 (car cache)))))
-                     wl-message-buffer-cache " "))) ))))
+         (if next
+             (if (wl-message-buffer-prefetch-p folder next)
+                 next
+               ;; for Multi folder
+               (wl-message-buffer-prefetch-get-next
+                folder next summary)))))))
+
+(defun wl-message-buffer-prefetch (folder number &optional
+                                         count summary charset)
+  (let* ((summary (or summary (get-buffer wl-summary-buffer-name))))
+    (when (wl-message-buffer-prefetch-p folder)
+      (wl-message-buffer-prefetch-clear-timer)
+      (wl-message-buffer-prefetch-set-timer
+       folder
+       number
+       (or count 1)
+       summary
+       charset))))
+
+(defun wl-message-buffer-prefetch-next (folder number &optional
+                                              count summary charset)
+  (let* ((summary (or summary (get-buffer wl-summary-buffer-name)))
+        (next (wl-message-buffer-prefetch-get-next folder number summary)))
+    (when (wl-message-buffer-prefetch-p folder)
+      (wl-message-buffer-prefetch-clear-timer)
+      (wl-message-buffer-prefetch-set-timer
+       folder
+       next
+       (or count 1)
+       summary
+       charset))))
+
+(defun wl-message-buffer-prefetch-subr (folder number count summary charset)
+  (if (buffer-live-p summary)
+      (with-current-buffer summary
+       (if (and number
+                (numberp count)
+                (>= (setq count (- count 1)) 0)
+                (string= (elmo-folder-name-internal folder)
+                         (wl-summary-buffer-folder-name)))
+           (let* ((wl-mime-charset      charset)
+                  (default-mime-charset charset)
+                  (message-id (elmo-message-field folder number 'message-id))
+                  (key (list (elmo-folder-name-internal folder)
+                             number message-id))
+                  (hit (wl-message-buffer-cache-hit key)))
+             (when wl-message-buffer-prefetch-debug
+               (message "%S: count %S, hit %S" number count hit))
+             (if (and hit (buffer-live-p hit))
+                 (progn
+                   (wl-message-buffer-cache-sort
+                    (wl-message-buffer-cache-entry-make key hit))
+                   (wl-message-buffer-prefetch-subr
+                    folder
+                    (wl-message-buffer-prefetch-get-next
+                     folder number summary)
+                    count summary charset))
+               (let* ((size (elmo-message-field folder number 'size))
+                      result time1 time2 sec micro)
+                 (when (or (elmo-message-file-p folder number)
+                           (not (and (integerp size)
+                                     elmo-message-fetch-threshold
+                                     (>= size
+                                         elmo-message-fetch-threshold))))
+                   (when wl-message-buffer-prefetch-debug
+                     (setq time1 (current-time))
+                     (message "Prefetching %d..." number))
+                   (setq result (wl-message-buffer-display
+                                 folder number 'mime nil 'unread))
+                   (when wl-message-buffer-prefetch-debug
+                     (setq time2 (current-time))
+                     (setq sec  (- (nth 1 time2)(nth 1 time1)))
+                     (setq micro (- (nth 2 time2)(nth 2 time1)))
+                     (setq micro (+ micro (* 1000000 sec)))
+                     (message "Prefetching %d...done(%f msec)."
+                              number
+                              (/ micro 1000.0))
+                     (sit-for 0))
+                   ;; set next prefetch
+                   (wl-message-buffer-prefetch-set-timer
+                    folder
+                    (wl-message-buffer-prefetch-get-next
+                     folder number summary)
+                    count summary charset)
+                   ;(wl-message-buffer-prefetch-next
+                   ;folder next count summary charset)
+                   (sit-for 0)
+                   ;; success prefetch
+                   )))))
+       ;; finish prefetch
+       (when wl-message-buffer-prefetch-debug
+         (message "Buffer Cached Messages: %s"
+                  (mapconcat
+                   '(lambda (cache)
+                      (if (string=
+                           (nth 0 (car cache))
+                           (elmo-folder-name-internal folder))
+                          (format "%d"
+                                  (nth 1 (car cache)))
+                        (format "*%d" (nth 1 (car cache)))))
+                   wl-message-buffer-cache " "))) )))
 
 (defvar wl-message-button-map (make-sparse-keymap))
 
index 9b49316..07f53fb 100644 (file)
@@ -2602,6 +2602,11 @@ If ARG, without confirm."
                       ;; wl-auto-select-first is non-nil and
                       ;; unreadp is non-nil but not important
                       (setq retval 'disp-msg))
+                     ((and wl-auto-prefetch-first
+                           (wl-summary-auto-select-msg-p unreadp))
+                      ;; wl-auto-select-first is non-nil and
+                      ;; unreadp is non-nil but not important
+                      (setq retval 'prefetch-msg))
                      ((not (wl-summary-auto-select-msg-p unreadp))
                       ;; unreadp is nil or important
                       (setq retval 'more-next))))
@@ -2627,6 +2632,13 @@ If ARG, without confirm."
                (wl-highlight-summary (point-min) (point-max))))
          (if (eq retval 'disp-msg)
              (wl-summary-redisplay))
+         (if (eq retval 'prefetch-msg)
+             (wl-message-buffer-prefetch
+              folder
+              (wl-summary-message-number)
+              wl-message-buffer-prefetch-depth
+              (current-buffer)
+              wl-summary-buffer-mime-charset))
          (if mes (message "%s" mes))
          (if (and interactive wl-summary-recenter)
              (recenter (/ (- (window-height) 2) 2))))))
index 9382d3a..bca224b 100644 (file)
@@ -1666,6 +1666,12 @@ It uses wl-summary-move-direction-downward as a direction flag."
   :group 'wl-pref
   :group 'wl-setting)
 
+(defcustom wl-auto-prefetch-first nil
+  "*If non-nil, prefetch selected first message when enter summary."
+  :type 'boolean
+  :group 'wl-pref
+  :group 'wl-setting)
+
 (defcustom wl-auto-select-next nil
   "*If non-nil, offer to go to the next folder from the end of the previous.
 If the value is the symbol `unread', go to the next folder