121 lines
4.9 KiB
Org Mode
121 lines
4.9 KiB
Org Mode
:PROPERTIES:
|
|
:ID: cce/dynamic_agendas
|
|
:ROAM_REFS: https://d12frosted.io/posts/2021-01-16-task-management-with-roam-vol5.html
|
|
:ROAM_ALIASES: "Task management with org-roam Vol. 5"
|
|
:END:
|
|
#+TITLE: Dynamic and fast agenda
|
|
#+ARCOLOGY_KEY: cce/dynamic-fast-agenda
|
|
#+ARROYO_MODULE_WANTS: cce/org-roam.org
|
|
#+ARROYO_MODULE_WANTS: cce/org_mode_installation.org
|
|
|
|
#+filetags: :CCE:
|
|
|
|
#+PROPERTY: header-args :mkdirp yes :results none
|
|
#+PROPERTY: header-args:emacs-lisp :tangle dynamic-fast-agenda.el
|
|
#+PROPERTY: header-args:yaml :tangle roles/endpoint/tasks/dynamic-fast-agenda.yml
|
|
|
|
#+ARROYO_EMACS_MODULE: dynamic-fast-agenda
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
#+begin_src emacs-lisp
|
|
(provide 'cce/dynamic-fast-agenda)
|
|
#+end_src
|
|
|
|
[[id:d17a9ccf-0bfe-426e-85b3-d15771d3ee03][Archive]] of [[ https://d12frosted.io/posts/2021-01-16-task-management-with-roam-vol5.html][this]] blog post about keeping the size of the =org-agenda-files= list as light as it can be
|
|
|
|
#+begin_quote
|
|
In my experience, once I reached 1200 note files, org-agenda constantly took more than 50 seconds to build, rendering this tool completely useless. But then I realised that only 3% of those files actually contain any TODO entries, so there is no need to traverse whole org-roam-directory!
|
|
#+end_quote
|
|
|
|
#+SUMMARY:
|
|
This is a clever use of the [[id:cce/org-roam][org-roam]] APIs and database to automatically populate the [[id:cce/my_org_mode_agendas][Org-mode Agendas]] file list, and has some really neat ideas which I'll integrate in to the [[id:cce/cce][CCE]] I think.
|
|
Without migrating out of [[id:47a31dca-d077-4cd8-ab3b-f98427696302][Projects]], I have src_elisp{(length org-agenda-files)} {{{results(=22=)}}} files which are Project and Agendize tagged.
|
|
|
|
I use this to keep track of todo items in my org day-journal, to split out work that needs to be done in my Agendas, and not to lose track of long-term or low priority projects
|
|
|
|
|
|
It works by having a save-hook that adds or removes a =Project= filetag if there are any TODO items on the page, and then there is a hook in the =org-agenda= functionality to use the org-roam database
|
|
|
|
* =org-element= search and update
|
|
|
|
I might turn this off.
|
|
|
|
There is some really sharp code in here to use the [[roam:Org Element]] API to search for =TODO= headlines and add a =Project= tag to the =ROAM_TAGS= [[id:cce/org-roam][org-roam]] metadata keyword:
|
|
|
|
#+begin_src emacs-lisp
|
|
(defun +org-notes-project-p ()
|
|
"Return non-nil if current buffer has any todo entry.
|
|
|
|
TODO entries marked as done are ignored, meaning the this
|
|
function returns nil if current buffer contains only completed
|
|
tasks."
|
|
(seq-find
|
|
(lambda (type)
|
|
(eq type 'todo))
|
|
(org-element-map
|
|
(org-element-parse-buffer 'headline)
|
|
'headline
|
|
(lambda (h)
|
|
(org-element-property :todo-type h)))))
|
|
|
|
(add-hook 'before-save-hook #'+org-notes-project-update-tag)
|
|
|
|
(defun +org-notes-project-update-tag ()
|
|
"Update PROJECT tag in the current buffer."
|
|
(save-excursion
|
|
(goto-char (point-min))
|
|
(when (and (not (active-minibuffer-window))
|
|
(+org-notes-buffer-p))
|
|
(if (+org-notes-project-p)
|
|
(org-roam-tag-add '("Project"))
|
|
(org-roam-tag-remove '("Project"))))))
|
|
|
|
(defun +org-notes-buffer-p ()
|
|
"Return non-nil if the currently visited buffer is a note."
|
|
(and buffer-file-name
|
|
(string-prefix-p
|
|
(expand-file-name (file-name-as-directory org-roam-directory))
|
|
(file-name-directory buffer-file-name))))
|
|
#+end_src
|
|
|
|
** DONE Evaluate turning this off.
|
|
SCHEDULED: <2021-03-08 Mon>
|
|
|
|
- Note taken on [2021-04-06 Tue 17:24] \\
|
|
i think this works pretty well, now that i have it working...
|
|
- State "DONE" from "NEXT" [2021-04-06 Tue 17:24]
|
|
I'm not sure I want this on by default, but it seems nice and great to have documented lying around.
|
|
|
|
* =org-agenda-list= updating
|
|
|
|
a query against the [[id:cce/org-roam][org-roam]] =tags= table is unfortunately un-normalized. I want to add =Agendize= roam tag to it as well, and since it's non-normal and I think unsorted in the DB i need to be careful about it. Finally, remove files tagged =Icebox=. it basically works though:
|
|
|
|
#+begin_src emacs-lisp :results none
|
|
(defun cce/org-roam-files-with-tags (&optional tags)
|
|
"Return a list of note files containing Project tag."
|
|
(let ((tags (or tags '("Project" "Agendize"))))
|
|
(thread-last
|
|
tags
|
|
(mapcar #'arcology-files-by-tag)
|
|
(apply #'append))))
|
|
#+end_src
|
|
|
|
and an advice function to update the DB before showing the agenda:
|
|
|
|
#+begin_src emacs-lisp :results none
|
|
(defun cce/agenda-files-update (&rest _)
|
|
"Update the value of `org-agenda-files'."
|
|
(setq org-agenda-files (cce/org-roam-files-with-tags)))
|
|
|
|
(advice-add 'org-agenda :before #'cce/agenda-files-update)
|
|
#+end_src
|
|
|
|
* Tasks
|
|
|
|
** DONE extend this to include [[id:Journal][Journal]] tasks! :Programming:CCE:
|
|
|
|
- State "DONE" from "NEXT" [2021-03-01 Mon 22:33]
|
|
- Note taken on [2021-03-01 Mon 16:52] \\
|
|
those should have a ROAM_TAG anyways.......
|
|
|