1
0
Fork 0

[oni-org-roam] Add any files with tasks in them to org agenda files

This commit is contained in:
Tom Willemse 2021-11-16 21:38:33 -08:00
parent ad7152a4d2
commit 9a7c7e0673

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2021.1028.195800
;; Version: 2021.1116.213141
;; Package-Requires: (oni-org org-roam)
;; This program is free software; you can redistribute it and/or modify
@ -30,11 +30,29 @@
;;; Code:
(require 'org-roam)
(require 'seq)
(setq org-roam-completion-everywhere t)
(setq org-roam-directory (expand-file-name "~/documents/exocortex/"))
(mkdir org-roam-directory t)
;;; Taken from/inspired by
;;; https://magnus.therning.org/2021-07-23-keeping-todo-items-in-org-roam-v2.html
(defun oni-org-roam--todo-node-p (node)
"Predicate to check whether or not NODE is task."
(not (null (org-roam-node-todo node))))
(defun oni-org-roam--todo-files ()
"Get a list of all the files in the org-roam database with tasks in them."
(let ((nodes (seq-filter #'oni-org-roam--todo-node-p (org-roam-node-list))))
(seq-uniq (seq-map #'org-roam-node-file nodes))))
(defun oni-org-roam-update-todo-files (&rest _)
"Set org-agenda-files to all roam files with a task in them."
(setq org-agenda-files (seq-uniq (append org-agenda-files (oni-org-roam--todo-files)))))
(advice-add 'org-agenda :before #'oni-org-roam-update-todo-files)
;;;###autoload
(setq org-roam-v2-ack t)