Radosław Grzanka <radosl...@gmail.com> writes:

>   yes, I've simplified examples to the point which made no sense. I'm
> very sorry.
>   All entries should have had some kind of timestamp, deadline or
> schedule. Yes, I'd like daily/weekly agenda view filtered by tags.

No problem. Maybe the tags search examples I provided will prove useful
to someone else who stumbles across them. :)

> - org-agenda-filter-preset - but that seems not to support "or" (maybe
> I'm missing something?)

Filtering allows for inherited tags but not for or logic. It's a quick
and simple way to include or exclude by tag. E.g., '("+work" "+internet")
will filter for items tagged work and internet.

> - org-agenda-skip-function - which I found googling around - with
> regexp like '(org-agenda-skip-subtree-if 'regexp ":work:")' - but that
> seems not to support "inherited" tags.

The regexp argument of org-agenda-skip-subtree-if function, on the other
hand, allows for or logic but not for inherited tags. E.g., 

(org-agenda-skip-subtree-if 'notregexp ":\\(work\\|internet\\):")

...will find items tagged with work or internet, but only if they are
local.

I believe the only option is to write a skip function that uses
org-entry-get to get all the tags at point.

Here's an example:

--8<---------------cut here---------------start------------->8---
(defun org-agenda-skip-entry-unless-tags (tags)
  "Skip entries that do not contain specified tags.
TAGS is a list specifying which tags should be displayed.
Inherited tags will be considered."
  (let ((subtree-end (save-excursion (org-end-of-subtree t)))
        (atags (split-string (org-entry-get nil "ALLTAGS") ":")))
    (if (catch 'match
          (mapc (lambda (tag)
                  (when (member tag atags)
                    (throw 'match t)))
                tags)
          nil)
        nil
      subtree-end)))
                        
(setq org-agenda-custom-commands
      '(("x" "Work and internet" agenda ""
         ((org-agenda-skip-function '(org-agenda-skip-entry-unless-tags 
'("work" "internet")))))))
--8<---------------cut here---------------end--------------->8---

Best,
Matt

Reply via email to