emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Lazy project definitions


From: Bernt Hansen
Subject: [Orgmode] Re: Lazy project definitions
Date: Tue, 18 May 2010 07:31:05 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Matt Lundin <address@hidden> writes:

> Hi Bernt,
>
> Bernt Hansen <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]