[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] FYI: with-org-today-date macro, helps with testing
From: |
Kyle Meyer |
Subject: |
Re: [O] FYI: with-org-today-date macro, helps with testing |
Date: |
Sat, 29 Jul 2017 16:26:23 -0400 |
Adam Porter <address@hidden> writes:
> Kyle Meyer <address@hidden> 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