(defun wl-thread-save-top-list (dir)
(let ((top-file (expand-file-name wl-thread-entity-list-file dir))
(entity wl-thread-entity-list)
- (tmp-buffer (get-buffer-create " *wl-thread-save-top-list*"))
print-length)
- (save-excursion
- (set-buffer tmp-buffer)
- (erase-buffer)
+ (with-temp-buffer
(when (file-writable-p top-file)
- (prin1 entity tmp-buffer)
- (princ "\n" tmp-buffer)
- (write-region (point-min) (point-max) top-file nil 'no-msg)
- (kill-buffer tmp-buffer)))))
+ (prin1 entity (current-buffer))
+ (princ "\n" (current-buffer))
+ (write-region (point-min) (point-max) top-file nil 'no-msg)))))
(defun wl-thread-save-entities (dir)
(let ((top-file (expand-file-name wl-thread-entity-file dir))
(entities wl-thread-entities)
- (tmp-buffer (get-buffer-create " *wl-thread-save-entities*"))
print-length print-level)
- (save-excursion
- (set-buffer tmp-buffer)
- (erase-buffer)
+ (with-temp-buffer
(when (file-writable-p top-file)
- (prin1 entities tmp-buffer)
- (princ "\n" tmp-buffer)
- (write-region (point-min) (point-max) top-file nil 'no-msg)
- (kill-buffer tmp-buffer)))))
+ (prin1 entities (current-buffer))
+ (princ "\n" (current-buffer))
+ (write-region (point-min) (point-max) top-file nil 'no-msg)))))
(defsubst wl-thread-entity-get-number (entity)
(nth 0 entity))
(setq entity (wl-thread-get-entity (car msgs))))
ret-val))
-(defsubst wl-thread-entity-get-descendant (entity)
+(defun wl-thread-entity-get-descendant (entity)
(let (children
ret-val msgs-stack
(msgs (list (car entity))))
(if (null children)
(while (and (null msgs) msgs-stack)
(setq msgs (wl-pop msgs-stack)))
- (setq ret-val (append ret-val (copy-sequence children)))
+ (setq ret-val (nconc ret-val (copy-sequence children)))
(wl-push msgs msgs-stack)
(setq msgs children))
(setq entity (wl-thread-get-entity (car msgs))))
(cdr (memq (car entity) wl-thread-entity-list)))))
(defun wl-thread-jump-to-msg (&optional number)
+ "Jump to the message with specified number in the current summary."
(interactive)
(let ((num (or number
(string-to-int
(parent-msg (or parent-msg (wl-thread-entity-get-parent entity)))
(buffer-read-only nil)
(inhibit-read-only t)
- message-entity temp-mark summary-line invisible-top dest-pair)
+ message-entity temp-mark summary-line invisible-top)
(if (wl-thread-delete-line-from-buffer msg)
(progn
(cond
((memq msg wl-summary-buffer-target-mark-list)
(setq temp-mark "*"))
((setq temp-mark (wl-summary-registered-temp-mark msg))
- (setq dest-pair (cons (nth 0 temp-mark)(nth 2 temp-mark))
- temp-mark (nth 1 temp-mark)))
+ (setq temp-mark (nth 1 temp-mark)))
(t (setq temp-mark (wl-summary-get-score-mark msg))))
(when (setq message-entity
(elmo-message-entity wl-summary-buffer-elmo-folder
(elmo-message-entity wl-summary-buffer-elmo-folder
parent-msg)
temp-mark
- (elmo-message-flags wl-summary-buffer-elmo-folder
- msg)
- (elmo-message-cached-p wl-summary-buffer-elmo-folder
- msg)
+ (elmo-message-status wl-summary-buffer-elmo-folder msg)
(if wl-thread-insert-force-opened
nil
(wl-thread-maybe-get-children-num msg))
(wl-thread-make-indent-string entity)
- (wl-thread-entity-get-linked entity)))
- (if dest-pair
- (wl-summary-print-argument (car dest-pair)
- (cdr dest-pair)))))
+ (wl-thread-entity-get-linked entity)))))
;; insert thread (moving thread)
(if (not (setq invisible-top
(wl-thread-entity-parent-invisible-p entity)))
(let ((entity (wl-thread-get-entity msg))
top-child top-entity update-msgs invisible-top)
(setq wl-summary-buffer-number-list
- (delq msg wl-summary-buffer-number-list))
+ (delq msg wl-summary-buffer-number-list))
(when entity
+ (when deep
+ (setq wl-summary-buffer-number-list
+ (elmo-list-delete
+ (wl-thread-entity-get-descendant entity)
+ wl-summary-buffer-number-list
+ #'delq)))
(let ((parent (wl-thread-entity-get-parent-entity entity)))
(if parent
;; has parent.
(wl-thread-reparent-children children top-child)
(wl-append update-msgs children))))
;; delete myself from top list.
- (let ((older-brothers (wl-thread-entity-get-older-brothers
- entity nil))
- (younger-brothers (wl-thread-entity-get-younger-brothers
- entity nil)))
- (setq wl-thread-entity-list
- (append (append older-brothers
- (and top-child (list top-child)))
- younger-brothers))))))
+ (let ((match (memq msg wl-thread-entity-list)))
+ (when match
+ (if top-child
+ (setcar match top-child)
+ (setq wl-thread-entity-list
+ (delq msg wl-thread-entity-list))))))))
;;
(if deep
;; delete thread on buffer
When optional argument UPDATE is non-nil,
Message is inserted to the summary buffer."
(let ((parent (wl-thread-get-entity parent-msg))
- (depth 0) cur
child-entity invisible-top)
;;; Update the thread view...not implemented yet.
;;; (when force-insert
;;; (if parent
;;; (wl-thread-entity-force-open parent))
(when (and wl-summary-max-thread-depth parent)
- (setq cur parent)
- (while cur
- (incf depth)
- (setq cur (wl-thread-entity-get-parent-entity cur)))
- (when (> depth wl-summary-max-thread-depth)
- (setq parent nil)))
+ (let ((cur parent)
+ (depth 0))
+ (while cur
+ (incf depth)
+ (setq cur (wl-thread-entity-get-parent-entity cur)))
+ (when (> depth wl-summary-max-thread-depth)
+ (setq parent nil
+ parent-msg nil))))
(if parent
;; insert as children.
(wl-thread-entity-insert-as-children
(wl-thread-update-children-number invisible-top)
nil))))
+;(defun wl-thread-get-parent-list (msgs)
+; ;; return ancestors
+; (let* ((msgs2 msgs)
+; myself)
+; (while msgs2
+; (setq myself (car msgs2)
+; msgs2 (cdr msgs2))
+; (while (not (eq myself (car msgs2)))
+; (if (wl-thread-descendant-p myself (car msgs2))
+; (setq msgs (delq (car msgs2) msgs)))
+; (setq msgs2 (or (cdr msgs2) msgs)))
+; (setq msgs2 (cdr msgs2)))
+; msgs))
+
(defun wl-thread-get-parent-list (msgs)
- (let* ((msgs2 msgs)
- myself)
- (while msgs2
- (setq myself (car msgs2)
- msgs2 (cdr msgs2))
- (while (not (eq myself (car msgs2)))
- (if (wl-thread-descendant-p myself (car msgs2))
- (setq msgs (delq (car msgs2) msgs)))
- (setq msgs2 (or (cdr msgs2) msgs)))
- (setq msgs2 (cdr msgs2)))
- msgs))
+ ;; return connected ancestors
+ (let ((ptr msgs)
+ parent ret)
+ (while (car ptr)
+ (setq parent (wl-thread-entity-get-parent (wl-thread-get-entity (car ptr))))
+ (when (or (not parent)
+ (not (memq parent msgs)))
+ (setq ret (append ret (list (car ptr)))))
+ (setq ptr (cdr ptr)))
+ ret))
(defun wl-thread-update-indent-string-thread (top-list)
- (let ((top-list (wl-thread-get-parent-list top-list))
- beg)
+ (let* ((top-list (wl-thread-get-parent-list top-list))
+ (num (length top-list))
+ (i 0)
+ beg)
(while top-list
+ (when (> num elmo-display-progress-threshold)
+ (setq i (1+ i))
+ (when (or (zerop (% i 5)) (= i num))
+ (elmo-display-progress
+ 'wl-thread-update-indent-string-thread
+ "Updating thread indent..."
+ (/ (* i 100) num))))
(when (car top-list)
(wl-summary-jump-to-msg (car top-list))
(setq beg (point))
(wl-thread-goto-bottom-of-sub-thread)
(wl-thread-update-indent-string-region beg (point)))
- (setq top-list (cdr top-list)))))
+ (setq top-list (cdr top-list)))
+ (message "Updating thread indent...done")))
(defun wl-thread-update-children-number (entity)
"Update the children number."
(interactive "P")
(wl-thread-call-region-func 'wl-summary-mark-as-important-region arg))
+(defun wl-thread-set-flags (&optional arg)
+ (interactive "P")
+ (wl-thread-call-region-func 'wl-summary-set-flags-region arg))
+
+(defun wl-thread-mark-as-answered (&optional arg)
+ (interactive "P")
+ (wl-thread-call-region-func 'wl-summary-mark-as-answered-region arg))
+
+(defun wl-thread-recover-messages (&optional arg)
+ "Recover killed messages which are contained current thread."
+ (interactive "P")
+ (wl-thread-call-region-func 'wl-summary-recover-messages-region arg))
+
(defun wl-thread-unmark (&optional arg)
(interactive "P")
(wl-thread-call-region-func 'wl-summary-unmark-region arg))
(defun wl-thread-force-open (&optional msg-num)
"force open current folder"
- (if msg-num
- (wl-summary-jump-to-msg msg-num))
- (let ((wl-thread-insert-force-opened t))
- (wl-thread-open-close)))
+ (when msg-num
+ (wl-summary-jump-to-msg msg-num))
+ (wl-thread-open-close 'force-open))
(defun wl-thread-entity-force-open (entity)
(let ((wl-thread-insert-force-opened t)
(elmo-message-entity wl-summary-buffer-elmo-folder
(nth 0 parent-entity))
temp-mark
- (elmo-message-flags wl-summary-buffer-elmo-folder
- msg-num)
- (elmo-message-cached-p wl-summary-buffer-elmo-folder
- msg-num)
+ (elmo-message-status wl-summary-buffer-elmo-folder msg-num)
(if wl-thread-insert-force-opened
nil
(wl-thread-maybe-get-children-num msg-num))
(incf depth)
(setq entity (wl-thread-get-entity number)))
depth))
-
+
(defun wl-thread-update-indent-string-region (beg end)
(interactive "r")
(save-excursion
(wl-thread-entity-set-children
dst-parent-entity
(append children (list number)))
- (wl-thread-entity-set-linked entity t))
+ (wl-thread-entity-set-linked
+ entity
+ (let ((parent (elmo-message-entity-parent
+ wl-summary-buffer-elmo-folder
+ (elmo-message-entity
+ wl-summary-buffer-elmo-folder
+ number))))
+ (or (null parent)
+ (/= parent-number (elmo-message-entity-number parent))))))
;; insert as top
(wl-append wl-thread-entity-list (list number))
(wl-thread-entity-set-linked entity nil))