condensed org element parent tree function
This commit is contained in:
parent
750d37652c
commit
bf3a252eae
14
conf.org
14
conf.org
|
@ -2805,7 +2805,7 @@ TYPE is an org element type symbol and OBJ is a list of elements/objects."
|
||||||
(nd/org-element-find-type type obj-rem))))
|
(nd/org-element-find-type type obj-rem))))
|
||||||
|
|
||||||
(defun nd/org-element-get-parent-type (type obj)
|
(defun nd/org-element-get-parent-type (type obj)
|
||||||
"Return parent element of type TYPE for obj or nil if not found."
|
"Return parent element of type TYPE for OBJ or nil if not found."
|
||||||
(when obj
|
(when obj
|
||||||
(let ((parent (org-element-property :parent obj)))
|
(let ((parent (org-element-property :parent obj)))
|
||||||
(if (eq type (org-element-type parent))
|
(if (eq type (org-element-type parent))
|
||||||
|
@ -2820,17 +2820,15 @@ TYPE is an org element type symbol and OBJ is a list of elements/objects."
|
||||||
parent
|
parent
|
||||||
(nd/org-element-get-parent-headline parent)))))
|
(nd/org-element-get-parent-headline parent)))))
|
||||||
|
|
||||||
;; TODO merge thing above with thing below
|
|
||||||
(defun nd/org-element-get-parent-tree (obj &optional acc)
|
(defun nd/org-element-get-parent-tree (obj &optional acc)
|
||||||
"Construct parent tree path for object OBJ and concatenate to ACC.
|
"Construct parent tree path for object OBJ and concatenate to ACC.
|
||||||
Returns '/' delimited path of headlines or nil if obj is in a toplevel
|
Returns '/' delimited path of headlines or nil if obj is in a toplevel
|
||||||
headline."
|
headline."
|
||||||
(let ((parent (org-element-property :parent obj)))
|
(let ((parent-hl (nd/org-element-get-parent-headline obj)))
|
||||||
(if parent
|
(if parent-hl
|
||||||
(let* ((txt (and (eq 'headline (org-element-type parent))
|
(let* ((txt (org-element-property :raw-value parent-hl))
|
||||||
(org-element-property :raw-value parent)))
|
(new-acc (concat "/" txt acc)))
|
||||||
(acc-new (if txt (concat "/" txt acc) acc)))
|
(nd/org-element-get-parent-tree parent-hl new-acc))
|
||||||
(nd/org-element-get-parent-tree parent acc-new))
|
|
||||||
acc)))
|
acc)))
|
||||||
|
|
||||||
(defun nd/org-element-get-parent-tags (obj &optional acc)
|
(defun nd/org-element-get-parent-tags (obj &optional acc)
|
||||||
|
|
Loading…
Reference in New Issue