1;;; holidays.el --- holiday functions for the calendar package 2 3;;; Copyright (C) 1989, 1990, 1992, 1993, 1994 Free Software Foundation, Inc. 4 5;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> 6;; Keywords: holidays, calendar 7 8;; This file is part of GNU Emacs. 9 10;; GNU Emacs is free software; you can redistribute it and/or modify 11;; it under the terms of the GNU General Public License as published by 12;; the Free Software Foundation; either version 2, or (at your option) 13;; any later version. 14 15;; GNU Emacs is distributed in the hope that it will be useful, 16;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18;; GNU General Public License for more details. 19 20;; You should have received a copy of the GNU General Public License 21;; along with GNU Emacs; see the file COPYING. If not, write to 22;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 24;;; Commentary: 25 26;; This collection of functions implements the holiday features as described 27;; in calendar.el. 28 29;; Comments, corrections, and improvements should be sent to 30;; Edward M. Reingold Department of Computer Science 31;; (217) 333-6733 University of Illinois at Urbana-Champaign 32;; reingold@cs.uiuc.edu 1304 West Springfield Avenue 33;; Urbana, Illinois 61801 34 35;; Technical details of all the calendrical calculations can be found in 36;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, 37;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990), 38;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical 39;; Calendars'' by E. M. Reingold, N. Dershowitz, and S. M. Clamen, 40;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), 41;; pages 383-404. 42 43;; Hard copies of these two papers can be obtained by sending email to 44;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and 45;; the message BODY containing your mailing address (snail). 46 47;;; Code: 48 49(require 'calendar) 50 51(autoload 'solar-equinoxes-solstices "solar" 52 "Date and time of equinoxes and solstices, if visible in the calendar window. 53Requires floating point." 54 t) 55 56(defun holidays (&optional arg) 57 "Display the holidays for last month, this month, and next month. 58If called with an optional prefix argument, prompts for month and year. 59 60This function is suitable for execution in a .emacs file." 61 (interactive "P") 62 (save-excursion 63 (let* ((completion-ignore-case t) 64 (date (calendar-current-date)) 65 (displayed-month 66 (if arg 67 (cdr (assoc 68 (capitalize 69 (completing-read 70 "Month name: " 71 (mapcar 'list (append calendar-month-name-array nil)) 72 nil t)) 73 (calendar-make-alist calendar-month-name-array))) 74 (extract-calendar-month date))) 75 (displayed-year 76 (if arg 77 (calendar-read 78 "Year (>0): " 79 '(lambda (x) (> x 0)) 80 (int-to-string 81 (extract-calendar-year (calendar-current-date)))) 82 (extract-calendar-year date)))) 83 (list-calendar-holidays)))) 84 85(defun check-calendar-holidays (date) 86 "Check the list of holidays for any that occur on DATE. 87The value returned is a list of strings of relevant holiday descriptions. 88The holidays are those in the list calendar-holidays." 89 (let* ((displayed-month (extract-calendar-month date)) 90 (displayed-year (extract-calendar-year date)) 91 (h (calendar-holiday-list)) 92 (holiday-list)) 93 (while h 94 (if (calendar-date-equal date (car (car h))) 95 (setq holiday-list (append holiday-list (cdr (car h))))) 96 (setq h (cdr h))) 97 holiday-list)) 98 99(defun calendar-cursor-holidays () 100 "Find holidays for the date specified by the cursor in the calendar window." 101 (interactive) 102 (message "Checking holidays...") 103 (let* ((date (calendar-cursor-to-date t)) 104 (date-string (calendar-date-string date)) 105 (holiday-list (check-calendar-holidays date)) 106 (holiday-string (mapconcat 'identity holiday-list "; ")) 107 (msg (format "%s: %s" date-string holiday-string))) 108 (if (not holiday-list) 109 (message "No holidays known for %s" date-string) 110 (if (<= (length msg) (frame-width)) 111 (message msg) 112 (set-buffer (get-buffer-create holiday-buffer)) 113 (setq buffer-read-only nil) 114 (calendar-set-mode-line date-string) 115 (erase-buffer) 116 (insert (mapconcat 'identity holiday-list "\n")) 117 (goto-char (point-min)) 118 (set-buffer-modified-p nil) 119 (setq buffer-read-only t) 120 (display-buffer holiday-buffer) 121 (message "Checking holidays...done"))))) 122 123(defun mark-calendar-holidays () 124 "Mark notable days in the calendar window." 125 (interactive) 126 (setq mark-holidays-in-calendar t) 127 (message "Marking holidays...") 128 (let ((holiday-list (calendar-holiday-list))) 129 (while holiday-list 130 (mark-visible-calendar-date 131 (car (car holiday-list)) calendar-holiday-marker) 132 (setq holiday-list (cdr holiday-list)))) 133 (message "Marking holidays...done")) 134 135(defun list-calendar-holidays () 136 "Create a buffer containing the holidays for the current calendar window. 137The holidays are those in the list calendar-notable-days. Returns t if any 138holidays are found, nil if not." 139 (interactive) 140 (message "Looking up holidays...") 141 (let ((holiday-list (calendar-holiday-list)) 142 (m1 displayed-month) 143 (y1 displayed-year) 144 (m2 displayed-month) 145 (y2 displayed-year)) 146 (if (not holiday-list) 147 (progn 148 (message "Looking up holidays...none found") 149 nil) 150 (set-buffer (get-buffer-create holiday-buffer)) 151 (setq buffer-read-only nil) 152 (increment-calendar-month m1 y1 -1) 153 (increment-calendar-month m2 y2 1) 154 (calendar-set-mode-line 155 (if (= y1 y2) 156 (format "Notable Dates from %s to %s, %d%%-" 157 (calendar-month-name m1) (calendar-month-name m2) y2) 158 (format "Notable Dates from %s, %d to %s, %d%%-" 159 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) 160 (erase-buffer) 161 (insert 162 (mapconcat 163 '(lambda (x) (concat (calendar-date-string (car x)) 164 ": " (car (cdr x)))) 165 holiday-list "\n")) 166 (goto-char (point-min)) 167 (set-buffer-modified-p nil) 168 (setq buffer-read-only t) 169 (display-buffer holiday-buffer) 170 (message "Looking up holidays...done") 171 t))) 172 173(defun calendar-holiday-list () 174 "Form the list of holidays that occur on dates in the calendar window. 175The holidays are those in the list calendar-holidays." 176 (let ((p calendar-holidays) 177 (holiday-list)) 178 (while p 179 (let* ((holidays 180 (if calendar-debug-sexp 181 (let ((stack-trace-on-error t)) 182 (eval (car p))) 183 (condition-case nil 184 (eval (car p)) 185 (error (beep) 186 (message "Bad holiday list item: %s" (car p)) 187 (sleep-for 2)))))) 188 (if holidays 189 (setq holiday-list (append holidays holiday-list)))) 190 (setq p (cdr p))) 191 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) 192 193;; Below are the functions that calculate the dates of holidays; these 194;; are eval'ed in the function calendar-holiday-list. If you 195;; write other such functions, be sure to imitate the style used below. 196;; Remember that each function must return a list of items of the form 197;; ((month day year) string) of VISIBLE dates in the calendar window. 198 199(defun holiday-fixed (month day string) 200 "Holiday on MONTH, DAY (Gregorian) called STRING. 201If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year) 202STRING)). Returns nil if it is not visible in the current calendar window." 203 (let ((m displayed-month) 204 (y displayed-year)) 205 (increment-calendar-month m y (- 11 month)) 206 (if (> m 9) 207 (list (list (list month day y) string))))) 208 209(defun holiday-float (month dayname n string &optional day) 210 "Holiday on MONTH, DAYNAME (Nth occurrence, Gregorian) called STRING. 211If the Nth DAYNAME in MONTH is visible, the value returned is the list 212\(((MONTH DAY year) STRING)). 213 214If N<0, count backward from the end of MONTH. 215 216An optional parameter DAY means the Nth DAYNAME after/before MONTH DAY. 217 218Returns nil if it is not visible in the current calendar window." 219 (let ((m displayed-month) 220 (y displayed-year)) 221 (increment-calendar-month m y (- 11 month)) 222 (if (> m 9) 223 (list (list (calendar-nth-named-day n dayname month y day) string))))) 224 225(defun holiday-julian (month day string) 226 "Holiday on MONTH, DAY (Julian) called STRING. 227If MONTH, DAY (Julian) is visible, the value returned is corresponding 228Gregorian date in the form of the list (((month day year) STRING)). Returns 229nil if it is not visible in the current calendar window." 230 (let ((m1 displayed-month) 231 (y1 displayed-year) 232 (m2 displayed-month) 233 (y2 displayed-year) 234 (year)) 235 (increment-calendar-month m1 y1 -1) 236 (increment-calendar-month m2 y2 1) 237 (let* ((start-date (calendar-absolute-from-gregorian 238 (list m1 1 y1))) 239 (end-date (calendar-absolute-from-gregorian 240 (list m2 (calendar-last-day-of-month m2 y2) y2))) 241 (julian-start (calendar-julian-from-absolute start-date)) 242 (julian-end (calendar-julian-from-absolute end-date)) 243 (julian-y1 (extract-calendar-year julian-start)) 244 (julian-y2 (extract-calendar-year julian-end))) 245 (setq year (if (< 10 month) julian-y1 julian-y2)) 246 (let ((date (calendar-gregorian-from-absolute 247 (calendar-absolute-from-julian 248 (list month day year))))) 249 (if (calendar-date-is-visible-p date) 250 (list (list date string))))))) 251 252(defun holiday-islamic (month day string) 253 "Holiday on MONTH, DAY (Islamic) called STRING. 254If MONTH, DAY (Islamic) is visible, the value returned is corresponding 255Gregorian date in the form of the list (((month day year) STRING)). Returns 256nil if it is not visible in the current calendar window." 257 (let* ((islamic-date (calendar-islamic-from-absolute 258 (calendar-absolute-from-gregorian 259 (list displayed-month 15 displayed-year)))) 260 (m (extract-calendar-month islamic-date)) 261 (y (extract-calendar-year islamic-date)) 262 (date)) 263 (if (< m 1) 264 nil;; Islamic calendar doesn't apply. 265 (increment-calendar-month m y (- 10 month)) 266 (if (> m 7);; Islamic date might be visible 267 (let ((date (calendar-gregorian-from-absolute 268 (calendar-absolute-from-islamic (list month day y))))) 269 (if (calendar-date-is-visible-p date) 270 (list (list date string)))))))) 271 272(defun holiday-hebrew (month day string) 273 "Holiday on MONTH, DAY (Hebrew) called STRING. 274If MONTH, DAY (Hebrew) is visible, the value returned is corresponding 275Gregorian date in the form of the list (((month day year) STRING)). Returns 276nil if it is not visible in the current calendar window." 277 (if (memq displayed-month;; This test is only to speed things up a bit; 278 (list ;; it works fine without the test too. 279 (if (< 11 month) (- month 11) (+ month 1)) 280 (if (< 10 month) (- month 10) (+ month 2)) 281 (if (< 9 month) (- month 9) (+ month 3)) 282 (if (< 8 month) (- month 8) (+ month 4)) 283 (if (< 7 month) (- month 7) (+ month 5)))) 284 (let ((m1 displayed-month) 285 (y1 displayed-year) 286 (m2 displayed-month) 287 (y2 displayed-year) 288 (year)) 289 (increment-calendar-month m1 y1 -1) 290 (increment-calendar-month m2 y2 1) 291 (let* ((start-date (calendar-absolute-from-gregorian 292 (list m1 1 y1))) 293 (end-date (calendar-absolute-from-gregorian 294 (list m2 (calendar-last-day-of-month m2 y2) y2))) 295 (hebrew-start (calendar-hebrew-from-absolute start-date)) 296 (hebrew-end (calendar-hebrew-from-absolute end-date)) 297 (hebrew-y1 (extract-calendar-year hebrew-start)) 298 (hebrew-y2 (extract-calendar-year hebrew-end))) 299 (setq year (if (< 6 month) hebrew-y2 hebrew-y1)) 300 (let ((date (calendar-gregorian-from-absolute 301 (calendar-absolute-from-hebrew 302 (list month day year))))) 303 (if (calendar-date-is-visible-p date) 304 (list (list date string)))))))) 305 306(defun holiday-sexp (sexp string) 307 "Sexp holiday for dates in the calendar window. 308SEXP is an expression in variable `year' evaluates to `date'. 309 310STRING is an expression in `date' that evaluates to the holiday description 311of `date'. 312 313If `date' is visible in the calendar window, the holiday STRING is on that 314date. If date is nil, or if the date is not visible, there is no holiday." 315 (let ((m displayed-month) 316 (y displayed-year)) 317 (increment-calendar-month m y -1) 318 (filter-visible-calendar-holidays 319 (append 320 (let* ((year y) 321 (date (eval sexp)) 322 (string (if date (eval string)))) 323 (list (list date string))) 324 (let* ((year (1+ y)) 325 (date (eval sexp)) 326 (string (if date (eval string)))) 327 (list (list date string))))))) 328 329(defun holiday-advent () 330 "Date of Advent, if visible in calendar window." 331 (let ((year displayed-year) 332 (month displayed-month)) 333 (increment-calendar-month month year -1) 334 (let ((advent (calendar-gregorian-from-absolute 335 (calendar-dayname-on-or-before 0 336 (calendar-absolute-from-gregorian 337 (list 12 3 year)))))) 338 (if (calendar-date-is-visible-p advent) 339 (list (list advent "Advent")))))) 340 341(defun holiday-easter-etc () 342 "List of dates related to Easter, as visible in calendar window." 343 (if (and (> displayed-month 5) (not all-christian-calendar-holidays)) 344 nil;; Ash Wednesday, Good Friday, and Easter are not visible. 345 (let* ((century (1+ (/ displayed-year 100))) 346 (shifted-epact ;; Age of moon for April 5... 347 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule 348 (- ;; ...corrected for the Gregorian century rule 349 (/ (* 3 century) 4)) 350 (/ ;; ...corrected for Metonic cycle inaccuracy. 351 (+ 5 (* 8 century)) 25) 352 (* 30 century));; Keeps value positive. 353 30)) 354 (adjusted-epact ;; Adjust for 29.5 day month. 355 (if (or (= shifted-epact 0) 356 (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) 357 (1+ shifted-epact) 358 shifted-epact)) 359 (paschal-moon ;; Day after the full moon on or after March 21. 360 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) 361 adjusted-epact)) 362 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) 363 (mandatory 364 (list 365 (list (calendar-gregorian-from-absolute abs-easter) 366 "Easter Sunday") 367 (list (calendar-gregorian-from-absolute (- abs-easter 2)) 368 "Good Friday") 369 (list (calendar-gregorian-from-absolute (- abs-easter 46)) 370 "Ash Wednesday"))) 371 (optional 372 (list 373 (list (calendar-gregorian-from-absolute (- abs-easter 63)) 374 "Septuagesima Sunday") 375 (list (calendar-gregorian-from-absolute (- abs-easter 56)) 376 "Sexagesima Sunday") 377 (list (calendar-gregorian-from-absolute (- abs-easter 49)) 378 "Shrove Sunday") 379 (list (calendar-gregorian-from-absolute (- abs-easter 48)) 380 "Shrove Monday") 381 (list (calendar-gregorian-from-absolute (- abs-easter 47)) 382 "Shrove Tuesday") 383 (list (calendar-gregorian-from-absolute (- abs-easter 14)) 384 "Passion Sunday") 385 (list (calendar-gregorian-from-absolute (- abs-easter 7)) 386 "Palm Sunday") 387 (list (calendar-gregorian-from-absolute (- abs-easter 3)) 388 "Maundy Thursday") 389 (list (calendar-gregorian-from-absolute (+ abs-easter 35)) 390 "Rogation Sunday") 391 (list (calendar-gregorian-from-absolute (+ abs-easter 39)) 392 "Ascension Day") 393 (list (calendar-gregorian-from-absolute (+ abs-easter 49)) 394 "Pentecost (Whitsunday)") 395 (list (calendar-gregorian-from-absolute (+ abs-easter 50)) 396 "Whitmunday") 397 (list (calendar-gregorian-from-absolute (+ abs-easter 56)) 398 "Trinity Sunday") 399 (list (calendar-gregorian-from-absolute (+ abs-easter 60)) 400 "Corpus Christi"))) 401 (output-list 402 (filter-visible-calendar-holidays mandatory))) 403 (if all-christian-calendar-holidays 404 (setq output-list 405 (append 406 (filter-visible-calendar-holidays optional) 407 output-list))) 408 output-list))) 409 410(defun holiday-greek-orthodox-easter () 411 "Date of Easter according to the rule of the Council of Nicaea." 412 (let ((m displayed-month) 413 (y displayed-year)) 414 (increment-calendar-month m y 1) 415 (let* ((julian-year 416 (extract-calendar-year 417 (calendar-julian-from-absolute 418 (calendar-absolute-from-gregorian 419 (list m (calendar-last-day-of-month m y) y))))) 420 (shifted-epact ;; Age of moon for April 5. 421 (% (+ 14 422 (* 11 (% julian-year 19))) 423 30)) 424 (paschal-moon ;; Day after full moon on or after March 21. 425 (- (calendar-absolute-from-julian (list 4 19 julian-year)) 426 shifted-epact)) 427 (nicaean-easter;; Sunday following the Paschal moon 428 (calendar-gregorian-from-absolute 429 (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) 430 (if (calendar-date-is-visible-p nicaean-easter) 431 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))) 432 433(defun holiday-rosh-hashanah-etc () 434 "List of dates related to Rosh Hashanah, as visible in calendar window." 435 (if (or (< displayed-month 8) 436 (> displayed-month 11)) 437 nil;; None of the dates is visible 438 (let* ((abs-r-h (calendar-absolute-from-hebrew 439 (list 7 1 (+ displayed-year 3761)))) 440 (mandatory 441 (list 442 (list (calendar-gregorian-from-absolute abs-r-h) 443 (format "Rosh HaShanah %d" (+ 3761 displayed-year))) 444 (list (calendar-gregorian-from-absolute (+ abs-r-h 9)) 445 "Yom Kippur") 446 (list (calendar-gregorian-from-absolute (+ abs-r-h 14)) 447 "Sukkot") 448 (list (calendar-gregorian-from-absolute (+ abs-r-h 21)) 449 "Shemini Atzeret") 450 (list (calendar-gregorian-from-absolute (+ abs-r-h 22)) 451 "Simchat Torah"))) 452 (optional 453 (list 454 (list (calendar-gregorian-from-absolute 455 (calendar-dayname-on-or-before 6 (- abs-r-h 4))) 456 "Selichot (night)") 457 (list (calendar-gregorian-from-absolute (1- abs-r-h)) 458 "Erev Rosh HaShannah") 459 (list (calendar-gregorian-from-absolute (1+ abs-r-h)) 460 "Rosh HaShanah (second day)") 461 (list (calendar-gregorian-from-absolute 462 (if (= (% abs-r-h 7) 4) (+ abs-r-h 3) (+ abs-r-h 2))) 463 "Tzom Gedaliah") 464 (list (calendar-gregorian-from-absolute 465 (calendar-dayname-on-or-before 6 (+ 7 abs-r-h))) 466 "Shabbat Shuvah") 467 (list (calendar-gregorian-from-absolute (+ abs-r-h 8)) 468 "Erev Yom Kippur") 469 (list (calendar-gregorian-from-absolute (+ abs-r-h 13)) 470 "Erev Sukkot") 471 (list (calendar-gregorian-from-absolute (+ abs-r-h 15)) 472 "Sukkot (second day)") 473 (list (calendar-gregorian-from-absolute (+ abs-r-h 16)) 474 "Hol Hamoed Sukkot (first day)") 475 (list (calendar-gregorian-from-absolute (+ abs-r-h 17)) 476 "Hol Hamoed Sukkot (second day)") 477 (list (calendar-gregorian-from-absolute (+ abs-r-h 18)) 478 "Hol Hamoed Sukkot (third day)") 479 (list (calendar-gregorian-from-absolute (+ abs-r-h 19)) 480 "Hol Hamoed Sukkot (fourth day)") 481 (list (calendar-gregorian-from-absolute (+ abs-r-h 20)) 482 "Hoshannah Rabbah"))) 483 (output-list 484 (filter-visible-calendar-holidays mandatory))) 485 (if all-hebrew-calendar-holidays 486 (setq output-list 487 (append 488 (filter-visible-calendar-holidays optional) 489 output-list))) 490 output-list))) 491 492(defun holiday-hanukkah () 493 "List of dates related to Hanukkah, as visible in calendar window." 494 (if (memq displayed-month;; This test is only to speed things up a bit; 495 '(10 11 12 1 2));; it works fine without the test too. 496 (let ((m displayed-month) 497 (y displayed-year)) 498 (increment-calendar-month m y 1) 499 (let* ((h-y (extract-calendar-year 500 (calendar-hebrew-from-absolute 501 (calendar-absolute-from-gregorian 502 (list m (calendar-last-day-of-month m y) y))))) 503 (abs-h (calendar-absolute-from-hebrew (list 9 25 h-y)))) 504 (filter-visible-calendar-holidays 505 (list 506 (list (calendar-gregorian-from-absolute (1- abs-h)) 507 "Erev Hanukkah") 508 (list (calendar-gregorian-from-absolute abs-h) 509 "Hanukkah (first day)") 510 (list (calendar-gregorian-from-absolute (1+ abs-h)) 511 "Hanukkah (second day)") 512 (list (calendar-gregorian-from-absolute (+ abs-h 2)) 513 "Hanukkah (third day)") 514 (list (calendar-gregorian-from-absolute (+ abs-h 3)) 515 "Hanukkah (fourth day)") 516 (list (calendar-gregorian-from-absolute (+ abs-h 4)) 517 "Hanukkah (fifth day)") 518 (list (calendar-gregorian-from-absolute (+ abs-h 5)) 519 "Hanukkah (sixth day)") 520 (list (calendar-gregorian-from-absolute (+ abs-h 6)) 521 "Hanukkah (seventh day)") 522 (list (calendar-gregorian-from-absolute (+ abs-h 7)) 523 "Hanukkah (eighth day)"))))))) 524 525(defun holiday-passover-etc () 526 "List of dates related to Passover, as visible in calendar window." 527 (if (< 7 displayed-month) 528 nil;; None of the dates is visible 529 (let* ((abs-p (calendar-absolute-from-hebrew 530 (list 1 15 (+ displayed-year 3760)))) 531 (mandatory 532 (list 533 (list (calendar-gregorian-from-absolute abs-p) 534 "Passover") 535 (list (calendar-gregorian-from-absolute (+ abs-p 50)) 536 "Shavuot"))) 537 (optional 538 (list 539 (list (calendar-gregorian-from-absolute 540 (calendar-dayname-on-or-before 6 (- abs-p 43))) 541 "Shabbat Shekalim") 542 (list (calendar-gregorian-from-absolute 543 (calendar-dayname-on-or-before 6 (- abs-p 30))) 544 "Shabbat Zachor") 545 (list (calendar-gregorian-from-absolute 546 (if (= (% abs-p 7) 2) (- abs-p 33) (- abs-p 31))) 547 "Fast of Esther") 548 (list (calendar-gregorian-from-absolute (- abs-p 31)) 549 "Erev Purim") 550 (list (calendar-gregorian-from-absolute (- abs-p 30)) 551 "Purim") 552 (list (calendar-gregorian-from-absolute 553 (if (zerop (% abs-p 7)) (- abs-p 28) (- abs-p 29))) 554 "Shushan Purim") 555 (list (calendar-gregorian-from-absolute 556 (- (calendar-dayname-on-or-before 6 (- abs-p 14)) 7)) 557 "Shabbat Parah") 558 (list (calendar-gregorian-from-absolute 559 (calendar-dayname-on-or-before 6 (- abs-p 14))) 560 "Shabbat HaHodesh") 561 (list (calendar-gregorian-from-absolute 562 (calendar-dayname-on-or-before 6 (1- abs-p))) 563 "Shabbat HaGadol") 564 (list (calendar-gregorian-from-absolute (1- abs-p)) 565 "Erev Passover") 566 (list (calendar-gregorian-from-absolute (1+ abs-p)) 567 "Passover (second day)") 568 (list (calendar-gregorian-from-absolute (+ abs-p 2)) 569 "Hol Hamoed Passover (first day)") 570 (list (calendar-gregorian-from-absolute (+ abs-p 3)) 571 "Hol Hamoed Passover (second day)") 572 (list (calendar-gregorian-from-absolute (+ abs-p 4)) 573 "Hol Hamoed Passover (third day)") 574 (list (calendar-gregorian-from-absolute (+ abs-p 5)) 575 "Hol Hamoed Passover (fourth day)") 576 (list (calendar-gregorian-from-absolute (+ abs-p 6)) 577 "Passover (seventh day)") 578 (list (calendar-gregorian-from-absolute (+ abs-p 7)) 579 "Passover (eighth day)") 580 (list (calendar-gregorian-from-absolute (+ abs-p 12)) 581 "Yom HaShoah") 582 (list (calendar-gregorian-from-absolute 583 (if (zerop (% abs-p 7)) 584 (+ abs-p 18) 585 (if (= (% abs-p 7) 6) 586 (+ abs-p 19) 587 (+ abs-p 20)))) 588 "Yom HaAtzma'ut") 589 (list (calendar-gregorian-from-absolute (+ abs-p 33)) 590 "Lag BaOmer") 591 (list (calendar-gregorian-from-absolute (+ abs-p 43)) 592 "Yom Yerushalim") 593 (list (calendar-gregorian-from-absolute (+ abs-p 49)) 594 "Erev Shavuot") 595 (list (calendar-gregorian-from-absolute (+ abs-p 51)) 596 "Shavuot (second day)"))) 597 (output-list 598 (filter-visible-calendar-holidays mandatory))) 599 (if all-hebrew-calendar-holidays 600 (setq output-list 601 (append 602 (filter-visible-calendar-holidays optional) 603 output-list))) 604 output-list))) 605 606(defun holiday-tisha-b-av-etc () 607 "List of dates around Tisha B'Av, as visible in calendar window." 608 (if (or (< displayed-month 5) 609 (> displayed-month 9)) 610 nil;; None of the dates is visible 611 (let* ((abs-t-a (calendar-absolute-from-hebrew 612 (list 5 9 (+ displayed-year 3760))))) 613 614 (filter-visible-calendar-holidays 615 (list 616 (list (calendar-gregorian-from-absolute 617 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21))) 618 "Tzom Tammuz") 619 (list (calendar-gregorian-from-absolute 620 (calendar-dayname-on-or-before 6 abs-t-a)) 621 "Shabbat Hazon") 622 (list (calendar-gregorian-from-absolute 623 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a)) 624 "Tisha B'Av") 625 (list (calendar-gregorian-from-absolute 626 (calendar-dayname-on-or-before 6 (+ abs-t-a 7))) 627 "Shabbat Nahamu")))))) 628 629(defun filter-visible-calendar-holidays (l) 630 "Return a list of all visible holidays of those on L." 631 (let ((visible) 632 (p l)) 633 (while p 634 (and (car (car p)) 635 (calendar-date-is-visible-p (car (car p))) 636 (setq visible (append (list (car p)) visible))) 637 (setq p (cdr p))) 638 visible)) 639 640(provide 'holidays) 641 642;;; holidays.el ends here 643