From 19ee311eb35bc4cde08e61bc485a679df2d584dd Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Sun, 5 Apr 2020 15:47:45 +0200 Subject: [PATCH] Handle ".+" repeater style for hours * lisp/org.el (org-auto-repeat-maybe): Handle ".+" repeater style for hours. * doc/org-manual.org (Repeated tasks): Add an example. --- doc/org-manual.org | 4 ++++ lisp/org.el | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 5f55e9bd5..ee054a744 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -6337,6 +6337,10 @@ special repeaters =++= and =.+=. For example: ,** TODO Check the batteries in the smoke detectors DEADLINE: <2005-11-01 Tue .+1m> Marking this DONE will shift the date to one month after today. + +,** TODO Play a major third while pushing the bird through the door + DEADLINE: <2019-04-05 08:00 Sun .+1h> + Marking this DONE shifts the date to exactly one hour from now. #+end_example #+vindex: org-agenda-skip-scheduled-if-deadline-is-shown diff --git a/lisp/org.el b/lisp/org.el index 06891b8bd..b9742514d 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10146,9 +10146,14 @@ This function is run automatically after each state change to a DONE state." (repeater-type (match-string 1 ts))) (cond ((equal "." repeater-type) - ;; Shift starting date to today. - (org-timestamp-change (- (org-today) (time-to-days time)) - 'day)) + ;; Shift starting date to today, or now if + ;; repeater is by hours. + (if (equal what "h") + (org-timestamp-change + (floor (/ (- (org-time-stamp-to-now ts t)) 60)) + 'minute) + (org-timestamp-change (- (org-today) (time-to-days time)) + 'day))) ((equal "+" repeater-type) (let ((nshiftmax 10) (nshift 0)) -- 2.26.0