From df3396bd8f98eca3bf63550410d33cacf514830f Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 5 Jun 2022 14:14:56 -0700 Subject: [PATCH] [oni-org] Search through the archive for project tasks When I archive tasks I still want them to show up in the projects. --- oni-org/oni-org.el | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index a1f9336..9f5cfaf 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2022.0526.181315 +;; Version: 2022.0602.214649 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti mixed-pitch) ;; This program is free software; you can redistribute it and/or modify @@ -828,24 +828,30 @@ This is an around advice for ‘org-html--svg-image’ as FUN." (add-hook 'org-property-allowed-value-functions #'oni-org-pick-project) (defun oni-org-dblock-write-project-steps (_params) - "Generate backlinks to org headings." - (let ((current-heading (nth 4 (org-heading-components))) - (current-heading-id + "Generate back-links to org headings." + (let ((current-heading-id (let ((properties (org-entry-properties))) (or (alist-get "CUSTOM_ID" properties nil nil #'string=) (org-id-get-create)))) + (files (org-add-archive-files (list (buffer-file-name)))) backlinks) (when (not (null current-heading-id)) (save-excursion - (goto-char (point-min)) - (while (re-search-forward - (rx (or (seq "[[id:" (literal current-heading-id) "]") - (seq "#" (literal current-heading-id) "]"))) - nil t) - (unless (or (oni-org-in-dblock-p) - (oni-org-at-origin-property-p)) - (let ((components (org-heading-components))) - (push (list (org-entry-is-done-p) (point) (nth 4 components)) backlinks)))))) + (mapc (lambda (file) + (with-current-buffer (or (get-file-buffer file) + (progn + (find-file-noselect file) + (get-file-buffer file))) + (goto-char (point-min)) + (while (re-search-forward + (rx (or (seq "[[id:" (literal current-heading-id) "]") + (seq "#" (literal current-heading-id) "]"))) + nil t) + (unless (or (oni-org-in-dblock-p) + (oni-org-at-origin-property-p)) + (let ((components (org-heading-components))) + (push (list (org-entry-is-done-p) (point) (nth 4 components)) backlinks)))))) + files))) (insert (string-join (mapcar (lambda (link) (concat "- " (if (car link) "[X]" "[ ]") " [[*" (caddr link) "][" (caddr link) "]]"))