emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Do something useful with ".+" and hours repeaters


From: Nicolas Goaziou
Subject: Do something useful with ".+" and hours repeaters
Date: Sun, 05 Apr 2020 15:58:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hello,

Someone on #org-mode (sorry, I cannot remember the nickname) reported
that ".+" repeater style was not handling properly (not handling at all,
actually) hours spans.

As a reminder, ".+" means "repeat, starting from today as the base
date". With hours, it seems logical to "repeat, starting from now as the
base date". The attached patch does that.

WDYT?

-- 
Nicolas Goaziou
>From 19ee311eb35bc4cde08e61bc485a679df2d584dd Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]