Adam Porter <a...@alphapapa.net> writes:

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

Reply via email to