0

The Problem

What's the best way to schedule complicated time-based procedures that are repeated on irregular dates? E.g., say I signed up to do night watch on a set of arbitrary dates. The night watch procedure requires certain actions at certain times:

* Night Watch <2023-07-10 18:00>--<2023-07-11 09:00>
** TODO Rounds 
SCHEDULED: <2023-07-10 19:00>
** TODO Call in
SCHEDULED: <2023-07-10 22:00>

Is there an easy way to have "Night Watch" and its children show up on the agenda on any arbitrary set of dates (i.e, with no pattern)?

What I've tried

  1. I found one question where an org-capture template was loaded with a handmade script that prompted for a date and manipulated the dates--but unfortunately they did not include an example of adding a time range to an input date, and I couldn't figure out how from the onboard documentation.
3
  • Not an answer, just a clarification. These look like appointments to me: you should probably use (active) timestamps only. See Deadlines and Scheduling in the manual, in particular the Important note at the end of the SCHEDULED description: note that SCHEDULED does not mean what you might normally think it means.
    – NickD
    Jul 17, 2023 at 15:33
  • I did read that note; that's why "night duty" has a plain timestamp range and the two tasks (upon which would be my duty to do at some point within a certain timeframe) are SCHEDULED. Unless there's a more "canonical" way to format such things? Jul 17, 2023 at 23:57
  • SCHEDULED tasks are meant to be done at or after the stated time. The agenda will keep reminding you until they are marked DONE. If that's what you want, then that's fine.
    – NickD
    Jul 18, 2023 at 0:33

1 Answer 1

0

The short answer is that no, this isn't possible. The reason it isn't possible is that the agenda view has to read the data from org-mode files, so the data has to be there.

Org provides a function, org-clone-subtree-with-time-shift, which you can copy multiple times with a given time shift, e.g. +1d. Obviously, it can only create regular intervals, but it can be a starting point.

For instance, I called it to make two clones at one day intervals : M-x org-clone-subtree-with-time-shift RET 2 RET +1d and I got this:

* Night Watch <2023-07-10 18:00>--<2023-07-11 09:00>
** TODO Rounds 
SCHEDULED: <2023-07-10 19:00>
** TODO Call in
SCHEDULED: <2023-07-10 22:00>
* Night Watch <2023-07-11 Tue 18:00>--<2023-07-12 Wed 09:00>
** TODO Rounds 
SCHEDULED: <2023-07-11 Tue 19:00>
** TODO Call in
SCHEDULED: <2023-07-11 Tue 22:00>
* Night Watch <2023-07-12 Wed 18:00>--<2023-07-13 Thu 09:00>
** TODO Rounds 
SCHEDULED: <2023-07-12 Wed 19:00>
** TODO Call in

Based on a somewhat cursory examination of the code, it looks like it uses this pattern to update all the relevant dates (that is, starting and ending dates of a range):

(while (re-search-forward org-ts-regexp-both nil t)
              (org-timestamp-change 1 'day))

So you could use this to write your own code.

It might be simpler, however, to just call org-clone-subtree-with-time-shift multiple times to create multiple single copies. Anything irregular is best done by a human being.

1
  • This seems like a good answer. Perhaps I could make a derivative of org-clone-subtree-with-time-shift that allows the input of an absolute date or even series of dates. It would be a good feature to have an event repeat on a given set of dates, and have children able to inherit (partial) date/time data from their parents--maybe eventually I can make a package for that. Jul 17, 2023 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.