From: Kyle Meyer <kyle@kyleam.com>
To: Adam Porter <adam@alphapapa.net>, emacs-orgmode@gnu.org
Subject: Re: FYI: with-org-today-date macro, helps with testing
Date: Sat, 29 Jul 2017 16:26:23 -0400 [thread overview]
Message-ID: <87inibouq8.fsf@kyleam.com> (raw)
In-Reply-To: <877eyrvxhr.fsf@alphapapa.net>
Adam Porter <adam@alphapapa.net> writes:
> Kyle Meyer <kyle@kyleam.com> writes:
[...]
>> You should be able to simplify the macro body to
>>
>> `(cl-letf (((symbol-function 'org-today) (lambda () (date-to-day ,date))))
>> ,@body)
>
> Hi Kyle,
>
> I tried that, but it didn't work, so I had to come up with this uglier
> one. I couldn't figure out why, but with cl-letf, the redefined
> function didn't seem to persist deeper in the tree of function calls,
> only to the first level. Maybe I did something wrong, but all I know
> now is that at least this works. :)
On my end,
(defmacro with-org-today-date (date &rest body)
`(cl-letf (((symbol-function 'org-today) (lambda () (date-to-day ,date))))
,@body))
(with-org-today-date "2017-07-05 00:00"
(let ((org-agenda-files (list "~/test.org"))
(org-agenda-span 'day))
(org-agenda-list nil)))
produces the same result as your original macro.
--
Kyle
next prev parent reply other threads:[~2017-07-29 20:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-29 6:11 FYI: with-org-today-date macro, helps with testing Adam Porter
2017-07-29 14:43 ` Kyle Meyer
2017-07-29 19:44 ` Adam Porter
2017-07-29 20:26 ` Kyle Meyer [this message]
2017-07-29 23:03 ` Adam Porter
2018-10-23 20:56 ` Samuel Wales
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87inibouq8.fsf@kyleam.com \
--to=kyle@kyleam.com \
--cc=adam@alphapapa.net \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.