From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: Lazy project definitions Date: Tue, 18 May 2010 00:18:14 -0400 Message-ID: <87fx1p9721.fsf@fastmail.fm> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=58604 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEE9e-0006CG-Vm for emacs-orgmode@gnu.org; Tue, 18 May 2010 00:11:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OEE9Y-0006x8-LQ for emacs-orgmode@gnu.org; Tue, 18 May 2010 00:11:42 -0400 Received: from out1.smtp.messagingengine.com ([66.111.4.25]:42139) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEE9Y-0006wl-Ig for emacs-orgmode@gnu.org; Tue, 18 May 2010 00:11:36 -0400 In-Reply-To: <87vdamnfv7.fsf@gollum.intra.norang.ca> (Bernt Hansen's message of "Mon, 17 May 2010 21:44:12 -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: Bernt Hansen Cc: emacs-orgmode@gnu.org, Carsten Dominik 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--- Best, Matt