emacs-orgmode
[Top][All Lists]
Advanced

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

[O] [PATCH] lisp/org-el: Fix explanation, if state change is blocked by


From: Marc Ihm
Subject: [O] [PATCH] lisp/org-el: Fix explanation, if state change is blocked by contained checkboxes
Date: Fri, 14 Apr 2017 17:49:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (windows-nt)

Hi,

The patch below fixes a minor problem:

Consider a node, which contains unchecked checkboxes; if you have set
org-enforce-todo-checkbox-dependencies and try to change the node to
DONE, you will be denied with a message explaining why. However in this
special case the explanation would be wrong in talking of an unrelated
node instead of the checkboxes.

The fix uses the already existing variable org-blocked-by-checkboxes
(which is handled in org-block-todo-from-checkboxes).  Similar code is
already present in org-agenda-dim-blocked-tasks within org-agenda.el.


Please review the patch and let me know, if you have any comments or
questions.

Thanks,
Marc


>From 97311babee20c291aad0f1e6fa0f147c3ed416bf Mon Sep 17 00:00:00 2001
From: "U-IHM-NOTEBOOK\\Olli" <address@hidden>
Date: Fri, 14 Apr 2017 17:14:02 +0200
Subject: [PATCH 1/1] org-el: Fix explanation, if state change is blocked by
 contained checkboxes

---
 lisp/org.el | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 17caa3f..00d3802 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12369,6 +12369,7 @@ nil or a string to be used for the todo mark." )
        (replace-match "0" t nil nil 1)))))
 
 (defvar org-state) ;; dynamically scoped into this function
+(defvar org-blocked-by-checkboxes) ; dynamically scoped
 (defun org-todo (&optional arg)
   "Change the TODO state of an item.
 
@@ -12518,20 +12519,24 @@ When called through ELisp, arg is also interpreted in 
the following way:
                                     :position startpos))
                 dolog now-done-p)
            (when org-blocker-hook
-             (setq org-last-todo-state-is-todo
-                   (not (member this org-done-keywords)))
-             (unless (save-excursion
-                       (save-match-data
-                         (org-with-wide-buffer
-                          (run-hook-with-args-until-failure
-                           'org-blocker-hook change-plist))))
-               (if (called-interactively-p 'interactive)
-                   (user-error "TODO state change from %s to %s blocked (by 
\"%s\")"
-                               this org-state org-block-entry-blocking)
-                 ;; fail silently
-                 (message "TODO state change from %s to %s blocked (by \"%s\")"
-                          this org-state org-block-entry-blocking)
-                 (throw 'exit nil))))
+             (let (org-blocked-by-checkboxes block-reason)
+               (setq org-last-todo-state-is-todo
+                     (not (member this org-done-keywords)))
+               (unless (save-excursion
+                         (save-match-data
+                           (org-with-wide-buffer
+                            (run-hook-with-args-until-failure
+                             'org-blocker-hook change-plist))))
+                 (setq block-reason (if org-blocked-by-checkboxes
+                                        "contained checkboxes"
+                                      (format "\"%s\"" 
org-block-entry-blocking)))
+                 (if (called-interactively-p 'interactive)
+                     (user-error "TODO state change from %s to %s blocked (by 
%s)"
+                                 this org-state block-reason)
+                   ;; fail silently
+                   (message "TODO state change from %s to %s blocked (by %s)"
+                            this org-state block-reason)
+                   (throw 'exit nil)))))
            (store-match-data match-data)
            (replace-match next t t)
            (cond ((equal this org-state)
@@ -12714,7 +12719,6 @@ 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
-- 
2.8.3


reply via email to

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