[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to mark task as done at specified (past) time?

From: Tim Landscheidt
Subject: Re: How to mark task as done at specified (past) time?
Date: Wed, 08 Jul 2020 20:50:00 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Kyle Meyer <kyle@kyleam.com> wrote a long time ago:

> […]

>> Do I have to cl-flet org-current-time or something similar?

> Something along those lines would probably be the most straightforward.
> Light testing with the command below suggests overriding current-time is
> sufficient:

>     (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)))

I finally got around to this and ended up with an entry in
gnus-select-article-hook à la:

| (lambda nil
|   (if
|       (and
|        (string= gnus-newsgroup-name "mail.only.this.group")
|        (string-match "^Regular expression that matches subject$"
|                      (gnus-summary-article-subject)))
|       (let
|           ((article-time
|             (gnus-date-get-time
|              (mail-header-date
|               (gnus-summary-article-header)))))
|         (cl-letf
|             (((symbol-function 'current-time)
|               (lambda nil article-time)))
|           (find-file "/path/to/file.org")
|           (goto-char
|            (org-find-entry-with-id "TASK-ID"))
|           (org-todo 'done)))))

I have an icky feeling about cl-letfing current-time because
Murphy might cause a timer to fire in just that time frame
and I have no idea what current-time is for that timer; so
if future org-mode releases would provide a cleaner API I
would very much appreciate that :-).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]