From 8280bce15c8f3e3b0fd34274c77c2397d55badea Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 19 Nov 2020 23:57:20 -0800 Subject: [PATCH] Add the TODO state to backlinks --- oni-org/oni-org.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index bd43c7b..be193b9 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; 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)