From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: Re: Lazy project definitions Date: Tue, 18 May 2010 07:31:05 -0400 Message-ID: <87r5l9o39i.fsf@gollum.intra.norang.ca> References: <878w7jbl6m.fsf@gollum.intra.norang.ca> <2C475BA4-862D-434D-A123-8AADAF8A8EB2@gmail.com> <878w7ipvxi.fsf@gollum.intra.norang.ca> <87vdamnfv7.fsf@gollum.intra.norang.ca> <87fx1p9721.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=51403 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEL16-0000lP-2T for emacs-orgmode@gnu.org; Tue, 18 May 2010 07:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OEL11-0007gA-Lp for emacs-orgmode@gnu.org; Tue, 18 May 2010 07:31:19 -0400 Received: from mho-01-ewr.mailhop.org ([204.13.248.71]:57541) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEL11-0007g3-JV for emacs-orgmode@gnu.org; Tue, 18 May 2010 07:31:15 -0400 In-Reply-To: <87fx1p9721.fsf@fastmail.fm> (Matt Lundin's message of "Tue\, 18 May 2010 00\:18\:14 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Matt Lundin Cc: emacs-orgmode@gnu.org, Carsten Dominik Matt Lundin writes: > Hi Bernt, > > Bernt Hansen writes: > >> I've been beating my head against the wall for hours on this now. I >> tried the example from the manual and have similar results to the >> description below. >> >> Here's what I came up with as my skip function >> >> ,---- >> | (defun bh/skip-non-stuck-projects () >> | "Skip trees that are not projects" >> | (let* ((subtree-end (save-excursion (org-end-of-subtree t))) >> | (is-project (save-excursion (re-search-forward "^\\*\\{3,\\}" subtree-end t))) >> | (has-next (save-excursion (re-search-forward "^\\*\\** NEXT " subtree-end t)))) >> | (if (and is-project (not has-next)) >> | nil ; a stuck project, has subtasks but no next task >> | subtree-end))) >> `---- >> >> and my custom agenda command is 'x' for testing >> >> ,---- >> | ("x" "Stuck Projects" tags-todo "LEVEL=2-REFILE/!-DONE-CANCELLED" >> | ((org-agenda-skip-function >> | (bh/skip-non-stuck-projects))))) >> `---- >> >> but this doesn't work at all like I expect. I lost a bunch of time when >> I had the 'stuck projects' selection instead of tags-todo -- it seems >> the skip function doesn't do anything useful with the stuck-projects >> setting. >> >> My returned list of tasks is still incorrect -- it contains level 2 >> tasks with no children. Sometimes it throws an error -- depending on >> what buffer is displayed and where (point) is when I run C-c a x. > > The custom command (and the skip function) works for me when written as > follows: > > --8<---------------cut here---------------start------------->8--- > (setq org-agenda-custom-commands > '(("x" "Stuck Projects" tags "LEVEL=2-REFILE/-DONE-CANCELLED" > ((org-agenda-skip-function 'bh/skip-non-stuck-projects))))) > --8<---------------cut here---------------end--------------->8--- > > I made a couple of changes: (a) I quoted the function name and (b) I > changed tags-todo to tags and removed the exclamation point. Both > tags-todo and the exclamation point limited the results to entries with > active states, whereas (if I understand correctly) you are interested in > all level 2 headings. > > When I tested the command/skip function on the following tree, only the > first 2nd level entry (** Testing) showed up in the agenda. Is this the > desired result? > > --8<---------------cut here---------------start------------->8--- > * Example > ** Testing > *** Nothing > ** Testing two > *** NEXT A todo > ** Testing three > --8<---------------cut here---------------end--------------->8--- Thanks for this Matt!! This seems to do exactly what I want. I had a bunch of misfires trying to set this up using the example from the manual but I didn't want 'todo' as the selection criteria since I can't match LEVEL=2 with that and I assumed that I could use any of the Choice: values in the custom agenda commands when using a skipping function. I'm off to play with this new setup. Regards, Bernt