[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: time-warping - retroactively marking DONE?
From: |
Adam Spiers |
Subject: |
Re: time-warping - retroactively marking DONE? |
Date: |
Sun, 25 Jun 2023 17:03:39 +0100 |
Three years later, I finally tried this:
On Wed, 8 Jul 2020 at 05:53, Kyle Meyer <kyle@kyleam.com> wrote:
> Adam Spiers writes:
> > I'm looking for a way to retroactively mark a task as having been done
> > at a previous time/date. I know that I can just change the keyword to
> > DONE and then edit the timestamp, but this is tedious when it's a
> > repeating event, e.g.:
> [...]
>
> I'm not aware of any built-in support for this.
>
> > If this is not currently possible, would it make sense to write a
> > wrapper around `org-todo', e.g. `org-todo-timewarp' or
> > `org-retroactive-todo', which interactively prompts for a timestamp
> > before invoking `org-todo'?
>
> I think this is the easiest approach, though I'm not sure such a wrapper
> needs to live in Org proper. Here's a snippet from a recent thread [*]
> that should get you most of the way there:
>
> (defun my-org-todo-time-machine ()
> (interactive)
> (cl-letf (((symbol-function 'current-time)
> (lambda ()
> (apply #'encode-time (org-parse-time-string
> "2019-11-27 Mi 16:44")))))
> (call-interactively #'org-todo)))
>
>
> [*]
> https://orgmode.org/list/875zj42rpx.fsf@passepartout.tim-landscheidt.de/T/#u
I made it read a time interactively:
(defun as-org-todo-time-machine (arg)
(interactive "P")
(let ((fake-time
(apply #'encode-time (org-parse-time-string
(org-read-date)
))))
(cl-letf (((symbol-function 'current-time)
(lambda () fake-time)))
(call-interactively #'org-todo))))
It almost works perfectly, although monkey-patching current-time doesn't affect
the code in org-auto-repeat-maybe which sets LAST_REPEAT, since that uses
the built-in format-time-string:
(org-entry-put nil "LAST_REPEAT" (format-time-string
(org-time-stamp-format t t))))
I found that adding (current-time) as the optional time parameter fixed it:
(org-entry-put nil "LAST_REPEAT" (format-time-string
(org-time-stamp-format t t)
(current-time))))
since that allows the monkey-patching to apply there too. Is it worth
submitting
a patch for this?
- Re: time-warping - retroactively marking DONE?,
Adam Spiers <=