emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turn Emacs holidays into Org appointments?


From: Richard Lawrence
Subject: Re: Turn Emacs holidays into Org appointments?
Date: Mon, 07 Feb 2022 21:41:39 +0100

Hi David and all,

David Rogers <davidandrewrogers@gmail.com> writes:

> Is there a way that I can use something like the Emacs holiday 
> forms ... but from inside an Org-mode appointment timestamp

Yes, this should be possible. 

> Here's a mock example of what I'm trying to do:
>
> * Easter
> <(holiday-easter-etc 0)>
> ** stuff for Easter
>
> * The Sunday after Easter
> <(holiday-easter-etc 7)>
> ** stuff for after Easter

Actually, you're pretty close already.

Org understands diary sexp entries in timestamps, and diary sexp entries
basically allow arbitrary elisp, so you should be able to use the diary
functions in combination with the holiday functions to do what you want.
See the 'Timestamps' entry in the Org manual, and the 'Special Diary
Entries' entry in the Emacs manual, for more.

Here is a quick and dirty proof of concept; see if it works for you:

* The Sunday after Easter
  <%%(apply #'diary-date (caar (holiday-easter-etc 7)))>

The angle brackets tell Org this is a timestamp. The '%%' says that the
following sexp is a diary sexp. And the code inside it feeds the (M D Y)
date representation returned by holiday-easter-etc into diary-date.

You may need to fiddle with this a bit...holiday-easter-etc is a bit too
closely tied to the calendar (it depends on a couple of calendar
variables, displayed-year and displayed-month, that cannot be
dynamically bound). But you could create your own version that doesn't
have this limitation. 

Hope that helps.

-- 
Best,
Richard



reply via email to

[Prev in Thread] Current Thread [Next in Thread]