Putting Holidays On The Calendar

So we have just tweaked my Emacs calendar a bit for better integration with Org Mode, but to make planning and scheduling easier, I want the local, Japanese holidays as well as the corporate ones to be shown and stand out. Both in the calendar as well as agenda views.

Japanese Holidays

Good thing that Takashi Hattori wrote japanese-holidays.el a while ago. That saves us the trouble. This little Emacs add-on is now kept up to date at GitHub. It doesn't change often but I keep up with this repository via mr with a stanza in my vcsh pim module and just add the checked out location to my load-path.

(add-to-list 'load-path "~/.emacs.d/lib/japanese-holidays" t)

Unlike the recommendations in the upstream README, I prefer to initialize the local holidays with the Japanese ones because, well, they are local for me.

(require 'japanese-holidays)
(setq holiday-local-holidays japanese-holidays)

Corporate And Other Holidays

I use the holiday-other-holidays variable to define company and other holidays in a separate file. These are mostly related to the Obon (お盆) and Year's End and New Year's (年末年始) periods but you could also add your days off there is so inclined.

(load "~/.emacs.d/other-holidays.el" t t t t)

While the recurring holidays can just use a holiday-fixed entry, one-off holidays should be added to holiday-filter-visible-calendar. This gives something like:

(setq holiday-other-holidays
      '((holiday-fixed 12 31 "大晦日")
        (holiday-filter-visible-calendar
         '(((12 30 2016) "会社休日")
           (( 1  3 2017) "会社休日")))))

Putting Things Together

Now we are ready to define the total list of calendar-holidays. At the same time, we tweak a few look-and-feel variables. These result in Sundays getting marked as holidays and Saturdays as something that can be thought of as a semi-holiday. Not everyone lives with the luxury of a five day workweek.

(setq calendar-holidays
      (append holiday-local-holidays holiday-other-holidays))

(setq mark-holidays-in-calendar t
      japanese-holiday-weekend '(0 6)
      japanese-holiday-weekend-marker
      '(holiday nil nil nil nil nil japanese-holiday-saturday))

(add-hook 'calendar-today-visible-hook 'calendar-mark-today)
(add-hook 'calendar-today-visible-hook 'japanese-holiday-mark-weekend)
(add-hook 'calendar-today-invisible-hook 'japanese-holiday-mark-weekend)

Finally, to make Org Mode aware of all the holidays as well, just put a headline with content like below in one of your agenda files.

* Holidays
  :PROPERTIES:
  :CATEGORY: holiday
  :END:
  #%%(org-calendar-holiday)