0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 21:37:50 +00:00

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

View file

@ -207,11 +207,11 @@ This does two different kinds of triggers:
(org-refresh-properties org-effort-property 'org-effort) (org-refresh-properties org-effort-property 'org-effort)
;; Get information from the plist ;; Get information from the plist
(let* ((type (plist-get change-plist :type)) (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)) (from (plist-get change-plist :from))
(to (plist-get change-plist :to)) (to (plist-get change-plist :to))
(org-log-done nil) ; IMPROTANT!: no logging during automatic trigger! (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 (catch 'return
(unless (eq type 'todo-state-change) (unless (eq type 'todo-state-change)
;; We are only handling 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) (setq id (match-string 1 tr)
kwd (match-string 2 tr) kwd (match-string 2 tr)
p1 (org-find-entry-with-id id)) p1 (org-find-entry-with-id id))
(when p1 ;; First check current buffer, then all files.
;; there is an entry with this ID, mark it TODO (if p1
(save-excursion ;; There is an entry with this ID, mark it TODO.
(goto-char p1) (save-excursion
(org-todo kwd)))) (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) ((string-match "\\`chain-siblings-scheduled\\'" tr)
(let ((time (org-get-scheduled-time pos))) (let ((time (org-get-scheduled-time pos)))
(when time (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." this ID property, that entry is also checked."
;; Get information from the plist ;; Get information from the plist
(let* ((type (plist-get change-plist :type)) (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)) (from (plist-get change-plist :from))
(to (plist-get change-plist :to)) (to (plist-get change-plist :to))
(org-log-done nil) ; IMPROTANT!: no logging during automatic trigger (org-log-done nil) ; IMPROTANT!: no logging during automatic trigger
blocker blockers bl p1 blocker blockers bl p1 p2
(proceed-p (proceed-p
(catch 'return (catch 'return
;; If this is not a todo state change, or if this entry is ;; 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! ;; return nil, to indicate that we block the change!
(org-mark-ring-push) (org-mark-ring-push)
(throw 'return nil))))) (throw 'return nil)))))
((setq p1 (org-find-entry-with-id bl)) ((setq p1 (org-find-entry-with-id bl))
;; there is an entry with this ID, check it out ;; there is an entry with this ID, check it out
(save-excursion (save-excursion
@ -403,9 +408,16 @@ this ID property, that entry is also checked."
(unless (org-entry-is-done-p) (unless (org-entry-is-done-p)
;; return nil, to indicate that we block the change! ;; return nil, to indicate that we block the change!
(org-mark-ring-push) (org-mark-ring-push)
(throw 'return nil)))))) (throw 'return nil))))
t ; return t to indicate that we are not blocking ((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 (when org-depend-tag-blocked
(org-toggle-tag "blocked" (if proceed-p 'off 'on))) (org-toggle-tag "blocked" (if proceed-p 'off 'on)))