summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Bradd <adrian.bradd@gmail.com>2017-07-13 22:49:26 -0400
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-01 10:33:15 +0200
commitfbf31df38a20e03127a3d415f4391b6a72fc73a4 (patch)
tree1c9716d7341009e16630b2f2b838d4427c1a8a4e
parent0c1b4da1f620067c8e0925f47d13769a302b9546 (diff)
downloadorg-mode-fbf31df38a20e03127a3d415f4391b6a72fc73a4.tar.gz
org-depend: Add multi-file TRIGGER and BLOCKER tasks
contrib/lisp/org-depend.el (org-depend-trigger-todo): (org-depend-block-todo): Implement multi-file TRIGGER and BLOCKER tasks.
-rw-r--r--contrib/lisp/org-depend.el38
1 files changed, 25 insertions, 13 deletions
diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el
index d1b9844..d442c02 100644
--- a/contrib/lisp/org-depend.el
+++ b/contrib/lisp/org-depend.el
@@ -207,11 +207,11 @@ This does two different kinds of triggers:
(org-refresh-properties org-effort-property 'org-effort)
;; Get information from the plist
(let* ((type (plist-get change-plist :type))
- (pos (plist-get change-plist :position))
+ (pos (plist-get change-plist :position))
(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,17 @@ 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
- ;; there is an entry with this ID, mark it TODO
- (save-excursion
- (goto-char p1)
- (org-todo kwd))))
+ ;; 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))
+ (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
@@ -358,11 +364,11 @@ Any other words are treated as entry id's. If an entry exists with the
this ID property, that entry is also checked."
;; Get information from the plist
(let* ((type (plist-get change-plist :type))
- (pos (plist-get change-plist :position))
+ (pos (plist-get change-plist :position))
(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
@@ -395,7 +401,6 @@ this ID property, that entry is also checked."
;; return nil, to indicate that we block the change!
(org-mark-ring-push)
(throw 'return nil)))))
-
((setq p1 (org-find-entry-with-id bl))
;; there is an entry with this ID, check it out
(save-excursion
@@ -403,9 +408,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))))))
- t ; return t to indicate that we are not blocking
- )))
+ (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)))))))
+ ;; Return t to indicate that we are not blocking.
+ t)))
(when org-depend-tag-blocked
(org-toggle-tag "blocked" (if proceed-p 'off 'on)))