- (delq msg wl-summary-buffer-number-list))
- (setq older-brothers (wl-thread-entity-get-older-brothers
- entity nil))
- (setq 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))))
-
+ (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.
+ (let (children
+ (older-brothers (wl-thread-entity-get-older-brothers
+ entity parent))
+ (younger-brothers (wl-thread-entity-get-younger-brothers
+ entity parent)))
+ (unless deep
+ (setq children (wl-thread-entity-get-children entity))
+ (wl-thread-reparent-children
+ children (wl-thread-entity-get-number parent))
+ (setq update-msgs
+ (apply (function nconc)
+ update-msgs
+ (mapcar
+ (function
+ (lambda (message)
+ (wl-thread-get-children-msgs message t)))
+ children))))
+ (wl-thread-entity-set-children
+ parent (append older-brothers children younger-brothers))
+ ;; If chidren and younger-brothers do not exist,
+ ;; update nearly older brother.
+ (when (and older-brothers
+ (not younger-brothers)
+ (not children))
+ (wl-append
+ update-msgs
+ (wl-thread-get-children-msgs (car (last older-brothers))))))
+ ;; top...oldest child becomes top.
+ (unless deep
+ (let ((children (wl-thread-entity-get-children entity)))
+ (when children
+ (setq top-child (car children)
+ children (cdr children))
+ (setq top-entity (wl-thread-get-entity top-child))
+ (wl-thread-entity-set-parent top-entity nil)
+ (wl-thread-entity-set-linked top-entity nil)
+ (wl-append update-msgs
+ (wl-thread-get-children-msgs top-child t)))
+ (when children
+ (wl-thread-entity-set-children
+ top-entity
+ (append
+ (wl-thread-entity-get-children top-entity)
+ children))
+ (wl-thread-reparent-children children top-child)
+ (wl-append update-msgs children))))
+ ;; delete myself from top list.
+ (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))))))))
+ ;;