Hi all, 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.: *** NEXT [#A] meditate 15 minutes every day SCHEDULED: <2020-07-06 Mon 11:30-11:50 .+1d> :PROPERTIES: :LAST_REPEAT: [2020-07-05 Sun 11:13] :ID: 142a639c-e06d-4d4b-ad1c-edcd0d9ba6ce :Effort: 0:20 :STYLE: habit :END: - State "DONE" from "NEXT" [2020-07-05 Sun 10:15] - State "DONE" from "NEXT" [2020-07-04 Sat 10:30] - State "DONE" from "NEXT" [2020-07-03 Fri 10:05] - State "DONE" from "NEXT" [2020-07-02 Thu 11:15] I forgot to mark it as done yesterday, which means that I would have to manually edit /three/ timestamps to log the correct data: 1) the SCHEDULED timestamp, 2) the :LAST_REPEAT: property, and 3) the state change history. 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'? Another possibility would be to add yet another magic prefix argument to `org-todo', but it seems that is already heavily overloaded, so it would have to be 'C-u C-u C-u C-u' which isn't particularly convenient. I can even imagine users occasionally wanting to mark stuff done in the future, e.g. if they have an activity planned for tomorrow while they're offline. So maybe using the word 'retroactive' in the wrapper function name is a bit too limiting. Cheers, Adam
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
On 2020-07-07, at 13:26, Adam Spiers <orgmode@adamspiers.org> wrote: > Hi all, > > 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 org-todo-yesterday? Hth, -- Marcin Borkowski http://mbork.pl
I emailed Adam directly with an experimental package I wrote to solve the problem of changing the todo-state of an entry at an arbitrary time. He suggested I posted here as well: https://github.com/progfolio/epoch/ The package advises current-time to return `epoch-current-time' if is set (falling back to the usual current-time if not). A macro, `epoch-with-time' is provided which allows a body to be executed with current-time set to an arbitrary time. Two commands (which I may separate into their own package), `epoch-todo' and `epoch-agenda-todo' call their respective org-mode commands. `org-read-date' is called with the tasks's SCHEDULED or DEADLINE time pre-populated so one can easily edit relative to that time. Still very much a work in progress, but the two commands are useful for me so far. Any ideas, suggestions, criticisms are appreciated.
On Wed, 8 Jul 2020 at 23:09, No Wayman <iarchivedmywholelife@gmail.com> wrote: > I emailed Adam directly with an experimental package I wrote to > solve the problem of changing the todo-state of an entry at an > arbitrary time. > He suggested I posted here as well: > > https://github.com/progfolio/epoch/ > > The package advises current-time to return `epoch-current-time' if > is set (falling back to the usual current-time if not). > A macro, `epoch-with-time' is provided which allows a body to be > executed with current-time set to an arbitrary time. > Two commands (which I may separate into their own package), > `epoch-todo' and `epoch-agenda-todo' call their respective > org-mode commands. > `org-read-date' is called with the tasks's SCHEDULED or DEADLINE > time pre-populated so one can easily edit relative to that time. > > Still very much a work in progress, but the two commands are > useful for me so far. > > Any ideas, suggestions, criticisms are appreciated. Many thanks again for this. It's working great for me! In case anyone's interested, here's my use-package config (which uses the awesome straight.el package manager to install it): https://github.com/aspiers/emacs/blob/aa62bd84b51a02cb0fc980862a63514349d253bf/.emacs.d/init.d/as-org-mode.el#L111-L116 I agree with your observation that it might be nicer to separate out the org-specific stuff into a separate package, because the epoch stuff seems useful in its own right outside org-mode.
Adam Spiers <orgmode@adamspiers.org> writes:
> Many thanks again for this. It's working great for me!
>
> In case anyone's interested, here's my use-package config (which
> uses
> the awesome straight.el package manager to install it):
>
> https://github.com/aspiers/emacs/blob/aa62bd84b51a02cb0fc980862a63514349d253bf/.emacs.d/init.d/as-org-mode.el#L111-L116
>
> I agree with your observation that it might be nicer to separate
> out
> the org-specific stuff into a separate package, because the
> epoch
> stuff seems useful in its own right outside org-mode.
Thanks for trying it out. There are still some rough edges I have
to work out, but I plan on working on it more when I get some more
free time.
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?
On Sun, 25 Jun 2023 at 17:03, Adam Spiers <orgmode@adamspiers.org> wrote: > Three years later, I finally tried this: Apologies for the noise; apparently three years is enough time for me to completely forget that I'd already found a better solution to this: https://list.orgmode.org/CAOkDyE-DwkH4_kW1q5bzHAiG1-EyxnJnt4nw_DhhYHUi12unvw@mail.gmail.com/T/#me7c7a5f2d750217c47ec27c1a4ed712a62991a9d
On 2023-06-25, at 18:03, Adam Spiers <orgmode@adamspiers.org> wrote: > 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. Not built-in, and yet another solution, but see also here: https://mbork.pl/2019-08-05_datefudge_and_agenda_testing And, of course, `org-todo-yesterday'. Best, -- Marcin Borkowski http://mbork.pl