*** empty log message ***
[emacs.git] / lisp / calendar / holidays.el
blob8f6aed27dca09ba54b38ec4f8cdc132d20e1d6e5
1 ;;; holidays.el --- holiday functions for the calendar package
3 ;;; Copyright (C) 1989, 1990 Free Software Foundation, Inc.
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
6 ;; Keywords: calendar
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY. No author or distributor
12 ;; accepts responsibility to anyone for the consequences of using it
13 ;; or for whether it serves any particular purpose or works at all,
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public
15 ;; License for full details.
17 ;; Everyone is granted permission to copy, modify and redistribute
18 ;; GNU Emacs, but only under the conditions described in the
19 ;; GNU Emacs General Public License. A copy of this license is
20 ;; supposed to have been given to you along with GNU Emacs so you
21 ;; can know your rights and responsibilities. It should be in a
22 ;; file named COPYING. Among other things, the copyright notice
23 ;; and this notice must be preserved on all copies.
25 ;;; Commentary:
27 ;; This collection of functions implements the holiday features as described
28 ;; in calendar.el.
30 ;; Comments, corrections, and improvements should be sent to
31 ;; Edward M. Reingold Department of Computer Science
32 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
33 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
34 ;; Urbana, Illinois 61801
36 ;; Technical details of all the calendrical calculations can be found in
37 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
38 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
39 ;; pages 899-928.
41 ;;; Code:
43 (require 'calendar)
45 ;;;###autoload
46 (defun holidays ()
47 "Display the holidays for last month, this month, and next month.
48 This function is suitable for execution in a .emacs file."
49 (interactive)
50 (save-excursion
51 (let* ((date (calendar-current-date))
52 (displayed-month (extract-calendar-month date))
53 (displayed-year (extract-calendar-year date)))
54 (list-calendar-holidays))))
56 (defun check-calendar-holidays (date)
57 "Check the list of holidays for any that occur on DATE.
58 The value returned is a list of strings of relevant holiday descriptions.
59 The holidays are those in the list calendar-holidays."
60 (let* ((displayed-month (extract-calendar-month date))
61 (displayed-year (extract-calendar-year date))
62 (h (calendar-holiday-list))
63 (holiday-list))
64 (while h
65 (if (calendar-date-equal date (car (car h)))
66 (setq holiday-list (append holiday-list (cdr (car h)))))
67 (setq h (cdr h)))
68 holiday-list))
70 (defun calendar-cursor-holidays ()
71 "Find holidays for the date specified by the cursor in the calendar window."
72 (interactive)
73 (message "Checking holidays...")
74 (let* ((date (or (calendar-cursor-to-date)
75 (error "Cursor is not on a date!")))
76 (date-string (calendar-date-string date))
77 (holiday-list (check-calendar-holidays date))
78 (holiday-string (mapconcat 'identity holiday-list "; "))
79 (msg (format "%s: %s" date-string holiday-string)))
80 (if (not holiday-list)
81 (message "No holidays known for %s" date-string)
82 (if (<= (length msg) (frame-width))
83 (message msg)
84 (set-buffer (get-buffer-create holiday-buffer))
85 (setq buffer-read-only nil)
86 (setq mode-line-format
87 (format "--------------------------%s%%-"
88 date-string))
89 (erase-buffer)
90 (insert (mapconcat 'identity holiday-list "\n"))
91 (goto-char (point-min))
92 (set-buffer-modified-p nil)
93 (setq buffer-read-only t)
94 (display-buffer holiday-buffer)
95 (message "Checking holidays...done")))))
97 (defun mark-calendar-holidays ()
98 "Mark notable days in the calendar window."
99 (interactive)
100 (setq mark-holidays-in-calendar t)
101 (message "Marking holidays...")
102 (let ((holiday-list (calendar-holiday-list)))
103 (while holiday-list
104 (mark-visible-calendar-date
105 (car (car holiday-list)) calendar-holiday-marker)
106 (setq holiday-list (cdr holiday-list))))
107 (message "Marking holidays...done"))
109 (defun list-calendar-holidays ()
110 "Create a buffer containing the holidays for the current calendar window.
111 The holidays are those in the list calendar-notable-days. Returns t if any
112 holidays are found, nil if not."
113 (interactive)
114 (message "Looking up holidays...")
115 (let ((holiday-list (calendar-holiday-list))
116 (m1 displayed-month)
117 (y1 displayed-year)
118 (m2 displayed-month)
119 (y2 displayed-year))
120 (if (not holiday-list)
121 (progn
122 (message "Looking up holidays...none found")
123 nil)
124 (set-buffer (get-buffer-create holiday-buffer))
125 (setq buffer-read-only nil)
126 (increment-calendar-month m1 y1 -1)
127 (increment-calendar-month m2 y2 1)
128 (setq mode-line-format
129 (format "-------------Notable Dates from %s, %d to %s, %d%%-"
130 (calendar-month-name m1) y1 (calendar-month-name m2) y2))
131 (erase-buffer)
132 (insert
133 (mapconcat
134 '(lambda (x) (concat (calendar-date-string (car x))
135 ": " (car (cdr x))))
136 holiday-list "\n"))
137 (goto-char (point-min))
138 (set-buffer-modified-p nil)
139 (setq buffer-read-only t)
140 (display-buffer holiday-buffer)
141 (message "Looking up holidays...done")
142 t)))
144 (defun calendar-holiday-list ()
145 "Form the list of holidays that occur on dates in the calendar window.
146 The holidays are those in the list calendar-holidays."
147 (let ((p calendar-holidays)
148 (holiday-list))
149 (while p
150 (let* ((function-name
151 (intern (format "calendar-holiday-function-%s" (car (car p)))))
152 (holidays
153 (if (cdr (car p));; optional arguments
154 (funcall function-name (cdr (car p)))
155 (funcall function-name))))
156 (if holidays
157 (setq holiday-list (append holidays holiday-list))))
158 (setq p (cdr p)))
159 (setq holiday-list (sort holiday-list 'calendar-date-compare))))
161 ;; Below are the functions that calculate the dates of holidays; these
162 ;; are called by the funcall in the function calendar-holiday-list. If you
163 ;; write other such functions, be sure to imitate the style used below,
164 ;; including the evaluation of each element in the list that constitutes
165 ;; the argument to the function. If you don't do this evaluation, the
166 ;; list calendar-holidays cannot contain expressions (as, for example, in
167 ;; the entry for the Islamic new year. Also remember that each function
168 ;; must return a list of items of the form ((month day year) string);
169 ;; the date (month day year) should be visible in the calendar window.
171 (defun calendar-holiday-function-fixed (x)
172 "Returns the corresponding Gregorian date, if visible in the window, to
173 month, year where month is (car X) and year is (car (cdr X)). If it is
174 visible, the value returned is the list (((month day year) string)) where
175 string is (car (nthcdr 2 X)). Returns nil if it is not visible in the
176 current calendar window."
177 (let* ((month (eval (car x)))
178 (day (eval (car (cdr x))))
179 (string (eval (car (nthcdr 2 x))))
180 (m displayed-month)
181 (y displayed-year))
182 (increment-calendar-month m y (- 11 month))
183 (if (> m 9)
184 (list (list (list month day y) string)))))
186 (defun calendar-holiday-function-float (x)
187 "Returns the corresponding Gregorian date, if visible in the window, to the
188 n-th occurrence (negative counts from the end of the month) of dayname in
189 month, year where month is (car X), year is (car (cdr X)), n is
190 \(car \(nthcdr 2 X\)\). If it is visible, the value returned is the list
191 \(\(\(month day year)\ string\)\) where string is (car (nthcdr 3 X)).
192 Returns nil if it is not visible in the current calendar window."
193 (let* ((month (eval (car x)))
194 (dayname (eval (car (cdr x))))
195 (n (eval (car (nthcdr 2 x))))
196 (string (eval (car (nthcdr 3 x))))
197 (m displayed-month)
198 (y displayed-year))
199 (increment-calendar-month m y (- 11 month))
200 (if (> m 9)
201 (list (list (calendar-nth-named-day n dayname month y) string)))))
203 (defun calendar-holiday-function-julian (x)
204 "Returns the corresponding Gregorian date, if visible in the window, to the
205 Julian date month, year where month is (car X) and year is (car (cdr X)).
206 If it is visible, the value returned is the list (((month day year) string))
207 where string is (car (nthcdr 2 X)). Returns nil if it is not visible in the
208 current calendar window."
209 (let* ((month (eval (car x)))
210 (day (eval (car (cdr x))))
211 (string (eval (car (nthcdr 2 x))))
212 (m1 displayed-month)
213 (y1 displayed-year)
214 (m2 displayed-month)
215 (y2 displayed-year)
216 (year))
217 (increment-calendar-month m1 y1 -1)
218 (increment-calendar-month m2 y2 1)
219 (let* ((start-date (calendar-absolute-from-gregorian
220 (list m1 1 y1)))
221 (end-date (calendar-absolute-from-gregorian
222 (list m2 (calendar-last-day-of-month m2 y2) y2)))
223 (julian-start (calendar-julian-from-absolute start-date))
224 (julian-end (calendar-julian-from-absolute end-date))
225 (julian-y1 (extract-calendar-year julian-start))
226 (julian-y2 (extract-calendar-year julian-end)))
227 (setq year (if (< 10 month) julian-y1 julian-y2))
228 (let ((date (calendar-gregorian-from-absolute
229 (calendar-absolute-from-julian
230 (list month day year)))))
231 (if (calendar-date-is-visible-p date)
232 (list (list date string)))))))
234 (defun calendar-holiday-function-islamic (x)
235 "Returns the corresponding Gregorian date, if visible in the window, to the
236 Islamic date month, day where month is (car X) and day is (car (cdr X)).
237 If it is visible, the value returned is the list (((month day year) string))
238 where string is (car (nthcdr 2 X)). Returns nil if it is not visible in
239 the current calendar window."
240 (let* ((month (eval (car x)))
241 (day (eval (car (cdr x))))
242 (string (eval (car (nthcdr 2 x))))
243 (islamic-date (calendar-islamic-from-absolute
244 (calendar-absolute-from-gregorian
245 (list displayed-month 15 displayed-year))))
246 (m (extract-calendar-month islamic-date))
247 (y (extract-calendar-year islamic-date))
248 (date))
249 (if (< m 1)
250 nil;; Islamic calendar doesn't apply.
251 (increment-calendar-month m y (- 10 month))
252 (if (> m 7);; Islamic date might be visible
253 (let ((date (calendar-gregorian-from-absolute
254 (calendar-absolute-from-islamic (list month day y)))))
255 (if (calendar-date-is-visible-p date)
256 (list (list date string))))))))
258 (defun calendar-holiday-function-hebrew (x)
259 "Returns the corresponding Gregorian date, if visible in the window, to the
260 Hebrew date month, day where month is (car X) and day is (car (cdr X)).
261 If it is visible, the value returned is the list (((month day year) string))
262 where string is (car (nthcdr 2 X)). Returns nil if it is not visible in
263 the current calendar window."
264 (let* ((month (eval (car x)))
265 (day (eval (car (cdr x))))
266 (string (eval (car (nthcdr 2 x)))))
267 (if (memq displayed-month;; This test is only to speed things up a bit;
268 (list ;; it works fine without the test too.
269 (if (< 11 month) (- month 11) (+ month 1))
270 (if (< 10 month) (- month 10) (+ month 2))
271 (if (< 9 month) (- month 9) (+ month 3))
272 (if (< 8 month) (- month 8) (+ month 4))
273 (if (< 7 month) (- month 7) (+ month 5))))
274 (let ((m1 displayed-month)
275 (y1 displayed-year)
276 (m2 displayed-month)
277 (y2 displayed-year)
278 (year))
279 (increment-calendar-month m1 y1 -1)
280 (increment-calendar-month m2 y2 1)
281 (let* ((start-date (calendar-absolute-from-gregorian
282 (list m1 1 y1)))
283 (end-date (calendar-absolute-from-gregorian
284 (list m2 (calendar-last-day-of-month m2 y2) y2)))
285 (hebrew-start (calendar-hebrew-from-absolute start-date))
286 (hebrew-end (calendar-hebrew-from-absolute end-date))
287 (hebrew-y1 (extract-calendar-year hebrew-start))
288 (hebrew-y2 (extract-calendar-year hebrew-end)))
289 (setq year (if (< 6 month) hebrew-y2 hebrew-y1))
290 (let ((date (calendar-gregorian-from-absolute
291 (calendar-absolute-from-hebrew
292 (list month day year)))))
293 (if (calendar-date-is-visible-p date)
294 (list (list date string)))))))))
296 (defun calendar-holiday-function-if (x)
297 "Conditional holiday for dates in the calendar window.
298 The boolean condition is (car X). If t, the holiday (car (cdr X)) is
299 checked. If nil, the holiday (car (cdr (cdr X))), if there, is checked."
300 (let* ((boolean (eval (car x)))
301 (h (if boolean (car (cdr x)) (car (cdr (cdr x))))))
302 (if h
303 (let* ((function-name
304 (intern (format "calendar-holiday-function-%s" (car h))))
305 (holidays
306 (if (cdr h);; optional arguments
307 (funcall function-name (cdr h))
308 (funcall function-name))))
309 holidays))))
311 (defun calendar-holiday-function-advent ()
312 "Date of Advent, if visible in calendar window."
313 (let ((year displayed-year)
314 (month displayed-month))
315 (increment-calendar-month month year -1)
316 (let ((advent (calendar-gregorian-from-absolute
317 (calendar-dayname-on-or-before 0
318 (calendar-absolute-from-gregorian
319 (list 12 3 year))))))
320 (if (calendar-date-is-visible-p advent)
321 (list (list advent "Advent"))))))
323 (defun calendar-holiday-function-easter-etc ()
324 "List of dates related to Easter, as visible in calendar window."
325 (if (and (> displayed-month 5) (not all-christian-calendar-holidays))
326 nil;; Ash Wednesday, Good Friday, and Easter are not visible.
327 (let* ((century (1+ (/ displayed-year 100)))
328 (shifted-epact ;; Age of moon for April 5...
329 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule
330 (- ;; ...corrected for the Gregorian century rule
331 (/ (* 3 century) 4))
332 (/ ;; ...corrected for Metonic cycle inaccuracy.
333 (+ 5 (* 8 century)) 25)
334 (* 30 century));; Keeps value positive.
335 30))
336 (adjusted-epact ;; Adjust for 29.5 day month.
337 (if (or (= shifted-epact 0)
338 (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
339 (1+ shifted-epact)
340 shifted-epact))
341 (paschal-moon ;; Day after the full moon on or after March 21.
342 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
343 adjusted-epact))
344 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
345 (mandatory
346 (list
347 (list (calendar-gregorian-from-absolute abs-easter)
348 "Easter Sunday")
349 (list (calendar-gregorian-from-absolute (- abs-easter 2))
350 "Good Friday")
351 (list (calendar-gregorian-from-absolute (- abs-easter 46))
352 "Ash Wednesday")))
353 (optional
354 (list
355 (list (calendar-gregorian-from-absolute (- abs-easter 63))
356 "Septuagesima Sunday")
357 (list (calendar-gregorian-from-absolute (- abs-easter 56))
358 "Sexagesima Sunday")
359 (list (calendar-gregorian-from-absolute (- abs-easter 49))
360 "Shrove Sunday")
361 (list (calendar-gregorian-from-absolute (- abs-easter 48))
362 "Shrove Monday")
363 (list (calendar-gregorian-from-absolute (- abs-easter 47))
364 "Shrove Tuesday")
365 (list (calendar-gregorian-from-absolute (- abs-easter 14))
366 "Passion Sunday")
367 (list (calendar-gregorian-from-absolute (- abs-easter 7))
368 "Palm Sunday")
369 (list (calendar-gregorian-from-absolute (- abs-easter 3))
370 "Maundy Thursday")
371 (list (calendar-gregorian-from-absolute (+ abs-easter 35))
372 "Rogation Sunday")
373 (list (calendar-gregorian-from-absolute (+ abs-easter 39))
374 "Ascension Sunday")
375 (list (calendar-gregorian-from-absolute (+ abs-easter 49))
376 "Pentecost (Whitsunday)")
377 (list (calendar-gregorian-from-absolute (+ abs-easter 50))
378 "Whitmunday")
379 (list (calendar-gregorian-from-absolute (+ abs-easter 56))
380 "Trinity Sunday")
381 (list (calendar-gregorian-from-absolute (+ abs-easter 60))
382 "Corpus Christi")))
383 (output-list
384 (filter-visible-calendar-holidays mandatory)))
385 (if all-christian-calendar-holidays
386 (setq output-list
387 (append
388 (filter-visible-calendar-holidays optional)
389 output-list)))
390 output-list)))
392 (defun calendar-holiday-function-rosh-hashanah-etc ()
393 "List of dates related to Rosh Hashanah, as visible in calendar window."
394 (if (or (< displayed-month 8)
395 (> displayed-month 11))
396 nil;; None of the dates is visible
397 (let* ((abs-r-h (calendar-absolute-from-hebrew
398 (list 7 1 (+ displayed-year 3761))))
399 (mandatory
400 (list
401 (list (calendar-gregorian-from-absolute abs-r-h)
402 (format "Rosh HaShanah %d" (+ 3761 displayed-year)))
403 (list (calendar-gregorian-from-absolute (+ abs-r-h 9))
404 "Yom Kippur")
405 (list (calendar-gregorian-from-absolute (+ abs-r-h 14))
406 "Sukkot")
407 (list (calendar-gregorian-from-absolute (+ abs-r-h 21))
408 "Shemini Atzeret")
409 (list (calendar-gregorian-from-absolute (+ abs-r-h 22))
410 "Simchat Torah")))
411 (optional
412 (list
413 (list (calendar-gregorian-from-absolute
414 (calendar-dayname-on-or-before 6 (- abs-r-h 4)))
415 "Selichot (night)")
416 (list (calendar-gregorian-from-absolute (1- abs-r-h))
417 "Erev Rosh HaShannah")
418 (list (calendar-gregorian-from-absolute (1+ abs-r-h))
419 "Rosh HaShanah (second day)")
420 (list (calendar-gregorian-from-absolute
421 (if (= (% abs-r-h 7) 4) (+ abs-r-h 3) (+ abs-r-h 2)))
422 "Tzom Gedaliah")
423 (list (calendar-gregorian-from-absolute
424 (calendar-dayname-on-or-before 6 (+ 7 abs-r-h)))
425 "Shabbat Shuvah")
426 (list (calendar-gregorian-from-absolute (+ abs-r-h 8))
427 "Erev Yom Kippur")
428 (list (calendar-gregorian-from-absolute (+ abs-r-h 13))
429 "Erev Sukkot")
430 (list (calendar-gregorian-from-absolute (+ abs-r-h 15))
431 "Sukkot (second day)")
432 (list (calendar-gregorian-from-absolute (+ abs-r-h 16))
433 "Hol Hamoed Sukkot (first day)")
434 (list (calendar-gregorian-from-absolute (+ abs-r-h 17))
435 "Hol Hamoed Sukkot (second day)")
436 (list (calendar-gregorian-from-absolute (+ abs-r-h 18))
437 "Hol Hamoed Sukkot (third day)")
438 (list (calendar-gregorian-from-absolute (+ abs-r-h 19))
439 "Hol Hamoed Sukkot (fourth day)")
440 (list (calendar-gregorian-from-absolute (+ abs-r-h 20))
441 "Hoshannah Rabbah")))
442 (output-list
443 (filter-visible-calendar-holidays mandatory)))
444 (if all-hebrew-calendar-holidays
445 (setq output-list
446 (append
447 (filter-visible-calendar-holidays optional)
448 output-list)))
449 output-list)))
451 (defun calendar-holiday-function-hanukkah ()
452 "List of dates related to Hanukkah, as visible in calendar window."
453 (if (memq displayed-month;; This test is only to speed things up a bit;
454 '(10 11 12 1 2));; it works fine without the test too.
455 (let ((m displayed-month)
456 (y displayed-year))
457 (increment-calendar-month m y 1)
458 (let* ((h-y (extract-calendar-year
459 (calendar-hebrew-from-absolute
460 (calendar-absolute-from-gregorian
461 (list m (calendar-last-day-of-month m y) y)))))
462 (abs-h (calendar-absolute-from-hebrew (list 9 25 h-y))))
463 (filter-visible-calendar-holidays
464 (list
465 (list (calendar-gregorian-from-absolute (1- abs-h))
466 "Erev Hanukkah")
467 (list (calendar-gregorian-from-absolute abs-h)
468 "Hanukkah (first day)")
469 (list (calendar-gregorian-from-absolute (1+ abs-h))
470 "Hanukkah (second day)")
471 (list (calendar-gregorian-from-absolute (+ abs-h 2))
472 "Hanukkah (third day)")
473 (list (calendar-gregorian-from-absolute (+ abs-h 3))
474 "Hanukkah (fourth day)")
475 (list (calendar-gregorian-from-absolute (+ abs-h 4))
476 "Hanukkah (fifth day)")
477 (list (calendar-gregorian-from-absolute (+ abs-h 5))
478 "Hanukkah (sixth day)")
479 (list (calendar-gregorian-from-absolute (+ abs-h 6))
480 "Hanukkah (seventh day)")
481 (list (calendar-gregorian-from-absolute (+ abs-h 7))
482 "Hanukkah (eighth day)")))))))
484 (defun calendar-holiday-function-passover-etc ()
485 "List of dates related to Passover, as visible in calendar window."
486 (if (< 7 displayed-month)
487 nil;; None of the dates is visible
488 (let* ((abs-p (calendar-absolute-from-hebrew
489 (list 1 15 (+ displayed-year 3760))))
490 (mandatory
491 (list
492 (list (calendar-gregorian-from-absolute abs-p)
493 "Passover")
494 (list (calendar-gregorian-from-absolute (+ abs-p 50))
495 "Shavuot")))
496 (optional
497 (list
498 (list (calendar-gregorian-from-absolute
499 (calendar-dayname-on-or-before 6 (- abs-p 43)))
500 "Shabbat Shekalim")
501 (list (calendar-gregorian-from-absolute
502 (calendar-dayname-on-or-before 6 (- abs-p 30)))
503 "Shabbat Zachor")
504 (list (calendar-gregorian-from-absolute
505 (if (= (% abs-p 7) 2) (- abs-p 33) (- abs-p 31)))
506 "Fast of Esther")
507 (list (calendar-gregorian-from-absolute (- abs-p 31))
508 "Erev Purim")
509 (list (calendar-gregorian-from-absolute (- abs-p 30))
510 "Purim")
511 (list (calendar-gregorian-from-absolute
512 (if (zerop (% abs-p 7)) (- abs-p 28) (- abs-p 29)))
513 "Shushan Purim")
514 (list (calendar-gregorian-from-absolute
515 (- (calendar-dayname-on-or-before 6 (- abs-p 14)) 7))
516 "Shabbat Parah")
517 (list (calendar-gregorian-from-absolute
518 (calendar-dayname-on-or-before 6 (- abs-p 14)))
519 "Shabbat HaHodesh")
520 (list (calendar-gregorian-from-absolute
521 (calendar-dayname-on-or-before 6 (1- abs-p)))
522 "Shabbat HaGadol")
523 (list (calendar-gregorian-from-absolute (1- abs-p))
524 "Erev Passover")
525 (list (calendar-gregorian-from-absolute (1+ abs-p))
526 "Passover (second day)")
527 (list (calendar-gregorian-from-absolute (+ abs-p 2))
528 "Hol Hamoed Passover (first day)")
529 (list (calendar-gregorian-from-absolute (+ abs-p 3))
530 "Hol Hamoed Passover (second day)")
531 (list (calendar-gregorian-from-absolute (+ abs-p 4))
532 "Hol Hamoed Passover (third day)")
533 (list (calendar-gregorian-from-absolute (+ abs-p 5))
534 "Hol Hamoed Passover (fourth day)")
535 (list (calendar-gregorian-from-absolute (+ abs-p 6))
536 "Passover (seventh day)")
537 (list (calendar-gregorian-from-absolute (+ abs-p 7))
538 "Passover (eighth day)")
539 (list (calendar-gregorian-from-absolute (+ abs-p 12))
540 "Yom HaShoah")
541 (list (calendar-gregorian-from-absolute
542 (if (zerop (% abs-p 7))
543 (+ abs-p 18)
544 (if (= (% abs-p 7) 6)
545 (+ abs-p 19)
546 (+ abs-p 20))))
547 "Yom HaAtzma'ut")
548 (list (calendar-gregorian-from-absolute (+ abs-p 33))
549 "Lag BaOmer")
550 (list (calendar-gregorian-from-absolute (+ abs-p 43))
551 "Yom Yerushalim")
552 (list (calendar-gregorian-from-absolute (+ abs-p 49))
553 "Erev Shavuot")
554 (list (calendar-gregorian-from-absolute (+ abs-p 51))
555 "Shavuot (second day)")))
556 (output-list
557 (filter-visible-calendar-holidays mandatory)))
558 (if all-hebrew-calendar-holidays
559 (setq output-list
560 (append
561 (filter-visible-calendar-holidays optional)
562 output-list)))
563 output-list)))
565 (defun calendar-holiday-function-tisha-b-av-etc ()
566 "List of dates around Tisha B'Av, as visible in calendar window."
567 (if (or (< displayed-month 5)
568 (> displayed-month 9))
569 nil;; None of the dates is visible
570 (let* ((abs-t-a (calendar-absolute-from-hebrew
571 (list 5 9 (+ displayed-year 3760)))))
573 (filter-visible-calendar-holidays
574 (list
575 (list (calendar-gregorian-from-absolute
576 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21)))
577 "Tzom Tammuz")
578 (list (calendar-gregorian-from-absolute
579 (calendar-dayname-on-or-before 6 abs-t-a))
580 "Shabbat Hazon")
581 (list (calendar-gregorian-from-absolute
582 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a))
583 "Tisha B'Av")
584 (list (calendar-gregorian-from-absolute
585 (calendar-dayname-on-or-before 6 (+ abs-t-a 7)))
586 "Shabbat Nahamu"))))))
588 (defun filter-visible-calendar-holidays (l)
589 "Return a list of all visible holidays of those on L."
590 (let ((visible)
591 (p l))
592 (while p
593 (if (calendar-date-is-visible-p (car (car p)))
594 (setq visible (append (list (car p)) visible)))
595 (setq p (cdr p)))
596 visible))
598 (provide 'holidays)
600 ;;; holidays.el ends here