From 06056781fef0df592c3cf974807092c896227723 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Thu, 19 Feb 2009 11:12:52 +0100 Subject: [PATCH] Agenda: Do not make tasks invisible if they are blocked by checkboxes. John Rakestraw writes: > I noticed today that, at least in my set-up, setting these variables > this way: > > (setq org-agenda-dim-blocked-tasks 'invisible) > (setq org-enforce-todo-checkbox-dependencies t) > > means that a TODO task with checkboxes doesn't get included in the > agenda. However, the sub-tasks in the checkbox list don't get included, > either. So the TODO task with checkboxes doesn't show up in the agenda. > > It makes sense given the way the variables work. However, I wonder if > it makes more sense for a task with checklisted sub-tasks to be > included in the agenda so that the tasks and sub-tasks don't get lost. > Or, to put the point slightly differently, I think that a TODO that's > blocked because it has dependent TODOs might be treated differently in > agenda listings than a TODO that's blocked because it has dependent > checklist items. > > Not a big deal to me because I don't typically use checkboxes for TODO > items. But I thought I'd raise it for consideration. I agree with this view and the commit implements exactly this. --- lisp/ChangeLog | 8 +++++++- lisp/org-agenda.el | 28 +++++++++++++++++++--------- lisp/org.el | 6 +++++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0dd8ac04a..bd7c5cd20 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,8 +1,14 @@ 2009-02-19 Carsten Dominik + * org.el (org-block-todo-from-checkboxes): Announce that + checkboxes are the culprit. + * org-agenda.el (org-agenda-show-1): Renamed from `org-agenda-show'. - (org-agenda-show): Re-install the old version ofr now. + (org-agenda-show): Re-install the old version for now. + (org-agenda-dim-blocked-tasks): Update docstring. Scope a + variable into the blokker hook, so that the checkbox checker can + anounce that it caused the blocking. * org.el (org-track-ordered-property-with-tag): New option. (org-toggle-ordered-property): Honor diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f649debf1..625ff15f3 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -523,12 +523,19 @@ deadlines are always turned off when the item is DONE." (defcustom org-agenda-dim-blocked-tasks t "Non-nil means, dim blocked tasks in the agenda display. -This causes some overhead during agenda construction, but if you have turned -on `org-enforce-todo-dependencies' or any other blocking mechanism, this -will create useful feedback in the agenda. -Instead ot t, this variable can also have the value `invisible'. Then -blocked tasks will be invisible and only become visible when they -become unblocked." +This causes some overhead during agenda construction, but if you +have turned on `org-enforce-todo-dependencies', +`org-enforce-todo-checkbox-dependencies', or any other blocking +mechanism, this will create useful feedback in the agenda. + +Instead ot t, this variable can also have the value `invisible'. +Then blocked tasks will be invisible and only become visible when +they become unblocked. An exemption to this behavior is when a task is +blocked because of unchecked checkboxes below it. Since checkboxes do +not show up in the agenda views, making this task invisible you remove any +trace from agenda views that there is something to do. Therefore, a task +that is blocked because of checkboxes will never be made invisible, it +will only be dimmed." :group 'org-agenda-daily/weekly :group 'org-agenda-todo-list :type '(choice @@ -2206,10 +2213,12 @@ VALUE defaults to t." (let ((inhibit-read-only t) (org-depend-tag-blocked nil) (invis (eq org-agenda-dim-blocked-tasks 'invisible)) - b e p ov h l) + org-blocked-by-checkboxes + invis1 b e p ov h l) (goto-char (point-min)) (while (let ((pos (next-single-property-change (point) 'todo-state))) (and pos (goto-char (1+ pos)))) + (setq org-blocked-by-checkboxes nil invis1 invis) (let ((marker (get-text-property (point) 'org-hd-marker))) (when (and marker (not (with-current-buffer (marker-buffer marker) @@ -2221,10 +2230,11 @@ VALUE defaults to t." :position marker :from 'todo :to 'done)))))) - (setq b (if invis (max (point-min) (1- (point))) (point)) + (if org-blocked-by-checkboxes (setq invis1 nil)) + (setq b (if invis1 (max (point-min) (1- (point))) (point)) e (point-at-eol) ov (org-make-overlay b e)) - (if invis + (if invis1 (org-overlay-put ov 'invisible t) (org-overlay-put ov 'face 'org-agenda-dimmed-todo-face)) (org-overlay-put ov 'org-type 'org-blocked-todo))))))) diff --git a/lisp/org.el b/lisp/org.el index cca1aea3e..9b12d38a6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8748,6 +8748,7 @@ See variable `org-track-ordered-property-with-tag'." (and tag (org-toggle-tag tag 'on)) (message "Subtasks must be completed in sequence"))))) +(defvar org-blocked-by-checkboxes) ; dynamically scoped (defun org-block-todo-from-checkboxes (change-plist) "Block turning an entry into a TODO, using checkboxes. This checks whether the current task should be blocked from state @@ -8770,7 +8771,10 @@ changes because there are uncheckd boxes in this entry." (goto-char beg) (if (re-search-forward "^[ \t]*\\([-+*]\\|[0-9]+[.)]\\)[ \t]+\\[[- ]\\]" end t) - (throw 'dont-block nil)))) + (progn + (if (boundp 'org-blocked-by-checkboxes) + (setq org-blocked-by-checkboxes t)) + (throw 'dont-block nil))))) t)) ; do not block (defun org-update-parent-todo-statistics ()