From: teranisi Date: Mon, 23 Apr 2001 06:20:39 +0000 (+0000) Subject: * elmo-shimbun.el (elmo-shimbun-check-interval): New user option. X-Git-Tag: wl-2_6-root^3~34 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=6d5dd8249129765547679cea0d1f6465a1dc2141;p=elisp%2Fwanderlust.git * elmo-shimbun.el (elmo-shimbun-check-interval): New user option. (elmo-shimbun-headers-cache): New internal variable. (elmo-shimbun-headers-cache-header-list): New inline function. (elmo-shimbun-headers-cache-set-header-list): Ditto. (elmo-shimbun-headers-cache-header-hash): Ditto. (elmo-shimbun-headers-cache-set-header-hash): Ditto. (elmo-shimbun-headers-cache-last-check): Ditto. (elmo-shimbun-headers-cache-set-last-check): Ditto. (elmo-shimbun-lapse-seconds): Ditto. (elmo-shimbun-headers-cache-check-p): Ditto. (elmo-shimbun-get-headers): New function. (elmo-folder-open-internal): Call it. (elmo-quit): Define (Clear headers-cache). * wl-summary.el (wl-summary-set-message-buffer-or-redisplay): Check wl-message-buffer lives before set-buffer. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index ba9dbbd..a034169 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,19 @@ +2001-04-23 Yuuichi Teranishi + + * elmo-shimbun.el (elmo-shimbun-check-interval): New user option. + (elmo-shimbun-headers-cache): New internal variable. + (elmo-shimbun-headers-cache-header-list): New inline function. + (elmo-shimbun-headers-cache-set-header-list): Ditto. + (elmo-shimbun-headers-cache-header-hash): Ditto. + (elmo-shimbun-headers-cache-set-header-hash): Ditto. + (elmo-shimbun-headers-cache-last-check): Ditto. + (elmo-shimbun-headers-cache-set-last-check): Ditto. + (elmo-shimbun-lapse-seconds): Ditto. + (elmo-shimbun-headers-cache-check-p): Ditto. + (elmo-shimbun-get-headers): New function. + (elmo-folder-open-internal): Call it. + (elmo-quit): Define (Clear headers-cache). + 2001-04-18 Yuuichi Teranishi * elmo-nntp.el (elmo-folder-initialize): Fixed typo (folder->name). diff --git a/elmo/elmo-shimbun.el b/elmo/elmo-shimbun.el index b16c582..11d3169 100644 --- a/elmo/elmo-shimbun.el +++ b/elmo/elmo-shimbun.el @@ -32,11 +32,94 @@ (require 'elmo-map) (require 'shimbun) +(defcustom elmo-shimbun-check-interval 60 + "*Check interval for shimbun." + :type 'integer + :group 'elmo) + +;; Internal variable. +;; A list of elements like: +;; ("server.group" . [header-list header-hash last-check]). +(defvar elmo-shimbun-headers-cache nil) + (eval-and-compile (luna-define-class elmo-shimbun-folder (elmo-map-folder) (shimbun headers header-hash group)) (luna-define-internal-accessors 'elmo-shimbun-folder)) +(defsubst elmo-shimbun-headers-cache-header-list (entry) + (aref entry 0)) + +(defsubst elmo-shimbun-headers-cache-set-header-list (entry list) + (aset entry 0 list)) + +(defsubst elmo-shimbun-headers-cache-header-hash (entry) + (aref entry 1)) + +(defsubst elmo-shimbun-headers-cache-set-header-hash (entry hash) + (aset entry 1 hash)) + +(defsubst elmo-shimbun-headers-cache-last-check (entry) + (aref entry 2)) + +(defsubst elmo-shimbun-headers-cache-set-last-check (entry time) + (aset entry 2 time)) + +(defsubst elmo-shimbun-lapse-seconds (time) + (let ((now (current-time))) + (+ (* (- (car now) (car time)) 65536) + (- (nth 1 now) (nth 1 time))))) + +(defsubst elmo-shimbun-headers-cache-check-p (cache) + (or (null (elmo-shimbun-headers-cache-last-check cache)) + (and (elmo-shimbun-headers-cache-last-check cache) + (> (elmo-shimbun-lapse-seconds + (elmo-shimbun-headers-cache-last-check cache)) + elmo-shimbun-check-interval)))) + +(defun elmo-shimbun-get-headers (folder) + (shimbun-open-group + (elmo-shimbun-folder-shimbun-internal folder) + (elmo-shimbun-folder-group-internal folder)) + (let* ((shimbun (elmo-shimbun-folder-shimbun-internal folder)) + (key (concat (shimbun-server-internal shimbun) + "." (shimbun-current-group-internal shimbun))) + (elmo-hash-minimum-size 0) + entry headers hash done) + (if (setq entry (cdr (assoc key elmo-shimbun-headers-cache))) + (unless (elmo-shimbun-headers-cache-check-p entry) + (elmo-shimbun-folder-set-headers-internal + folder + (elmo-shimbun-headers-cache-header-list entry)) + (elmo-shimbun-folder-set-header-hash-internal + folder + (elmo-shimbun-headers-cache-header-hash entry)) + (elmo-shimbun-headers-cache-header-list entry) + (setq done t))) + (unless done + (setq headers + (elmo-shimbun-folder-set-headers-internal + folder (shimbun-headers + (elmo-shimbun-folder-shimbun-internal folder)))) + (setq hash + (elmo-shimbun-folder-set-header-hash-internal + folder + (elmo-make-hash + (length (elmo-shimbun-folder-headers-internal folder))))) + ;; Set up header hash. + (dolist (header (elmo-shimbun-folder-headers-internal folder)) + (elmo-set-hash-val + (shimbun-header-id header) header + (elmo-shimbun-folder-header-hash-internal folder))) + (if entry + (progn + (elmo-shimbun-headers-cache-set-header-list entry headers) + (elmo-shimbun-headers-cache-set-header-hash entry hash) + (elmo-shimbun-headers-cache-set-last-check entry (current-time))) + (setq elmo-shimbun-headers-cache + (cons (cons key (vector headers hash (current-time))) + elmo-shimbun-headers-cache)))))) + (luna-define-method elmo-folder-initialize ((folder elmo-shimbun-folder) name) @@ -57,20 +140,7 @@ (luna-define-method elmo-folder-open-internal :before ((folder elmo-shimbun-folder)) (when (elmo-folder-plugged-p folder) - (shimbun-open-group - (elmo-shimbun-folder-shimbun-internal folder) - (elmo-shimbun-folder-group-internal folder)) - (elmo-shimbun-folder-set-headers-internal - folder (shimbun-headers - (elmo-shimbun-folder-shimbun-internal folder))) - (elmo-shimbun-folder-set-header-hash-internal - folder - (elmo-make-hash (length (elmo-shimbun-folder-headers-internal folder)))) - ;; Set up header hash. - (dolist (header (elmo-shimbun-folder-headers-internal folder)) - (elmo-set-hash-val - (shimbun-header-id header) header - (elmo-shimbun-folder-header-hash-internal folder))))) + (elmo-shimbun-get-headers folder))) (luna-define-method elmo-folder-close-internal :after ((folder elmo-shimbun-folder)) @@ -252,7 +322,10 @@ (luna-define-method elmo-folder-mark-as-read ((folder elmo-shimbun-folder) numbers) t) - + +(luna-define-method elmo-quit ((folder elmo-shimbun-folder)) + (setq elmo-shimbun-headers-cache nil)) + (require 'product) (product-provide (provide 'elmo-shimbun) (require 'elmo-version)) diff --git a/wl/ChangeLog b/wl/ChangeLog index 116fc41..582b5c0 100644 --- a/wl/ChangeLog +++ b/wl/ChangeLog @@ -1,3 +1,8 @@ +2001-04-23 Yuuichi Teranishi + + * wl-summary.el (wl-summary-set-message-buffer-or-redisplay): + Check wl-message-buffer lives before set-buffer. + 2001-04-07 Masahiro MURATA * wl-expire.el (wl-summary-expire): Fixed problem that do not expire diff --git a/wl/wl-summary.el b/wl/wl-summary.el index 92b5683..94534bd 100644 --- a/wl/wl-summary.el +++ b/wl/wl-summary.el @@ -4570,7 +4570,8 @@ Return t if message exists." (if (wl-summary-no-mime-p folder) (wl-summary-redisplay-no-mime folder number) (wl-summary-redisplay-internal folder number)) - (set-buffer wl-message-buffer) + (when (buffer-live-p wl-message-buffer) + (set-buffer wl-message-buffer)) nil))) (defun wl-summary-target-mark-forward (&optional arg)