Task management with org-roam Vol. 6: Select a person and view related tasks
Sharing a quick utility I wrote to view all tasks related to a specific person in org-roam. By combining vulpea's selection functions with org-agenda's tag matching, we can easily see everything tagged with a person's name (including their aliases). Just a few lines of code, but it makes a big difference in managing person-related tasks!
In one of the previous articles (Vol. 3 to be precise) we talked about automatic setup of filetags
, so each of the task in note related to a person is automatically tagged thanks to tag inheritance. Then, in Vol. 4 we talked about automatic tagging of tasks whenever a person is mentioned either in the title or the body of some task. This all makes org-agenda
matching capabilities really useful for when we want to see the list of all tasks related to specific person.
In this article, we are going to write a small utility function that asks user to select a person and then presents and org-agenda
buffer with tasks related to selected person.
Believe me, intro is longer than the content!
Change Log:
[2021-03-02 Tue]
: Update naming convention to match personal configurations.[2021-05-10 Mon]
: Update post to reflect changes in org-roam v2. Previous version of this article is available on GitHub.[2022-07-11 Mon]
: Adapt code to changes in Org mode and new functions invulpea
. Combination ofvulpea-select-from
andvulpea-db-query-by-tags-some
works faster than genericvulpea-select
.
Related posts
- Task management with org-roam Vol. 7: Capture – Sharing my org-roam capture workflow, focusing on quick task entry and efficient processing. I've set up a dedicated inbox file per machine to avoid sync issues, and use org-agenda with the REFILE tag to process captured items. For meetings, I've created a smarter capture template that automatically places one-on-one notes in the right person's file - a nice example of using org-roam's query capabilities to streamline capture.
- Task management with org-roam Vol. 5: Dynamic and fast agenda – Sharing a significant performance optimization I created for org-roam agenda generation. By dynamically tracking notes containing TODOs with a 'project' tag, I reduced agenda loading from over 50 seconds to under 1 second. The solution automatically updates tags when files are visited or saved, querying only relevant files when building the agenda view. I've included all the code and explained the implementation details, from checking for TODO entries to SQL queries.
- Task management with org-roam Vol. 4: Automatic tagging – Sharing how I automated task tagging in org-roam with vulpea. When you mention someone in a task by linking to their note, the task automatically gets tagged with that person's name. I'm using vulpea-insert hooks to handle this cleanly, avoiding the need for advice on org-roam functions. The code includes checks to ensure we only add person tags to actual TODO items.
- Task management with org-roam Vol. 3: FILETAGS – Sharing my approach to managing person-related tasks in org-roam notes. I explain how to use filetags to automatically tag all tasks in a person's note (like @FrodoBaggins), maintaining the tag inheritance functionality from regular org-mode while moving to individual roam notes. I've included code to automate the tagging process, making it easier to maintain consistency when adding new people notes.
- Task management with org-roam Vol. 2: Categories – Sharing how I improved the agenda view for org-roam notes by fixing category display. Rather than showing file IDs, we can now show meaningful categories based on note titles or explicit CATEGORY properties. I've included a function to automatically extract and format categories, plus options to handle long titles gracefully. The result is a cleaner, more readable agenda that better integrates with org-roam's note-taking approach.
- Task management with org-roam Vol. 1: Path to Roam – Sharing my approach to task management in org-roam, showing how to organize tasks and projects across notes while maintaining compatibility with org-mode's agenda features. While org-roam favors smaller files over larger ones, we can still implement a familiar structure of tasks, projects, and meta-projects. The article explains the basic setup, though there are some visual quirks in the agenda buffer that we'll address in a follow-up post.
Long story short, here is the function you can bind or call by name using M-x
:
(defun vulpea-agenda-person () "Show main `org-agenda' view." (interactive) (let* ((person (vulpea-select-from "Person" (vulpea-db-query-by-tags-some '("people")))) (node (org-roam-node-from-id (vulpea-note-id person))) (names (cons (org-roam-node-title node) (org-roam-node-aliases node))) (tags (seq-map #'vulpea--title-to-tag names)) (query (string-join tags "|"))) (let ((org-agenda-overriding-arguments (list t query))) (org-agenda nil "M"))))
Now some explanations.
- This code uses vulpea library1 to select a person. You can achieve the same result without
vulpea
, of course, but it saves some effort.vulpea-select-from
asks the use to select a note from a list of notes, returned byvulpea-db-query-by-tags-some
. In this case, we simply present only people notes. The same result can be achieved by usingvulpea-select
that takes a predicate, butvulpea-db-query-by-tags-some
works faster. See Performance section ofvulpea
documentation. - Once we have a selected
vulpea-note
, we can get all titles on that file (e.g. main title and aliases). This is important for alias users. For example, in some notes I want use Mr. Frodo instead of Frodo Baggins, but I want to see tasks tagged as@Mr.Forod
and@FrodoBaggins
at the same time. It's the same person after all (don't ask me about Gollum, better useM-x doctor
)! - Now we simply convert those names into tags using
vulpea--title-to-tag
from Vol. 4. - Then we join the tags using
|
separator into single query string. - The last step is to execute
org-agenda
withM
argument (match for tags, but list onlyTODO
items). In order to pass a query to relevant agenda function, we useorg-agenda-overriding-arguments
. Not sure if it's documented anywhere, but you can read the sources oforg-agenda
to figure out how to use it.dlet
here is used for dynamic binding. If you are not using lexical scope, you can use regularlet
here.
That's it! Now see it in action, again.
References
Footnotes
-
Yikes, I advertise my own libraries on this blog! ↩