From 97311babee20c291aad0f1e6fa0f147c3ed416bf Mon Sep 17 00:00:00 2001 From: "U-IHM-NOTEBOOK\\Olli" 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