10

This may have an obvious solution, which would explain why I cannot find it anywhere online, but I would like to customize the holidays that show up in my org-agenda--as easily as possible. Instead of manually entering each holiday in a diary or org mode file, I'd ideally like to draw on the "holidays.el" package. To do this I currently have the line %%(org-calendar-holiday) in an org mode file. The only problem is that I get every single holiday showing up in my agenda now, most of which are only useful in clogging up my agenda.

Is there a way to "turn off" some of these calendar lists so they don't get displayed in my agenda? I tried going the route of setting variables like holiday-solar-holidays to "nil," but that doesn't seem to affect their display in the agenda. This increases my suspicion that the holiday-xx-holidays variables are only applicable to the calendar, and not the agenda. If that's the case I'll assuredly have to go another route, and other suggestions would be welcome.

My end goal is to have major U.S. holidays and solar holidays displayed in my agenda. With so few holidays you may ask why I don't manually enter them and forget the org-calendar-holiday function and "holidays.el" library all together. Well, coding the dates of all future solstices and equinoxes doesn't sound very appealing. Plus, I like drawing on what's already been done when I can--in this case the "holidays" package. Although I could be using it in an entirely different manner than it was intended.

As a side note, I read the post entitled "Programmatically add birthdays/holidays to agenda view in org-mode", but there didn't seem to be enough detail to tell if it's the same issue I'm encountering. And interesting as the current answer in that post is, it's not the solution I'm hoping for.

Thanks for your help.

kgo
  • 532
  • 3
  • 15
  • The link you cited is the code that I wrote up a few days ago -- it does exactly what you want. You can just paste the code into your `*scratch*` buffer and type `M-x eval-buffer RET` and then type `M-x org-agenda RET` and then select `Y`. It is a fully functional working draft, but needs a little customization to make it prettier and add ability to sort alphabetically, etc. I invented it because it didn't exist. I'm sorry that I haven't wrote up any documentation yet. If you don't like it after you try it, just restart Emacs and you'll be back to where you were before you tried it. – lawlist Apr 27 '15 at 18:37
  • That's terrific. Thank you so much, @lawlist. It's interesting that nobody addressed this issue before, or at least published their patch. Thank you for your work on that code. Just to clarify, and as an example, how would I integrate your script with the `holidays.el` package (as it sounds like it can) to display `holiday-solar-holidays` holidays too? I read through the `calendar-holidays` documentation, but it's still not evident to me. This could just be my inexperience showing through! – kgo Apr 27 '15 at 21:52
  • Earlier today, I extracted the relevant code from the variable `holiday-solar-holidays` and inserted it into `org-agenda--holiday-list`. The code I extracted and added to my own example looks like this: `(solar-equinoxes-solstices) (holiday-sexp calendar-daylight-savings-starts . . .` In other words, your feature request has already been incorporated into my example. – lawlist Apr 27 '15 at 22:27
  • Ah, right. I thought it was in there somewhere. What threw, and continues to throw, me off is the absence of those solar holidays in my agenda. All of your other holidays appear (e.g., birthdays, U.S. holidays) but no sign of DST or the astronomical events. Do these holidays show up for you? Any ideas what I might be doing wrong? Everything else looks terrific. I see the `(solar-equinoxes-solstices) ...` code, so I didn't simply omit it by accident. – kgo Apr 27 '15 at 23:30
  • With a basic Emacs installation and only the code in the example, I get four (4) entries for the function `(solar-equinoxes-solstices)`: **(6 21 2015) -- holiday -- Summer Solstice 9:37am (PDT)**; **(9 23 2015) -- holiday -- Autumnal Equinox 1:20am (PDT)**; **(12 21 2015) -- holiday -- Winter Solstice 8:47pm (PST)**; and, **(3 19 2016) -- holiday -- Vernal Equinox 9:29pm (PDT)**. The function uses certain values depending upon whether or not the user has defined the following variables: `calendar-time-zone` and `calendar-standard-time-zone-name` -- e.g., UTC will be used if no time zone. – lawlist Apr 28 '15 at 04:53
  • For daylight savings, I get two (2) entries: **(11 1 2015) -- holiday -- Daylight Saving Time Ends 2:00am (PDT)**; and, **(3 13 2016) -- holiday -- Daylight Saving Time Begins 2:00am (PST)**. Perhaps you have altered my example by removing or changing something (**?**), or perhaps you have something in your *existing* configuration that is conflicting -- in which case, try it with **emacs -Q**. – lawlist Apr 28 '15 at 05:02
  • Here is a quick example of how you can test whether the function `solar-equinoxes-solstices` is doing what it should -- in a `*Scratch*` buffer, evaluate: `(let* ((displayed-month 03) (displayed-year 2005)) (require 'solar) (solar-equinoxes-solstices))` -- the result should be something like: **(((3 20 2005) "Vernal Equinox 4:33am (PST)"))** It is also possible the current version of Emacs already requires the library `solar` as part of `holidays\calendar`, and you may have an older version of Emacs that does not -- in which, case that may also resolve your issue -- i.e., `(require 'solar)` – lawlist Apr 28 '15 at 05:40
  • I did try explicitly requiring the `solar` library before, but that didn't seem to help. It turns out that there is some conflict going on somewhere. Using your advice to evaluate your script using a quick emacs initialization, all of the solar dates are present in the agenda. Now to track down the conflict .... Thanks again, @lawlist, for your code, and for all your help diagnosing my issue. Please let me know if you have the slightest where I might find this `solar` conflict. – kgo Apr 28 '15 at 13:17

2 Answers2

9

I have holidays displayed in my org-agenda; here's how I do it. Via Customize, (changing custom-set-variables) :

Turn off holidays I don't want displayed :

'(holiday-bahai-holidays nil)
'(holiday-hebrew-holidays nil)
'(holiday-islamic-holidays nil)

Tell agenda to display events from calendar diary:

'(org-agenda-include-diary t)

Result : holidays will show up in agenda. You can also create your own holidays by changing the variable holiday-other-holidays.

Jeffrey DeLeo
  • 246
  • 2
  • 5
  • Some of the holidays seem to need further effort to turn off, e.g., `(defalias 'holiday-bahai-ridvan #'ignore)`. – Joe Corneli Apr 30 '21 at 07:56
2

If you use calfw to show your calendar.

You should use

(setq cfw:display-calendar-holidays nil)

to switch for displaying holidays

as described here

azzamsa
  • 634
  • 7
  • 16
  • If `cfw:display-calendar-holidays` has a non-nil value, *calfw* displays holidays using the function `calendar-holiday-list`, which consults the variable `calendar-holidays`. A `nil` value for `cfw:display-calendar-holidays` will suppress the display of holidays. https://github.com/kiwanami/emacs-calfw/blob/master/calfw.el#L1852 As of 11/28/2017, the default value for the variable `cfw:display-calendar-holidays` is `t`. – lawlist Nov 28 '17 at 22:33