From 668ac6a825f65e5594c831dc1ebfdaeeb3aec403 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 6 Jun 2021 10:29:44 -0400 Subject: [PATCH] ADD test for DONE timestamp shifter --- local/lib/org-x/org-x.el | 26 +++++++++++++++----------- local/lib/org-x/test/org-x-test.el | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/local/lib/org-x/org-x.el b/local/lib/org-x/org-x.el index b5ed406..5edf2d5 100644 --- a/local/lib/org-x/org-x.el +++ b/local/lib/org-x/org-x.el @@ -1105,23 +1105,27 @@ timestamp in the contents of the headline will be shifted." (cl-labels ((shift-timestamps (offset unit subtree) - (if (not (member (org-ml-get-property :todo-keyword subtree) - org-x-done-keywords)) + (let ((kw (org-ml-get-property :todo-keyword subtree))) + (cond + ((null kw) + (org-ml-headline-map-contents* (org-x-logbook-config) + ;; wrap in a section here because the matcher needs a single node + ;; and not a list + (->> (apply #'org-ml-build-section it) + (org-ml-match-map* org-x--first-active-ts-pattern + (org-ml-timestamp-shift offset unit it)) + (org-ml-get-children)) + subtree)) + ((member kw org-x-done-keywords) + subtree) + (t (org-ml-headline-map-planning* (-some->> it (org-ml-map-property* :scheduled (when it (org-ml-timestamp-shift offset unit it))) (org-ml-map-property* :deadline (when it (org-ml-timestamp-shift offset unit it)))) - subtree) - (org-ml-headline-map-contents* (org-x-logbook-config) - ;; wrap in a section here because the matcher needs a single node - ;; and not a list - (->> (apply #'org-ml-build-section it) - (org-ml-match-map* org-x--first-active-ts-pattern - (org-ml-timestamp-shift offset unit it)) - (org-ml-get-children)) - subtree))) + subtree))))) (shift (offset unit subtree) (->> (shift-timestamps offset unit subtree) diff --git a/local/lib/org-x/test/org-x-test.el b/local/lib/org-x/test/org-x-test.el index 43f4de2..dac56c4 100644 --- a/local/lib/org-x/test/org-x-test.el +++ b/local/lib/org-x/test/org-x-test.el @@ -677,6 +677,30 @@ Forms are denoted like %(FORM)%." "CLOCK: [2021-04-18 Sun 13:02]--[2021-04-18 Sun 13:09] => 0:07" ":END:") + "task (DONE)" + ("* DONE headline" + "DEADLINE: <2020-01-01 Wed>" + ":PROPERTIES:" + ":CREATED: [2019-01-01 Tue]" + ":END:" + ":LOGGING:" + "- State \"DONE\" from \"TODO\" [2021-04-18 Sun 13:09]" + ":END:" + ":CLOCKING:" + "CLOCK: [2021-04-18 Sun 13:02]--[2021-04-18 Sun 13:09] => 0:07" + ":END:") + => (:result "* DONE headline" + "DEADLINE: <2020-01-01 Wed>" + ":PROPERTIES:" + ":CREATED: [2019-01-01 Tue]" + ":END:" + ":LOGGING:" + "- State \"DONE\" from \"TODO\" [2021-04-18 Sun 13:09]" + ":END:" + ":CLOCKING:" + "CLOCK: [2021-04-18 Sun 13:02]--[2021-04-18 Sun 13:09] => 0:07" + ":END:") + "subtask" ("* top" "** TODO headline"