emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-depend: multi-file TRIGGER and BLOCKER tasks
@ 2017-07-28  2:12 Adrian Bradd
  2017-07-28 13:48 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Adrian Bradd @ 2017-07-28  2:12 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 168 bytes --]

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`.

[-- Attachment #1.2: Type: text/html, Size: 230 bytes --]

[-- Attachment #2: 0001-org-depend-multi-file-TRIGGER-and-BLOCKER-tasks.patch --]
[-- Type: text/x-patch, Size: 2584 bytes --]

From d4095a57f1c9c42426d8c0d51ca7f4640f036a3a Mon Sep 17 00:00:00 2001
From: Adrian Bradd <adrian.bradd@gmail.com>
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-01  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28  2:12 [PATCH] org-depend: multi-file TRIGGER and BLOCKER tasks Adrian Bradd
2017-07-28 13:48 ` Nicolas Goaziou
2017-07-29 23:12   ` Adrian Bradd
2017-08-01  8:34     ` 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).