2

I have the following agenda command for things that I want to do at home:

     ("h" "thing TODO at Home"
     (

      (tags-todo "+dailies+SCHEDULED<=\"<today>+1\"")
      (agenda "" ((org-agenda-ndays 1)
                  (org-agenda-filter-by-tag  '("-work" ))
                  (org-agenda-sorting-strategy
                   (quote ((agenda time-up priority-down tag-up) )))
                  (org-deadline-warning-days 0)
                  ))
      (tags "reading")
      (tags "writing")
      (tags-todo "REFILE")


      )

     )

I am using org-agenda-filter-by-tag to remove all the entries that are tagged work. (I have some file wide tags on the files). However, the agenda works, but is showing me also the entries tagged work. I also tried putting the org-agenda-filter-by-tag on the top of the definition of the block agenda but it is also not working.

Org-mode: 8.3.2 Emacs 24.5.1 OS: Mac OSX Yosemite 10.10.4

Thanks

5

Your first problem is that org-agenda-filter-by-tag is a function. Interactively, this will apply a filter, but in an agenda command like this, you're just assigning a value to it as a variable. Since functions and variables are in different namespaces, this doesn't cause an error, but it doesn't do anything either.

Unfortunately, the variable you do want, org-agenda-tag-filter-preset, is designed to work agenda-wide and can't be usefully set per-block (see the footnote for this manual entry).

If you're okay with having the filter set for the whole agenda, your command should look like this (and I apologize for changing your indentation setup):

("h" "thing TODO at Home"
 ((tags-todo "+dailies+SCHEDULED<=\"<today>+1\"")
  (agenda "" ((org-agenda-ndays 1)
              (org-agenda-sorting-strategy
               (quote ((agenda time-up priority-down tag-up))))
              (org-deadline-warning-days 0)))
  (tags "reading")
  (tags "writing")
  (tags-todo "REFILE"))
 ((org-agenda-tag-filter-preset '("-work"))))

If you want work tasks to show up in your tags and tags-todo blocks, you can use skip functions instead. For some reason, there is no out-of-the-box skip function for tag filtering, but I wrote one for this answer; with that code, your agenda command should look like this:

("h" "thing TODO at Home"
 ((tags-todo "+dailies+SCHEDULED<=\"<today>+1\"")
  (agenda "" ((org-agenda-ndays 1)
              (org-agenda-skip-function
               '(my/org-agenda-skip-without-match "-work"))
              (org-agenda-sorting-strategy
               (quote ((agenda time-up priority-down tag-up))))
              (org-deadline-warning-days 0)))
  (tags "reading")
  (tags "writing")
  (tags-todo "REFILE")))
  • Hi, Thanks a lot for the clarification. I actually want to remove "-work" tag globally (in all the blocks). Your proposed solutions gives an error when I use it I changed to ` (org-agenda-tag-filter-preset '("-work"))` and it works, if you fix your answer I will mark it as accepted. Thanks a lot! :) – mfcabrera Nov 20 '15 at 9:16
  • Fixed. Sorry about that. I really should have checked the documentation more closely. – Aaron Harris Nov 20 '15 at 15:05
1

Here's a simple solution with the built-in org filtering commands.

This only works if the headline is tagged explicitly. It does not work if the tag is inherited

(agenda ""
        ((org-agenda-skip-function
          '(org-agenda-skip-entry-if 'regexp ":work:"))))

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.