* wl-summary.el (wl-summary-redisplay-internal): If `elmo-message-use-cache-p'
[elisp/wanderlust.git] / wl / wl-thread.el
index 7cdd0a0..067b10c 100644 (file)
 (defvar wl-thread-entities nil)
 (defvar wl-thread-entity-list nil)     ; entity list
 (defvar wl-thread-entity-hashtb nil)   ; obarray
-(defvar wl-thread-indent-regexp nil)
 
 (make-variable-buffer-local 'wl-thread-entity-hashtb)
 (make-variable-buffer-local 'wl-thread-entities)     ; ".wl-thread-entity"
 (make-variable-buffer-local 'wl-thread-entity-list)  ; ".wl-thread-entity-list"
-(make-variable-buffer-local 'wl-thread-entity-cur)
-(make-variable-buffer-local 'wl-thread-indent-regexp)
 
 ;;; global flag
 (defvar wl-thread-insert-force-opened nil)
        msgs-stack children)
     (while msgs
       (setq wl-summary-buffer-number-list (cons (car entity)
-                                       wl-summary-buffer-number-list))
+                                               wl-summary-buffer-number-list))
       (setq msgs (cdr msgs))
       (setq children (wl-thread-entity-get-children entity))
       (if children
@@ -370,10 +367,10 @@ ENTITY is returned."
   (interactive)
   (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-regexp-opt (list elmo-msgdb-unread-uncached-mark
+                                       elmo-msgdb-unread-cached-mark
+                                       elmo-msgdb-new-mark
+                                       elmo-msgdb-important-mark))))
     (wl-thread-entity-force-open (wl-thread-get-entity number))))
 
 (defsubst wl-thread-maybe-get-children-num (msg)
@@ -409,6 +406,7 @@ ENTITY is returned."
              (elmo-msgdb-overview-get-entity
               parent-msg (wl-summary-buffer-msgdb))
              temp-mark
+             (elmo-msgdb-get-mark (wl-summary-buffer-msgdb) msg)
              (if wl-thread-insert-force-opened
                  nil
                (wl-thread-maybe-get-children-num msg))
@@ -683,10 +681,9 @@ Message is inserted to the summary buffer."
                parent-msg (wl-summary-buffer-msgdb)))
              (when parent
                ;; use thread structure.
-               (wl-thread-entity-get-nearly-older-brother
-                child-entity parent))) ; return value
-;;;            (wl-thread-entity-get-number
-;;;             (wl-thread-entity-get-top-entity parent)))) ; return value;
+               ;;(wl-thread-entity-get-nearly-older-brother
+               ;; child-entity parent))) ; return value
+               (wl-thread-entity-get-number parent))) ; return value
 ;;;          (setq beg (point))
 ;;;          (wl-thread-goto-bottom-of-sub-thread)
 ;;;          (wl-thread-update-indent-string-region beg (point)))
@@ -720,48 +717,7 @@ Message is inserted to the summary buffer."
 
 (defun wl-thread-update-children-number (entity)
   "Update the children number."
-  (save-excursion
-    (wl-summary-jump-to-msg (wl-thread-entity-get-number entity))
-    (beginning-of-line)
-    (let ((text-prop (get-text-property (point) 'face))
-         from from-end beg str)
-      (cond
-       ((looking-at (concat "^" wl-summary-buffer-number-regexp
-                           "..../..\(.*\)..:.. ["
-                           wl-thread-indent-regexp
-                           "]*[[<]\\+\\([0-9]+\\):"))
-       (delete-region (match-beginning 1)(match-end 1))
-       (goto-char (match-beginning 1))
-       (setq str (format "%s" (wl-thread-entity-get-children-num entity)))
-       (if wl-summary-highlight
-           (put-text-property 0 (length str) 'face text-prop str))
-       (insert str))
-       ((looking-at (concat "^" wl-summary-buffer-number-regexp
-                           "..../..\(.*\)..:.. ["
-                           wl-thread-indent-regexp
-                           "]*[[<]"))
-       (goto-char (match-end 0))
-       (setq beg (current-column))
-       (setq from-end (save-excursion
-                        (move-to-column (+ 1 beg wl-summary-from-width))
-                        (point)))
-       (setq from (buffer-substring (match-end 0) from-end))
-       (delete-region (match-end 0) from-end)
-       (setq str (wl-set-string-width
-                  (1+ wl-summary-from-width)
-                  (format
-                   "+%s:%s"
-                   (wl-thread-entity-get-children-num
-                    entity)
-                   from)))
-       (if wl-summary-highlight
-           (put-text-property 0 (length str) 'face text-prop str))
-       (insert str)
-       (condition-case nil ; it's dangerous, so ignore error.
-           (run-hooks 'wl-thread-update-children-number-hook)
-         (error
-          (ding)
-          (message "Error in wl-thread-update-children-number-hook."))))))))
+  (wl-thread-update-line-on-buffer (wl-thread-entity-get-number entity)))
 
 ;;
 ;; Thread oriented commands.
@@ -786,9 +742,9 @@ Message is inserted to the summary buffer."
     (setq cur-mark (elmo-msgdb-get-mark msgdb msg))
     (elmo-msgdb-set-mark msgdb
                         msg
-                        (if (string= cur-mark wl-summary-important-mark)
+                        (if (string= cur-mark elmo-msgdb-important-mark)
                             nil
-                          wl-summary-important-mark))
+                          elmo-msgdb-important-mark))
     (wl-summary-set-mark-modified)))
 
 (defun wl-thread-mark-as-read (&optional arg)
@@ -880,7 +836,7 @@ Message is inserted to the summary buffer."
        (setq cur (1+ cur))
        (if (or (zerop (% cur 2)) (= cur len))
            (elmo-display-progress
-            'wl-thread-insert-top "Inserting thread..."
+            'wl-thread-insert-top "Inserting message..."
             (/ (* cur 100) len)))))))
 
 (defsubst wl-thread-insert-entity-sub (indent entity parent-entity all)
@@ -911,6 +867,7 @@ Message is inserted to the summary buffer."
          (elmo-msgdb-overview-get-entity
           (nth 0 parent-entity) (wl-summary-buffer-msgdb))
          temp-mark
+         (elmo-msgdb-get-mark (wl-summary-buffer-msgdb) msg-num)
          (if wl-thread-insert-force-opened
              nil
            (wl-thread-maybe-get-children-num msg-num))
@@ -1126,6 +1083,8 @@ Message is inserted to the summary buffer."
              (wl-summary-jump-to-msg msg)
              (wl-thread-close
               (wl-thread-get-entity (wl-summary-message-number)))))))
+      (when wl-summary-lazy-highlight
+       (wl-highlight-summary-window))
       (wl-summary-set-message-modified)
       (set-buffer-modified-p nil))))
 
@@ -1143,7 +1102,8 @@ Message is inserted to the summary buffer."
   (save-excursion
     (goto-char beg)
     (while (< (point) end)
-      (wl-thread-update-indent-string)
+      (save-excursion
+       (wl-thread-update-line-on-buffer-sub nil (wl-summary-message-number)))
       (forward-line 1))))
 
 (defsubst wl-thread-make-indent-string (entity)
@@ -1174,34 +1134,6 @@ Message is inserted to the summary buffer."
        (setq cur (wl-thread-entity-get-parent-entity cur))))
     ret-val))
 
-(defun wl-thread-update-indent-string ()
-  "Update indent string of current line."
-  (interactive)
-  (save-excursion
-    (beginning-of-line)
-    (let ((inhibit-read-only t)
-         (buffer-read-only nil)
-         thr-str)
-      (when (looking-at (concat "^ *\\([0-9]+\\)"
-                               "..../..\(.*\)..:.. \\("
-                               wl-highlight-thread-indent-string-regexp
-                               "\\)[[<]"))
-       (goto-char (match-beginning 2))
-       (delete-region (match-beginning 2)
-                      (match-end 2))
-       (setq thr-str
-             (wl-thread-make-indent-string
-              (wl-thread-get-entity (string-to-int (wl-match-buffer 1)))))
-       (if (and wl-summary-indent-length-limit
-                (< wl-summary-indent-length-limit
-                   (string-width thr-str)))
-           (setq thr-str (wl-set-string-width
-                          wl-summary-indent-length-limit
-                          thr-str)))
-       (insert thr-str)
-       (if wl-summary-highlight
-           (wl-highlight-summary-current-line))))))
-
 (defun wl-thread-set-parent (&optional parent-number)
   "Set current message's parent interactively."
   (interactive)