emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: How to mark task as done at specified (past) time?
Date: Wed, 08 Jul 2020 20:50:00 +0000	[thread overview]
Message-ID: <87366168av.fsf@passepartout.tim-landscheidt.de> (raw)
In-Reply-To: <877e32ql4w.fsf@kyleam.com> (Kyle Meyer's message of "Thu, 12 Dec 2019 03:26:55 +0000")

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 :-).

Thanks,
Tim


  reply	other threads:[~2020-07-08 20:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 10:57 How to mark task as done at specified (past) time? Tim Landscheidt
2019-12-12  3:26 ` Kyle Meyer
2020-07-08 20:50   ` Tim Landscheidt [this message]
2020-07-09  2:56     ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87366168av.fsf@passepartout.tim-landscheidt.de \
    --to=tim@tim-landscheidt.de \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).