From f58d0bc605c5e6775feecadb568ee63c7ce7b507 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 21 Feb 2022 19:33:26 -0500 Subject: [PATCH] ENH inherit links while scanning through buffer --- local/lib/org-x/org-x-dag.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/local/lib/org-x/org-x-dag.el b/local/lib/org-x/org-x-dag.el index d795469..28877c4 100644 --- a/local/lib/org-x/org-x-dag.el +++ b/local/lib/org-x/org-x-dag.el @@ -934,7 +934,8 @@ valid keyword or none of its parents have valid keywords." this-title (-if-let (s (match-string 3)) (s-trim s) "") this-tags (-some-> (match-string-no-properties 4) (split-string ":" t)) - this-key nil) + this-key nil + this-links nil) ;; Adjust the stack so that the top headline is the parent of the ;; current headline (while (and cur-path (<= this-level (nth 0 (car cur-path)))) @@ -953,9 +954,11 @@ valid keyword or none of its parents have valid keywords." (--mapcat (nth 2 it)) (append this-tags org-file-tags)) this-tags) - ;; TODO this could be inherited to make parent linking easier later this-links (or (org-x-dag-get-parent-links) - (when (not this-parent-key) this-file-links)) + (if this-parent-key + (-some->> (--first (nth 3 it) cur-path) + (nth 3)) + this-file-links)) this-meta (org-x-dag-build-meta file this-point this-level @@ -964,10 +967,9 @@ valid keyword or none of its parents have valid keywords." all-tags this-parent-key)) (!cons (cons this-key this-meta) acc-meta) - (!cons (cons this-key (append (list (nth 1 this-parent)) this-links)) - acc)) + (!cons (cons this-key `(,(nth 1 this-parent) ,@this-links)) acc)) ;; Add current headline to stack - (!cons (list this-level this-key this-tags) cur-path)) + (!cons (list this-level this-key this-tags this-links) cur-path)) (list (nreverse acc) (nreverse acc-meta)))) (defun org-x-dag-get-file-nodes (file)