* wl-util.el (wl-current-message-buffer): Follow the API change.
authorhmurata <hmurata>
Fri, 7 Jan 2005 17:08:03 +0000 (17:08 +0000)
committerhmurata <hmurata>
Fri, 7 Jan 2005 17:08:03 +0000 (17:08 +0000)
* wl-summary.el (wl-summary-redisplay-internal): Call
`wl-summary-mark-as-read' with 2nd argument as nil and update
unread count instead of persistent mark.

* wl-message.el (wl-message-buffer-mime-entity): New buffer local
variable.
(wl-message-redisplay): Follow the API change.
(wl-message-buffer-display): Managed mime-entity directly and
return preview buffer only.
(wl-message-display-internal): Rewrite.
(wl-message-buffer-prefetch-subr): Not save return value of
`wl-message-buffer-display'.

* elmo.el (elmo-find-fetch-strategy): Removed argument `entity'
and added `number', `require-entireness'.
(elmo-find-fetch-strategy): Rewrite.
(elmo-message-fetch): Unset `unread' flag when argument unread is
non-nil.

* elmo-spam.el (elmo-spam-message-fetch): Follow the API change.

* elmo-multi.el (elmo-find-fetch-strategy): Ditto.
(elmo-message-fetch): Notify event `flag-changed'.

* elmo-pipe.el: Likewise.

* elmo-mime.el (elmo-mime-entity): New class.
(elmo-mime-entity-display-p): New generic function.
(elmo-mime-entity-display): Ditto.
(elmo-mime-entity-display-as-is): Ditto.
(mime-elmo-buffer-entity, mime-elmo-imap-entity): Inherit
elmo-mime-entity.
(elmo-make-mime-message-location): Removed.
(elmo-mime-message-display): Ditto.
(elmo-mime-display-as-is): Ditto.
(elmo-message-mime-entity): New function.

* elmo-imap4.el (elmo-find-fetch-strategy): Rewrite.

* elmo-filter.el (elmo-find-fetch-strategy): Follow the API
change.
(elmo-message-fetch): Re-count flagged message number and notify
event `flag-changed'.

12 files changed:
elmo/ChangeLog
elmo/elmo-filter.el
elmo/elmo-imap4.el
elmo/elmo-mime.el
elmo/elmo-multi.el
elmo/elmo-pipe.el
elmo/elmo-spam.el
elmo/elmo.el
wl/ChangeLog
wl/wl-message.el
wl/wl-summary.el
wl/wl-util.el

index 41942de..ed39ac1 100644 (file)
@@ -1,5 +1,36 @@
 2005-01-07  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
+       * elmo.el (elmo-find-fetch-strategy): Removed argument `entity'
+       and added `number', `require-entireness'.
+       (elmo-find-fetch-strategy): Rewrite.
+       (elmo-message-fetch): Unset `unread' flag when argument unread is
+       non-nil.
+
+       * elmo-spam.el (elmo-spam-message-fetch): Follow the API change.
+
+       * elmo-multi.el (elmo-find-fetch-strategy): Ditto.
+       (elmo-message-fetch): Notify event `flag-changed'.
+
+       * elmo-pipe.el: Likewise.
+
+       * elmo-mime.el (elmo-mime-entity): New class.
+       (elmo-mime-entity-display-p): New generic function.
+       (elmo-mime-entity-display): Ditto.
+       (elmo-mime-entity-display-as-is): Ditto.
+       (mime-elmo-buffer-entity, mime-elmo-imap-entity): Inherit
+       elmo-mime-entity.
+       (elmo-make-mime-message-location): Removed.
+       (elmo-mime-message-display): Ditto.
+       (elmo-mime-display-as-is): Ditto.
+       (elmo-message-mime-entity): New function.
+
+       * elmo-imap4.el (elmo-find-fetch-strategy): Rewrite.
+
+       * elmo-filter.el (elmo-find-fetch-strategy): Follow the API
+       change.
+       (elmo-message-fetch): Re-count flagged message number and notify
+       event `flag-changed'.
+
        * elmo-version.el (elmo-version): Up to 2.13.1.
 
 2005-01-02  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
index 2fbcc9d..ff3767c 100644 (file)
 (luna-define-method elmo-folder-newsgroups ((folder elmo-filter-folder))
   (elmo-folder-newsgroups (elmo-filter-folder-target-internal folder)))
 
-(luna-define-method elmo-find-fetch-strategy
-  ((folder elmo-filter-folder) entity &optional ignore-cache)
+(luna-define-method elmo-find-fetch-strategy ((folder elmo-filter-folder)
+                                             number
+                                             &optional
+                                             ignore-cache
+                                             require-entireness)
   (elmo-find-fetch-strategy
    (elmo-filter-folder-target-internal folder)
-   entity ignore-cache))
+   number ignore-cache require-entireness))
 
 (luna-define-method elmo-folder-get-primitive-list ((folder
                                                     elmo-filter-folder))
 (luna-define-method elmo-message-fetch ((folder elmo-filter-folder)
                                        number strategy
                                        &optional section outbuf unseen)
-  (elmo-message-fetch
-   (elmo-filter-folder-target-internal folder)
-   number strategy section outbuf unseen))
+  (unless unseen
+    (elmo-filter-folder-countup-message-flags folder (list number) -1))
+  (when (elmo-message-fetch (elmo-filter-folder-target-internal folder)
+                           number strategy section outbuf unseen)
+    (unless unseen
+      (elmo-filter-folder-countup-message-flags folder (list number))
+      (elmo-folder-notify-event folder 'flag-changed (list number)))
+    t))
 
 (luna-define-method elmo-folder-delete-messages ((folder elmo-filter-folder)
                                                 numbers)
index fbb0815..762af05 100644 (file)
@@ -2536,52 +2536,41 @@ If optional argument REMOVE is non-nil, remove FLAG."
 
 ;; elmo-folder-open-internal: do nothing.
 
-(luna-define-method elmo-find-fetch-strategy
-  ((folder elmo-imap4-folder) entity &optional ignore-cache)
-  (let ((number (elmo-message-entity-number entity))
-       cache-file size message-id)
-    (setq size (elmo-message-entity-field entity 'size))
-    (setq message-id (elmo-message-entity-field entity 'message-id))
-    (setq cache-file (elmo-file-cache-get message-id))
-    (if (or ignore-cache
-           (null (elmo-file-cache-status cache-file)))
-       (if (and elmo-message-fetch-threshold
-                (integerp size)
-                (>= size elmo-message-fetch-threshold)
-                (or (not elmo-message-fetch-confirm)
-                    (not (prog1 (y-or-n-p
+(luna-define-method elmo-find-fetch-strategy ((folder elmo-imap4-folder) number
+                                             &optional
+                                             ignore-cache
+                                             require-entireness)
+  (let ((entity (elmo-message-entity folder number)))
+    (if (null entity)
+       (elmo-make-fetch-strategy 'entire)
+      (let* ((size (elmo-message-entity-field entity 'size))
+            (message-id (elmo-message-entity-field entity 'message-id))
+            (cache-file (elmo-file-cache-get message-id))
+            (use-cache (and (not ignore-cache)
+                            (elmo-message-use-cache-p folder number)
+                            (if require-entireness
+                                (eq (elmo-file-cache-status cache-file)
+                                    'entire)
+                              (elmo-file-cache-status cache-file)))))
+       (elmo-make-fetch-strategy
+        (if use-cache
+            (elmo-file-cache-status cache-file)
+          (if (and (not require-entireness)
+                   elmo-message-fetch-threshold
+                   (integerp size)
+                   (>= size elmo-message-fetch-threshold)
+                   (or (not elmo-message-fetch-confirm)
+                       (not (prog1
+                                (y-or-n-p
                                  (format
                                   "Fetch entire message at once? (%dbytes)"
                                   size))
-                           (message "")))))
-           ;; Fetch message as imap message.
-           (elmo-make-fetch-strategy 'section
-                                     nil
-                                     (elmo-message-use-cache-p
-                                      folder number)
-                                     (elmo-file-cache-path
-                                      cache-file))
-         ;; Don't use existing cache and fetch entire message at once.
-         (elmo-make-fetch-strategy 'entire nil
-                                   (elmo-message-use-cache-p
-                                    folder number)
-                                   (elmo-file-cache-path cache-file)))
-      ;; Cache found and use it.
-      (if (not ignore-cache)
-         (if (eq (elmo-file-cache-status cache-file) 'section)
-             ;; Fetch message with imap message.
-             (elmo-make-fetch-strategy 'section
-                                       t
-                                       (elmo-message-use-cache-p
-                                        folder number)
-                                       (elmo-file-cache-path
-                                        cache-file))
-           (elmo-make-fetch-strategy 'entire
-                                     t
-                                     (elmo-message-use-cache-p
-                                      folder number)
-                                     (elmo-file-cache-path
-                                      cache-file)))))))
+                              (message "")))))
+              'section
+            'entire))
+        use-cache
+        (elmo-message-use-cache-p folder number)
+        (elmo-file-cache-path cache-file))))))
 
 (luna-define-method elmo-folder-create-plugged ((folder elmo-imap4-folder))
   (elmo-imap4-send-command-wait
index 6ff192f..4fc8a93 100644 (file)
 (require 'mmimap)
 (require 'mime-view)
 
+;; MIME-Entity
 (eval-and-compile
-  (luna-define-class mime-elmo-buffer-entity (mime-buffer-entity) ())
-  (luna-define-class mime-elmo-imap-entity (mime-imap-entity) ()))
+  (luna-define-class elmo-mime-entity))
+
+(luna-define-generic elmo-mime-entity-display-p (entity mime-mode)
+  "Return non-nil if ENTITY is able to display with MIME-MODE.
+
+MIME-MODE is a symbol which is one of the following:
+  `mime'  (Can display each MIME part)
+  `as-is' (Can display raw message)")
+
+(luna-define-generic elmo-mime-entity-display (entity preview-buffer
+                                                     &optional
+                                                     original-major-mode
+                                                     keymap)
+  "Display MIME message ENTITY.
+PREVIEW-BUFFER is a view buffer.
+Optional argument ORIGINAL-MAJOR-MODE is major-mode of representation
+buffer of ENTITY.  If it is nil, current `major-mode' is used.
+If optional argument KEYMAP is specified,
+use for keymap of representation buffer.")
+
+(luna-define-generic elmo-mime-entity-display-as-is (entity
+                                                    preview-buffer
+                                                    &optional
+                                                    original-major-mode
+                                                    keymap)
+  "Display MIME message ENTITY as is.
+PREVIEW-BUFFER is a view buffer.
+Optional argument ORIGINAL-MAJOR-MODE is major-mode of representation
+buffer of ENTITY.  If it is nil, current `major-mode' is used.
+If optional argument KEYMAP is specified,
+use for keymap of representation buffer.")
+
+(luna-define-method elmo-mime-entity-display ((entity elmo-mime-entity)
+                                             preview-buffer
+                                             &optional
+                                             original-major-mode
+                                             keymap)
+  (mime-display-message entity
+                       preview-buffer
+                       nil
+                       keymap
+                       original-major-mode))
+
+
+(eval-and-compile
+  (luna-define-class mime-elmo-buffer-entity (mime-buffer-entity
+                                             elmo-mime-entity))
+  (luna-define-class mime-elmo-imap-entity (mime-imap-entity
+                                           elmo-mime-entity)))
 
 ;; Provide backend
 (provide 'mmelmo-imap)
@@ -184,103 +232,67 @@ value is used."
    elmo-message-sorted-field-list)
   (run-hooks 'elmo-message-header-inserted-hook))
 
-(defun elmo-make-mime-message-location (folder number strategy rawbuf unread)
-;; Return the MIME message location structure.
-;; FOLDER is the ELMO folder structure.
-;; NUMBER is the number of the message in the FOLDER.
-;; STRATEGY is the message fetching strategy.
-;; RAWBUF is the output buffer for original message.
-;; If second optional argument UNREAD is non-nil, message is not marked
-;; as read.
-  (if (and strategy
-          (eq (elmo-fetch-strategy-entireness strategy) 'section))
-      (luna-make-entity
-       'mime-elmo-imap-location
-       :folder folder
-       :number number
-       :rawbuf rawbuf
-       :strategy strategy)
-    (with-current-buffer rawbuf
-      (let (buffer-read-only)
-       (erase-buffer)
-       (if strategy
-           (elmo-message-fetch folder number strategy
-                               nil (current-buffer)
-                               unread))))
-    rawbuf))
-
-(defun elmo-mime-message-display (folder number viewbuf rawbuf original-mode
-                                        &optional ignore-cache unread keymap)
-  "Display MIME message.
-A message in the FOLDER with NUMBER is displayed on the VIEWBUF using RAWBUF.
-VIEWBUF is a view buffer and RAWBUF is a raw buffer.
-ORIGINAL is the major mode of RAWBUF.
-If optional argument IGNORE-CACHE is specified, existing cache is ignored.
-If second optional argument UNREAD is specified, message is displayed but
-keep it as unread.
-Return non-nil if not entire message was fetched."
-  (let (mime-display-header-hook ; Do nothing.
-       (elmo-message-displaying t)
-       entity strategy)
-    (unless (zerop (elmo-folder-length folder))
-      (setq entity (elmo-message-entity folder number)))
-    (setq strategy (if entity (elmo-find-fetch-strategy folder entity
-                                                       ignore-cache)
-                    (elmo-make-fetch-strategy 'entire)))
-    (mime-display-message
-     (mime-open-entity
-      (if (and strategy
-              (eq (elmo-fetch-strategy-entireness strategy) 'section))
-         'elmo-imap
-       'elmo-buffer)
-      (elmo-make-mime-message-location
-       folder number strategy rawbuf unread))
-     viewbuf nil keymap
-     original-mode)
-    (if strategy
-       (or (elmo-fetch-strategy-use-cache strategy)
-           (eq (elmo-fetch-strategy-entireness strategy)
-               'section)))))
-
-(defun elmo-mime-display-as-is (folder number viewbuf rawbuf original-mode
-                                      &optional ignore-cache unread keymap)
-  "Display MIME message.
-A message in the FOLDER with NUMBER is displayed on the VIEWBUF using RAWBUF.
-VIEWBUF is a view buffer and RAWBUF is a raw buffer.
-ORIGINAL is the major mode of RAWBUF.
-If optional argument IGNORE-CACHE is specified, existing cache is ignored.
-If second optional argument UNREAD is specified, message is displayed but
-keep it as unread.
-Return non-nil if cache is used."
-  (let (mime-display-header-hook ; Do nothing.
-       (elmo-message-displaying t)
-       entity cache-file cache-used)
-    (unless (zerop (elmo-folder-length folder))
-      (setq entity (elmo-message-entity folder number)))
-    (when entity
-      (setq cache-file
-           (elmo-file-cache-get
-            (elmo-message-entity-field entity 'message-id)))
-      ;; Required to be an entire cache.
-      (unless (eq (elmo-file-cache-status cache-file) 'entire)
-       (setq ignore-cache t)))
-    (elmo-mime-display-as-is-internal
-     (mime-open-entity
-      'elmo-buffer
-      (elmo-make-mime-message-location
-       folder number
-       (elmo-make-fetch-strategy 'entire
-                                (unless ignore-cache
-                                  (setq
-                                   cache-used
-                                   (and cache-file
-                                        (elmo-file-cache-status cache-file))))
-                                (elmo-message-use-cache-p folder number)
-                                (and cache-file
-                                     (elmo-file-cache-path cache-file)))
-       rawbuf unread))
-     viewbuf nil keymap original-mode)
-    cache-used))
+;; mime-elmo-buffer-entity
+(luna-define-method elmo-mime-entity-display-p
+  ((entity mime-elmo-buffer-entity) mime-mode)
+  ;; always return t.
+  t)
+
+(luna-define-method elmo-mime-entity-display-as-is ((entity
+                                                    mime-elmo-buffer-entity)
+                                                    preview-buffer
+                                                    &optional
+                                                    original-major-mode
+                                                    keymap)
+  (elmo-mime-display-as-is-internal entity
+                                   preview-buffer
+                                   nil
+                                   keymap
+                                   original-major-mode))
+
+;; mime-elmo-imap-entity
+(luna-define-method elmo-mime-entity-display-p
+  ((entity mime-elmo-imap-entity) mime-mode)
+  (not (eq mime-mode 'as-is)))
+
+(luna-define-method elmo-mime-entity-display-as-is ((entity
+                                                    mime-elmo-imap-entity)
+                                                    preview-buffer
+                                                    &optional
+                                                    original-major-mode
+                                                    keymap)
+  (error "Don't support this method."))
+
+
+(defun elmo-message-mime-entity (folder number rawbuf
+                                       &optional
+                                       ignore-cache unread entire)
+  "Return the mime-entity structure of the message in the FOLDER with NUMBER.
+RAWBUF is the output buffer for original message.
+If optional argument IGNORE-CACHE is non-nil, existing cache is ignored.
+If second optional argument UNREAD is non-nil,
+keep status of the message as unread.
+If third optional argument ENTIRE is non-nil, fetch entire message at once."
+  (let ((strategy (elmo-find-fetch-strategy folder number
+                                           ignore-cache
+                                           entire)))
+    (cond ((null strategy) nil)
+         ((eq (elmo-fetch-strategy-entireness strategy) 'section)
+          (mime-open-entity
+           'elmo-imap
+           (luna-make-entity 'mime-elmo-imap-location
+                             :folder folder
+                             :number number
+                             :rawbuf rawbuf
+                             :strategy strategy)))
+         (t
+          (with-current-buffer rawbuf
+            (let (buffer-read-only)
+              (erase-buffer)
+              (elmo-message-fetch folder number strategy
+                                  nil (current-buffer)
+                                  unread)))
+          (mime-open-entity 'elmo-buffer rawbuf)))))
 
 ;; Replacement of mime-display-message.
 (defun elmo-mime-display-as-is-internal (message
index 5903b1c..254a0a0 100644 (file)
   (let ((pair (elmo-multi-real-folder-number folder number)))
     (elmo-message-set-cached (car pair) (cdr pair) cached)))
 
-(luna-define-method elmo-find-fetch-strategy
-  ((folder elmo-multi-folder) entity &optional ignore-cache)
-  (let ((pair (elmo-multi-real-folder-number
-              folder
-              (elmo-message-entity-number entity))))
-    (elmo-find-fetch-strategy
-     (car pair)
-     (elmo-message-entity (car pair) (cdr pair)) ignore-cache)))
+(luna-define-method elmo-find-fetch-strategy ((folder elmo-multi-folder)
+                                             number
+                                             &optional
+                                             ignore-cache
+                                             require-entireness)
+  (let ((pair (elmo-multi-real-folder-number folder number)))
+    (elmo-find-fetch-strategy (car pair)
+                             (cdr pair)
+                             ignore-cache
+                             require-entireness)))
 
 (luna-define-method elmo-message-number ((folder elmo-multi-folder)
                                         message-id)
                                        number strategy
                                        &optional section outbuf unseen)
   (let ((pair (elmo-multi-real-folder-number folder number)))
-    (elmo-message-fetch (car pair) (cdr pair) strategy section outbuf unseen)))
+    (when (elmo-message-fetch (car pair) (cdr pair)
+                             strategy section outbuf unseen)
+      (unless unseen
+       (elmo-folder-notify-event folder 'flag-changed (list number)))
+      t)))
 
 (luna-define-method elmo-folder-delete-messages ((folder elmo-multi-folder)
                                                 numbers)
index d7e90dd..bf37ce4 100644 (file)
 (luna-define-method elmo-message-fetch ((folder elmo-pipe-folder)
                                        number strategy
                                        &optional section outbuf unseen)
-  (elmo-message-fetch (elmo-pipe-folder-dst-internal folder)
-                     number strategy section outbuf unseen))
+  (when (elmo-message-fetch (elmo-pipe-folder-dst-internal folder)
+                           number strategy section outbuf unseen)
+    (unless unseen
+      (elmo-folder-notify-event folder 'flag-changed (list number)))
+    t))
 
 (luna-define-method elmo-folder-clear :after ((folder elmo-pipe-folder)
                                              &optional keep-killed)
   (elmo-message-set-cached (elmo-pipe-folder-dst-internal folder)
                           number cached))
 
-(luna-define-method elmo-find-fetch-strategy
-  ((folder elmo-pipe-folder) entity &optional ignore-cache)
+(luna-define-method elmo-find-fetch-strategy ((folder elmo-pipe-folder)
+                                             number
+                                             &optional
+                                             ignore-cache
+                                             require-entireness)
   (elmo-find-fetch-strategy (elmo-pipe-folder-dst-internal folder)
-                           (elmo-message-entity
-                            (elmo-pipe-folder-dst-internal folder)
-                            (elmo-message-entity-number entity))
-                           ignore-cache))
+                           number
+                           ignore-cache
+                           require-entireness))
 
 (luna-define-method elmo-message-number ((folder elmo-pipe-folder)
                                         message-id)
index 683d443..883ded7 100644 (file)
@@ -124,8 +124,7 @@ If optional argument RESTORE is non-nil, unregister from spam list.")
   (let (elmo-message-fetch-threshold)
     (elmo-message-fetch
      folder number
-     (elmo-find-fetch-strategy folder
-                              (elmo-message-entity folder number))
+     (elmo-find-fetch-strategy folder number nil 'entire)
      nil (current-buffer) 'unread)))
 
 ;; generic implement
index 08c9dfb..9dcf42e 100644 (file)
@@ -504,86 +504,89 @@ NUMBER is a message number to test."
       (t
        (memq flag cur-flags)))))
 
-(luna-define-generic elmo-find-fetch-strategy
-  (folder entity &optional ignore-cache)
-;; Returns the message fetching strategy suitable for the message.
-;; FOLDER is the ELMO folder structure.
-;; ENTITY is the overview entity of the message in the folder.
-;; If optional argument IGNORE-CACHE is non-nil, cache is ignored.
-;; Returned value is a elmo-fetch-strategy object.
-;; If return value is nil, message should not be nil.
-  )
+(luna-define-generic elmo-find-fetch-strategy (folder number
+                                                     &optional
+                                                     ignore-cache
+                                                     require-entireness)
+  "Return the message fetching strategy suitable for the message with NUMBER.
+FOLDER is the ELMO folder structure.
+If optional argument IGNORE-CACHE is non-nil, existing cache is ignored.
+If second optional argument REQUIRE-ENTIRENESS is non-nil,
+ensure that entireness of the returned strategy is entire.
+Returned value is a elmo-fetch-strategy object.
+If return value is nil, message should not be nil.")
 
 (defmacro elmo-make-fetch-strategy (entireness
                                    &optional
                                    use-cache
                                    save-cache
                                    cache-path)
-;; Make elmo-message-fetching strategy.
-;; ENTIRENESS is 'entire or 'section.
-;; 'entire means fetch message entirely at once.
-;; 'section means fetch message section by section.
-;; If optional USE-CACHE is non-nil, existing cache is used and otherwise,
-;; existing cache is thrown away.
-;; If SAVE-CACHE is non-nil, fetched message is saved.
-;; CACHE-PATH is the cache path to be used as a message cache file.
-  (` (vector (, entireness)
-            (, use-cache) (, save-cache) (, cache-path))))
+  "Make elmo-message-fetching strategy.
+ENTIRENESS is 'entire or 'section.
+'entire means fetch message entirely at once.
+'section means fetch message section by section.
+If optional USE-CACHE is non-nil, existing cache is used and otherwise,
+existing cache is thrown away.
+If SAVE-CACHE is non-nil, fetched message is saved.
+CACHE-PATH is the cache path to be used as a message cache file."
+  `(vector ,entireness ,use-cache ,save-cache ,cache-path))
 
 (defmacro elmo-fetch-strategy-entireness (strategy)
-  ;; Return entireness of STRATEGY.
-  (` (aref (, strategy) 0)))
+  "Return entireness of STRATEGY."
+  `(aref ,strategy 0))
 
 (defmacro elmo-fetch-strategy-use-cache (strategy)
-  ;; Return use-cache of STRATEGY.
-  (` (aref (, strategy) 1)))
+  "Return use-cache of STRATEGY."
+  `(aref ,strategy 1))
 
 (defmacro elmo-fetch-strategy-save-cache (strategy)
-  ;; Return save-cache of STRATEGY.
-  (` (aref (, strategy) 2)))
+  "Return save-cache of STRATEGY."
+  `(aref ,strategy 2))
 
 (defmacro elmo-fetch-strategy-cache-path (strategy)
-  ;;  Return cache-path of STRATEGY.
-  (` (aref (, strategy) 3)))
-
-(luna-define-method elmo-find-fetch-strategy
-  ((folder elmo-folder) entity &optional ignore-cache)
-  (let (cache-file size message-id number)
-    (setq size (elmo-message-entity-field entity 'size))
-    (setq message-id (elmo-message-entity-field entity 'message-id))
-    (setq number (elmo-message-entity-number entity))
-    (setq cache-file (elmo-file-cache-get message-id))
-    (setq ignore-cache (or ignore-cache
-                          (null (elmo-message-use-cache-p folder number))))
-    (if (or ignore-cache
-           (null (elmo-file-cache-status cache-file)))
-       ;; No cache or ignore-cache.
-       (if (and (not (elmo-folder-local-p folder))
-                elmo-message-fetch-threshold
-                (integerp size)
-                (>= size elmo-message-fetch-threshold)
-                (or (not elmo-message-fetch-confirm)
-                    (not (prog1 (y-or-n-p
-                                 (format "Fetch entire message(%dbytes)? "
-                                         size))
-                           (message "")))))
-           ;; Don't fetch message at all.
-           nil
-         ;; Don't use existing cache and fetch entire message at once.
-         (elmo-make-fetch-strategy
-          'entire nil
-          (elmo-message-use-cache-p folder number)
-          (elmo-file-cache-path cache-file)))
-      ;; Cache exists.
-      (if (not ignore-cache)
-         (elmo-make-fetch-strategy
-          'entire
-          ;; ...But ignore current section cache and re-fetch
-          ;; if section cache.
-          (not (eq (elmo-file-cache-status cache-file) 'section))
-          ;; Save cache.
-          (elmo-message-use-cache-p folder number)
-          (elmo-file-cache-path cache-file))))))
+  "Return cache-path of STRATEGY."
+  `(aref ,strategy 3))
+
+(luna-define-method elmo-find-fetch-strategy ((folder elmo-folder) number
+                                             &optional
+                                             ignore-cache
+                                             require-entireness)
+  (let ((entity (elmo-message-entity folder number)))
+    (if (null entity)
+       (elmo-make-fetch-strategy 'entire)
+      (let* ((size (elmo-message-entity-field entity 'size))
+            (message-id (elmo-message-entity-field entity 'message-id))
+            (cache-file (elmo-file-cache-get message-id))
+            (use-cache (elmo-message-use-cache-p folder number)))
+       (if (and (not ignore-cache)
+                use-cache
+                (eq (elmo-file-cache-status cache-file) 'entire))
+           ;; Cache exists and use it.
+           (elmo-make-fetch-strategy
+            'entire
+            t                          ; Use cache.
+            use-cache                  ; Save cache.
+            (elmo-file-cache-path cache-file))
+         ;; No cache or ignore-cache.
+         (if (and (not (elmo-folder-local-p folder))
+                  (not require-entireness)
+                  elmo-message-fetch-threshold
+                  (integerp size)
+                  (>= size elmo-message-fetch-threshold)
+                  (or (not elmo-message-fetch-confirm)
+                      (not (prog1
+                               (y-or-n-p
+                                (format "Fetch entire message(%dbytes)? "
+                                        size))
+                             (message "")))))
+             ;; Don't fetch message at all.
+             nil
+           ;; Don't use existing cache and fetch entire message at once.
+           (elmo-make-fetch-strategy
+            'entire
+            nil                        ; Don't use cache.
+            use-cache                  ; Save cache.
+            (elmo-file-cache-path cache-file))))))))
 
 (luna-define-method elmo-folder-list-messages-internal
   ((folder elmo-folder) &optional visible-only)
@@ -1409,15 +1412,21 @@ If Optional LOCAL is non-nil, don't update server flag."
                                        section
                                        outbuf
                                        unread)
-  (if outbuf
-      (with-current-buffer outbuf
-       (erase-buffer)
-       (elmo-message-fetch-with-cache-process folder number
-                                              strategy section unread))
-    (with-temp-buffer
-      (elmo-message-fetch-with-cache-process folder number
-                                            strategy section unread)
-      (buffer-string))))
+  (let (result)
+    (prog1
+       (if outbuf
+           (with-current-buffer outbuf
+             (erase-buffer)
+             (setq result (elmo-message-fetch-with-cache-process
+                           folder number strategy section unread)))
+         (with-temp-buffer
+           (setq result (elmo-message-fetch-with-cache-process
+                         folder number strategy section unread))
+           (buffer-string)))
+      (when (and result
+                (not unread)
+                (elmo-message-flagged-p folder number 'unread))
+       (elmo-message-unset-flag folder number 'unread 'local)))))
 
 (luna-define-method elmo-message-fetch-with-cache-process ((folder elmo-folder)
                                                           number strategy
index 48f0cb6..c0d783a 100644 (file)
@@ -1,5 +1,20 @@
 2005-01-07  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
+       * wl-util.el (wl-current-message-buffer): Follow the API change.
+
+       * wl-summary.el (wl-summary-redisplay-internal): Call
+       `wl-summary-mark-as-read' with 2nd argument as nil and update
+       unread count instead of persistent mark.
+
+       * wl-message.el (wl-message-buffer-mime-entity): New buffer local
+       variable.
+       (wl-message-redisplay): Follow the API change.
+       (wl-message-buffer-display): Managed mime-entity directly and
+       return preview buffer only.
+       (wl-message-display-internal): Rewrite.
+       (wl-message-buffer-prefetch-subr): Not save return value of
+       `wl-message-buffer-display'.
+
        * Version number is increased to 2.13.1.
 
 2005-01-05  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
index 8f4c214..dd91c86 100644 (file)
@@ -62,6 +62,7 @@
 (defvar wl-message-buffer-original-buffer nil) ; original buffer.
 (defvar wl-message-buffer-mode-line-formatter nil)
 (defvar wl-message-buffer-flag-indicator nil)
+(defvar wl-message-buffer-mime-entity nil)
 
 (make-variable-buffer-local 'wl-message-buffer-cur-folder)
 (make-variable-buffer-local 'wl-message-buffer-cur-number)
@@ -71,6 +72,7 @@
 (make-variable-buffer-local 'wl-message-buffer-original-buffer)
 (make-variable-buffer-local 'wl-message-buffer-mode-line-formatter)
 (make-variable-buffer-local 'wl-message-buffer-flag-indicator)
+(make-variable-buffer-local 'wl-message-buffer-mime-entity)
 
 (defvar wl-fixed-window-configuration nil)
 
@@ -451,14 +453,10 @@ Returns non-nil if bottom of message."
   (let* ((default-mime-charset wl-mime-charset)
         (buffer-read-only nil)
         (summary-buf (current-buffer))
-        message-buf
-        strategy entity
-        cache-used
-        summary-win delim flags)
+        message-buf entity summary-win flags)
     (setq buffer-read-only nil)
-    (setq cache-used (wl-message-buffer-display
-                     folder number display-type force-reload))
-    (setq wl-message-buffer (car cache-used))
+    (setq wl-message-buffer (wl-message-buffer-display
+                            folder number display-type force-reload))
     (setq message-buf wl-message-buffer)
     (wl-message-select-buffer wl-message-buffer)
 
@@ -508,7 +506,6 @@ Returns non-nil if bottom of message."
 ;    (when wl-highlight-body-too
 ;      (wl-highlight-body))
     (ignore-errors (wl-message-narrow-to-page))
-    (setq cache-used (cdr cache-used))
     (goto-char (point-min))
     (when (re-search-forward "^$" nil t)
       (wl-message-add-buttons-to-header (point-min) (point))
@@ -524,18 +521,17 @@ Returns non-nil if bottom of message."
     (set-buffer summary-buf)
     (setq summary-win (get-buffer-window summary-buf))
     (if (window-live-p summary-win)
-       (select-window summary-win))
-    cache-used))
+       (select-window summary-win))))
 
 ;; Use message buffer cache.
 (defun wl-message-buffer-display (folder number display-type
                                         &optional force-reload unread)
-  (let* ((msg-id (ignore-errors (elmo-message-field folder number
-                                                   'message-id)))
+  (let* ((msg-id (ignore-errors
+                  (elmo-message-field folder number 'message-id)))
         (fname (elmo-folder-name-internal folder))
         (hit (wl-message-buffer-cache-hit (list fname number msg-id)))
-        (read nil)
-        cache-used)
+        (redisplay nil)
+        entity)
     (when (and hit (not (buffer-live-p hit)))
       (wl-message-buffer-cache-delete (list fname number msg-id))
       (setq hit nil))
@@ -544,67 +540,72 @@ Returns non-nil if bottom of message."
          ;; move hit to the top.
          (wl-message-buffer-cache-sort
           (wl-message-buffer-cache-entry-make (list fname number msg-id) hit))
-         ;; buffer cache is used.
-         (setq cache-used t)
          (with-current-buffer hit
            ;; Rewind to the top page
            (widen)
            (goto-char (point-min))
            (ignore-errors (wl-message-narrow-to-page))
+           (setq entity wl-message-buffer-mime-entity)
            (unless (eq wl-message-buffer-cur-display-type display-type)
-             (setq read t))))
+             (setq redisplay t))))
       ;; delete tail and add new to the top.
       (setq hit (wl-message-buffer-cache-add (list fname number msg-id)))
-      (setq read t))
-    (if (or force-reload read)
-       (condition-case err
-           (save-excursion
-             (set-buffer hit)
-             (setq
-              cache-used
-              (wl-message-display-internal folder number display-type
-                                           force-reload unread))
-             (setq wl-message-buffer-cur-display-type display-type))
-         (quit
-          (wl-message-buffer-cache-delete)
-          (error "Display message %s/%s is quitted" fname number))
-         (error
-          (wl-message-buffer-cache-delete)
-          (signal (car err) (cdr err))
-          nil))) ;; will not be used
-    (cons hit cache-used)))
-
-(defun wl-message-display-internal (folder number display-type
-                                          &optional force-reload unread)
+      (setq redisplay t))
+    (when (or force-reload redisplay)
+      (condition-case err
+         (save-excursion
+           (set-buffer hit)
+           (when (or force-reload
+                     (null entity)
+                     (not (elmo-mime-entity-display-p
+                           entity
+                           (if (wl-message-mime-analysis-p display-type)
+                               'mime
+                             'as-is))))
+             (setq entity (elmo-message-mime-entity
+                           folder
+                           number
+                           (wl-message-get-original-buffer)
+                           force-reload
+                           unread
+                           (not (wl-message-mime-analysis-p display-type)))))
+           (unless entity
+             (error "Cannot display message %s/%s" fname number))
+           (wl-message-display-internal entity display-type))
+       (quit
+        (wl-message-buffer-cache-delete)
+        (error "Display message %s/%s is quitted" fname number))
+       (error
+        (wl-message-buffer-cache-delete)
+        (signal (car err) (cdr err))
+        nil))) ;; will not be used
+    hit))
+
+(defun wl-message-display-internal (entity display-type)
   (let ((default-mime-charset wl-mime-charset)
-       (elmo-mime-charset wl-mime-charset))
-    (setq wl-message-buffer-require-all-header
-         (wl-message-display-all-header-p display-type))
-    (prog1
-       (if (wl-message-mime-analysis-p display-type)
-           (elmo-mime-message-display folder number
-                                      (current-buffer)
-                                      (wl-message-get-original-buffer)
-                                      'wl-original-message-mode
-                                      force-reload
-                                      unread
-                                      (wl-message-define-keymap))
-         (let* ((elmo-mime-display-header-analysis
-                 (wl-message-mime-analysis-p display-type 'header))
-                (wl-highlight-x-face-function
-                 (and elmo-mime-display-header-analysis
-                      wl-highlight-x-face-function)))
-           (prog1 (elmo-mime-display-as-is folder number
-                                           (current-buffer)
-                                           (wl-message-get-original-buffer)
-                                           'wl-original-message-mode
-                                           force-reload
-                                           unread
-                                           (wl-message-define-keymap))
-             (let (buffer-read-only)
-               (wl-highlight-message (point-min) (point-max) t)))))
-      (run-hooks 'wl-message-display-internal-hook)
-      (setq buffer-read-only t))))
+       (elmo-mime-charset wl-mime-charset)
+       (wl-message-buffer-require-all-header
+        (wl-message-display-all-header-p display-type)))
+    (if (wl-message-mime-analysis-p display-type)
+       (elmo-mime-entity-display entity
+                                 (current-buffer)
+                                 'wl-original-message-mode
+                                 (wl-message-define-keymap))
+      (let* ((elmo-mime-display-header-analysis
+             (wl-message-mime-analysis-p display-type 'header))
+            (wl-highlight-x-face-function
+             (and elmo-mime-display-header-analysis
+                  wl-highlight-x-face-function)))
+       (elmo-mime-entity-display-as-is entity
+                                       (current-buffer)
+                                       'wl-original-message-mode
+                                       (wl-message-define-keymap))
+       (let (buffer-read-only)
+         (wl-highlight-message (point-min) (point-max) t))))
+    (setq wl-message-buffer-cur-display-type display-type
+         wl-message-buffer-mime-entity entity)
+    (run-hooks 'wl-message-display-internal-hook)
+    (setq buffer-read-only t)))
 
 (defun wl-message-buffer-prefetch-p (folder &optional number)
   (and (or (not number)
@@ -721,7 +722,7 @@ Returns non-nil if bottom of message."
                   (display-type (wl-message-make-display-type
                                  wl-summary-buffer-display-mime-mode
                                  wl-summary-buffer-display-header-mode))
-                  result time1 time2 sec micro)
+                  time1 time2 sec micro)
              (when wl-message-buffer-prefetch-debug
                (message "%d: count %d, hit %s" number count (buffer-name hit)))
              (if (and hit (buffer-live-p hit))
@@ -737,8 +738,8 @@ Returns non-nil if bottom of message."
                (when wl-message-buffer-prefetch-debug
                  (setq time1 (current-time))
                  (message "Prefetching %d..." number))
-               (setq result (wl-message-buffer-display
-                             folder number display-type nil 'unread))
+               (wl-message-buffer-display folder number
+                                          display-type nil 'unread)
                (when (elmo-message-use-cache-p folder number)
                  (elmo-message-set-cached folder number t))
                (when wl-message-buffer-prefetch-debug
index 910c8aa..f24d6ec 100644 (file)
@@ -4547,7 +4547,7 @@ If ARG is numeric number, decode message as following:
         (num (or number (wl-summary-message-number)))
         (wl-mime-charset      wl-summary-buffer-mime-charset)
         (default-mime-charset wl-summary-buffer-mime-charset)
-        no-folder-mark fld-buf fld-win thr-entity
+        fld-buf fld-win thr-entity
         (elmo-message-fetch-confirm (or elmo-message-fetch-confirm
                                         (and force-reload
                                              elmo-message-fetch-threshold))))
@@ -4569,33 +4569,27 @@ If ARG is numeric number, decode message as following:
              (if (setq fld-win (get-buffer-window fld-buf))
                  (delete-window fld-win)))
          (setq wl-current-summary-buffer (current-buffer))
-         (setq no-folder-mark
-               ;; If cache is used, change folder-mark.
-               (if (wl-message-redisplay
-                    folder num
-                    (wl-message-make-display-type
-                     (or mime-mode
-                         (wl-summary-buffer-display-mime-mode))
-                     (or header-mode
-                         (wl-summary-buffer-display-header-mode)))
-                    (or force-reload
-                        (string= (elmo-folder-name-internal folder)
-                                 wl-draft-folder)))
-                   nil
-                 ;; plugged, then leave folder-mark.
-                 (if (and (not (elmo-folder-local-p
-                                wl-summary-buffer-elmo-folder))
-                          (elmo-folder-plugged-p
-                           wl-summary-buffer-elmo-folder))
-                     'leave)))
+         (wl-message-redisplay folder num
+                               (wl-message-make-display-type
+                                (or mime-mode
+                                    (wl-summary-buffer-display-mime-mode))
+                                (or header-mode
+                                    (wl-summary-buffer-display-header-mode)))
+                               (or force-reload
+                                   (string= (elmo-folder-name-internal folder)
+                                            wl-draft-folder)))
          (when (elmo-message-use-cache-p folder num)
            (elmo-message-set-cached folder num t))
          (ignore-errors
            (if (elmo-message-flagged-p wl-summary-buffer-elmo-folder
                                        num
                                        'unread)
-               (wl-summary-mark-as-read num no-folder-mark)
-             (wl-summary-update-persistent-mark)))
+               (wl-summary-mark-as-read num)
+             (wl-summary-count-unread)
+             (wl-summary-update-modeline)
+             (wl-folder-update-unread
+              (wl-summary-buffer-folder-name)
+              wl-summary-buffer-unread-count)))
          (setq wl-summary-buffer-current-msg num)
          (when wl-summary-recenter
            (recenter (/ (- (window-height) 2) 2))
index eba2e3c..b8771db 100644 (file)
@@ -536,11 +536,11 @@ that `read' can handle, whenever this is possible."
     (with-current-buffer wl-current-summary-buffer
       (or wl-message-buffer
          (and (wl-summary-message-number)
-              (car (wl-message-buffer-display
-                    wl-summary-buffer-elmo-folder
-                    (wl-summary-message-number)
-                    wl-summary-buffer-display-mime-mode
-                    nil nil)))))))
+              (wl-message-buffer-display
+               wl-summary-buffer-elmo-folder
+               (wl-summary-message-number)
+               wl-summary-buffer-display-mime-mode
+               nil nil))))))
 
 (defmacro wl-kill-buffers (regexp)
   (` (mapcar (function