I have attached an amended version. Let me know if there are any other
changes that need to be made.
From d18f299c2dfe3610e04b156d08a70ddafb052ab2 Mon Sep 17 00:00:00 2001
From: Adrian Bradd <adrian.br...@gmail.com>
Date: Thu, 13 Jul 2017 22:49:26 -0400
Subject: [PATCH] contrib/lisp/org-depend.el (org-depend-trigger-todo,
 org-depend-block-todo): 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..136a14eb2 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
+		(with-current-buffer
+		  (find-file-noselect (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
+		  (with-current-buffer
+		    (find-file-noselect (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

Reply via email to