4

I want to list all TODO entries which have specific property value.
For example:

  • I have many TODO entries which are listed beneath Collage heading.
  • Collage heading have property CATEGORY set to school.
  • There are multiple headers with corresponding value of CATEGORY property in single org file.

I currently know of two useful org-mode functionalities which could help here.

  • I can make a sparse tree of all collage headings using M-x org-sparse-tree p CATEGORY collage.
  • Also know how to make list of all TODO entries using M-x org-agenda t.

How to combine those two?
Or how to do it more elegant way?

  • 1
    The following link contains examples of how to search property drawers using the org-agenda.el library: orgmode.org/worg/org-tutorials/advanced-searching.html See also: orgmode.org/manual/… I am assuming the original poster is referring to a property drawer underneath :PROPERTIES: that looks like :CATEGORY: school and, if so the OP could evaluate the following expression in a *scratch* buffer: (org-tags-view nil "CATEGORY={school}") – lawlist Jun 23 '16 at 20:17
2

This is what org-agenda-custom-commands is for. It lets you add additional agenda view to org-agenda. Here we attach "S" to a search for all TODO items whose CATEGORY is school:

(add-to-list 'org-agenda-custom-commands
             '("S" "School"
               tags-todo "+CATEGORY=\"school\""))

Access it with M-x org-agenda S. There are many, many options allowing you to customize exactly what get shown.

  • Thank you! This is exactly what I want. Actually, I knew that org-mode has an elegant solution but I couldn't find it. :) – foki Jun 24 '16 at 7:39
  • But... There is a little problem here. It works well if I evaluate it in scratch buffer after initialization but when I put it inside org-mode-hook (where all my org-mode settings reside) it doesn't. In which loading phase one should execute it? – foki Jun 24 '16 at 8:28
  • 1
    I've figured it out. Org agenda could be called before org-mode activation, it means before org-mode-hook, so one should set this outside that hook. And since org-agenda-custom-commands is free variable by default one should do it through setq like so: (setq org-agenda-custom-commands '(("S" "School" tags-todo "+CATEGORY=\"school\"")) – foki Jun 24 '16 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.