1
0
Fork 0

[oni-org] Search through the archive for project tasks

When I archive tasks I still want them to show up in the projects.
This commit is contained in:
Tom Willemse 2022-06-05 14:14:56 -07:00
parent c63f5f0fec
commit df3396bd8f

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; 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) ;; 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 ;; 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) (add-hook 'org-property-allowed-value-functions #'oni-org-pick-project)
(defun oni-org-dblock-write-project-steps (_params) (defun oni-org-dblock-write-project-steps (_params)
"Generate backlinks to org headings." "Generate back-links to org headings."
(let ((current-heading (nth 4 (org-heading-components))) (let ((current-heading-id
(current-heading-id
(let ((properties (org-entry-properties))) (let ((properties (org-entry-properties)))
(or (alist-get "CUSTOM_ID" properties nil nil #'string=) (or (alist-get "CUSTOM_ID" properties nil nil #'string=)
(org-id-get-create)))) (org-id-get-create))))
(files (org-add-archive-files (list (buffer-file-name))))
backlinks) backlinks)
(when (not (null current-heading-id)) (when (not (null current-heading-id))
(save-excursion (save-excursion
(goto-char (point-min)) (mapc (lambda (file)
(while (re-search-forward (with-current-buffer (or (get-file-buffer file)
(rx (or (seq "[[id:" (literal current-heading-id) "]") (progn
(seq "#" (literal current-heading-id) "]"))) (find-file-noselect file)
nil t) (get-file-buffer file)))
(unless (or (oni-org-in-dblock-p) (goto-char (point-min))
(oni-org-at-origin-property-p)) (while (re-search-forward
(let ((components (org-heading-components))) (rx (or (seq "[[id:" (literal current-heading-id) "]")
(push (list (org-entry-is-done-p) (point) (nth 4 components)) backlinks)))))) (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 (insert (string-join
(mapcar (lambda (link) (mapcar (lambda (link)
(concat "- " (if (car link) "[X]" "[ ]") " [[*" (caddr link) "][" (caddr link) "]]")) (concat "- " (if (car link) "[X]" "[ ]") " [[*" (caddr link) "][" (caddr link) "]]"))