emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Reschedule "++" repeaters on same day if in future
@ 2016-06-27  6:49 Don March
  2016-06-30 12:16 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Don March @ 2016-06-27  6:49 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2133 bytes --]

If you have a task with the following timestamp:

    SCHEDULED: <2016-06-19 Sun 21:00 ++1w>

then marking it as DONE at [2016-06-27 at 07:00] should (debatably) result in

    SCHEDULED: <2016-06-26 Sun 21:00 ++1w>

but instead it becomes

    SCHEDULED: <2016-07-03 Sun 21:00 ++1w>

The attached patch changes the behavior to not skip a repeat occurrence that
would occur on the day that a task is completed, if there is a time in the
timestamp and it is after the current time. This is really useful, at least for
me, and also matches a literal reading of the docs. They say (regarding a "++1w"
repeater)

#+BEGIN_QUOTE
Marking this DONE will shift the date by at least one week, but also by as many
weeks as it takes to get this date into the future.
#+END_QUOTE

With a time before the repeater

    SCHEDULED: <2016-06-19 Sun 21:00 ++1w>

you seem to be saying that you don't start working on this task until Sunday
evening every week. If you get busy and don't mark it DONE until the next Sunday
morning, then you must be talking about the previous instance, not the repeat
occurrence which will become available later that day. So it makes sense to
increase the timestamp to later that day:

    SCHEDULED: <2016-06-26 Sun 21:00 ++1w>

For another example,  suppose you empty the kitchen trash every night:

    SCHEDULED: <2016-06-19 Sun 22:00 ++1d>

If you don't complete that occurrence for two days and then empty the trash on
Tuesday morning, you would still want to empty it that night:

    SCHEDULED: <2016-06-21 Tue 22:00 ++1d>

as opposed to skipping Tuesday night and repeating on Wednesday.

These examples seem useful to me. But this change could, in theory, lead to the
absurd situation of rescheduling a task for just a couple minutes after its
completion. But to me that seems the lesser of two evils; you just mark it DONE
again, versus the alternative of thinking that you'll be reminded of a task only
to forget all about it.

If the task is *already* scheduled for later today, this patch does not affect
the current behavior--the task will still be rescheduled on the next occurrence
on some future day.

[-- Attachment #2: 0001-Reschedule-repeaters-on-same-day-if-in-future.patch --]
[-- Type: text/x-patch, Size: 944 bytes --]

From 59328aa0089bb376df86c89128a741a59d41c378 Mon Sep 17 00:00:00 2001
From: Don March <don@ohspite.net>
Date: Sun, 26 Jun 2016 23:35:44 -0700
Subject: [PATCH] Reschedule "++" repeaters on same day if in future

* lisp/org.el (org-auto-repeat-maybe): Include a time in a
  timestamp (hours and minutes) when checking if a repeat occurrence is
  in the future.
---
 lisp/org.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index e13e82d..0b102fb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13287,8 +13287,8 @@ has been set"
 			(let ((nshiftmax 10)
 			      (nshift 0))
 			  (while (or (= nshift 0)
-				     (<= (time-to-days time)
-					 (time-to-days (current-time))))
+				     (or (time-less-p time (current-time))
+					 (equal time (current-time))))
 			    (when (= (cl-incf nshift) nshiftmax)
 			      (or (y-or-n-p
 				   (format "%d repeater intervals were not \
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-07-02 22:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-27  6:49 [PATCH] Reschedule "++" repeaters on same day if in future Don March
2016-06-30 12:16 ` Nicolas Goaziou
2016-06-30 23:07   ` Don March
2016-07-01  9:27     ` Nicolas Goaziou
2016-07-01 16:30       ` Don March
2016-07-01 17:33         ` Nicolas Goaziou
2016-07-02  6:45           ` Don March
2016-07-02 22:24             ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).