From: okada Date: Mon, 21 Jan 2002 19:23:36 +0000 (+0000) Subject: * wl-message.el (wl-message-buffer-prefetch-next): Rewrite. X-Git-Tag: wl-2_9_6~22 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d2133eda8328b568d49286e02b9c43112456f7e;p=elisp%2Fwanderlust.git * wl-message.el (wl-message-buffer-prefetch-next): Rewrite. (wl-message-buffer-prefetch-subr): Rewrite. --- diff --git a/wl/ChangeLog b/wl/ChangeLog index 18c14e1..b2c9771 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,8 @@ +2002-01-22 Kenichi OKADA + + * wl-message.el (wl-message-buffer-prefetch-next): Rewrite. + (wl-message-buffer-prefetch-subr): Rewrite. + 2002-01-21 Yoichi NAKAYAMA * wl-vars.el (wl-draft-cite-function): Moved from `wl-draft.el'. diff --git a/wl/wl-message.el b/wl/wl-message.el index 26e1f51..863c1ad 100644 --- a/wl/wl-message.el +++ b/wl/wl-message.el @@ -33,6 +33,7 @@ (require 'wl-highlight) (require 'elmo) (require 'elmo-mime) +(require 'timer) (eval-when-compile (require 'wl-mime) @@ -548,56 +549,59 @@ 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 count &optional - summary charset) +(defun wl-message-buffer-prefetch-next (folder number &optional + count summary charset) (if (wl-message-buffer-prefetch-p folder) - (with-current-buffer (or summary (get-buffer wl-summary-buffer-name)) - (let* ((next (funcall wl-message-buffer-prefetch-get-next-function - number))) - (when (and next (wl-message-buffer-prefetch-p folder next)) - (if (not (fboundp 'run-with-idle-timer)) - (when (sit-for wl-message-buffer-prefetch-idle-time) - (wl-message-buffer-prefetch - folder next count summary charset)) - (unless wl-message-buffer-prefetch-timer - (setq wl-message-buffer-prefetch-timer - (run-with-idle-timer - wl-message-buffer-prefetch-idle-time - nil - 'wl-message-buffer-prefetch - folder next count summary charset))))))))) - -(defun wl-message-buffer-prefetch (folder number count summary charset) - (setq wl-message-buffer-prefetch-timer nil) - (if (and (numberp count) - (>= (setq count (- count 1)) 0)) - (if (buffer-live-p summary) - (save-excursion - (set-buffer summary) - (if (string= (elmo-folder-name-internal folder) - (wl-summary-buffer-folder-name)) - (let* ((message-id (elmo-message-field folder number 'message-id)) - (wl-mime-charset charset) + (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)) +;;; cannot use for the bug of fsf-compat package (1.09). +;;; (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 (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) - number message-id)) - (hit (wl-message-buffer-cache-hit key)) - result time1 time2 sec micro) + 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)) - (wl-message-buffer-cache-sort - (wl-message-buffer-cache-entry-make key hit)) - (let* ((size (elmo-message-field folder number 'size))) - (when (or (elmo-message-file-p folder number) - (not - (and (integerp size) - elmo-message-fetch-threshold - (>= size - elmo-message-fetch-threshold)))) - ;;(not (elmo-file-cache-exists-p message-id))))) + (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..." number)) - (setq result (wl-message-buffer-display folder number + (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)) @@ -605,15 +609,21 @@ Returns non-nil if bottom of message." (setq micro (- (nth 2 time2)(nth 2 time1))) (setq micro (+ micro (* 1000000 sec))) (message "Prefetching %d...done(%f msec)." - number - (/ micro 1000.0)))))) - (wl-message-buffer-prefetch-next - folder number count summary charset))))) - (when wl-message-buffer-prefetch-debug - (message "Buffer Cached Messages %S" - (mapcar '(lambda (cache) - (nth 1 (car cache))) - wl-message-buffer-cache))))) + 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" + (mapcar '(lambda (cache) + (nth 1 (car cache))) + wl-message-buffer-cache))) )))) (defvar wl-message-button-map (make-sparse-keymap))