From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Ihm Subject: [PATCH] lisp/org-el: Fix explanation, if state change is blocked by contained checkboxes Date: Fri, 14 Apr 2017 17:49:50 +0200 Message-ID: <867f2ndm5d.fsf@ihm.name> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cz3U7-0002RX-NK for emacs-orgmode@gnu.org; Fri, 14 Apr 2017 11:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cz3U4-0001N5-KY for emacs-orgmode@gnu.org; Fri, 14 Apr 2017 11:50:07 -0400 Received: from [195.159.176.226] (port=48691 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cz3U4-0001Me-Cv for emacs-orgmode@gnu.org; Fri, 14 Apr 2017 11:50:04 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cz3Tr-0007Aw-Fj for emacs-orgmode@gnu.org; Fri, 14 Apr 2017 17:49:51 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-el-Fix-explanation-if-state-change-is-blocked-by.patch Content-Description: org-el: Fix explanation, if state change is blocked by contained checkboxes >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 --=-=-=--