Function: org-list-parents-alist
org-list-parents-alist is a byte-compiled function defined in
org-list.el.gz.
Signature
(org-list-parents-alist STRUCT)
Documentation
Return alist between item and parent in STRUCT.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-list.el.gz
(defun org-list-parents-alist (struct)
"Return alist between item and parent in STRUCT."
(let* ((ind-to-ori (list (list (nth 1 (car struct)))))
(top-item (org-list-get-top-point struct))
(prev-pos (list top-item)))
(cons prev-pos
(mapcar (lambda (item)
(let ((pos (car item))
(ind (nth 1 item))
(prev-ind (caar ind-to-ori)))
(push pos prev-pos)
(cond
((> prev-ind ind)
;; A sub-list is over. Find the associated
;; origin in IND-TO-ORI. If it cannot be
;; found (ill-formed list), set its parent as
;; the first item less indented. If there is
;; none, make it a top-level item.
(setq ind-to-ori
(or (member (assq ind ind-to-ori) ind-to-ori)
(catch 'exit
(mapc
(lambda (e)
(when (< (car e) ind)
(throw 'exit (member e ind-to-ori))))
ind-to-ori)
(list (list ind)))))
(cons pos (cdar ind-to-ori)))
;; A sub-list starts. Every item at IND will
;; have previous item as its parent.
((< prev-ind ind)
(let ((origin (nth 1 prev-pos)))
(push (cons ind origin) ind-to-ori)
(cons pos origin)))
;; Another item in the same sub-list: it shares
;; the same parent as the previous item.
(t (cons pos (cdar ind-to-ori))))))
(cdr struct)))))