From: hmurata Date: Tue, 8 May 2001 01:38:25 +0000 (+0000) Subject: * elmo.el (elmo-message-fetch): Define. X-Git-Tag: wl-2_6-root^3~21 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1a1971dd79281eba688a1b485dc93d31a378dcf;p=elisp%2Fwanderlust.git * elmo.el (elmo-message-fetch): Define. (elmo-message-fetch-with-cache-process): New generic method. (elmo-message-fetch-internal): New generic method. * elmo-archive.el (elmo-message-fetch-internal): Define. (elmo-message-fetch): Eliminated. * elmo-localdir.el (elmo-message-fetch-internal): Define. (elmo-message-fetch): Eliminated. * elmo-map.el (elmo-map-message-fetch): Eliminated optional argument OUTBUF. (elmo-message-fetch-internal): Define (Renamed from `elmo-message-fetch'). * elmo-cache.el (elmo-message-fetch-with-cache-process): Define. (elmo-map-message-fetch): Merged with elmo-cache-folder-map-message-fetch. * elmo-mark.el (elmo-message-fetch-with-cache-process): Define. (elmo-map-message-fetch): Merged with `elmo-mark-folder-map-message-fetch'. * elmo-maildir.el (elmo-map-message-fetch): Rewrite. * elmo-nmz.el (elmo-map-message-fetch): Ditto. * elmo-shimbun.el (elmo-map-message-fetch): Ditto. * elmo-net.el (elmo-message-fetch-plugged): Remove cache process. (elmo-message-fetch-unplugged): New generic method. (elmo-message-fetch-internal): Remove cache process (Renamed from `elmo-message-fetch'). * elmo-nntp.el (elmo-message-fetch-with-cache-process): Define. (elmo-message-fetch): Eliminated. (elmo-message-fetch-unplugged): Ditto. * elmo-imap4.el (elmo-message-fetch-unplugged): Remove cache process. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 90de14a..99bdc90 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,9 +1,48 @@ +2001-05-08 Hiroya Murata + + * elmo.el (elmo-message-fetch): Define. + (elmo-message-fetch-with-cache-process): New generic method. + (elmo-message-fetch-internal): New generic method. + + * elmo-archive.el (elmo-message-fetch-internal): Define. + (elmo-message-fetch): Eliminated. + + * elmo-localdir.el (elmo-message-fetch-internal): Define. + (elmo-message-fetch): Eliminated. + + * elmo-map.el (elmo-map-message-fetch): Eliminated optional + argument OUTBUF. + (elmo-message-fetch-internal): Define (Renamed from `elmo-message-fetch'). + + * elmo-cache.el (elmo-message-fetch-with-cache-process): Define. + (elmo-map-message-fetch): Merged with elmo-cache-folder-map-message-fetch. + + * elmo-mark.el (elmo-message-fetch-with-cache-process): Define. + (elmo-map-message-fetch): Merged with `elmo-mark-folder-map-message-fetch'. + + * elmo-maildir.el (elmo-map-message-fetch): Rewrite. + + * elmo-nmz.el (elmo-map-message-fetch): Ditto. + + * elmo-shimbun.el (elmo-map-message-fetch): Ditto. + + * elmo-net.el (elmo-message-fetch-plugged): Remove cache process. + (elmo-message-fetch-unplugged): New generic method. + (elmo-message-fetch-internal): Remove cache process (Renamed from + `elmo-message-fetch'). + + * elmo-nntp.el (elmo-message-fetch-with-cache-process): Define. + (elmo-message-fetch): Eliminated. + (elmo-message-fetch-unplugged): Ditto. + + * elmo-imap4.el (elmo-message-fetch-unplugged): Remove cache process. + 2001-05-02 Hiroya Murata * elmo-multi.el (elmo-multi-folder-append-msgdb): Fixed structure of `to-be-deleted' from number-alist to number-list. -2001-04-26 Hiroya Murata +2001-04-26 Hiroya Murata * elmo-pipe.el (elmo-folder-unmark-important): Fixed typo. (elmo-folder-mark-as-important): Ditto. @@ -22,7 +61,7 @@ * elmo.el (elmo-generic-folder-append-msgdb): Ditto. -2001-04-24 Hiroya Murata +2001-04-24 Hiroya Murata * elmo-util.el (elmo-list-subdirectories-1): New function. (elmo-list-subdirectories): Use `elmo-list-subdirectories-1'. diff --git a/elmo/elmo-archive.el b/elmo/elmo-archive.el index 6d3f891..e6b768e 100644 --- a/elmo/elmo-archive.el +++ b/elmo/elmo-archive.el @@ -539,16 +539,10 @@ TYPE specifies the archiver's symbol." (elmo-archive-call-method method args t)) (elmo-delete-cr-buffer))))) -(luna-define-method elmo-message-fetch ((folder elmo-archive-folder) - number strategy &optional section - outbuf unseen) - (if outbuf - (with-current-buffer outbuf - (elmo-archive-message-fetch-internal folder number) - t) - (with-temp-buffer - (elmo-archive-message-fetch-internal folder number) - (buffer-string)))) +(luna-define-method elmo-message-fetch-internal ((folder elmo-archive-folder) + number strategy + &optional section unseen) + (elmo-archive-message-fetch-internal folder number)) (luna-define-method elmo-folder-append-buffer ((folder elmo-archive-folder) unread &optional number) diff --git a/elmo/elmo-cache.el b/elmo/elmo-cache.el index 6631534..7c4e308 100644 --- a/elmo/elmo-cache.el +++ b/elmo/elmo-cache.el @@ -151,28 +151,19 @@ (expand-file-name location (elmo-cache-folder-directory-internal folder))))) -(defsubst elmo-cache-folder-map-message-fetch (folder location strategy - section outbuf unseen) +(luna-define-method elmo-message-fetch-with-cache-process + ((folder elmo-cache-folder) number strategy &optional section unseen) + ;; disbable cache process + (elmo-message-fetch-internal folder number strategy section unseen)) + +(luna-define-method elmo-map-message-fetch ((folder elmo-cache-folder) + location strategy + &optional section unseen) (let ((file (expand-file-name location (elmo-cache-folder-directory-internal folder)))) (when (file-exists-p file) - (if outbuf - (with-current-buffer outbuf - (erase-buffer) - (insert-file-contents-as-binary file) - (elmo-delete-cr-buffer) - t) - (with-temp-buffer - (insert-file-contents-as-binary file) - (elmo-delete-cr-buffer) - (buffer-string)))))) - -(luna-define-method elmo-map-message-fetch ((folder elmo-cache-folder) - location strategy &optional - section outbuf unseen) - (elmo-cache-folder-map-message-fetch folder location strategy - section outbuf unseen)) + (insert-file-contents-as-binary file)))) (luna-define-method elmo-folder-creatable-p ((folder elmo-cache-folder)) nil) diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index fe13a15..a515a51 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -2427,21 +2427,9 @@ If optional argument REMOVE is non-nil, remove FLAG." (luna-define-method elmo-message-fetch-unplugged ((folder elmo-imap4-folder) number strategy &optional section outbuf unseen) - (let ((cache-file (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section))) - (if (and (elmo-fetch-strategy-use-cache strategy) - (file-exists-p cache-file)) - (if outbuf - (with-current-buffer outbuf - (insert-file-contents-as-binary cache-file) - t) - (with-temp-buffer - (insert-file-contents-as-binary cache-file) - (buffer-string))) - (error "%d%s is not cached." number (if section - (format "(%s)" section) - ""))))) + (error "%d%s is not cached." number (if section + (format "(%s)" section) + ""))) (defsubst elmo-imap4-message-fetch (folder number strategy section outbuf unseen) diff --git a/elmo/elmo-localdir.el b/elmo/elmo-localdir.el index 3d6adab..3d9358e 100644 --- a/elmo/elmo-localdir.el +++ b/elmo/elmo-localdir.el @@ -266,23 +266,12 @@ (delete-file filename) t))) -(luna-define-method elmo-message-fetch ((folder elmo-localdir-folder) - number strategy - &optional section outbuf unseen) - ;; strategy, section, unseen is ignored. - (if outbuf - (with-current-buffer outbuf - (erase-buffer) - (when (file-exists-p (elmo-message-file-name folder number)) - (insert-file-contents-as-binary - (elmo-message-file-name folder number)) - (elmo-delete-cr-buffer)) - t) - (with-temp-buffer - (when (file-exists-p (elmo-message-file-name folder number)) - (insert-file-contents-as-binary (elmo-message-file-name folder number)) - (elmo-delete-cr-buffer)) - (buffer-string)))) +(luna-define-method elmo-message-fetch-internal ((folder elmo-localdir-folder) + number strategy + &optional section unread) + (when (file-exists-p (elmo-message-file-name folder number)) + (insert-file-contents-as-binary + (elmo-message-file-name folder number)))) (luna-define-method elmo-folder-list-messages-internal ((folder elmo-localdir-folder) &optional nohide) diff --git a/elmo/elmo-maildir.el b/elmo/elmo-maildir.el index 0c8b315..4bd8a08 100644 --- a/elmo/elmo-maildir.el +++ b/elmo/elmo-maildir.el @@ -418,20 +418,11 @@ file name for maildir directories." (delete-file file))))) (luna-define-method elmo-map-message-fetch ((folder elmo-maildir-folder) - location strategy &optional - section outbuf unseen) + location strategy + &optional section unseen) (let ((file (elmo-maildir-message-file-name folder location))) (when (file-exists-p file) - (if outbuf - (with-current-buffer outbuf - (erase-buffer) - (insert-file-contents-as-binary file) - (elmo-delete-cr-buffer) - t) - (with-temp-buffer - (insert-file-contents-as-binary file) - (elmo-delete-cr-buffer) - (buffer-string)))))) + (insert-file-contents-as-binary file)))) (luna-define-method elmo-folder-exists-p ((folder elmo-maildir-folder)) (let ((basedir (elmo-maildir-folder-directory-internal folder))) diff --git a/elmo/elmo-map.el b/elmo/elmo-map.el index d36d1b0..5b10067 100644 --- a/elmo/elmo-map.el +++ b/elmo/elmo-map.el @@ -78,7 +78,7 @@ strategy &optional section - outbuf unseen) + unseen) "") (luna-define-generic elmo-map-folder-list-unreads (folder) @@ -267,12 +267,13 @@ folder (elmo-map-folder-numbers-to-locations folder numbers))) -(luna-define-method elmo-message-fetch ((folder elmo-map-folder) number - strategy section outbuf unread) +(luna-define-method elmo-message-fetch-internal ((folder elmo-map-folder) + number strategy + &optional section unread) (elmo-map-message-fetch folder (elmo-map-message-location folder number) - strategy section outbuf unread)) + strategy section unread)) (luna-define-method elmo-folder-list-unreads-internal ((folder elmo-map-folder) unread-marks &optional mark-alist) diff --git a/elmo/elmo-mark.el b/elmo/elmo-mark.el index 03bf8d3..4e3a4d0 100644 --- a/elmo/elmo-mark.el +++ b/elmo/elmo-mark.el @@ -146,26 +146,17 @@ (dolist (location locations) (elmo-msgdb-global-mark-delete location))) -(luna-define-method elmo-map-message-fetch ((folder elmo-mark-folder) - location strategy &optional - section outbuf unseen) - (elmo-mark-folder-map-message-fetch folder location strategy - section outbuf unseen)) +(luna-define-method elmo-message-fetch-with-cache-process + ((folder elmo-cache-folder) number strategy &optional section unseen) + ;; disbable cache process + (elmo-message-fetch-internal folder number strategy section unseen)) -(defun elmo-mark-folder-map-message-fetch (folder location strategy - section outbuf unseen) +(luna-define-method elmo-map-message-fetch ((folder elmo-mark-folder) + location strategy + &optional section unseen) (let ((file (elmo-file-cache-get-path location))) (when (file-exists-p file) - (if outbuf - (with-current-buffer outbuf - (erase-buffer) - (insert-file-contents-as-binary file) - (elmo-delete-cr-buffer) - t) - (with-temp-buffer - (insert-file-contents-as-binary file) - (elmo-delete-cr-buffer) - (buffer-string)))))) + (insert-file-contents-as-binary file)))) (luna-define-method elmo-folder-exists-p ((folder elmo-mark-folder)) t) diff --git a/elmo/elmo-net.el b/elmo/elmo-net.el index 9d4c1e6..19208ec 100644 --- a/elmo/elmo-net.el +++ b/elmo/elmo-net.el @@ -413,69 +413,34 @@ Returns a process object. if making session failed, returns nil." folder 'elmo-folder-mark-as-read-unplugged numbers)) t)) -(luna-define-method elmo-message-fetch ((folder elmo-net-folder) - number strategy - &optional section - outbuf - unseen) +(luna-define-generic elmo-message-fetch-plugged (folder number strategy + &optional + section + outbuf + unseen) + "") + +(luna-define-generic elmo-message-fetch-unplugged (folder number strategy + &optional + section + outbuf + unseen) + "") + +(luna-define-method elmo-message-fetch-internal ((folder elmo-net-folder) + number strategy + &optional section unseen) (if (elmo-folder-plugged-p folder) - (let ((cache-file (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section))) - (if (and (elmo-fetch-strategy-use-cache strategy) - (file-exists-p cache-file)) - (if outbuf - (with-current-buffer outbuf - (insert-file-contents-as-binary cache-file) - t) - (with-temp-buffer - (insert-file-contents-as-binary cache-file) - (buffer-string))) - (if outbuf - (with-current-buffer outbuf - (elmo-folder-send folder 'elmo-message-fetch-plugged - number strategy section + (elmo-message-fetch-plugged folder number + strategy section (current-buffer) unseen) - (elmo-delete-cr-buffer) - (when (and (> (buffer-size) 0) - (elmo-fetch-strategy-save-cache strategy) - (elmo-fetch-strategy-cache-path strategy)) - (elmo-file-cache-save - (elmo-fetch-strategy-cache-path strategy) - section)) - t) - (with-temp-buffer - (elmo-folder-send folder 'elmo-message-fetch-plugged - number strategy section - (current-buffer) unseen) - (elmo-delete-cr-buffer) - (when (and (> (buffer-size) 0) - (elmo-fetch-strategy-save-cache strategy) - (elmo-fetch-strategy-cache-path strategy)) - (elmo-file-cache-save - (elmo-fetch-strategy-cache-path strategy) - section)) - (buffer-string))))) - (elmo-folder-send folder 'elmo-message-fetch-unplugged - number strategy section outbuf unseen))) + (elmo-message-fetch-unplugged folder number + strategy section + (current-buffer) unseen))) (luna-define-method elmo-message-fetch-unplugged ((folder elmo-net-folder) number strategy &optional section outbuf unseen) - (if (elmo-fetch-strategy-use-cache strategy) - (if outbuf - (with-current-buffer outbuf - (insert-file-contents-as-binary - (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section)) - t) - (with-temp-buffer - (insert-file-contents-as-binary - (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section)) - (buffer-string))) - (error "Unplugged"))) + (error "Unplugged")) (luna-define-method elmo-folder-check ((folder elmo-net-folder)) (if (elmo-folder-plugged-p folder) diff --git a/elmo/elmo-nmz.el b/elmo/elmo-nmz.el index 0bb4bb4..c361f20 100644 --- a/elmo/elmo-nmz.el +++ b/elmo/elmo-nmz.el @@ -163,19 +163,10 @@ temp-dir)) (luna-define-method elmo-map-message-fetch ((folder elmo-nmz-folder) - location strategy &optional - section outbuf unseen) - (if outbuf - (with-current-buffer outbuf - (erase-buffer) - (when (file-exists-p location) - (insert-file-contents-as-binary location) - (elmo-delete-cr-buffer) - t)) - (with-temp-buffer - (insert-file-contents-as-binary location) - (elmo-delete-cr-buffer) - (buffer-string)))) + location strategy + &optional section unseen) + (when (file-exists-p location) + (insert-file-contents-as-binary location))) (luna-define-method elmo-map-folder-list-message-locations ((folder elmo-nmz-folder)) diff --git a/elmo/elmo-nntp.el b/elmo/elmo-nntp.el index cb4d468..d2500f6 100644 --- a/elmo/elmo-nntp.el +++ b/elmo/elmo-nntp.el @@ -965,57 +965,12 @@ Don't cache if nil.") (with-current-buffer (elmo-network-session-buffer session) (std11-field-body "Newsgroups"))))) -(luna-define-method elmo-message-fetch ((folder elmo-nntp-folder) - number strategy - &optional section - outbuf - unread) - (if (elmo-folder-plugged-p folder) - (let ((cache-file (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section))) - (if (and (elmo-fetch-strategy-use-cache strategy) - (file-exists-p cache-file)) - (if outbuf - (with-current-buffer outbuf - (insert-file-contents-as-binary cache-file) - (elmo-nntp-setup-crosspost-buffer folder number) - (unless unread - (elmo-nntp-folder-update-crosspost-message-alist - folder (list number))) - t) - (with-temp-buffer - (insert-file-contents-as-binary cache-file) - (elmo-nntp-setup-crosspost-buffer folder number) - (unless unread - (elmo-nntp-folder-update-crosspost-message-alist - folder (list number))) - (buffer-string))) - (if outbuf - (with-current-buffer outbuf - (elmo-folder-send folder 'elmo-message-fetch-plugged - number strategy section - (current-buffer) unread) - (elmo-delete-cr-buffer) - (when (and (> (buffer-size) 0) - (elmo-fetch-strategy-save-cache strategy)) - (elmo-file-cache-save - (elmo-fetch-strategy-cache-path strategy) - section)) - t) - (with-temp-buffer - (elmo-folder-send folder 'elmo-message-fetch-plugged - number strategy section - (current-buffer) unread) - (elmo-delete-cr-buffer) - (when (and (> (buffer-size) 0) - (elmo-fetch-strategy-save-cache strategy)) - (elmo-file-cache-save - (elmo-fetch-strategy-cache-path strategy) - section)) - (buffer-string))))) - (elmo-folder-send folder 'elmo-message-fetch-unplugged - number strategy section outbuf unread))) +(luna-define-method elmo-message-fetch-with-cache-process :after + ((folder elmo-nntp-folder) number strategy &optional section unread) + (elmo-nntp-setup-crosspost-buffer folder number) + (unless unread + (elmo-nntp-folder-update-crosspost-message-alist + folder (list number)))) (luna-define-method elmo-message-fetch-plugged ((folder elmo-nntp-folder) number strategy @@ -1023,34 +978,6 @@ Don't cache if nil.") unread) (elmo-nntp-message-fetch folder number strategy section outbuf unread)) -(luna-define-method elmo-message-fetch-unplugged ((folder elmo-nntp-folder) - number strategy - &optional section outbuf - unread) - (if (elmo-fetch-strategy-use-cache strategy) - (if outbuf - (with-current-buffer outbuf - (insert-file-contents-as-binary - (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section)) - (elmo-nntp-setup-crosspost-buffer folder number) - (unless unread - (elmo-nntp-folder-update-crosspost-message-alist - folder (list number))) - t) - (with-temp-buffer - (insert-file-contents-as-binary - (elmo-file-cache-expand-path - (elmo-fetch-strategy-cache-path strategy) - section)) - (elmo-nntp-setup-crosspost-buffer folder number) - (unless unread - (elmo-nntp-folder-update-crosspost-message-alist - folder (list number))) - (buffer-string))) - (error "Unplugged"))) - (defun elmo-nntp-message-fetch (folder number strategy section outbuf unread) (let ((session (elmo-nntp-get-session folder)) newsgroups) diff --git a/elmo/elmo-shimbun.el b/elmo/elmo-shimbun.el index 11d3169..16eb0b8 100644 --- a/elmo/elmo-shimbun.el +++ b/elmo/elmo-shimbun.el @@ -244,22 +244,12 @@ nil) (luna-define-method elmo-map-message-fetch ((folder elmo-shimbun-folder) - location strategy &optional - section outbuf unseen) - (if outbuf - (with-current-buffer outbuf - (erase-buffer) - (shimbun-article (elmo-shimbun-folder-shimbun-internal folder) - (elmo-get-hash-val - location - (elmo-shimbun-folder-header-hash-internal folder))) - t) - (with-temp-buffer - (shimbun-article (elmo-shimbun-folder-shimbun-internal folder) - (elmo-get-hash-val - location - (elmo-shimbun-folder-header-hash-internal folder))) - (buffer-string)))) + location strategy + &optional section unseen) + (shimbun-article (elmo-shimbun-folder-shimbun-internal folder) + (elmo-get-hash-val + location + (elmo-shimbun-folder-header-hash-internal folder)))) (luna-define-method elmo-folder-list-messages-internal :around ((folder elmo-shimbun-folder) &optional nohide) diff --git a/elmo/elmo.el b/elmo/elmo.el index 70245f1..7157b15 100644 --- a/elmo/elmo.el +++ b/elmo/elmo.el @@ -527,6 +527,33 @@ inserted to the buffer and returns t if fetch was ended successfully. If third optional argument UNREAD is non-nil, message is not marked as read. Returns non-nil if fetching was succeed.") +(luna-define-generic elmo-message-fetch-with-cache-process (folder + number strategy + &optional + section + unread) + "Fetch a message into current buffer with cache process. +FOLDER is the ELMO folder structure. +NUMBER is the number of the message in the FOLDER. +STRATEGY is the message fetching strategy. +If optional argument SECTION is specified, only the SECTION of the message +is fetched (if possible). +If second optional argument UNREAD is non-nil, message is not marked as read. +Returns non-nil if fetching was succeed.") + +(luna-define-generic elmo-message-fetch-internal (folder number strategy + &optional + section + unread) + "Fetch a message into current buffer. +FOLDER is the ELMO folder structure. +NUMBER is the number of the message in the FOLDER. +STRATEGY is the message fetching strategy. +If optional argument SECTION is specified, only the SECTION of the message +is fetched (if possible). +If second optional argument UNREAD is non-nil, message is not marked as read. +Returns non-nil if fetching was succeed.") + (luna-define-generic elmo-message-folder (folder number) "Get primitive folder of the message.") @@ -1053,6 +1080,43 @@ FIELD is a symbol of the field." (nthcdr (max (- len elmo-folder-update-threshold) 0) appends) appends)))) +(luna-define-method elmo-message-fetch ((folder elmo-folder) + number strategy + &optional + section + outbuf + unread) + (if outbuf + (with-current-buffer outbuf + (erase-buffer) + (elmo-message-fetch-with-cache-process folder number + strategy section unread) + t) + (with-temp-buffer + (elmo-message-fetch-with-cache-process folder number + strategy section unread) + (buffer-string)))) + +(luna-define-method elmo-message-fetch-with-cache-process ((folder elmo-folder) + number strategy + &optional + section unread) + (let (cache-file) + (if (and (elmo-fetch-strategy-use-cache strategy) + (setq cache-file (elmo-file-cache-expand-path + (elmo-fetch-strategy-cache-path strategy) + section)) + (file-exists-p cache-file)) + (insert-file-contents-as-binary cache-file) + (elmo-message-fetch-internal folder number strategy section unread) + (elmo-delete-cr-buffer) + (when (and (> (buffer-size) 0) + (elmo-fetch-strategy-save-cache strategy) + (elmo-fetch-strategy-cache-path strategy)) + (elmo-file-cache-save + (elmo-fetch-strategy-cache-path strategy) + section))))) + (defun elmo-folder-synchronize (folder new-mark ;"N" unread-uncached-mark ;"U"