emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: Lazy project definitions


From: Matt Lundin
Subject: [Orgmode] Re: Lazy project definitions
Date: Tue, 18 May 2010 00:18:14 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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---

Best,
Matt



reply via email to

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