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.
This commit is contained in:
Adrian Bradd 2017-07-13 22:49:26 -04:00 committed by Nicolas Goaziou
parent 0c1b4da1f6
commit fbf31df38a
1 changed files with 25 additions and 13 deletions

View File

@ -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)))