1
0
Fork 0

Include links that use the custom id

This commit is contained in:
Tom Willemse 2020-09-22 22:15:33 -07:00
parent e9b7271ceb
commit 91a59dcd56

View file

@ -153,12 +153,19 @@ _l_: Store link ^^ _j_: Journal entry
(defun oni-org-dblock-write-backlinks (_params) (defun oni-org-dblock-write-backlinks (_params)
"Generate backlinks to org headings." "Generate backlinks to org headings."
(let ((current-heading (nth 4 (org-heading-components))) (let ((current-heading (nth 4 (org-heading-components)))
(current-heading-id (alist-get "CUSTOM_ID" (org-entry-properties) nil nil #'string=))
backlinks) backlinks)
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (rx-to-string `(and "*" ,current-heading "]")) nil t) (while (re-search-forward (rx-to-string `(and "*" ,current-heading "]")) nil t)
(unless (oni-org-in-dblock-p) (unless (oni-org-in-dblock-p)
(push (nth 4 (org-heading-components)) backlinks)))) (push (nth 4 (org-heading-components)) backlinks))))
(when (not (null current-heading-id))
(save-excursion
(goto-char (point-min))
(while (re-search-forward (rx-to-string `(and "#" ,current-heading-id "]")) nil t)
(unless (oni-org-in-dblock-p)
(push (nth 4 (org-heading-components)) backlinks)))))
(insert (string-join (insert (string-join
(mapcar (lambda (link) (mapcar (lambda (link)
(concat "- [[*" link "][" link "]]")) (concat "- [[*" link "][" link "]]"))