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 10:43:29 -0400 [thread overview]
Message-ID: <87lgn7palq.fsf@kyleam.com> (raw)
In-Reply-To: <87fudfepqo.fsf@alphapapa.net>
Adam Porter <adam@alphapapa.net> writes:
> #+BEGIN_SRC elisp
> (defmacro with-org-today-date (date &rest body)
> "Run BODY with the `org-today' function set to return simply DATE.
> DATE should be a date-time string (both date and time must be included)."
> (declare (indent defun))
> `(let ((day (date-to-day ,date))
> (orig (symbol-function 'org-today)))
> (unwind-protect
> (progn
> (fset 'org-today (lambda () day))
> ,@body)
> (fset 'org-today orig))))
> #+END_SRC
You should be able to simplify the macro body to
`(cl-letf (((symbol-function 'org-today) (lambda () (date-to-day ,date))))
,@body)
--
Kyle
next prev parent reply other threads:[~2017-07-29 14:43 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 [this message]
2017-07-29 19:44 ` Adam Porter
2017-07-29 20:26 ` Kyle Meyer
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=87lgn7palq.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.