2

I have a number of "daily" tasks which repeat daily. If I forget to mark each task as DONE, it is removed from the timeline, and appears as an overdue item at the top of the agenda. For example, I forgot to turn off the hot water the last three days, so this task does not appear at its previously scheduled time (23:45), but instead appears at the top, because it's overdue.

  repeating:  Sched.3x:  TODO Turn off hot water           :daily:                                                                                
               8:00...... ----------------
              10:00...... ----------------
              12:00...... ----------------
              14:00...... ----------------
              16:00...... ----------------
              16:05...... now - - - - - - - - - - - - - - - - - - 
  repeating:  17:30-18:30 Scheduled:  TODO Go for a walk   :daily:                                                          
              18:00...... ----------------
              20:00...... ----------------

Original todo tasks (today's date is 2022-05-26):

* TODO Go for a walk :daily:
SCHEDULED: <2022-05-26 Thu 17:30-18:30 .+1d>
:PROPERTIES:
:LAST_REPEAT: [2022-05-25 Sat 18:34]
:Effort:   01:00
:END:

* TODO Turn off hot water :daily:
SCHEDULED: <2022-05-23 Mon 23:45-23:46 .+1d>
:PROPERTIES:
:LAST_REPEAT: [2022-05-22 Mon 23:37]
:Effort:   00:01
:END:

What I want is for any uncompleted daily task to be automatically rescheduled to the same time again today (23:45). I don't care if I'm overdue turning off the hot water from yesterday - I just want to remember to turn if off at the right time again today.

I've had a go at writing a method to do this:

(defun org-reset-daily ()
  "Reschedule all old tasks tagged as daily in the agenda to today"
  (interactive)
  (org-map-entries
   (org-agenda-schedule nil "+0d")
   (format-time-string "daily+SCHEDULED<\"<%Y-%m-%d>\"") 'agenda))

(add-hook 'org-agenda-mode-hook
          (lambda () (define-key org-agenda-mode-map "r" #'org-reset-daily)))

Here the string "daily+SCHEDULED<"<%Y-%m-%d>"" matches entries which are tagged as "daily" and scheduled for a time before the given date (today).

However, there are two problems:

  1. For some reason when I run it in agenda mode, it only applies to the entry at point instead of all entries which match.
  2. Rescheduling with the time delta "+0d" strips the time range from the schedule date (e.g. "23:45-23:46 ").

Any ideas on how to fix this?

4
  • Without a minimal working example with sample org-mode raw data to create a proposed solution, it is difficult to write up an answer. The org-agenda output that is extracted from the raw data (which is missing) is insufficient. There is presently no way to know for sure whether a habit entry is different than a regular entry, and whether we are dealing with deadline or scheduled, or both, and whether a time-span is mission critical.
    – lawlist
    May 26, 2022 at 4:32
  • @lawlist Apologies, have added the todo's to the question also.
    – Ishmael7
    May 26, 2022 at 7:47
  • @lawlist Is that what you were looking for, or is additional information required?
    – Ishmael7
    Jun 16, 2022 at 8:44
  • As far as I can tell, the information you have provided is now sufficient for someone to write-up an answer. It is just a matter of someone taking the initiative to tackle the problem.
    – lawlist
    Jun 16, 2022 at 16:40

1 Answer 1

0

I found an answer to another question which solves this problem using a custom agenda bulk action. The following should be added to config.el:

;; Add bulk action shortcut to reschedule task to today, while preserving schedule time
(add-to-list 'org-agenda-bulk-custom-functions '(?D (lambda () (call-interactively 'org-agenda-date-later))))

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.