Adds multi-file TRIGGER and BLOCKER tasks to org-depend by first searching
the current file `org-find-entry-with-id` and then all files visisble
through `org-find-id`.
From d4095a57f1c9c42426d8c0d51ca7f4640f036a3a Mon Sep 17 00:00:00 2001
From: Adrian Bradd <[email protected]>
Date: Thu, 13 Jul 2017 22:49:26 -0400
Subject: [PATCH] org-depend: multi-file TRIGGER and BLOCKER tasks
---
contrib/lisp/org-depend.el | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el
index d1b98441c..fc7d69d1d 100644
--- a/contrib/lisp/org-depend.el
+++ b/contrib/lisp/org-depend.el
@@ -211,7 +211,7 @@ This does two different kinds of triggers:
(from (plist-get change-plist :from))
(to (plist-get change-plist :to))
(org-log-done nil) ; IMPROTANT!: no logging during automatic trigger!
- trigger triggers tr p1 kwd id)
+ trigger triggers tr p1 p2 kwd id)
(catch 'return
(unless (eq type 'todo-state-change)
;; We are only handling todo-state-change....
@@ -336,11 +336,18 @@ This does two different kinds of triggers:
(setq id (match-string 1 tr)
kwd (match-string 2 tr)
p1 (org-find-entry-with-id id))
- (when p1
+ ;; first check current buffer, then all files
+ (if p1
;; there is an entry with this ID, mark it TODO
(save-excursion
(goto-char p1)
- (org-todo kwd))))
+ (org-todo kwd))
+ (when (setq p2 (org-id-find id))
+ (save-excursion
+ (save-window-excursion
+ (find-file (car p2))
+ (goto-char (cdr p2))
+ (org-todo kwd))))))
((string-match "\\`chain-siblings-scheduled\\'" tr)
(let ((time (org-get-scheduled-time pos)))
(when time
@@ -362,7 +369,7 @@ this ID property, that entry is also checked."
(from (plist-get change-plist :from))
(to (plist-get change-plist :to))
(org-log-done nil) ; IMPROTANT!: no logging during automatic trigger
- blocker blockers bl p1
+ blocker blockers bl p1 p2
(proceed-p
(catch 'return
;; If this is not a todo state change, or if this entry is
@@ -403,7 +410,16 @@ this ID property, that entry is also checked."
(unless (org-entry-is-done-p)
;; return nil, to indicate that we block the change!
(org-mark-ring-push)
- (throw 'return nil))))))
+ (throw 'return nil))))
+
+ ((setq p2 (org-id-find bl))
+ (save-excursion
+ (save-window-excursion
+ (find-file (car p2))
+ (goto-char (cdr p2))
+ (unless (org-entry-is-done-p)
+ (org-mark-ring-push)
+ (throw 'return nil)))))))
t ; return t to indicate that we are not blocking
)))
(when org-depend-tag-blocked
--
2.11.0