emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Lazy project definitions
@ 2010-05-16 21:17 Bernt Hansen
  2010-05-17  9:43 ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Bernt Hansen @ 2010-05-16 21:17 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I've been using the definition that all LEVEL 2 tasks are projects for a
long time.  Recently I tried switching to explicitly marked projects
using a :project: tag (or PROJECT keyword) but I really dislike having
to manually mark projects in my task lists.

A project for me is basically any LEVEL 2 task that has one or more
subtasks.

I would like to define my org stuck projects as LEVEL=2/!-DONE-CANCELLED
with an added skipping function that does not consider level 2 tasks if
they have no children.  I can't figure out how to make this work in the
org-agenda-custom-commands using the skipping function but I think it
should be possible.

My goal here is to add 2 custom agenda commands:
  p - show me projects (level 2 tasks not completed with children)
  o - show me other (non-project) tasks (level 2 tasks without children)

I don't want the 'o' - other tasks listed in my stuck projects view
since these are really one-task items and are not a project by my
simplistic definition above.

I've been using everything as a project that is defined at LEVEL 2 for
ages and that works really well for me -- except I want to stop spending
any time dealing with simple (non-project) tasks when looking for next
tasks and stuck projects.  Sure I could manually mark my tasks as
projects but I don't think that should really be necessary for what I
want to do here... and if it could just say a LEVEL 2 task with children
is a project it would work automagically for me without any additional
input.

For simple non-project tasks I don't need to mark them as NEXT to make
them unstuck -- they aren't projects to begin with and I can have
a convenient way to view all of these simple non-project commands in the
agenda using the 'o' custom command.

Is there a way to this?

Thanks,
Bernt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-16 21:17 Lazy project definitions Bernt Hansen
@ 2010-05-17  9:43 ` Carsten Dominik
  2010-05-17 11:28   ` Bernt Hansen
  2010-05-17 12:14   ` Bernt Hansen
  0 siblings, 2 replies; 8+ messages in thread
From: Carsten Dominik @ 2010-05-17  9:43 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hi Bernt,

I guess you can use the regexp options, both in the stuck projects,  
and in a skipping condition for an agenda custom command.

In the stuck project definition, adding "^\\*\\{3,\\}" as the 4th  
element should exclude anything that has level 3 or up in the subtree.

for the agenda commands,

    (org-skip-subtree-if 'regexp "\\*\\{3,\\}")

or so should take care of it, am I right?

- Carsten

On for 16, 2010, at 11:17 PM, Bernt Hansen wrote:

> Hi,
>
> I've been using the definition that all LEVEL 2 tasks are projects  
> for a
> long time.  Recently I tried switching to explicitly marked projects
> using a :project: tag (or PROJECT keyword) but I really dislike having
> to manually mark projects in my task lists.
>
> A project for me is basically any LEVEL 2 task that has one or more
> subtasks.
>
> I would like to define my org stuck projects as LEVEL=2/!-DONE- 
> CANCELLED
> with an added skipping function that does not consider level 2 tasks  
> if
> they have no children.  I can't figure out how to make this work in  
> the
> org-agenda-custom-commands using the skipping function but I think it
> should be possible.
>
> My goal here is to add 2 custom agenda commands:
>  p - show me projects (level 2 tasks not completed with children)
>  o - show me other (non-project) tasks (level 2 tasks without  
> children)
>
> I don't want the 'o' - other tasks listed in my stuck projects view
> since these are really one-task items and are not a project by my
> simplistic definition above.
>
> I've been using everything as a project that is defined at LEVEL 2 for
> ages and that works really well for me -- except I want to stop  
> spending
> any time dealing with simple (non-project) tasks when looking for next
> tasks and stuck projects.  Sure I could manually mark my tasks as
> projects but I don't think that should really be necessary for what I
> want to do here... and if it could just say a LEVEL 2 task with  
> children
> is a project it would work automagically for me without any additional
> input.
>
> For simple non-project tasks I don't need to mark them as NEXT to make
> them unstuck -- they aren't projects to begin with and I can have
> a convenient way to view all of these simple non-project commands in  
> the
> agenda using the 'o' custom command.
>
> Is there a way to this?
>
> Thanks,
> Bernt
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-17  9:43 ` Carsten Dominik
@ 2010-05-17 11:28   ` Bernt Hansen
  2010-05-17 12:14   ` Bernt Hansen
  1 sibling, 0 replies; 8+ messages in thread
From: Bernt Hansen @ 2010-05-17 11:28 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

This works:

 ("p" "Projects" tags-todo "LEVEL=2/!-DONE-CANCELLED"
  ((org-agenda-skip-function
    '(org-agenda-skip-subtree-if 'notregexp "^\\*\\{3,\\}"))))
 ("o" "Other (non-project tasks)" tags "LEVEL=2/!-DONE-CANCELLED"
  ((org-agenda-skip-function
    '(org-agenda-skip-subtree-if 'regexp "^\\*\\{3,\\}"))))


Awesome!

Thanks Carsten!

-Bernt


Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hi Bernt,
>
> I guess you can use the regexp options, both in the stuck projects,
> and in a skipping condition for an agenda custom command.
>
> In the stuck project definition, adding "^\\*\\{3,\\}" as the 4th
> element should exclude anything that has level 3 or up in the subtree.
>
> for the agenda commands,
>
>    (org-skip-subtree-if 'regexp "\\*\\{3,\\}")
>
> or so should take care of it, am I right?
>
> - Carsten
>
> On for 16, 2010, at 11:17 PM, Bernt Hansen wrote:
>
>> Hi,
>>
>> I've been using the definition that all LEVEL 2 tasks are projects
>> for a
>> long time.  Recently I tried switching to explicitly marked projects
>> using a :project: tag (or PROJECT keyword) but I really dislike having
>> to manually mark projects in my task lists.
>>
>> A project for me is basically any LEVEL 2 task that has one or more
>> subtasks.
>>
>> I would like to define my org stuck projects as LEVEL=2/!-DONE- 
>> CANCELLED
>> with an added skipping function that does not consider level 2 tasks
>> if
>> they have no children.  I can't figure out how to make this work in
>> the
>> org-agenda-custom-commands using the skipping function but I think it
>> should be possible.
>>
>> My goal here is to add 2 custom agenda commands:
>>  p - show me projects (level 2 tasks not completed with children)
>>  o - show me other (non-project) tasks (level 2 tasks without
>> children)
>>
>> I don't want the 'o' - other tasks listed in my stuck projects view
>> since these are really one-task items and are not a project by my
>> simplistic definition above.
>>
>> I've been using everything as a project that is defined at LEVEL 2 for
>> ages and that works really well for me -- except I want to stop
>> spending
>> any time dealing with simple (non-project) tasks when looking for next
>> tasks and stuck projects.  Sure I could manually mark my tasks as
>> projects but I don't think that should really be necessary for what I
>> want to do here... and if it could just say a LEVEL 2 task with
>> children
>> is a project it would work automagically for me without any additional
>> input.
>>
>> For simple non-project tasks I don't need to mark them as NEXT to make
>> them unstuck -- they aren't projects to begin with and I can have
>> a convenient way to view all of these simple non-project commands in
>> the
>> agenda using the 'o' custom command.
>>
>> Is there a way to this?
>>
>> Thanks,
>> Bernt
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
> - Carsten

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-17  9:43 ` Carsten Dominik
  2010-05-17 11:28   ` Bernt Hansen
@ 2010-05-17 12:14   ` Bernt Hansen
  2010-05-17 16:54     ` Carsten Dominik
  1 sibling, 1 reply; 8+ messages in thread
From: Bernt Hansen @ 2010-05-17 12:14 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> In the stuck project definition, adding "^\\*\\{3,\\}" as the 4th
> element should exclude anything that has level 3 or up in the subtree.

I don't think this will work.  The regexp matches all tasks with level 3
or higher subtrees ... which is all projects so all projects are
considered unstuck.

I need to be able to somehow say a project is not stuck if it doesn't
have a level 3 task (ie. no children) because it's not a project in this
case.

Is there a way to do that?

Regards,
Bernt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-17 12:14   ` Bernt Hansen
@ 2010-05-17 16:54     ` Carsten Dominik
  2010-05-18  1:44       ` Bernt Hansen
  0 siblings, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2010-05-17 16:54 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode


On May 17, 2010, at 2:14 PM, Bernt Hansen wrote:

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> In the stuck project definition, adding "^\\*\\{3,\\}" as the 4th
>> element should exclude anything that has level 3 or up in the  
>> subtree.
>
> I don't think this will work.  The regexp matches all tasks with  
> level 3
> or higher subtrees ... which is all projects so all projects are
> considered unstuck.
>
> I need to be able to somehow say a project is not stuck if it doesn't
> have a level 3 task (ie. no children) because it's not a project in  
> this
> case.

You are right.  Ahh, I wish we had the power of Perl
regular expressions in Emacs.  It would be sooo easy then.
No, I don't see a good way here.

Maybe the best is to completely write your own skipper here.  This
is actually not too hard, see the Appendix A7 for an example.

HTH

- Carsten

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-17 16:54     ` Carsten Dominik
@ 2010-05-18  1:44       ` Bernt Hansen
  2010-05-18  4:18         ` Matt Lundin
  0 siblings, 1 reply; 8+ messages in thread
From: Bernt Hansen @ 2010-05-18  1:44 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On May 17, 2010, at 2:14 PM, Bernt Hansen wrote:
>
>> Carsten Dominik <carsten.dominik@gmail.com> writes:
>>
>>> In the stuck project definition, adding "^\\*\\{3,\\}" as the 4th
>>> element should exclude anything that has level 3 or up in the
>>> subtree.
>>
>> I don't think this will work.  The regexp matches all tasks with
>> level 3
>> or higher subtrees ... which is all projects so all projects are
>> considered unstuck.
>>
>> I need to be able to somehow say a project is not stuck if it doesn't
>> have a level 3 task (ie. no children) because it's not a project in
>> this
>> case.
>
> You are right.  Ahh, I wish we had the power of Perl
> regular expressions in Emacs.  It would be sooo easy then.
> No, I don't see a good way here.
>
> Maybe the best is to completely write your own skipper here.  This
> is actually not too hard, see the Appendix A7 for an example.

Thanks for the pointer to the manual.  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.

In this mail buffer I get

Debugger entered--Lisp error: (error "Before first headline at position 2577 in buffer *wide reply to Carsten Dominik*")
  signal(error ("Before first headline at position 2577 in buffer *wide reply to Carsten Dominik*"))
  error("Before first headline at position %d in buffer %s" 2577 #<buffer *wide reply to Carsten Dominik*>)
  (condition-case nil (outline-back-to-heading invisible-ok) (error (error "Before first headline at position %d in buffer %s" ... ...)))
  org-back-to-heading(t)
  org-end-of-subtree(t)
  (save-excursion (org-end-of-subtree t))
  (let* ((subtree-end ...) (is-project ...) (has-next ...)) (message "is a project %s" is-project) (message "has next %s" has-next) (if (and is-project ...) nil subtree-end))
  (save-excursion (let* (... ... ...) (message "is a project %s" is-project) (message "has next %s" has-next) (if ... nil subtree-end)))
  bh/skip-non-stuck-projects()
  (let ((org-agenda-skip-function ...)) (org-tags-view (quote ...) match))
  eval((let ((org-agenda-skip-function ...)) (org-tags-view (quote ...) match)))
  org-let(((org-agenda-skip-function (bh/skip-non-stuck-projects))) (org-tags-view (quote (4)) match))
  (cond ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((functionp type) (org-let lprops ...)) ((fboundp type) (org-let lprops ...)) (t (error "Invalid custom agenda command type %s" type)))
  (progn (setq type (nth 2 entry) match (eval ...) lprops (nth 4 entry)) (put (quote org-agenda-redo-command) (quote org-lprops) lprops) (cond (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ... ...) (... ... ...) (... ... ...) (... ...) (... ...) (t ...)))
  (if (or (symbolp ...) (functionp ...)) (progn (setq type ... match ... lprops ...) (put ... ... lprops) (cond ... ... ... ... ... ... ... ... ... ... ... ... ...)) (org-run-agenda-series (nth 1 entry) (cddr entry)))
  (cond ((setq entry ...) (if ... ... ...)) ((equal keys "C") (setq org-agenda-custom-commands org-agenda-custom-commands-orig) (customize-variable ...)) ((equal keys "a") (call-interactively ...)) ((equal keys "s") (call-interactively ...)) ((equal keys "t") (call-interactively ...)) ((equal keys "T") (org-call-with-arg ... ...)) ((equal keys "m") (call-interactively ...)) ((equal keys "M") (org-call-with-arg ... ...)) ((equal keys "e") (call-interactively ...)) ((equal keys "?") (org-tags-view nil "+FLAGGED") (org-add-hook ... ... t t)) ((equal keys "L") (unless ... ...) (unless restriction ... ...)) ((equal keys "#") (call-interactively ...)) ((equal keys "/") (call-interactively ...)) ((equal keys "!") (customize-variable ...)) (t (error "Invalid agenda key")))
  (let* ((prefix-descriptions nil) (org-agenda-window-setup ...) (org-agenda-custom-commands-orig org-agenda-custom-commands) (org-agenda-custom-commands ...) (buf ...) (bfn ...) entry key type match lprops ans) (unless org-agenda-overriding-restriction (unless ... ...) (setq org-agenda-restrict nil) (move-marker org-agenda-restrict-begin nil) (move-marker org-agenda-restrict-end nil)) (put (quote org-agenda-redo-command) (quote org-lprops) nil) (setq org-agenda-last-dispatch-buffer (current-buffer)) (unless keys (setq ans ... keys ... restriction ...)) (when (and ... restriction) (put ... ... ...) (cond ... ...)) (cond (... ...) (... ... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ... ...) (... ... ...) (... ...) (... ...) (... ...) (t ...)))
  (catch (quote exit) (let* (... ... ... ... ... ... entry key type match lprops ans) (unless org-agenda-overriding-restriction ... ... ... ...) (put ... ... nil) (setq org-agenda-last-dispatch-buffer ...) (unless keys ...) (when ... ... ...) (cond ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...)))
  org-agenda(nil)
  call-interactively(org-agenda)


If I call it on a task headline or body I get a bunch of tasks but the
results are incorrect.

If I call it from the last line (blank) of an org-mode buffer I get this

Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)")
  re-search-forward("^\\*\\{3,\\}" 154508 t)
  (save-excursion (re-search-forward "^\\*\\{3,\\}" subtree-end t))
  (let* ((subtree-end ...) (is-project ...) (has-next ...)) (message "is a project %s" is-project) (message "has next %s" has-next) (if (and is-project ...) nil subtree-end))
  (save-excursion (let* (... ... ...) (message "is a project %s" is-project) (message "has next %s" has-next) (if ... nil subtree-end)))
  bh/skip-non-stuck-projects()
  (let ((org-agenda-skip-function ...)) (org-tags-view (quote ...) match))
  eval((let ((org-agenda-skip-function ...)) (org-tags-view (quote ...) match)))
  org-let(((org-agenda-skip-function (bh/skip-non-stuck-projects))) (org-tags-view (quote (4)) match))
  (cond ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((functionp type) (org-let lprops ...)) ((fboundp type) (org-let lprops ...)) (t (error "Invalid custom agenda command type %s" type)))
  (progn (setq type (nth 2 entry) match (eval ...) lprops (nth 4 entry)) (put (quote org-agenda-redo-command) (quote org-lprops) lprops) (cond (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ... ...) (... ... ...) (... ... ...) (... ...) (... ...) (t ...)))
  (if (or (symbolp ...) (functionp ...)) (progn (setq type ... match ... lprops ...) (put ... ... lprops) (cond ... ... ... ... ... ... ... ... ... ... ... ... ...)) (org-run-agenda-series (nth 1 entry) (cddr entry)))
  (cond ((setq entry ...) (if ... ... ...)) ((equal keys "C") (setq org-agenda-custom-commands org-agenda-custom-commands-orig) (customize-variable ...)) ((equal keys "a") (call-interactively ...)) ((equal keys "s") (call-interactively ...)) ((equal keys "t") (call-interactively ...)) ((equal keys "T") (org-call-with-arg ... ...)) ((equal keys "m") (call-interactively ...)) ((equal keys "M") (org-call-with-arg ... ...)) ((equal keys "e") (call-interactively ...)) ((equal keys "?") (org-tags-view nil "+FLAGGED") (org-add-hook ... ... t t)) ((equal keys "L") (unless ... ...) (unless restriction ... ...)) ((equal keys "#") (call-interactively ...)) ((equal keys "/") (call-interactively ...)) ((equal keys "!") (customize-variable ...)) (t (error "Invalid agenda key")))
  (let* ((prefix-descriptions nil) (org-agenda-window-setup ...) (org-agenda-custom-commands-orig org-agenda-custom-commands) (org-agenda-custom-commands ...) (buf ...) (bfn ...) entry key type match lprops ans) (unless org-agenda-overriding-restriction (unless ... ...) (setq org-agenda-restrict nil) (move-marker org-agenda-restrict-begin nil) (move-marker org-agenda-restrict-end nil)) (put (quote org-agenda-redo-command) (quote org-lprops) nil) (setq org-agenda-last-dispatch-buffer (current-buffer)) (unless keys (setq ans ... keys ... restriction ...)) (when (and ... restriction) (put ... ... ...) (cond ... ...)) (cond (... ...) (... ... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ... ...) (... ... ...) (... ...) (... ...) (... ...) (t ...)))
  (catch (quote exit) (let* (... ... ... ... ... ... entry key type match lprops ans) (unless org-agenda-overriding-restriction ... ... ... ...) (put ... ... nil) (setq org-agenda-last-dispatch-buffer ...) (unless keys ...) (when ... ... ...) (cond ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...)))
  org-agenda(nil)
  call-interactively(org-agenda)
  recursive-edit()
  byte-code("Æ\x10	@Ç=ƒ!\0ÈÉÊ\"ˆËÉ!‰\x1aA@)¢Ì=ƒ!\0ÈÍÊ\"ˆÎ\v!ˆÏ ˆÐ	!ˆ\fƒc\0Ñed\"\rVƒW\0ebˆÒ\r¥yˆ`\x1e^[dbˆÒ\r¥\rZyˆ\x0e^[`|ˆ)ÓcˆebˆÔÕÖ \"ˆ× ˆÔØ!ˆÙÊ\x1e\x1c\x1e\x1dÔØ!ˆŠÚ ˆ+Ù‡" [unread-command-char debugger-args x debugger-buffer noninteractive debugger-batch-max-lines -1 debug backtrace-debug 4 t backtrace-frame lambda 5 pop-to-buffer debugger-mode debugger-setup-buffer count-lines 2 "...\n" message "%s" buffer-string kill-emacs "" nil recursive-edit middlestart buffer-read-only standard-output] 4)
  debug(error (error "Before first headline at position 2577 in buffer *wide reply to Carsten Dominik*"))
  signal(error ("Before first headline at position 2577 in buffer *wide reply to Carsten Dominik*"))
  error("Before first headline at position %d in buffer %s" 2577 #<buffer *wide reply to Carsten Dominik*>)
  (condition-case nil (outline-back-to-heading invisible-ok) (error (error "Before first headline at position %d in buffer %s" ... ...)))
  org-back-to-heading(t)
  org-end-of-subtree(t)
  (save-excursion (org-end-of-subtree t))
  (let* ((subtree-end ...) (is-project ...) (has-next ...)) (message "is a project %s" is-project) (message "has next %s" has-next) (if (and is-project ...) nil subtree-end))
  (save-excursion (let* (... ... ...) (message "is a project %s" is-project) (message "has next %s" has-next) (if ... nil subtree-end)))
  bh/skip-non-stuck-projects()
  (let ((org-agenda-skip-function ...)) (org-tags-view (quote ...) match))
  eval((let ((org-agenda-skip-function ...)) (org-tags-view (quote ...) match)))
  org-let(((org-agenda-skip-function (bh/skip-non-stuck-projects))) (org-tags-view (quote (4)) match))
  (cond ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((eq type ...) (org-check-for-org-mode) (org-let lprops ...)) ((functionp type) (org-let lprops ...)) ((fboundp type) (org-let lprops ...)) (t (error "Invalid custom agenda command type %s" type)))
  (progn (setq type (nth 2 entry) match (eval ...) lprops (nth 4 entry)) (put (quote org-agenda-redo-command) (quote org-lprops) lprops) (cond (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ... ...) (... ... ...) (... ... ...) (... ...) (... ...) (t ...)))
  (if (or (symbolp ...) (functionp ...)) (progn (setq type ... match ... lprops ...) (put ... ... lprops) (cond ... ... ... ... ... ... ... ... ... ... ... ... ...)) (org-run-agenda-series (nth 1 entry) (cddr entry)))
  (cond ((setq entry ...) (if ... ... ...)) ((equal keys "C") (setq org-agenda-custom-commands org-agenda-custom-commands-orig) (customize-variable ...)) ((equal keys "a") (call-interactively ...)) ((equal keys "s") (call-interactively ...)) ((equal keys "t") (call-interactively ...)) ((equal keys "T") (org-call-with-arg ... ...)) ((equal keys "m") (call-interactively ...)) ((equal keys "M") (org-call-with-arg ... ...)) ((equal keys "e") (call-interactively ...)) ((equal keys "?") (org-tags-view nil "+FLAGGED") (org-add-hook ... ... t t)) ((equal keys "L") (unless ... ...) (unless restriction ... ...)) ((equal keys "#") (call-interactively ...)) ((equal keys "/") (call-interactively ...)) ((equal keys "!") (customize-variable ...)) (t (error "Invalid agenda key")))
  (let* ((prefix-descriptions nil) (org-agenda-window-setup ...) (org-agenda-custom-commands-orig org-agenda-custom-commands) (org-agenda-custom-commands ...) (buf ...) (bfn ...) entry key type match lprops ans) (unless org-agenda-overriding-restriction (unless ... ...) (setq org-agenda-restrict nil) (move-marker org-agenda-restrict-begin nil) (move-marker org-agenda-restrict-end nil)) (put (quote org-agenda-redo-command) (quote org-lprops) nil) (setq org-agenda-last-dispatch-buffer (current-buffer)) (unless keys (setq ans ... keys ... restriction ...)) (when (and ... restriction) (put ... ... ...) (cond ... ...)) (cond (... ...) (... ... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... ... ...) (... ... ...) (... ...) (... ...) (... ...) (t ...)))
  (catch (quote exit) (let* (... ... ... ... ... ... entry key type match lprops ans) (unless org-agenda-overriding-restriction ... ... ... ...) (put ... ... nil) (setq org-agenda-last-dispatch-buffer ...) (unless keys ...) (when ... ... ...) (cond ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...)))
  org-agenda(nil)
  call-interactively(org-agenda)

so either I'm doing something fundamentally wrong here or there's a bug
somewhere.

Any suggestions are most welcome.  I can't wait to get this new setup to
work! :)

Regards,
Bernt

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-18  1:44       ` Bernt Hansen
@ 2010-05-18  4:18         ` Matt Lundin
  2010-05-18 11:31           ` Bernt Hansen
  0 siblings, 1 reply; 8+ messages in thread
From: Matt Lundin @ 2010-05-18  4:18 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode, Carsten Dominik

Hi Bernt,

Bernt Hansen <bernt@norang.ca> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Lazy project definitions
  2010-05-18  4:18         ` Matt Lundin
@ 2010-05-18 11:31           ` Bernt Hansen
  0 siblings, 0 replies; 8+ messages in thread
From: Bernt Hansen @ 2010-05-18 11:31 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode, Carsten Dominik

Matt Lundin <mdl@imapmail.org> writes:

> Hi Bernt,
>
> Bernt Hansen <bernt@norang.ca> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-05-18 11:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-16 21:17 Lazy project definitions Bernt Hansen
2010-05-17  9:43 ` Carsten Dominik
2010-05-17 11:28   ` Bernt Hansen
2010-05-17 12:14   ` Bernt Hansen
2010-05-17 16:54     ` Carsten Dominik
2010-05-18  1:44       ` Bernt Hansen
2010-05-18  4:18         ` Matt Lundin
2010-05-18 11:31           ` Bernt Hansen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).