Function: org-element-adopt

org-element-adopt is a byte-compiled function defined in org-element-ast.el.gz.

Signature

(org-element-adopt PARENT &rest CHILDREN)

Documentation

Append CHILDREN to the contents of PARENT.

PARENT is a syntax node. CHILDREN can be elements, objects, or strings.

If PARENT is nil, create a new anonymous node containing CHILDREN.

The function takes care of setting :parent property for each child. Return the modified PARENT.

Aliases

org-element-adopt-elements

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element-ast.el.gz
(defun org-element-adopt (parent &rest children)
  "Append CHILDREN to the contents of PARENT.

PARENT is a syntax node.  CHILDREN can be elements, objects, or
strings.

If PARENT is nil, create a new anonymous node containing CHILDREN.

The function takes care of setting `:parent' property for each child.
Return the modified PARENT."
  (declare (indent 1))
  (if (not children) parent
    ;; Link every child to PARENT. If PARENT is nil, it is a secondary
    ;; string: parent is the list itself.
    (dolist (child children)
      (when child
        (org-element-put-property child :parent (or parent children))))
    ;; Add CHILDREN at the end of PARENT contents.
    (when parent
      (apply #'org-element-set-contents
	     parent
	     (nconc (org-element-contents parent) children)))
    ;; Return modified PARENT element.
    (or parent children)))