Function: mh-thread-add-link
mh-thread-add-link is a byte-compiled function defined in
mh-thread.el.gz.
Signature
(mh-thread-add-link PARENT CHILD &optional AT-END-P)
Documentation
Add links so that PARENT becomes a parent of CHILD.
Doesn't make any changes if CHILD is already an ancestor of PARENT. If optional argument AT-END-P is non-nil, the CHILD is added to the end of the children list of PARENT.
Source Code
;; Defined in /usr/src/emacs/lisp/mh-e/mh-thread.el.gz
(defsubst mh-thread-add-link (parent child &optional at-end-p)
"Add links so that PARENT becomes a parent of CHILD.
Doesn't make any changes if CHILD is already an ancestor of
PARENT. If optional argument AT-END-P is non-nil, the CHILD is
added to the end of the children list of PARENT."
(let ((parent-container (cond ((null parent) nil)
((mh-thread-container-p parent) parent)
(t (mh-thread-id-container parent))))
(child-container (if (mh-thread-container-p child)
child (mh-thread-id-container child))))
(when (and parent-container
(not (mh-thread-ancestor-p child-container parent-container))
(not (mh-thread-ancestor-p parent-container child-container)))
(mh-thread-remove-parent-link child-container)
(cond ((not at-end-p)
(push child-container (mh-container-children parent-container)))
((null (mh-container-children parent-container))
(push child-container (mh-container-children parent-container)))
(t (let ((last-child (mh-container-children parent-container)))
(while (cdr last-child)
(setq last-child (cdr last-child)))
(setcdr last-child (cons child-container nil)))))
(setf (mh-container-parent child-container) parent-container))
(unless parent-container
(mh-thread-remove-parent-link child-container))))