Function: org-element--list-struct
org-element--list-struct is a byte-compiled function defined in
org-element.el.gz.
Signature
(org-element--list-struct LIMIT)
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; Plain List
(defun org-element--list-struct (limit)
;; Return structure of list at point. Internal function. See
;; `org-list-struct' for details.
(let ((case-fold-search t)
(top-ind limit)
(item-re (org-item-re))
(inlinetask-re (and (featurep 'org-inlinetask)
(boundp 'org-inlinetask-min-level)
(boundp 'org-inlinetask-max-level)
(format "^\\*\\{%d,%d\\}+ "
org-inlinetask-min-level
org-inlinetask-max-level)))
items struct)
(save-excursion
(catch :exit
(while t
(cond
;; At limit: end all items.
((>= (point) limit)
(let ((end (progn (skip-chars-backward " \r\t\n")
(line-beginning-position 2))))
(dolist (item items) (setcar (nthcdr 6 item) end)))
(throw :exit (sort (nconc items struct) #'car-less-than-car)))
;; At list end: end all items.
((looking-at org-list-end-re)
(dolist (item items) (setcar (nthcdr 6 item) (point)))
(throw :exit (sort (nconc items struct) #'car-less-than-car)))
;; At a new item: end previous sibling.
((looking-at item-re)
(let ((ind (save-excursion (skip-chars-forward " \t")
(org-current-text-column))))
(setq top-ind (min top-ind ind))
(while (and items (<= ind (nth 1 (car items))))
(let ((item (pop items)))
(setcar (nthcdr 6 item) (point))
(push item struct)))
(push (progn (looking-at org-list-full-item-re)
(let ((bullet (match-string-no-properties 1)))
(list (point)
ind
bullet
(match-string-no-properties 2) ; counter
(match-string-no-properties 3) ; checkbox
;; Description tag.
(and (save-match-data
(string-match "[-+*]" bullet))
(match-string-no-properties 4))
;; Ending position, unknown so far.
nil)))
items))
(forward-line))
;; Skip empty lines.
((looking-at "^[ \t]*$") (forward-line))
;; Skip inline tasks and blank lines along the way.
((and inlinetask-re (looking-at inlinetask-re))
(forward-line)
(let ((origin (point)))
(when (re-search-forward inlinetask-re limit t)
(if (looking-at-p "END[ \t]*$") (forward-line)
(goto-char origin)))))
;; At some text line. Check if it ends any previous item.
(t
(let ((ind (save-excursion
(skip-chars-forward " \t")
(org-current-text-column)))
(end (save-excursion
(skip-chars-backward " \r\t\n")
(line-beginning-position 2))))
(while (<= ind (nth 1 (car items)))
(let ((item (pop items)))
(setcar (nthcdr 6 item) end)
(push item struct)
(unless items
(throw :exit (sort struct #'car-less-than-car))))))
;; Skip blocks (any type) and drawers contents.
(cond
((and (looking-at "[ \t]*#\\+BEGIN\\(:\\|_\\S-+\\)")
(re-search-forward
(format "^[ \t]*#\\+END%s[ \t]*$" (match-string 1))
limit t)))
((and (looking-at org-element-drawer-re)
(re-search-forward "^[ \t]*:END:[ \t]*$" limit t))))
(forward-line))))))))