From 25f12218d2fe1152cba840d1a0caedddb1656d90 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 14 Sep 2017 15:33:51 +0200 Subject: [PATCH] Fix `org-auto-repeat-maybe' * lisp/org.el (org-auto-repeat-maybe): Fix `org-auto-repeat-maybe'. * testing/lisp/test-org.el (test-org/auto-repeat-maybe): Add test. Reported-by: Samuel Wales --- lisp/org.el | 5 +++-- testing/lisp/test-org.el | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 576e07314..5ebfa82f6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -13053,8 +13053,9 @@ This function is run automatically after each state change to a DONE state." ;; a clock, set LAST_REPEAT property. (when (or org-log-repeat (catch :clock - (while (re-search-forward org-clock-line-re end t) - (when (org-at-clock-log-p) (throw :clock t))))) + (save-excursion + (while (re-search-forward org-clock-line-re end t) + (when (org-at-clock-log-p) (throw :clock t)))))) (org-entry-put nil "LAST_REPEAT" (format-time-string (org-time-stamp-format t t) (current-time)))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 28e2d7f24..c4a2a58e9 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6047,7 +6047,7 @@ Paragraph" (cl-letf (((symbol-function 'org-add-log-setup) (lambda (&rest args) nil))) (org-test-with-temp-text - "* TODO H\n<2012-03-29 Thu. +2y>\nCLOCK: [2012-03-29 Thu 16:40]" + "* TODO H\n<2012-03-29 Thu +2y>\nCLOCK: [2012-03-29 Thu 16:40]" (org-todo "DONE") (buffer-string)))))) ;; When a SCHEDULED entry has no repeater, remove it upon repeating @@ -6059,6 +6059,19 @@ Paragraph" (org-test-with-temp-text "* TODO H\nSCHEDULED: <2014-03-04 Tue>\n<2012-03-29 Thu +2y>" (org-todo "DONE") + (buffer-string))))) + ;; Properly advance repeater even when a clock entry is specified + ;; and `org-log-repeat' is nil. + (should + (string-match-p + "SCHEDULED: <2014-03-29" + (let ((org-log-repeat nil) + (org-todo-keywords '((sequence "TODO" "DONE")))) + (org-test-with-temp-text + "* TODO H +SCHEDULED: <2012-03-29 Thu +2y> +CLOCK: [2012-03-29 Thu 10:00]--[2012-03-29 Thu 16:40] => 6:40" + (org-todo "DONE") (buffer-string)))))) -- 2.11.4.GIT