Function: org-element--parse-objects
org-element--parse-objects is a byte-compiled function defined in
org-element.el.gz.
Signature
(org-element--parse-objects BEG END ACC RESTRICTION &optional PARENT)
Documentation
Parse objects between BEG and END and return recursive structure.
Objects are accumulated in ACC. RESTRICTION is a list of object successors which are allowed in the current object.
ACC becomes the parent for all parsed objects. However, if ACC is nil (i.e., a secondary string is being parsed) and optional argument PARENT is non-nil, use it as the parent for all objects. Eventually, if both ACC and PARENT are nil, the common parent is the list of objects itself.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defun org-element--parse-objects (beg end acc restriction &optional parent)
"Parse objects between BEG and END and return recursive structure.
Objects are accumulated in ACC. RESTRICTION is a list of object
successors which are allowed in the current object.
ACC becomes the parent for all parsed objects. However, if ACC
is nil (i.e., a secondary string is being parsed) and optional
argument PARENT is non-nil, use it as the parent for all objects.
Eventually, if both ACC and PARENT are nil, the common parent is
the list of objects itself."
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(let (next-object contents)
(while (and (not (eobp))
(setq next-object (org-element--object-lex restriction)))
;; Text before any object.
(let ((obj-beg (org-element-begin next-object)))
(unless (= (point) obj-beg)
(let ((text (buffer-substring-no-properties (point) obj-beg)))
(push (if acc (org-element-put-property text :parent acc) text)
contents))))
;; Object...
(let ((obj-end (org-element-end next-object))
(cont-beg (org-element-contents-begin next-object)))
(when acc (org-element-put-property next-object :parent acc))
(push (if cont-beg
;; Fill contents of NEXT-OBJECT if possible.
(org-element--parse-objects
cont-beg
(org-element-contents-end next-object)
next-object
(org-element-restriction next-object))
next-object)
contents)
(goto-char obj-end)))
;; Text after last object.
(unless (eobp)
(let ((text (buffer-substring-no-properties (point) end)))
(push (if acc (org-element-put-property text :parent acc) text)
contents)))
;; Result. Set appropriate parent.
(if acc (apply #'org-element-set-contents acc (nreverse contents))
(let* ((contents (nreverse contents))
(parent (or parent contents)))
(dolist (datum contents contents)
(org-element-put-property datum :parent parent))))))))