emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Turn Emacs holidays into Org appointments?
@ 2022-02-07 19:12 David Rogers
  2022-02-07 20:41 ` Richard Lawrence
  0 siblings, 1 reply; 2+ messages in thread
From: David Rogers @ 2022-02-07 19:12 UTC (permalink / raw)
  To: Org-mode list

Hello

I'm using Org-mode to organize readings and music for Christian 
church services. These services are scheduled according to certain 
holidays, and Emacs already "knows" all of the holidays that 
matter for this discussion - they're viewable by selecting the 
appropriate settings for the calendar. (The ones that don't matter 
right now are those that are simply X days or X weeks from the 
important ones.)

I don't currently view or use any of the Emacs holidays as they 
were intended, and I don't really need to.

Is there a way that I can use something like the Emacs holiday 
forms - shown at 
https://www.gnu.org/software/emacs/manual/html_node/emacs/Holiday-Customizing.html 
- but from inside an Org-mode appointment timestamp, so that I can 
use the result in my "Work2022.org" file? 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


This way, there would be less chance for error on my part, and the 
scheduling lines would stay the same from year to year, rather 
than having to look up individual dates and re-write them.

I'd prefer them to show up as appointments and schedules that I 
can modify and rearrange one by one in the scheduling lines of my 
Org files, rather than as a group of holidays that get inserted 
into the agenda from a holidays file - but maybe that just isn't 
how Emacs is set up.

I suppose if I ended up with my own extremely customized holidays 
file, and I added a link in each day's Org subtree to the 
corresponding line in the holidays file, that could be a 
workaround . . .

-- 
Thanks
David


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Turn Emacs holidays into Org appointments?
  2022-02-07 19:12 Turn Emacs holidays into Org appointments? David Rogers
@ 2022-02-07 20:41 ` Richard Lawrence
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Lawrence @ 2022-02-07 20:41 UTC (permalink / raw)
  To: David Rogers, Org-mode list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-07 20:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 19:12 Turn Emacs holidays into Org appointments? David Rogers
2022-02-07 20:41 ` Richard Lawrence

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).