Using categories to organize your Org agenda
Posted: - Modified: | emacs, orgD.C. Toedt wanted to share this tip for Org Mode agenda organization:
I've just discovered that it helps to add a :CATEGORY: property to the top-level, non-TODO heading that identifies the project. Using your example:
* Project ABC :PROPERTIES: :CATEGORY: ABC :END: ** TODO A task related to Project ABC ** TODO Another task related to ABC *** TODO Subtask SCHEDULED:In my bog-standard org-mode setup, this results in “ABC” being displayed in the far-left column of the agenda instead of just “todo” (which seems to be the default). This is great — it means that, in the text of the “Subtask” todo entry itself, I don't need to include a reminder of what project the todo entry is associated with.
Here's an agenda mockup to illustrate the point, augmented with a “default” entry from my own to-do list:
todo: Scheduled: Follow up on expense reimbursement request ABC: Scheduled: SubtaskThis also allows filtering the agenda by the category.
Thanks for sharing, D.C.!
The category actually defaults to the first part of your filename.org, so todo.org becomes todo, organizer.org becomes organizer, etc. I keep an organizer.org, routines.org, business.org, etc. Keeping my routine tasks in routines.org allows me to filter them with a custom agenda command like:
("w" "Weekly review" agenda "" ((org-agenda-span 7) (org-agenda-log-mode 1)) "~/Dropbox/agenda/this-week.html") ("W" "Weekly review sans routines" agenda "" ((org-agenda-span 7) (org-agenda-log-mode 1) (org-agenda-tag-filter-preset '("-routine"))) "~/Dropbox/agenda/this-week-nonroutine.html")
so that I can see all the tasks (including routine tasks) in my regular weekly review, and just the special stuff in a separate view. You can see the whole definition of org-agenda-custom-commands
in my Emacs configuration.
Update 2016-12-18: Oops! I just remembered that filtering by -routine
is actually made possible by the #+FILETAGS: :routine:
I have in routines.org, which has the additional benefit of allowing me to mark tasks in other files as routine by adding the :routine:
tag to them. You can, however, still use categories to filter your agenda. < (org-agenda-filter-by-category
) in an agenda view will filter by category, or use a match filter like CATEGORY="routines"
to match on the category. Also, it turns out you can set up category icons by customizing org-agenda-category-icon-alist
– hmm…
D.C.'s tip is handy if you want to keep those groups of tasks in one file, but still want that kind of visual indication in your agenda (and the ability to filter by it).
Have fun!
16 comments
Will
2016-12-20T15:20:38ZSacha, do you filter your agenda by effort estimates? If so, is that something you've added to your config? I've cribbed heavily from Bernt Hansen's config with great results. But I can't seem to come to grips with filtering by effort. I haven't been able to understand the org mode manual entry on this topic.
sachac
2016-12-22T02:09:26ZBack when I set effort estimates on my tasks, I tended to sort by effort estimate instead of filtering by it. For an example, see the "All unscheduled by context" org-agenda-custom-commands in my config at http://sachachua.com/blog/d... . Would something like that work for you?
Will
2016-12-22T11:10:47ZThanks, Sacha. My agenda already sorts by effort and that can become visible if I use org-agenda-columns. I wanted to filter so that only tasks or projects of a certain effort estimate are visible. I could limit the original agenda to a certain effort but that would take more time. I like how quickly I'm able to filter and already compiled agenda.
Having said all that, your config reminds me that there are many ways to approach these problems in Emacs. So thanks again!
sachac
2016-12-23T03:26:12ZOh, try an org-agenda-custom-commands entry like this: ("5" "Quick tasks" tags-todo "EFFORT>=\"0:05\"&EFFORT<=\"0:15\"")
I put a minimum effort filter in there so that it skips tasks that don't have any effort estimates set. You could also use something like ("0" "Unestimated tasks" tags-todo "EFFORT=\"\"") to look for tasks that don't have effort estimates.
Will
2016-12-23T12:47:31ZThat is very helpful. Although my goal is to filter by effort on an already created agenda, this gets me pretty close. I clearly need to take a closer look at the "tags-todo" variable. Thank you!
sachac
2016-12-31T06:32:09ZAh! That's actually more straightforward. You should be able to use / (org-agenda-filter-by-tag) http://orgmode.org/manual/F... . On my system, I need to press TAB in order to edit the query.
If you want to do this programmatically so that you can create your own shortcut for it, it would probably look something like (setq org-agenda-query-string "EFFORT<=\"0:05\"&EFFORT>"\"") (org-agenda-redo). Is that enough for you to go on?
Will
2016-12-31T14:51:35ZSacha, I appreciate your help but I'm afraid that manual effort filtering has never worked for me.
You describe agenda filtering by entering "/" (org-agenda-filter-by-tag) and then "TAB". I'm not sure how this is supposed to work. I tried entering the regular expression string above but that didn't work. I'm sure I'm misunderstanding something basic. I'm also unsure of how to use the elisp to create the shortcut although I haven't explored that thoroughly yet.
However, I want to mention something that would seem to be the obvious approach to filtering for effort: entering "_" (org-agenda-filter-by-effort) and then entering an operator "<, >, =" followed by the one-digit index (eg, "3" for "0:30"). This is described pretty clearly in the manual. And I've tried just about every operator and value possible. However, the result of those attempts has always been the same: the filter removes all entries or displays all of them.
Until you provided some of the examples above, I thought that something in my agenda setup might be preventing effort properties from being utilized or made available for filtering. However, I'm able to create a heading in my agenda for tasks that have specific effort estimates attached (see the elisp below).
(tags-todo "EFFORT>=\"0:05\"&EFFORT<=\"0:30\""
((org-agenda-overriding-header "30 minute tasks")
(org-tags-match-list-sublevels nil)))
So I'm puzzled. My goal is to filter an already created agenda by effort. I can create headings in an agenda that have specific effort estimates but I'd like to leave my headings alone and filter as needed. I really appreciate your help. And these comments have helped me to clarify what I'm trying to do and the approaches that seem to be available. However, I'm still unsure of how to achieve my goal. Makes me wish I knew more elisp!
====
UPDATE
After looking into this a bit more, I think I've figured out the general problem. I failed to check *Messages* for any hints and when I did, I noticed this:
"Invalid face reference: org-agenda-filter-effort [2 times]"
As it turns out, face/font inheritance has been a problem event recently (see https://lists.gnu.org/archi.... My version of org-mode is pretty recent (Org mode version 9.0.3) and appears to have the changes from the patch described in the org-mode list. However, my issue, the disappearance of all entries/tasks when I filter my agenda by effort, may be related to these face/fontification problems.
Thanks for all your help, Sacha. Your blog is a gift to the Emacs community.
sachac
2017-01-02T05:33:29ZHuh, you're right, just changing org-agenda-query-string or using \ doesn't seem to filter it properly on my end.
Using _ to filter by effort works for me in 8.3.6, though. Hmm... (Thanks for teaching me about a new command!)
Might be something to ask on the Org Mode mailing list, in case it's a bug. Sorry about the confusion, and thanks for posting wonderfully detailed notes!
ibichka
2017-05-25T17:20:50ZHi Sacha, I was wondering if you could help me. I'm attempting at customising the org-agenda-custom-commands variable in my .emacs file (I'm new to emacs). I'd like to see in my 'C-a a' menu an extra shortcut to a customised view. Right now, by default, I have 'n' for "Agenda and all TODOs: set of 2 commands". I just would like to add another one view, which would be the same view but instead of showing all TODOs, showing only all _unscheduled_ TODOs (because the scheduled ones appear anyway in the agenda view). Any help much appreciated!
ibichka
2017-05-25T19:41:03ZA follow-up: I tried the following:
(add-to-list 'org-add-agenda-custom-commands
'("b" todo "UNSCHEDULED TODOs"
((org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled))
(org-agenda-overriding-header "Unscheduled TODOs: "))))
However, I get the following error:
"Symbol's value as variable is void: org-add-agenda-custom-command"
Any ideas?
sachac
2017-05-26T07:02:05ZGood try! org-add-agenda-custom-command is actually a function, so you probably want something more like (add-to-list 'org-agenda-custom-commands '("b" todo ...)).
I haven't used org-add-agenda-custom-command before, but it looks like you could use it like this: (org-add-agenda-custom-command '("b" todo ...)). http://orgmode.org/manual/S... has an example.
ibichka
2017-05-27T05:58:37ZThanks Sacha. However, the code you provided is exactly the same I wrote above and it won't work :(
sachac
2017-05-27T16:38:49ZIt's a subtle difference, I know! The first version doesn't have the word "add" and uses the plural - org-agenda-custom-commands, that's the variable. The second version uses org-add-agenda-custom-command doesn't have add-to-list. Hope that helps!
ibichka
2017-05-28T07:17:07ZThanks for your tips, Sacha. I think I solved this!
Päivi Eerola
2018-11-29T14:03:09ZI don't know what has happened but before it was ok with using #+CATEGORY: task below each heading so that it showed in my agenda on the left side of each item. But now I can't keep using this anymore, I must use the drawer instead! Any idea why this changed?
sachac
2018-12-11T12:29:01ZThat sounds like a file-level keyword, actually...