From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: Filtering agenda by tags. Date: Wed, 20 Apr 2011 10:02:38 -0400 Message-ID: <87vcy99g1t.fsf@fastmail.fm> References: <4DAEB2CE.2040708@gmail.com> <87bp01axv3.fsf@fastmail.fm> <4DAEDA14.8020409@gmail.com> <877hapawyl.fsf@fastmail.fm> <4DAEDCAA.3060005@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:48077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCXzN-0007Ag-L4 for emacs-orgmode@gnu.org; Wed, 20 Apr 2011 10:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QCXzM-0003d5-Cl for emacs-orgmode@gnu.org; Wed, 20 Apr 2011 10:02:41 -0400 Received: from out4.smtp.messagingengine.com ([66.111.4.28]:57838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCXzM-0003d1-90 for emacs-orgmode@gnu.org; Wed, 20 Apr 2011 10:02:40 -0400 In-Reply-To: <4DAEDCAA.3060005@gmail.com> (=?utf-8?Q?=22Rados=C5=82aw?= Grzanka"'s message of "Wed, 20 Apr 2011 15:16:26 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: radoslawg@gmail.com Cc: Org-mode ml Rados=C5=82aw Grzanka 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.,=20 (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))) =09=09=09 (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