* wl-thread.el (wl-thread-open-all-unread): Use
authorteranisi <teranisi>
Wed, 1 May 2002 03:24:16 +0000 (03:24 +0000)
committerteranisi <teranisi>
Wed, 1 May 2002 03:24:16 +0000 (03:24 +0000)
elmo-folder-list-messages-mark-match.
(wl-thread-insert-message): Removed argument `mark-alist'.
(wl-thread-msg-mark-as-important): Use elmo-msgdb-get-mark and
elmo-msgdb-set-mark.
(wl-thread-get-children-msgs-uncached): Likewise.
(wl-thread-get-exist-children): Added argument include-self.
(wl-thread-delete-message): Follow the change above.

* wl-summary.el (wl-summary-count-unread): Removed argument.
(wl-summary-rescan): Follow the change above.
(wl-summary-mark-as-read-region): Ditto
(wl-summary-mark-as-unread-region): Ditto.
(wl-summary-delete-messages-on-buffer): Ditto.
(wl-summary-sync-update): Ditto.
(wl-summary-switch-to-clone-buffer): Ditto.
(wl-summary-goto-folder-subr): Ditto.
(wl-summary-target-mark-mark-as-read): Ditto.
(wl-summary-target-mark-mark-as-unread): Ditto.
(wl-summary-target-mark-mark-as-important): Ditto.

* wl-folder.el (wl-folder-check-one-entity): Removed argument for
wl-summary-count-unread.

* wl-score.el  (wl-summary-score-update-all-lines): Ditto.
(wl-summary-score-update-all-lines): Use
elmo-msgdb-set-mark.

wl/ChangeLog
wl/wl-folder.el
wl/wl-score.el
wl/wl-summary.el
wl/wl-thread.el

index 0abf6f7..517919d 100644 (file)
@@ -1,3 +1,62 @@
+2002-05-01  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * wl-thread.el (wl-thread-open-all-unread): Use 
+       elmo-folder-list-messages-mark-match.
+       (wl-thread-insert-message): Removed argument `mark-alist'.
+       (wl-thread-msg-mark-as-important): Use elmo-msgdb-get-mark and
+       elmo-msgdb-set-mark.
+       (wl-thread-get-children-msgs-uncached): Likewise.
+       (wl-thread-get-exist-children): Added argument include-self.
+       (wl-thread-delete-message): Follow the change above.
+
+       * wl-summary.el (wl-summary-count-unread): Removed argument.
+       (wl-summary-rescan): Follow the change above.
+       (wl-summary-mark-as-read-region): Ditto
+       (wl-summary-mark-as-unread-region): Ditto.
+       (wl-summary-delete-messages-on-buffer): Ditto.
+       (wl-summary-sync-update): Ditto.
+       (wl-summary-switch-to-clone-buffer): Ditto.
+       (wl-summary-goto-folder-subr): Ditto.
+       (wl-summary-target-mark-mark-as-read): Ditto.
+       (wl-summary-target-mark-mark-as-unread): Ditto.
+       (wl-summary-target-mark-mark-as-important): Ditto.
+
+       (wl-summary-insert-thread-entity): Removed argument `mark-alist'.
+       (wl-summary-update-thread): Removed argument `mark-alist'.
+
+       (wl-summary-sync-marks): Use elmo-folder-list-messages-mark-match.
+
+       (wl-summary-mark-as-read-all): Use elmo-folder-replace-marks.
+       (wl-summary-resume-cache-status): Likewise.
+
+       (wl-summary-prefetch-msg): Use elmo-msgdb-get-mark and
+       elmo-msgdb-set-mark.
+       (wl-summary-mark-as-read-all): Likewise.
+       (wl-summary-delete-cache): Ditto.
+       (wl-summary-auto-select-msg-p): Ditto.
+       (wl-summary-mark-as-unread): Ditto.
+       (wl-summary-no-auto-refile-message-p): Ditto.
+       (wl-summary-mark-as-read): Ditto.
+       (wl-summary-mark-as-important): Ditto.
+
+       (wl-summary-auto-refile): Follow the change above.
+
+       (wl-summary-delete-all-marks): Removed.
+       (wl-summary-resume-marks-and-highlight): Ditto.
+       (wl-summary-resume-marks): Ditto.
+       (wl-summary-delete-important-msgs-from-list): Ditto.
+       (wl-summary-delete-canceled-msgs-from-list): Ditto.
+
+
+       
+
+       * wl-folder.el (wl-folder-check-one-entity): Removed argument for
+       wl-summary-count-unread.
+
+       * wl-score.el   (wl-summary-score-update-all-lines): Ditto.
+       (wl-summary-score-update-all-lines): Use
+       elmo-msgdb-set-mark.
+
 2002-04-30  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * wl-summary.el (wl-summary-summary-line-already-exists-p): Abolished.
index 2513336..9101f64 100644 (file)
@@ -850,9 +850,7 @@ Optional argument ARG is repeart count."
              all    (and all    (max 0 all))))
       (setq unread (or (and unread (- unread (or new 0)))
                       (elmo-folder-get-info-unread folder)
-                      (cdr (wl-summary-count-unread
-                            (elmo-msgdb-get-mark-alist
-                             (elmo-folder-msgdb folder))))))
+                      (cdr (wl-summary-count-unread))))
       (wl-folder-entity-hashtb-set wl-folder-entity-hashtb entity
                                   (list new unread all)
                                   (get-buffer wl-folder-buffer-name)))
index 0016bd2..fbcfa58 100644 (file)
@@ -1245,15 +1245,12 @@ Set `wl-score-cache' nil."
           'wl-summary-score-update-all-lines "Updating score..."
           (/ (* i 100) count))))
       (when dels
-       (setq mark-alist
-             (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
        (let ((marks dels))
          (while marks
-           (setq mark-alist
-                 (elmo-msgdb-mark-set mark-alist (pop marks) nil))))
+           (elmo-msgdb-set-mark (wl-summary-buffer-msgdb)
+                                (pop marks) nil)))
        (elmo-folder-mark-as-read wl-summary-buffer-elmo-folder
                                  dels)
-       (elmo-msgdb-set-mark-alist (wl-summary-buffer-msgdb) mark-alist)
        (wl-summary-delete-messages-on-buffer dels))
       (when (and update update-unread)
        (let ((num-db (elmo-msgdb-get-number-alist
@@ -1262,12 +1259,12 @@ Set `wl-score-cache' nil."
                           (wl-summary-buffer-msgdb))))
          ;; Update Folder mode
          (wl-folder-set-folder-updated (wl-summary-buffer-folder-name)
-                                       (list 0
-                                             (let ((pair
-                                                    (wl-summary-count-unread
-                                                     mark-alist)))
-                                               (+ (car pair) (cdr pair)))
-                                             (length num-db)))
+                                       (list 
+                                        0
+                                        (let ((pair
+                                               (wl-summary-count-unread)))
+                                          (+ (car pair) (cdr pair)))
+                                        (length num-db)))
          (wl-summary-update-modeline)))
       (message "Updating score...done")
       dels)))
index b5975c6..b15675e 100644 (file)
   (if wl-summary-buffer-disp-msg
       (wl-summary-redisplay)))
 
-(defun wl-summary-count-unread (mark-alist)
-  (let ((new 0)
-       (unread 0)
-       mark)
-    (while mark-alist
-      (setq mark (cadr (car mark-alist)))
-      (and mark
-          (cond
-           ((string= mark wl-summary-new-mark)
-            (setq new (+ 1 new)))
-           ((or (string= mark wl-summary-unread-uncached-mark)
-                (string= mark wl-summary-unread-cached-mark))
-            (setq unread (+ 1 unread)))))
-      (setq mark-alist (cdr mark-alist)))
+(defun wl-summary-count-unread ()
+  (let ((pair
+        (elmo-msgdb-count-marks (wl-summary-buffer-msgdb)
+                                wl-summary-new-mark
+                                (list wl-summary-unread-uncached-mark
+                                      wl-summary-unread-cached-mark))))
     (if (eq major-mode 'wl-summary-mode)
-       (setq wl-summary-buffer-new-count new
-             wl-summary-buffer-unread-count unread))
-    (cons new unread)))
+       (setq wl-summary-buffer-new-count (car pair)
+             wl-summary-buffer-unread-count (cdr pair)))
+    pair))
 
 (defun wl-summary-message-string (&optional use-cache)
   "Return full body string of current message.
@@ -836,7 +828,6 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
         (msgdb (wl-summary-buffer-msgdb))
         (overview (elmo-msgdb-get-overview msgdb))
         (number-alist (elmo-msgdb-get-number-alist msgdb))
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
         (elmo-mime-charset wl-summary-buffer-mime-charset)
         i percent num
         gc-message entity
@@ -908,9 +899,7 @@ Entering Folder mode calls the value of `wl-summary-mode-hook'."
                 (setq expunged (wl-summary-score-update-all-lines)))
        (message "%d message(s) are expunged by scoring." (length expunged))))
     (wl-summary-set-message-modified)
-    (wl-summary-count-unread
-     (elmo-msgdb-get-mark-alist
-      (elmo-folder-msgdb wl-summary-buffer-elmo-folder)))
+    (wl-summary-count-unread)
     (wl-summary-update-modeline)
     (goto-char (point-max))
     (forward-line -1)
@@ -1284,7 +1273,6 @@ If ARG is non-nil, checking is omitted."
   ;; prefetching procedure.
   (save-excursion
     (let* ((msgdb (wl-summary-buffer-msgdb))
-          (mark-alist (elmo-msgdb-get-mark-alist msgdb))
           (number-alist (elmo-msgdb-get-number-alist msgdb))
           (message-id (cdr (assq number number-alist)))
           (ov (elmo-msgdb-overview-get-entity message-id msgdb))
@@ -1321,7 +1309,7 @@ If ARG is non-nil, checking is omitted."
                                "??")))))) " ]")
                        size))))
              (message ""))             ; flush.
-           (setq mark (cadr (assq number mark-alist)))
+           (setq mark (elmo-msgdb-get-mark msgdb number))
            (if force-read
                (save-excursion
                  (save-match-data
@@ -1344,10 +1332,8 @@ If ARG is non-nil, checking is omitted."
                           ((string= mark wl-summary-read-uncached-mark)
                            nil)
                           (t mark)))
-                   (setq mark-alist (elmo-msgdb-mark-set
-                                     mark-alist number new-mark))
+                   (elmo-msgdb-set-mark msgdb number new-mark)
                    (or new-mark (setq new-mark " "))
-                   (elmo-msgdb-set-mark-alist msgdb mark-alist)
                    (wl-summary-set-mark-modified)
                    (wl-summary-update-modeline)
                    (wl-folder-update-unread
@@ -1498,19 +1484,6 @@ If ARG is non-nil, checking is omitted."
        (if (and sticky wl-summary-highlight)
            (wl-highlight-summary-current-line))))))
 
-(defun wl-summary-delete-all-marks (mark-alist mark)
-  "Delete all MARKs in MARK-ALIST."
-  (let ((malist mark-alist)
-       (ret-val mark-alist)
-       entity)
-    (while malist
-      (setq entity (car malist))
-      (if (string= (cadr entity) mark)
-         ;; delete this entity
-         (setq ret-val (delete entity ret-val)))
-      (setq malist (cdr malist)))
-    ret-val))
-
 ;; Does not work correctly...
 (defun wl-summary-mark-as-read-region (beg end)
   (interactive "r")
@@ -1541,7 +1514,7 @@ If ARG is non-nil, checking is omitted."
        (while (not (eobp))
          (wl-summary-mark-as-read t)
          (forward-line 1)))))
-  (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+  (wl-summary-count-unread)
   (wl-summary-update-modeline))
 
 (defun wl-summary-mark-as-unread-region (beg end)
@@ -1574,7 +1547,7 @@ If ARG is non-nil, checking is omitted."
        (while (not (eobp))
          (wl-summary-mark-as-unread)
          (forward-line 1)))))
-  (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+  (wl-summary-count-unread)
   (wl-summary-update-modeline))
 
 (defun wl-summary-mark-as-important-region (beg end)
@@ -1605,7 +1578,7 @@ If ARG is non-nil, checking is omitted."
        (while (not (eobp))
          (wl-summary-mark-as-important)
          (forward-line 1)))))
-  (wl-summary-count-unread (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+  (wl-summary-count-unread)
   (wl-summary-update-modeline))
 
 (defun wl-summary-mark-as-read-all ()
@@ -1615,9 +1588,6 @@ If ARG is non-nil, checking is omitted."
       (let* ((folder wl-summary-buffer-elmo-folder)
             (cur-buf (current-buffer))
             (msgdb (wl-summary-buffer-msgdb))
-;;;         (number-alist (elmo-msgdb-get-number-alist msgdb))
-            (mark-alist (elmo-msgdb-get-mark-alist msgdb))
-            (malist mark-alist)
             (inhibit-read-only t)
             (buffer-read-only nil)
             (case-fold-search nil)
@@ -1641,26 +1611,22 @@ If ARG is non-nil, checking is omitted."
                      (string= mark wl-summary-unread-cached-mark))
                  (progn
                    (insert " ")
-                   (setq mark-alist
-                         (elmo-msgdb-mark-set
-                          mark-alist
-                          msg
-;;; Use msg instead of (cdr (assq msg number-alist)).
-;;;                       (cdr (assq msg number-alist))
-                          nil)))
+                   (elmo-msgdb-set-mark msgdb msg nil))
                ;; New mark and unread-uncached mark
                (insert wl-summary-read-uncached-mark)
-               (setq mark-alist
-                     (elmo-msgdb-mark-set mark-alist
-                                          msg
-;;;                                       (cdr (assq msg number-alist))
-                                          wl-summary-read-uncached-mark)))
+               (elmo-msgdb-set-mark
+                msgdb msg wl-summary-read-uncached-mark))
              (if wl-summary-highlight
                  (wl-highlight-summary-current-line nil nil t)))))
-       (setq mark-alist (wl-summary-set-as-read-mark-alist mark-alist))
+       (elmo-folder-replace-marks
+        folder
+        (list (cons wl-summary-unread-cached-mark
+                    nil)
+              (cons wl-summary-unread-uncached-mark
+                    wl-summary-read-uncached-mark)
+              (cons wl-summary-new-mark
+                    wl-summary-read-uncached-mark)))
        (wl-summary-set-mark-modified)
-       (set-buffer cur-buf); why is this needed???
-       (elmo-msgdb-set-mark-alist msgdb mark-alist)
        (wl-folder-update-unread (wl-summary-buffer-folder-name) 0)
        (setq wl-summary-buffer-unread-count 0)
        (setq wl-summary-buffer-new-count    0)
@@ -1676,7 +1642,6 @@ If ARG is non-nil, checking is omitted."
           (buffer-read-only nil)
           (folder wl-summary-buffer-elmo-folder)
           (msgdb (wl-summary-buffer-msgdb))
-          (mark-alist (elmo-msgdb-get-mark-alist msgdb))
           (number-alist (elmo-msgdb-get-number-alist msgdb))
           (case-fold-search nil)
           mark number unread new-mark)
@@ -1705,9 +1670,7 @@ If ARG is non-nil, checking is omitted."
              (elmo-message-field wl-summary-buffer-elmo-folder
                                  number
                                  'message-id)))
-           (setq mark-alist
-                 (elmo-msgdb-mark-set mark-alist number new-mark))
-           (elmo-msgdb-set-mark-alist msgdb mark-alist)
+           (elmo-msgdb-set-mark msgdb number new-mark)
            (wl-summary-set-mark-modified)
            (if wl-summary-highlight
                (wl-highlight-summary-current-line nil nil t))
@@ -1720,7 +1683,6 @@ If ARG is non-nil, checking is omitted."
         (cur-buf (current-buffer))
         (msgdb (wl-summary-buffer-msgdb))
         (number-alist (elmo-msgdb-get-number-alist msgdb))
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
         (inhibit-read-only t)
         (buffer-read-only nil)
         (case-fold-search nil)
@@ -1732,7 +1694,7 @@ If ARG is non-nil, checking is omitted."
        (setq msg (string-to-int
                   (wl-match-buffer 1)))
        (setq mark (wl-match-buffer 2))
-       (setq msgid (cdr (assq msg number-alist)))
+       (setq msgid (elmo-msgdb-get-field msgdb msg 'message-id))
        (setq set-mark nil)
        (if (elmo-file-cache-exists-p msgid)
            (if (or
@@ -1750,82 +1712,16 @@ If ARG is non-nil, checking is omitted."
        (when set-mark
          (delete-region (match-beginning 2) (match-end 2))
          (insert set-mark)
-         (setq mark-alist
-               (elmo-msgdb-mark-set
-                mark-alist msg ; msgid
-                (if (string= set-mark " ") nil set-mark)))
+         (elmo-msgdb-set-mark msgdb msg
+                              (if (string= set-mark " ") nil set-mark))
          (if wl-summary-highlight
              (wl-highlight-summary-current-line))))
       (wl-summary-set-mark-modified)
-      (set-buffer cur-buf); why is this needed???
-      (elmo-msgdb-set-mark-alist msgdb mark-alist)
-      (wl-summary-count-unread mark-alist)
+      (wl-summary-count-unread)
       (wl-summary-update-modeline)
       (message "Resuming cache status...done")
       (set-buffer-modified-p nil))))
 
-(defun wl-summary-resume-marks-and-highlight ()
-  (let* ((msgdb (wl-summary-buffer-msgdb))
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
-;;;     (number-alist (elmo-msgdb-get-number-alist msgdb))
-        (count (count-lines (point-min)(point-max)))
-        (i 0)
-        msg-num percent smark)
-    (save-excursion
-      (goto-char (point-min))
-      (message "Resuming all marks...")
-      (while (not (eobp))
-       (setq msg-num (wl-summary-message-number))
-       (setq smark (car (cdr (assq msg-num mark-alist))))
-       (if (looking-at (format "^ *%s \\( \\)" msg-num))
-           (progn
-             (goto-char (match-end 1))
-             (delete-region (match-beginning 1) (match-end 1))
-             (insert (or smark " "))))
-       (wl-highlight-summary-current-line smark)
-       (when (> count elmo-display-progress-threshold)
-         (setq i (+ i 1))
-         (setq percent (/ (* i 100) count))
-         (elmo-display-progress
-          'wl-summary-resume-marks-and-highlight "Resuming all marks..."
-          percent))
-       (forward-line 1)))
-    (message "Resuming all marks...done")))
-
-(defun wl-summary-resume-marks ()
-  (let* ((msgdb (wl-summary-buffer-msgdb))
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
-        (number-alist (elmo-msgdb-get-number-alist msgdb))
-        (count (length mark-alist))
-        (i 0)
-        entity msg-num percent)
-    (save-excursion
-      (message "Resuming all marks...")
-      (while mark-alist
-       (setq entity (car mark-alist))
-       (if (setq msg-num (car (rassoc (car entity) number-alist)))
-           (progn
-;;;          (goto-char (point-min))
-             (if (re-search-forward (format "^ *%s \\( \\)" msg-num) nil t)
-                 (progn
-                   (delete-region (match-beginning 1) (match-end 1))
-                   (insert (or (cadr entity)
-                               " ")))
-               (if (re-search-backward (format "^ *%s \\( \\)" msg-num) nil t)
-                   (progn
-                     (goto-char (match-end 1))
-                     (delete-region (match-beginning 1) (match-end 1))
-                     (insert (or (cadr entity)
-                                 " ")))))))
-       (when (> count elmo-display-progress-threshold)
-         (setq i (+ i 1))
-         (setq percent (/ (* i 100) count))
-         (elmo-display-progress
-          'wl-summary-resume-marks "Resuming all marks..."
-          percent))
-       (setq mark-alist (cdr mark-alist)))
-      (message "Resuming all marks...done"))))
-
 (defun wl-summary-delete-messages-on-buffer (msgs &optional deleting-info)
   (interactive)
   (save-excursion
@@ -1864,47 +1760,12 @@ If ARG is non-nil, checking is omitted."
        (wl-thread-update-line-msgs (elmo-uniq-list update-list)
                                    (unless deleting-info 'no-msg))
        (wl-thread-cleanup-symbols msgs2))
-      (wl-summary-count-unread
-       (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+      (wl-summary-count-unread)
       (wl-summary-update-modeline)
       (wl-folder-update-unread
        (wl-summary-buffer-folder-name)
        (+ wl-summary-buffer-unread-count wl-summary-buffer-new-count)))))
 
-(defun wl-summary-set-as-read-mark-alist (mark-alist)
-  (let ((marks (list (cons wl-summary-unread-cached-mark
-                          nil)
-                    (cons wl-summary-unread-uncached-mark
-                          wl-summary-read-uncached-mark)
-                    (cons wl-summary-new-mark
-                          wl-summary-read-uncached-mark)))
-       (ret-val mark-alist)
-       entity pair)
-    (while mark-alist
-      (setq entity (car mark-alist))
-      (when (setq pair (assoc (cadr entity) marks))
-       (if (elmo-message-use-cache-p wl-summary-buffer-elmo-folder
-                                     (caar mark-alist))
-           (if (cdr pair)
-               (setcar (cdr entity) (cdr pair))
-             (setq ret-val (delete entity ret-val)))
-         (setq ret-val (delete entity ret-val))))
-      (setq mark-alist (cdr mark-alist)))
-    ret-val))
-
-(defun wl-summary-set-status-marks (mark-alist before after)
-  "Set the BEFORE marks to AFTER."
-  (let ((ret-val mark-alist)
-       entity)
-    (while mark-alist
-      (setq entity (car mark-alist))
-      (when (string= (cadr entity) before)
-       (if after
-           (setcar (cdr entity) after)
-         (setq ret-val (delete entity ret-val))))
-      (setq mark-alist (cdr mark-alist)))
-    ret-val))
-
 (defun wl-summary-set-status-marks-on-buffer (before after)
   "Set the MARKS marks on buffer."
   (interactive)
@@ -1939,24 +1800,6 @@ If ARG is non-nil, checking is omitted."
                   (error "Trash Folder is not created"))))
               wl-trash-folder)))))
 
-(defun wl-summary-delete-important-msgs-from-list (delete-list
-                                                  mark-alist)
-  (let ((dlist delete-list))
-    (while dlist
-      (if (string= wl-summary-important-mark
-                  (car (cdr (assq (car dlist) mark-alist))))
-         (setq delete-list (delete (car dlist) delete-list)))
-      (setq dlist (cdr dlist)))
-    delete-list))
-
-(defun wl-summary-delete-canceled-msgs-from-list (delete-list msgdb)
-  (let ((dlist delete-list))
-    (while dlist
-      (if (null (cdr (assq (car dlist) (cadr msgdb))))
-         (setq delete-list (delete (car dlist) delete-list)))
-      (setq dlist (cdr dlist)))
-    delete-list))
-
 (defun wl-summary-get-append-message-func ()
   (if (eq wl-summary-buffer-view 'thread)
       'wl-summary-insert-thread-entity
@@ -1985,9 +1828,9 @@ If ARG is non-nil, checking is omitted."
   (interactive)
   (let ((last-progress 0)
        (i 0)
-       mark-alist unread-marks importants unreads
+       unread-marks importants unreads
        importants-in-db unreads-in-db diff diffs
-       mes num-ma progress)
+       mes progress)
     ;; synchronize marks.
     (when (not (eq (elmo-folder-type-internal
                    wl-summary-buffer-elmo-folder)
@@ -1996,31 +1839,18 @@ If ARG is non-nil, checking is omitted."
       (setq unread-marks (list wl-summary-unread-cached-mark
                               wl-summary-unread-uncached-mark
                               wl-summary-new-mark)
-           mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb))
-           num-ma (length mark-alist)
+           importants-in-db (elmo-folder-list-messages-mark-match
+                             wl-summary-buffer-elmo-folder
+                             (regexp-quote wl-summary-important-mark))
+           unreads-in-db (elmo-folder-list-messages-mark-match
+                          wl-summary-buffer-elmo-folder
+                          (wl-regexp-opt unread-marks))
            importants (elmo-folder-list-importants
                        wl-summary-buffer-elmo-folder
                        wl-summary-important-mark)
            unreads (elmo-folder-list-unreads
                     wl-summary-buffer-elmo-folder
                     unread-marks))
-      (while mark-alist
-       (if (string= (cadr (car mark-alist))
-                    wl-summary-important-mark)
-           (setq importants-in-db (cons (car (car mark-alist))
-                                        importants-in-db))
-         (if (member (cadr (car mark-alist)) unread-marks)
-             (setq unreads-in-db (cons (car (car mark-alist))
-                                       unreads-in-db))))
-       (setq mark-alist (cdr mark-alist))
-       (when (> num-ma elmo-display-progress-threshold)
-         (setq i (1+ i)
-               progress (/ (* i 100) num-ma))
-         (if (not (eq progress last-progress))
-             (elmo-display-progress 'wl-summary-sync-marks
-                                    "Updating marks..."
-                                    progress))
-         (setq last-progress progress)))
       (setq diff (elmo-list-diff importants importants-in-db))
       (setq diffs (cadr diff)) ; important-deletes
       (setq mes (format "Updated (-%d" (length diffs)))
@@ -2056,7 +1886,7 @@ If ARG is non-nil, checking is omitted."
         (inhibit-read-only t)
         (buffer-read-only nil)
         gc-message
-        overview number-alist mark-alist
+        overview number-alist
         curp num i new-msgdb
         append-list delete-list crossed
         update-thread update-top-list
@@ -2107,13 +1937,13 @@ If ARG is non-nil, checking is omitted."
                (setq num (length curp))
                (when append-list
                  (setq i 0)
+
                  ;; set these value for append-message-func
                  (setq overview (elmo-msgdb-get-overview
                                  (elmo-folder-msgdb folder)))
                  (setq number-alist (elmo-msgdb-get-number-alist
                                      (elmo-folder-msgdb folder)))
-                 (setq mark-alist (elmo-msgdb-get-mark-alist
-                                   (elmo-folder-msgdb folder)))
+
                  (setq wl-summary-delayed-update nil)
                  (elmo-kill-buffer wl-summary-search-buf-name)
                  (while curp
@@ -2201,9 +2031,7 @@ If ARG is non-nil, checking is omitted."
       (wl-folder-set-folder-updated
        (elmo-folder-name-internal folder)
        (list 0
-            (let ((pair (wl-summary-count-unread
-                         (elmo-msgdb-get-mark-alist
-                          (elmo-folder-msgdb folder)))))
+            (let ((pair (wl-summary-count-unread)))
               (+ (car pair) (cdr pair)))
             (elmo-folder-messages folder)))
       (wl-summary-update-modeline)
@@ -2472,8 +2300,7 @@ If ARG, without confirm."
       (setq copy-variables (cdr copy-variables)))
     (switch-to-buffer buf)
     (kill-buffer cur-buf)
-    (wl-summary-count-unread
-     (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+    (wl-summary-count-unread)
     (wl-summary-update-modeline)
     (if msg
        (if (eq wl-summary-buffer-view 'thread)
@@ -2503,9 +2330,9 @@ If ARG, without confirm."
 (defun wl-summary-auto-select-msg-p (unread-msg)
   (and unread-msg
        (not (string=
-            (cadr (assoc unread-msg
-                         (elmo-msgdb-get-mark-alist
-                          (wl-summary-buffer-msgdb))))
+            (elmo-msgdb-get-mark
+             (wl-summary-buffer-msgdb)
+             unread-msg)
             wl-summary-important-mark))))
 
 (defsubst wl-summary-open-folder (folder)
@@ -2592,8 +2419,7 @@ If ARG, without confirm."
                                       (elmo-folder-msgdb-path folder))))
              (wl-summary-open-folder folder)
              (wl-summary-rescan))
-           (wl-summary-count-unread
-            (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+           (wl-summary-count-unread)
            (wl-summary-update-modeline)))
       (unless (eq wl-summary-buffer-view 'thread)
        (wl-summary-make-number-list))
@@ -2829,7 +2655,6 @@ If ARG, without confirm."
 (defun wl-summary-insert-thread-entity (entity msgdb update
                                               &optional force-insert)
   (let* ((overview (elmo-msgdb-get-overview msgdb))
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
         this-id
         parent-entity
         parent-number
@@ -2882,7 +2707,7 @@ If ARG, without confirm."
                            parent-entity) ""))))
            (setq parent-number nil))
        (setq retval
-             (wl-thread-insert-message entity mark-alist
+             (wl-thread-insert-message entity
                                        number parent-number update linked))
        (and retval
             (wl-append update-list (list retval)))
@@ -2898,7 +2723,6 @@ If ARG, without confirm."
     update-list))
 
 (defun wl-summary-update-thread (entity
-                                mark-alist
                                 thr-entity
                                 parent-entity)
   (let* ((this-id (elmo-msgdb-overview-entity-get-id entity))
@@ -2919,7 +2743,7 @@ If ARG, without confirm."
       (wl-summary-insert-line
        (wl-summary-create-line
        entity
-       parent-entity 
+       parent-entity
        nil
        (wl-thread-maybe-get-children-num msg)
        (wl-thread-make-indent-string thr-entity)
@@ -2935,13 +2759,12 @@ If ARG, without confirm."
          (buffer-read-only nil)
          (folder wl-summary-buffer-elmo-folder)
          (msgdb (wl-summary-buffer-msgdb))
-         (mark-alist (elmo-msgdb-get-mark-alist msgdb))
 ;;;      (number-alist (elmo-msgdb-get-number-alist msgdb))
          new-mark visible mark)
       (if number
          (progn
            (setq visible (wl-summary-jump-to-msg number))
-           (unless (setq mark (cadr (assq number mark-alist)))
+           (unless (setq mark (elmo-msgdb-get-mark msgdb number))
              (setq mark " ")))
        ;; interactive
        (setq visible t))
@@ -2981,11 +2804,7 @@ If ARG, without confirm."
            (when visible
              (delete-region (match-beginning 2) (match-end 2))
              (insert new-mark))
-           (setq mark-alist
-                 (elmo-msgdb-mark-set mark-alist
-                                      number
-                                      new-mark))
-           (elmo-msgdb-set-mark-alist msgdb mark-alist)
+           (elmo-msgdb-set-mark msgdb number new-mark)
            (unless no-modeline-update
              (setq wl-summary-buffer-unread-count
                    (+ 1 wl-summary-buffer-unread-count))
@@ -3405,8 +3224,9 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
       (wl-summary-prev)
     (wl-summary-next)))
 
-(defsubst wl-summary-no-auto-refile-message-p (msg mark-alist)
-  (member (cadr (assq msg mark-alist)) wl-summary-auto-refile-skip-marks))
+(defsubst wl-summary-no-auto-refile-message-p (msg)
+  (member (elmo-msgdb-get-mark (wl-summary-buffer-msgdb) msg)
+         wl-summary-auto-refile-skip-marks))
 
 (defun wl-summary-auto-refile (&optional open-all)
   "Set refile mark automatically according to 'wl-refile-guess-by-rule'."
@@ -3417,8 +3237,6 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
             open-all)
        (wl-thread-open-all))
     (let* ((spec (wl-summary-buffer-folder-name))
-          (mark-alist (elmo-msgdb-get-mark-alist
-                       (wl-summary-buffer-msgdb)))
           checked-dsts
           (count 0)
           number dst thr-entity)
@@ -3433,8 +3251,8 @@ If optional argument NUMBER is specified, mark message specified by NUMBER."
                                               (wl-thread-get-entity number))))
                                   (wl-thread-entity-get-descendant
                                    thr-entity))))
-         (when (and (not (wl-summary-no-auto-refile-message-p number
-                                                              mark-alist))
+         (when (and (not (wl-summary-no-auto-refile-message-p
+                          number))
                     (setq dst
                           (wl-folder-get-realname
                            (wl-refile-guess-by-rule
@@ -3957,8 +3775,7 @@ If ARG, exit virtual folder."
        (setq wl-summary-buffer-target-mark-list
              (delq (car mlist) wl-summary-buffer-target-mark-list))
        (setq mlist (cdr mlist)))
-      (wl-summary-count-unread
-       (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+      (wl-summary-count-unread)
       (wl-summary-update-modeline))))
 
 (defun wl-summary-target-mark-mark-as-unread ()
@@ -3987,8 +3804,7 @@ If ARG, exit virtual folder."
        (setq wl-summary-buffer-target-mark-list
              (delq (car mlist) wl-summary-buffer-target-mark-list))
        (setq mlist (cdr mlist)))
-      (wl-summary-count-unread
-       (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+      (wl-summary-count-unread)
       (wl-summary-update-modeline))))
 
 (defun wl-summary-target-mark-mark-as-important ()
@@ -4017,8 +3833,7 @@ If ARG, exit virtual folder."
        (setq wl-summary-buffer-target-mark-list
              (delq (car mlist) wl-summary-buffer-target-mark-list))
        (setq mlist (cdr mlist)))
-      (wl-summary-count-unread
-       (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
+      (wl-summary-count-unread)
       (wl-summary-update-modeline))))
 
 (defun wl-summary-target-mark-save ()
@@ -4056,14 +3871,13 @@ If ARG, exit virtual folder."
           (buffer-read-only nil)
           (folder wl-summary-buffer-elmo-folder)
           (msgdb (wl-summary-buffer-msgdb))
-          (mark-alist (elmo-msgdb-get-mark-alist msgdb))
 ;;;       (number-alist (elmo-msgdb-get-number-alist msgdb))
           (case-fold-search nil)
           mark stat visible uncached new-mark marked)
       (if number
          (progn
            (setq visible (wl-summary-jump-to-msg number))
-           (setq mark (cadr (assq number mark-alist))))
+           (setq mark (elmo-msgdb-get-mark msgdb number)))
        ;; interactive
        (setq visible t))
       (beginning-of-line)
@@ -4121,9 +3935,7 @@ If ARG, exit virtual folder."
                      (goto-char (match-end 2))
                      (delete-region (match-beginning 2) (match-end 2))
                      (insert (or new-mark " ")))
-                   (setq mark-alist
-                         (elmo-msgdb-mark-set mark-alist number new-mark))
-                   (elmo-msgdb-set-mark-alist msgdb mark-alist)
+                   (elmo-msgdb-set-mark msgdb number new-mark)
                    (wl-summary-set-mark-modified))
                  (if (and visible wl-summary-highlight)
                      (wl-highlight-summary-current-line nil nil t)))
@@ -4147,13 +3959,12 @@ If ARG, exit virtual folder."
          (buffer-read-only nil)
          (folder wl-summary-buffer-elmo-folder)
          (msgdb (wl-summary-buffer-msgdb))
-         (mark-alist (elmo-msgdb-get-mark-alist msgdb))
          (number-alist (elmo-msgdb-get-number-alist msgdb))
          message-id visible)
       (if number
          (progn
            (setq visible (wl-summary-jump-to-msg number))
-           (setq mark (or mark (cadr (assq number mark-alist)))))
+           (setq mark (or mark (elmo-msgdb-get-mark msgdb number))))
        (setq visible t))
       (when visible
        (if (null (setq number (wl-summary-message-number)))
@@ -4191,10 +4002,7 @@ If ARG, exit virtual folder."
                  (when visible
                    (delete-region (match-beginning 2) (match-end 2))
                    (insert " "))
-                 (setq mark-alist
-                       (elmo-msgdb-mark-set mark-alist
-                                            number
-                                            nil)))
+                 (elmo-msgdb-set-mark msgdb number nil))
              ;; server side mark
              (save-match-data
                (unless no-server-update
@@ -4202,10 +4010,8 @@ If ARG, exit virtual folder."
              (when visible
                (delete-region (match-beginning 2) (match-end 2))
                (insert wl-summary-important-mark))
-             (setq mark-alist
-                   (elmo-msgdb-mark-set mark-alist
-                                        number
-                                        wl-summary-important-mark))
+             (elmo-msgdb-set-mark msgdb number
+                                  wl-summary-important-mark)
              (if (eq (elmo-file-cache-exists-p message-id) 'entire)
                  (elmo-folder-mark-as-read folder (list number))
                ;; Force cache message.
@@ -4213,7 +4019,6 @@ If ARG, exit virtual folder."
              (unless no-server-update
                (elmo-msgdb-global-mark-set message-id
                                            wl-summary-important-mark)))
-           (elmo-msgdb-set-mark-alist msgdb mark-alist)
            (wl-summary-set-mark-modified)))
       (if (and visible wl-summary-highlight)
          (wl-highlight-summary-current-line nil nil t))))
index 52a30f0..7cdd0a0 100644 (file)
        curp curc)
     (setq curp to)
     (elmo-list-insert wl-summary-buffer-number-list
-                     (wl-thread-entity-get-number entity)
-                     (progn
-                       (while (setq curc
-                                    (wl-thread-entity-get-children curp))
-                         (setq curp (wl-thread-get-entity
-                                     (nth (- (length curc) 1)
-                                          curc))))
-                       (wl-thread-entity-get-number curp)))
+                     (wl-thread-entity-get-number entity)
+                     (progn
+                       (while (setq curc
+                                    (wl-thread-entity-get-children curp))
+                         (setq curp (wl-thread-get-entity
+                                     (nth (- (length curc) 1)
+                                          curc))))
+                       (wl-thread-entity-get-number curp)))
     (setcar (cddr to) (wl-append children
                                 (list (car entity))))
     (setq wl-thread-entities (cons entity wl-thread-entities))
@@ -368,17 +368,13 @@ ENTITY is returned."
 
 (defun wl-thread-open-all-unread ()
   (interactive)
-  (let ((mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
-       mark)
-    (while mark-alist
-      (if (setq mark (nth 1 (car mark-alist)))
-         (if (or (string= mark wl-summary-unread-uncached-mark)
-                 (string= mark wl-summary-unread-cached-mark)
-                 (string= mark wl-summary-new-mark)
-                 (string= mark wl-summary-important-mark))
-             (wl-thread-entity-force-open (wl-thread-get-entity
-                                           (nth 0 (car mark-alist))))))
-      (setq mark-alist (cdr mark-alist)))))
+  (dolist (number (elmo-folder-list-messages-mark-match
+                  wl-summary-buffer-elmo-folder
+                  (wl-regexp-opt (list wl-summary-unread-uncached-mark
+                                       wl-summary-unread-cached-mark
+                                       wl-summary-new-mark
+                                       wl-summary-important-mark))))
+    (wl-thread-entity-force-open (wl-thread-get-entity number))))
 
 (defsubst wl-thread-maybe-get-children-num (msg)
   (let ((entity (wl-thread-get-entity msg)))
@@ -389,7 +385,6 @@ ENTITY is returned."
   (let* ((entity (or entity (wl-thread-get-entity msg)))
         (parent-msg (or parent-msg (wl-thread-entity-get-parent entity)))
         (overview (elmo-msgdb-get-overview (wl-summary-buffer-msgdb)))
-        (mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
         (buffer-read-only nil)
         (inhibit-read-only t)
         overview-entity temp-mark summary-line invisible-top dest-pair)
@@ -427,7 +422,6 @@ ENTITY is returned."
                     (wl-thread-entity-parent-invisible-p entity)))
          (wl-summary-update-thread
           (elmo-msgdb-overview-get-entity msg (wl-summary-buffer-msgdb))
-          mark-alist
           entity
           (and parent-msg
                (elmo-msgdb-overview-get-entity
@@ -507,14 +501,15 @@ ENTITY is returned."
                             wl-thread-entity-hashtb))
       (setq msgs (cdr msgs)))))
 
-(defun wl-thread-get-exist-children (msg)
+(defun wl-thread-get-exist-children (msg &optional include-self)
   (let ((msgs (list msg))
        msgs-stack children
        entity ret-val)
     (while msgs
       (setq children (wl-thread-entity-get-children
                      (setq entity (wl-thread-get-entity (car msgs)))))
-      (when (elmo-msgdb-overview-get-entity (car msgs) (wl-summary-buffer-msgdb))
+      (when (elmo-msgdb-overview-get-entity (car msgs)
+                                           (wl-summary-buffer-msgdb))
        (wl-append ret-val (list (car msgs)))
        (setq children nil))
       (setq msgs (cdr msgs))
@@ -523,6 +518,7 @@ ENTITY is returned."
            (setq msgs (wl-pop msgs-stack)))
        (wl-push msgs msgs-stack)
        (setq msgs children)))
+    (unless include-self (setq ret-val (delq msg ret-val)))
     ret-val))
 
 (defun wl-thread-delete-message (msg &optional deep update)
@@ -620,7 +616,8 @@ ENTITY is returned."
          (let* (next-top insert-msgs ent e grandchildren)
            (if top-child
                (progn
-                 (setq insert-msgs (wl-thread-get-exist-children top-child))
+                 (setq insert-msgs (wl-thread-get-exist-children
+                                    top-child 'include-self))
                  (setq next-top (car insert-msgs))
                  (setq ent (wl-thread-get-entity next-top))
                  (when (and
@@ -655,7 +652,6 @@ ENTITY is returned."
        update-msgs)))) ; return value
 
 (defun wl-thread-insert-message (overview-entity
-                                mark-alist
                                 msg parent-msg &optional update linked)
   "Insert MSG to the entity.
 When optional argument UPDATE is non-nil,
@@ -682,7 +678,6 @@ Message is inserted to the summary buffer."
            (progn
              (wl-summary-update-thread
               overview-entity
-              mark-alist
               child-entity
               (elmo-msgdb-overview-get-entity
                parent-msg (wl-summary-buffer-msgdb)))
@@ -786,17 +781,14 @@ Message is inserted to the summary buffer."
 
 (defun wl-thread-msg-mark-as-important (msg)
   "Set mark as important for invisible MSG. Modeline is not changed."
-  (let* ((msgdb (wl-summary-buffer-msgdb))
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
-        cur-mark)
-    (setq cur-mark (cadr (assq msg mark-alist)))
-    (setq mark-alist
-         (elmo-msgdb-mark-set mark-alist
-                              msg
-                              (if (string= cur-mark wl-summary-important-mark)
-                                  nil
-                                wl-summary-important-mark)))
-    (elmo-msgdb-set-mark-alist msgdb mark-alist)
+  (let ((msgdb (wl-summary-buffer-msgdb))
+       cur-mark)
+    (setq cur-mark (elmo-msgdb-get-mark msgdb msg))
+    (elmo-msgdb-set-mark msgdb
+                        msg
+                        (if (string= cur-mark wl-summary-important-mark)
+                            nil
+                          wl-summary-important-mark))
     (wl-summary-set-mark-modified)))
 
 (defun wl-thread-mark-as-read (&optional arg)
@@ -892,8 +884,7 @@ Message is inserted to the summary buffer."
             (/ (* cur 100) len)))))))
 
 (defsubst wl-thread-insert-entity-sub (indent entity parent-entity all)
-  (let ((mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
-       msg-num
+  (let (msg-num
        overview-entity
        temp-mark
        summary-line)
@@ -1030,15 +1021,15 @@ Message is inserted to the summary buffer."
 
 (defun wl-thread-get-children-msgs-uncached (msg &optional uncached-marks)
   (let ((children-msgs (wl-thread-get-children-msgs msg))
-       (mark-alist (elmo-msgdb-get-mark-alist (wl-summary-buffer-msgdb)))
        (number-alist (elmo-msgdb-get-number-alist (wl-summary-buffer-msgdb)))
        mark
        uncached-list)
     (while children-msgs
       (if (and (not (eq msg (car children-msgs))) ; except itself
               (or (and uncached-marks
-                       (setq mark (cadr (assq (car children-msgs)
-                                              mark-alist)))
+                       (setq mark (elmo-msgdb-get-mark
+                                   (wl-summary-buffer-msgdb)
+                                   (car children-msgs)))
                        (member mark uncached-marks))
                   (and (not uncached-marks)
                        (null (elmo-file-cache-exists-p