emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* An issue with org-agenda-todo-list-sublevels
@ 2015-12-10 23:26 Marcin Borkowski
  2015-12-12  8:53 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Borkowski @ 2015-12-10 23:26 UTC (permalink / raw)
  To: Org-Mode mailing list

Hi list,

I have org-agenda-todo-list-sublevels set to nil.  However, given this
tree:

* DONE task
** TODO subtask

it turns out that the todo list in the agenda shows the "subtask" anyway.

Should it be so?  I would guess not.

The reason I'd like to exclude this "subtask" from displaying is
something like this: assume that I have a project, halfway done, which
must be postponed for some reason.  I'd like to be able to do this:

* SOMEDAY cool project
** DONE preparation
** TODO hard work

where SOMEDAY is a done-type keyword.

And of course, I don't want to be bothered by "hard work" in this case
in my global todo list.

Is there a way to achieve this?
(Org-mode version 8.3beta (release_8.3beta-1136-g0e7062).)

If not, can it be considered a feature request?

A cursory examination of org-agenda.el shows that the culprit is the
function org-agenda-get-todos, and that (probably) this is responsible:

--8<---------------cut here---------------start------------->8---
         (regexp (format org-heading-keyword-regexp-format
			 (cond
			  ((and org-select-this-todo-keyword
				(equal org-select-this-todo-keyword "*"))
			   org-todo-regexp)
			  (org-select-this-todo-keyword
			   (concat "\\("
				   (mapconcat 'identity
					      (org-split-string
					       org-select-this-todo-keyword
					       "|")
					      "\\|") "\\)"))
			  (t org-not-done-regexp))))
--8<---------------cut here---------------end--------------->8---

(notice the last line, with `org-not-done-regexp'!)

A possible course of action might be to change that line to use
`org-todo-regexp'; OTOH, the exclusion of tasks marked as done should be
then done differently.

(If there is any interest, I might try to look into it further.)

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-10 23:26 An issue with org-agenda-todo-list-sublevels Marcin Borkowski
@ 2015-12-12  8:53 ` Nicolas Goaziou
  2015-12-12 11:00   ` Marcin Borkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2015-12-12  8:53 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Org-Mode mailing list

Hello,

Marcin Borkowski <mbork@mbork.pl> writes:

> I have org-agenda-todo-list-sublevels set to nil.  However, given this
> tree:
>
> * DONE task
> ** TODO subtask
>
> it turns out that the todo list in the agenda shows the "subtask" anyway.
>
> Should it be so?  I would guess not.

It's not clear to to me it shouldn't be the case. AFAIU, the point of
`org-agenda-todo-list-sublevels' is not to skip TODO entries but to
limit the tasks you can process at a time.

> The reason I'd like to exclude this "subtask" from displaying is
> something like this: assume that I have a project, halfway done, which
> must be postponed for some reason.  I'd like to be able to do this:
>
> * SOMEDAY cool project
> ** DONE preparation
> ** TODO hard work
>
> where SOMEDAY is a done-type keyword.
>
> And of course, I don't want to be bothered by "hard work" in this case
> in my global todo list.
>
> Is there a way to achieve this?

You can use a dedicated function in `org-agenda-skip-function' for that
(e.g., ignore task if one of its parents is a done task).


Regards,

-- 
Nicolas Goaziou

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-12  8:53 ` Nicolas Goaziou
@ 2015-12-12 11:00   ` Marcin Borkowski
  2015-12-14 19:17     ` Marcin Borkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Borkowski @ 2015-12-12 11:00 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-Mode mailing list


On 2015-12-12, at 09:53, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Hello,
>
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> I have org-agenda-todo-list-sublevels set to nil.  However, given this
>> tree:
>>
>> * DONE task
>> ** TODO subtask
>>
>> it turns out that the todo list in the agenda shows the "subtask" anyway.
>>
>> Should it be so?  I would guess not.
>
> It's not clear to to me it shouldn't be the case. AFAIU, the point of
> `org-agenda-todo-list-sublevels' is not to skip TODO entries but to
> limit the tasks you can process at a time.

I see.

>> The reason I'd like to exclude this "subtask" from displaying is
>> something like this: assume that I have a project, halfway done, which
>> must be postponed for some reason.  I'd like to be able to do this:
>>
>> * SOMEDAY cool project
>> ** DONE preparation
>> ** TODO hard work
>>
>> where SOMEDAY is a done-type keyword.
>>
>> And of course, I don't want to be bothered by "hard work" in this case
>> in my global todo list.
>>
>> Is there a way to achieve this?
>
> You can use a dedicated function in `org-agenda-skip-function' for that
> (e.g., ignore task if one of its parents is a done task).

Wow, thanks, I didn't know about it.  Now that I look into this, should
I use `org-agenda-skip-function' or `org-agenda-skip-function-global'?

Also, how do I check whether one of the parents is done?  I know how to
climb through the hierarchy of headlines, how do I get the TODO keyword?
Is `org-get-todo-state' the right function to do that?

Now that I think of it, maybe I should use a tag for that (like
:project: or something).  I'll have to think about it.

> Regards,

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-12 11:00   ` Marcin Borkowski
@ 2015-12-14 19:17     ` Marcin Borkowski
  2015-12-14 20:48       ` Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Borkowski @ 2015-12-14 19:17 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-Mode mailing list


> On 2015-12-12, at 09:53, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
>> You can use a dedicated function in `org-agenda-skip-function' for that
>> (e.g., ignore task if one of its parents is a done task).

OK, so it doesn't work (probably because I'm doing something wrong...)

I did this:

--8<---------------cut here---------------start------------->8---
(defun mbork/org-agenda-skip-if-parent-done ()
  "Return t if any of the parents of the current entry is a DONE
  item."
  (save-excursion
    (catch 'done
      (while (org-up-heading-safe)
	(if (org-entry-is-done-p)
	    (throw 'done t))))))

(setq org-agenda-custom-commands
      '(("n"
	 "Agenda and TODOs"
	 ((agenda "")
	  (alltodo "" ((org-agenda-skip-function #'mbork/org-agenda-skip-if-parent-done)))))))
--8<---------------cut here---------------end--------------->8---

and I see this:

--8<---------------cut here---------------start------------->8---
and: Wrong type argument: integer-or-marker-p, t
--8<---------------cut here---------------end--------------->8---

What may be the problem?  How do I even debug this?

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-14 19:17     ` Marcin Borkowski
@ 2015-12-14 20:48       ` Nick Dokos
  2015-12-15 23:33         ` Marcin Borkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2015-12-14 20:48 UTC (permalink / raw)
  To: emacs-orgmode

Marcin Borkowski <mbork@mbork.pl> writes:

>> On 2015-12-12, at 09:53, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>>
>>> You can use a dedicated function in `org-agenda-skip-function' for that
>>> (e.g., ignore task if one of its parents is a done task).
>
> OK, so it doesn't work (probably because I'm doing something wrong...)
>
> I did this:
>
> (defun mbork/org-agenda-skip-if-parent-done ()
>   "Return t if any of the parents of the current entry is a DONE
>   item."
>   (save-excursion
>     (catch 'done
>       (while (org-up-heading-safe)
> 	(if (org-entry-is-done-p)
> 	    (throw 'done t))))))
>
> (setq org-agenda-custom-commands
>       '(("n"
> 	 "Agenda and TODOs"
> 	 ((agenda "")
> 	  (alltodo "" ((org-agenda-skip-function #'mbork/org-agenda-skip-if-parent-done)))))))
>
> and I see this:
>
> and: Wrong type argument: integer-or-marker-p, t
>
> What may be the problem?  How do I even debug this?
>

Are you testing it with emacs -q -l /path/to/min/org-init.el?
If not, you probably should: I don't get any errors with the
stuff above in my minimal org file, which leads me to suspect
it's something in (the rest of) your configuration.

--
Nick

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-14 20:48       ` Nick Dokos
@ 2015-12-15 23:33         ` Marcin Borkowski
  2015-12-16  1:54           ` Nick Dokos
  0 siblings, 1 reply; 8+ messages in thread
From: Marcin Borkowski @ 2015-12-15 23:33 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode



On 2015-12-14, at 21:48, Nick Dokos <ndokos@gmail.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>>> On 2015-12-12, at 09:53, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>>>
>>>> You can use a dedicated function in `org-agenda-skip-function' for that
>>>> (e.g., ignore task if one of its parents is a done task).
>>
>> OK, so it doesn't work (probably because I'm doing something wrong...)
>>
>> I did this:
>>
>> (defun mbork/org-agenda-skip-if-parent-done ()
>>   "Return t if any of the parents of the current entry is a DONE
>>   item."
>>   (save-excursion
>>     (catch 'done
>>       (while (org-up-heading-safe)
>> 	(if (org-entry-is-done-p)
>> 	    (throw 'done t))))))
>>
>> (setq org-agenda-custom-commands
>>       '(("n"
>> 	 "Agenda and TODOs"
>> 	 ((agenda "")
>> 	  (alltodo "" ((org-agenda-skip-function #'mbork/org-agenda-skip-if-parent-done)))))))
>>
>> and I see this:
>>
>> and: Wrong type argument: integer-or-marker-p, t
>>
>> What may be the problem?  How do I even debug this?
>>
>
> Are you testing it with emacs -q -l /path/to/min/org-init.el?
> If not, you probably should: I don't get any errors with the
> stuff above in my minimal org file, which leads me to suspect
> it's something in (the rest of) your configuration.

Strange.  I have the same error even with emacs -q, with minimal Org
config - the above function and one simple agenda file, containing this:

* DONE done
** TODO todo

Org-mode version 8.2.10 (release_8.2.10 @ /usr/local/share/emacs/25.0.50/lisp/org/)

Any hints?

Here's the debugger output:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p t)
  goto-char(t)
  (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to))
  (or (save-excursion (goto-char p) (looking-at comment-start-skip)) (and org-agenda-skip-archived-trees (not org-agenda-archives-mode) (get-text-property p :org-archived) (org-end-of-subtree t)) (and org-agenda-skip-comment-trees (get-text-property p :org-comment) (org-end-of-subtree t)) (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to)) (org-in-src-block-p t))
  (if (or (save-excursion (goto-char p) (looking-at comment-start-skip)) (and org-agenda-skip-archived-trees (not org-agenda-archives-mode) (get-text-property p :org-archived) (org-end-of-subtree t)) (and org-agenda-skip-comment-trees (get-text-property p :org-comment) (org-end-of-subtree t)) (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to)) (org-in-src-block-p t)) (progn (throw :skip t)))
  (let ((p (point-at-bol)) to) (if (or (save-excursion (goto-char p) (looking-at comment-start-skip)) (and org-agenda-skip-archived-trees (not org-agenda-archives-mode) (get-text-property p :org-archived) (org-end-of-subtree t)) (and org-agenda-skip-comment-trees (get-text-property p :org-comment) (org-end-of-subtree t)) (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to)) (org-in-src-block-p t)) (progn (throw :skip t))))
  org-agenda-skip()
  org-agenda-get-todos()
  org-agenda-get-day-entries("/home/mbork/org/emacs.org" (12 16 2015) :todo)
  org-todo-list(nil)
  funcall-interactively(org-todo-list nil)
  call-interactively(org-todo-list)
  (let ((org-agenda-skip-function (function mbork/org-agenda-skip-if-parent-done))) (call-interactively (quote org-todo-list)))
  (let nil (let ((org-agenda-skip-function (function mbork/org-agenda-skip-if-parent-done))) (call-interactively (quote org-todo-list))))
  eval((let nil (let ((org-agenda-skip-function (function mbork/org-agenda-skip-if-parent-done))) (call-interactively (quote org-todo-list)))))
  org-let2(nil ((org-agenda-skip-function (function mbork/org-agenda-skip-if-parent-done))) (call-interactively (quote org-todo-list)))
  org-agenda-run-series("Agenda and TODOs" (((agenda "") (alltodo "" ((org-agenda-skip-function (function mbork/org-agenda-skip-if-parent-done)))))))
  org-agenda(nil)
  funcall-interactively(org-agenda nil)
  call-interactively(org-agenda nil nil)
  command-execute(org-agenda)
--8<---------------cut here---------------end--------------->8---

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-15 23:33         ` Marcin Borkowski
@ 2015-12-16  1:54           ` Nick Dokos
  2015-12-16  8:20             ` Marcin Borkowski
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Dokos @ 2015-12-16  1:54 UTC (permalink / raw)
  To: emacs-orgmode

Marcin Borkowski <mbork@mbork.pl> writes:

> On 2015-12-14, at 21:48, Nick Dokos <ndokos@gmail.com> wrote:
>
>> Marcin Borkowski <mbork@mbork.pl> writes:
>>
>>>> On 2015-12-12, at 09:53, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>>>>
>>>>> You can use a dedicated function in `org-agenda-skip-function' for that
>>>>> (e.g., ignore task if one of its parents is a done task).
>>>
>>> OK, so it doesn't work (probably because I'm doing something wrong...)
>>>
>>> I did this:
>>>
>>> (defun mbork/org-agenda-skip-if-parent-done ()
>>>   "Return t if any of the parents of the current entry is a DONE
>>>   item."
>>>   (save-excursion
>>>     (catch 'done
>>>       (while (org-up-heading-safe)
>>> 	(if (org-entry-is-done-p)
>>> 	    (throw 'done t))))))
>>>
>>> (setq org-agenda-custom-commands
>>>       '(("n"
>>> 	 "Agenda and TODOs"
>>> 	 ((agenda "")
>>> 	  (alltodo "" ((org-agenda-skip-function #'mbork/org-agenda-skip-if-parent-done)))))))
>>>
>>> and I see this:
>>>
>>> and: Wrong type argument: integer-or-marker-p, t
>>>
>>> What may be the problem?  How do I even debug this?
>>>
>>
>> Are you testing it with emacs -q -l /path/to/min/org-init.el?
>> If not, you probably should: I don't get any errors with the
>> stuff above in my minimal org file, which leads me to suspect
>> it's something in (the rest of) your configuration.
>
> Strange.  I have the same error even with emacs -q, with minimal Org
> config - the above function and one simple agenda file, containing this:
>
> * DONE done
> ** TODO todo
>
> Org-mode version 8.2.10 (release_8.2.10 @ /usr/local/share/emacs/25.0.50/lisp/org/)
>
> Any hints?
>
> Here's the debugger output:
>
> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p t)
>   goto-char(t)
>   (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to))

Not so strange: I probably did not hit the (throw 'done t) in your
function. The spec says that the function has to return a position
in the buffer:

,----
| org-agenda-skip-function is a variable defined in ‘org-agenda.el’.
| Its value is nil
| 
|   This variable may be risky if used as a file-local variable.
| 
| Documentation:
| Function to be called at each match during agenda construction.
| If this function returns nil, the current match should not be skipped.
| Otherwise, the function must return a position from where the search
| should be continued.
`----

-- 
Nick

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

* Re: An issue with org-agenda-todo-list-sublevels
  2015-12-16  1:54           ` Nick Dokos
@ 2015-12-16  8:20             ` Marcin Borkowski
  0 siblings, 0 replies; 8+ messages in thread
From: Marcin Borkowski @ 2015-12-16  8:20 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode



On 2015-12-16, at 02:54, Nick Dokos <ndokos@gmail.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> On 2015-12-14, at 21:48, Nick Dokos <ndokos@gmail.com> wrote:
>>
>>> Marcin Borkowski <mbork@mbork.pl> writes:
>>>
>>>>> On 2015-12-12, at 09:53, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>>>>>
>>>>>> You can use a dedicated function in `org-agenda-skip-function' for that
>>>>>> (e.g., ignore task if one of its parents is a done task).
>>>>
>>>> OK, so it doesn't work (probably because I'm doing something wrong...)
>>>>
>>>> I did this:
>>>>
>>>> (defun mbork/org-agenda-skip-if-parent-done ()
>>>>   "Return t if any of the parents of the current entry is a DONE
>>>>   item."
>>>>   (save-excursion
>>>>     (catch 'done
>>>>       (while (org-up-heading-safe)
>>>> 	(if (org-entry-is-done-p)
>>>> 	    (throw 'done t))))))
>>>>
>>>> (setq org-agenda-custom-commands
>>>>       '(("n"
>>>> 	 "Agenda and TODOs"
>>>> 	 ((agenda "")
>>>> 	  (alltodo "" ((org-agenda-skip-function #'mbork/org-agenda-skip-if-parent-done)))))))
>>>>
>>>> and I see this:
>>>>
>>>> and: Wrong type argument: integer-or-marker-p, t
>>>>
>>>> What may be the problem?  How do I even debug this?
>>>>
>>>
>>> Are you testing it with emacs -q -l /path/to/min/org-init.el?
>>> If not, you probably should: I don't get any errors with the
>>> stuff above in my minimal org file, which leads me to suspect
>>> it's something in (the rest of) your configuration.
>>
>> Strange.  I have the same error even with emacs -q, with minimal Org
>> config - the above function and one simple agenda file, containing this:
>>
>> * DONE done
>> ** TODO todo
>>
>> Org-mode version 8.2.10 (release_8.2.10 @ /usr/local/share/emacs/25.0.50/lisp/org/)
>>
>> Any hints?
>>
>> Here's the debugger output:
>>
>> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p t)
>>   goto-char(t)
>>   (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to))
>
> Not so strange: I probably did not hit the (throw 'done t) in your
> function. The spec says that the function has to return a position
> in the buffer:
>
> ,----
> | org-agenda-skip-function is a variable defined in ‘org-agenda.el’.
> | Its value is nil
> | 
> |   This variable may be risky if used as a file-local variable.
> | 
> | Documentation:
> | Function to be called at each match during agenda construction.
> | If this function returns nil, the current match should not be skipped.
> | Otherwise, the function must return a position from where the search
> | should be continued.
> `----

Stupid me.  Thanks.

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

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

end of thread, other threads:[~2015-12-16  8:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-10 23:26 An issue with org-agenda-todo-list-sublevels Marcin Borkowski
2015-12-12  8:53 ` Nicolas Goaziou
2015-12-12 11:00   ` Marcin Borkowski
2015-12-14 19:17     ` Marcin Borkowski
2015-12-14 20:48       ` Nick Dokos
2015-12-15 23:33         ` Marcin Borkowski
2015-12-16  1:54           ` Nick Dokos
2015-12-16  8:20             ` Marcin Borkowski

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