3

Is there a set of holidays.el definitions for United Kingdom holidays? I don't want to maintain the list of holidays myself. I would like to use them in org-agenda, but that's not the focus of the question.

Croad Langshan
  • 3,192
  • 14
  • 42
  • 2
    This link looks really helpful: http://www.gnomon.org.uk/diary.html – lawlist Sep 20 '18 at 23:47
  • 2
    And instead of using the diary entries to get holidays into the org-mode stuff like agenda and so forth, you may be interested in a custom solution such as this link: https://emacs.stackexchange.com/questions/10871/programmatically-add-birthdays-holidays-to-agenda-view-in-org-mode [I have not played with Org-Mode 9+.] The same/similar approach will work for calfw. – lawlist Sep 20 '18 at 23:51
  • If you don't beat me to it I'll try to turn that first link into a full answer, thanks! – Croad Langshan Sep 21 '18 at 19:50
  • Yes, that would be very helpful if you could verify the holidays in the link work as advertised and then post that as an answer for others to find. I'm glad to hear that they appear to be working for you as advertised. – lawlist Sep 22 '18 at 04:33

1 Answers1

3

This answer uses org-calendar-holiday rather than setting org-agenda-include-diary because the latter makes it slow to page through the agenda (see https://orgmode.org/manual/Weekly_002fdaily-agenda.html#index-diary-integration).

In an .org file listed in the variable org-agenda-files, add a heading (or subheading) like this:

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

In your emacs configuration, add configuration like the following (taken from Roy Badami's configuration in http://www.gnomon.org.uk/diary.html and edited slightly to trim comments and to work in emacs 26.1):

;; UK public holidays, and other UK notable dates.
(setq calendar-holidays
      '((holiday-fixed 1 1 "New Year's Day")
        (holiday-new-year-bank-holiday)
        (holiday-fixed 2 14 "Valentine's Day")
        (holiday-fixed 3 17 "St. Patrick's Day")
        (holiday-fixed 4 1 "April Fools' Day")
        (holiday-easter-etc -47 "Shrove Tuesday")
        (holiday-easter-etc -21 "Mother's Day")
        (holiday-easter-etc -2 "Good Friday")
        (holiday-easter-etc 0 "Easter Sunday")
        (holiday-easter-etc 1 "Easter Monday")
        (holiday-float 5 1 1 "Early May Bank Holiday")
        (holiday-float 5 1 -1 "Spring Bank Holiday")
        (holiday-float 6 0 3 "Father's Day")
        (holiday-float 8 1 -1 "Summer Bank Holiday")
        (holiday-fixed 10 31 "Halloween")
        (holiday-fixed 12 24 "Christmas Eve")
        (holiday-fixed 12 25 "Christmas Day")
        (holiday-fixed 12 26 "Boxing Day")
        (holiday-christmas-bank-holidays)
        (holiday-fixed 12 31 "New Year's Eve")))
;; N.B. It is assumed that 1 January is defined with holiday-fixed -
;; this function only returns any extra bank holiday that is allocated
;; (if any) to compensate for New Year's Day falling on a weekend.
;;
;; Where 1 January falls on a weekend, the following Monday is a bank
;; holiday.
(defun holiday-new-year-bank-holiday ()
  (let ((m displayed-month)
        (y displayed-year))
    (calendar-increment-month m y 1)
    (when (<= m 3)
      (let ((d (calendar-day-of-week (list 1 1 y))))
        (cond ((= d 6)
                (list (list (list 1 3 y)
                            "New Year's Day Bank Holiday")))
              ((= d 0)
                (list (list (list 1 2 y)
                            "New Year's Day Bank Holiday"))))))))

;; N.B. It is assumed that 25th and 26th are defined with holiday-fixed -
;; this function only returns any extra bank holiday(s) that are
;; allocated (if any) to compensate for Christmas Day and/or Boxing Day
;; falling on a weekend.
(defun holiday-christmas-bank-holidays ()
  (let ((m displayed-month)
        (y displayed-year))
    (calendar-increment-month m y -1)
    (when (>= m 10)
      (let ((d (calendar-day-of-week (list 12 25 y))))
        (cond ((= d 5)
                (list (list (list 12 28 y)
                            "Boxing Day Bank Holiday")))
              ((= d 6)
                (list (list (list 12 27 y)
                            "Boxing Day Bank Holiday")
                      (list (list 12 28 y)
                            "Christmas Day Bank Holiday")))
              ((= d 0)
                (list (list (list 12 27 y)
                            "Christmas Day Bank Holiday"))))))))

After you evaluate those elisp forms (for example by restarting emacs), org-agenda's calendar should show only these holidays.

Note that I opted here to suppress the machinery that builds calendar-holidays from various other variables and just set that variable directly myself. For more details about that see M-x describe-variable calendar-holidays.

Croad Langshan
  • 3,192
  • 14
  • 42