Kyle Meyer <k...@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 :-).

Thanks,
Tim

Reply via email to