I often leave TODOs in my notes if I need to complete a train of thought or elaborate on something. I’ve been trying to implement an agenda view which picks up TODOs from not only the current note, but ones that are closely linked to it.
The minimum (not) working example I came up with was adding an custom agenda view which rebinds the
(setq org-agenda-custom-commands '(("e" "todos in nearby notes" ((todo "" ((org-agenda-files (org-roam-db--links-with-max-distance buffer-file-name 3))))))))
org-roam-db--links-with-max-distance call gets a list of all files that are within 3 links of the file in the current buffer. This doesn’t seem to work because by the time the let binding is evaluated,
buffer-file-name evaluates to nil because the agenda buffer is already created.
The other option I (and @zaeph) considered were just a wrapper around the agenda view. My version of this was
(defun tq/agenda-nearby-notes () (interactive) (let ((org-agenda-files (org-roam-db--links-with-max-distance buffer-file-name 3))) (org-todo-list)))
(defun zp/org-roam-agenda () (interactive) (let ((org-agenda-custom-commands `(("e" "todos in nearby notes" ((todo "" ((org-agenda-files ',(org-roam-db--links-with-max-distance (buffer-file-name) 3))))))))) (org-agenda nil "e")))
Disadvantages of wrappers are that It can’t be launched from my the default
org-agenda dispatcher, but it does give a bit more flexibility in functionality.
Has anyone implemented anything similar to this or has a better version they use?