* [PATCH] lisp/org-el: Fix explanation, if state change is blocked by contained checkboxes
@ 2017-04-14 15:49 Marc Ihm
2017-04-17 8:39 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Marc Ihm @ 2017-04-14 15:49 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 669 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-el: Fix explanation, if state change is blocked by contained checkboxes --]
[-- Type: text/x-patch, Size: 2815 bytes --]
From 97311babee20c291aad0f1e6fa0f147c3ed416bf Mon Sep 17 00:00:00 2001
From: "U-IHM-NOTEBOOK\\Olli" <marc@ihm.name>
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lisp/org-el: Fix explanation, if state change is blocked by contained checkboxes
2017-04-14 15:49 [PATCH] lisp/org-el: Fix explanation, if state change is blocked by contained checkboxes Marc Ihm
@ 2017-04-17 8:39 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2017-04-17 8:39 UTC (permalink / raw)
To: Marc Ihm; +Cc: emacs-orgmode
Hello,
Marc Ihm <marc@ihm.name> writes:
> 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.
Applied. Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-17 8:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-14 15:49 [PATCH] lisp/org-el: Fix explanation, if state change is blocked by contained checkboxes Marc Ihm
2017-04-17 8:39 ` Nicolas Goaziou
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).