1
0
Fork 0

Add the TODO state to backlinks

This commit is contained in:
Tom Willemse 2020-11-19 23:57:20 -08:00
parent e800025945
commit 8280bce15c

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2020.1119.234558
;; Version: 2020.1119.235712
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org-plus-contrib org-bullets org-edna diminish all-the-icons)
;; This program is free software; you can redistribute it and/or modify
@ -168,17 +168,21 @@ _l_: Store link ^^ _j_: Journal entry
(while (re-search-forward (rx-to-string `(and "*" ,current-heading "]")) nil t)
(unless (or (oni-org-in-dblock-p)
(oni-org-at-origin-property-p))
(push (nth 4 (org-heading-components)) backlinks))))
(let ((components (org-heading-components)))
(push (cons (nth 2 components) (nth 4 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)))))
(unless (or (oni-org-in-dblock-p)
(oni-org-at-origin-property-p))
(let ((components (org-heading-components)))
(push (cons (nth 2 components) (nth 4 components)) backlinks))))))
(insert (string-join
(mapcar (lambda (link)
(concat "- [[*" link "][" link "]]"))
(sort (seq-uniq backlinks #'string=) #'string<))
(concat "- [[*" (cdr link) "][" (if (car link) (format "%s - " (car link)) "") (cdr link) "]]"))
(sort (seq-uniq backlinks (lambda (a b) (string= (cdr a) (cdr b))))
(lambda (a b) (string< (cdr a) (cdr b)))))
"\n"))))
(defalias 'org-dblock-write:oni-backlinks 'oni-org-dblock-write-backlinks)