Mercurial > emacs
annotate lisp/calendar/holidays.el @ 5020:94de08fd8a7c
(Fnext_single_property_change): Fix missing \n\.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 15 Nov 1993 06:41:45 +0000 |
| parents | 4bfa62882154 |
| children | baab03aaf3b9 |
| rev | line source |
|---|---|
|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; holidays.el --- holiday functions for the calendar package |
|
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
2 |
| 957 | 3 ;;; Copyright (C) 1989, 1990, 1992 Free Software Foundation, Inc. |
|
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
|
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> |
| 957 | 6 ;; Keywords: holidays, calendar |
|
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
7 |
| 406 | 8 ;; This file is part of GNU Emacs. |
| 9 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
10 |
| 406 | 11 ;; GNU Emacs is distributed in the hope that it will be useful, |
| 12 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
| 13 ;; accepts responsibility to anyone for the consequences of using it | |
| 14 ;; or for whether it serves any particular purpose or works at all, | |
| 15 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
| 16 ;; License for full details. | |
| 17 | |
| 18 ;; Everyone is granted permission to copy, modify and redistribute | |
| 19 ;; GNU Emacs, but only under the conditions described in the | |
| 20 ;; GNU Emacs General Public License. A copy of this license is | |
| 21 ;; supposed to have been given to you along with GNU Emacs so you | |
| 22 ;; can know your rights and responsibilities. It should be in a | |
| 23 ;; file named COPYING. Among other things, the copyright notice | |
| 24 ;; and this notice must be preserved on all copies. | |
| 25 | |
|
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
26 ;;; Commentary: |
|
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
27 |
| 406 | 28 ;; This collection of functions implements the holiday features as described |
| 29 ;; in calendar.el. | |
| 30 | |
| 31 ;; Comments, corrections, and improvements should be sent to | |
| 32 ;; Edward M. Reingold Department of Computer Science | |
| 33 ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
| 34 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
| 35 ;; Urbana, Illinois 61801 | |
| 36 | |
| 37 ;; Technical details of all the calendrical calculations can be found in | |
| 38 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, | |
| 39 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990), | |
| 957 | 40 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical |
| 41 ;; Calendars'' by E. M. Reingold, N. Dershowitz, and S. M. Clamen, | |
|
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
42 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), |
|
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
43 ;; pages 383-404. |
| 957 | 44 |
| 45 ;; Hard copies of these two papers can be obtained by sending email to | |
| 46 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and | |
| 47 ;; the message BODY containing your mailing address (snail). | |
| 406 | 48 |
|
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
49 ;;; Code: |
|
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
50 |
| 406 | 51 (require 'calendar) |
| 732 | 52 |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
53 (autoload 'solar-equinoxes-solstices "solar" |
| 957 | 54 "Date and time of equinoxes and solstices, if visible in the calendar window. |
| 55 Requires floating point." | |
| 56 t) | |
| 57 | |
| 58 (defun holidays (&optional arg) | |
| 406 | 59 "Display the holidays for last month, this month, and next month. |
| 957 | 60 If called with an optional prefix argument, prompts for month and year. |
| 61 | |
| 406 | 62 This function is suitable for execution in a .emacs file." |
| 957 | 63 (interactive "P") |
| 406 | 64 (save-excursion |
| 957 | 65 (let* ((completion-ignore-case t) |
| 66 (date (calendar-current-date)) | |
| 67 (displayed-month | |
| 68 (if arg | |
| 69 (cdr (assoc | |
| 70 (capitalize | |
| 71 (completing-read | |
| 72 "Month name: " | |
| 73 (mapcar 'list (append calendar-month-name-array nil)) | |
| 74 nil t)) | |
| 75 (calendar-make-alist calendar-month-name-array))) | |
| 76 (extract-calendar-month date))) | |
| 77 (displayed-year | |
| 78 (if arg | |
| 79 (calendar-read | |
| 80 "Year (>0): " | |
| 81 '(lambda (x) (> x 0)) | |
| 82 (int-to-string | |
| 83 (extract-calendar-year (calendar-current-date)))) | |
| 84 (extract-calendar-year date)))) | |
| 406 | 85 (list-calendar-holidays)))) |
| 86 | |
| 87 (defun check-calendar-holidays (date) | |
| 88 "Check the list of holidays for any that occur on DATE. | |
| 89 The value returned is a list of strings of relevant holiday descriptions. | |
| 90 The holidays are those in the list calendar-holidays." | |
| 91 (let* ((displayed-month (extract-calendar-month date)) | |
| 92 (displayed-year (extract-calendar-year date)) | |
| 93 (h (calendar-holiday-list)) | |
| 94 (holiday-list)) | |
| 95 (while h | |
| 96 (if (calendar-date-equal date (car (car h))) | |
| 97 (setq holiday-list (append holiday-list (cdr (car h))))) | |
| 98 (setq h (cdr h))) | |
| 99 holiday-list)) | |
| 100 | |
| 101 (defun calendar-cursor-holidays () | |
| 102 "Find holidays for the date specified by the cursor in the calendar window." | |
| 103 (interactive) | |
| 104 (message "Checking holidays...") | |
| 732 | 105 (let* ((date (or (calendar-cursor-to-date) |
| 106 (error "Cursor is not on a date!"))) | |
| 406 | 107 (date-string (calendar-date-string date)) |
| 108 (holiday-list (check-calendar-holidays date)) | |
| 109 (holiday-string (mapconcat 'identity holiday-list "; ")) | |
| 110 (msg (format "%s: %s" date-string holiday-string))) | |
| 111 (if (not holiday-list) | |
| 112 (message "No holidays known for %s" date-string) | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
113 (if (<= (length msg) (frame-width)) |
| 406 | 114 (message msg) |
| 115 (set-buffer (get-buffer-create holiday-buffer)) | |
| 116 (setq buffer-read-only nil) | |
| 957 | 117 (calendar-set-mode-line date-string) |
| 406 | 118 (erase-buffer) |
| 119 (insert (mapconcat 'identity holiday-list "\n")) | |
| 120 (goto-char (point-min)) | |
| 121 (set-buffer-modified-p nil) | |
| 122 (setq buffer-read-only t) | |
| 123 (display-buffer holiday-buffer) | |
| 124 (message "Checking holidays...done"))))) | |
| 125 | |
| 126 (defun mark-calendar-holidays () | |
| 127 "Mark notable days in the calendar window." | |
| 128 (interactive) | |
| 129 (setq mark-holidays-in-calendar t) | |
| 130 (message "Marking holidays...") | |
| 131 (let ((holiday-list (calendar-holiday-list))) | |
| 132 (while holiday-list | |
| 133 (mark-visible-calendar-date | |
| 134 (car (car holiday-list)) calendar-holiday-marker) | |
| 135 (setq holiday-list (cdr holiday-list)))) | |
| 136 (message "Marking holidays...done")) | |
| 137 | |
| 138 (defun list-calendar-holidays () | |
| 139 "Create a buffer containing the holidays for the current calendar window. | |
| 140 The holidays are those in the list calendar-notable-days. Returns t if any | |
| 141 holidays are found, nil if not." | |
| 142 (interactive) | |
| 143 (message "Looking up holidays...") | |
| 144 (let ((holiday-list (calendar-holiday-list)) | |
| 145 (m1 displayed-month) | |
| 146 (y1 displayed-year) | |
| 147 (m2 displayed-month) | |
| 148 (y2 displayed-year)) | |
| 149 (if (not holiday-list) | |
| 150 (progn | |
| 151 (message "Looking up holidays...none found") | |
| 152 nil) | |
| 153 (set-buffer (get-buffer-create holiday-buffer)) | |
| 154 (setq buffer-read-only nil) | |
| 155 (increment-calendar-month m1 y1 -1) | |
| 156 (increment-calendar-month m2 y2 1) | |
| 957 | 157 (calendar-set-mode-line |
| 158 (format "Notable Dates from %s, %d to %s, %d%%-" | |
| 406 | 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. | |
| 175 The holidays are those in the list calendar-holidays." | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
176 (let ((p calendar-holidays) |
| 406 | 177 (holiday-list)) |
| 178 (while p | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
179 (let* ((holidays |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
180 (if calendar-debug-sexp |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
181 (let ((stack-trace-on-error t)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
182 (eval (car p))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
183 (condition-case nil |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
184 (eval (car p)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
185 (error (beep) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
186 (message "Bad holiday list item: %s" (car p)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
187 (sleep-for 2)))))) |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
194 ;; are eval'ed in the function calendar-holiday-list. If you |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
195 ;; write other such functions, be sure to imitate the style used below. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
196 ;; Remember that each function must return a list of items of the form |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
197 ;; ((month day year) string) of VISIBLE dates in the calendar window. |
| 406 | 198 |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
199 (defun holiday-fixed (month day string) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
200 "Holiday on MONTH, DAY (Gregorian) called STRING. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
201 If MONTH, DAY is visible, the value returned is the list (((MONTH DAY year) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
202 STRING)). Returns nil if it is not visible in the current calendar window." |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
203 (let ((m displayed-month) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
204 (y displayed-year)) |
| 406 | 205 (increment-calendar-month m y (- 11 month)) |
| 206 (if (> m 9) | |
| 207 (list (list (list month day y) string))))) | |
| 208 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
209 (defun holiday-float (month dayname n string &optional day) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
210 "Holiday on MONTH, DAYNAME (Nth occurrence, Gregorian) called STRING. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
211 If the Nth DAYNAME in MONTH is visible, the value returned is the list |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
212 (((MONTH DAY year) STRING)). |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
213 |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
214 If N<0, count backward from the end of MONTH. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
215 |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
216 An optional parameter DAY means the Nth DAYNAME after/before MONTH DAY. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
217 |
| 406 | 218 Returns nil if it is not visible in the current calendar window." |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
219 (let ((m displayed-month) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
220 (y displayed-year)) |
| 406 | 221 (increment-calendar-month m y (- 11 month)) |
| 222 (if (> m 9) | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
223 (list (list (calendar-nth-named-day n dayname month y day) string))))) |
| 406 | 224 |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
225 (defun holiday-julian (month day string) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
226 "Holiday on MONTH, DAY (Julian) called STRING. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
227 If MONTH, DAY (Julian) is visible, the value returned is corresponding |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
228 Gregorian date in the form of the list (((month day year) STRING)). Returns |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
229 nil if it is not visible in the current calendar window." |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
230 (let ((m1 displayed-month) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
231 (y1 displayed-year) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
232 (m2 displayed-month) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
233 (y2 displayed-year) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
234 (year)) |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
252 (defun holiday-islamic (month day string) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
253 "Holiday on MONTH, DAY (Islamic) called STRING. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
254 If MONTH, DAY (Islamic) is visible, the value returned is corresponding |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
255 Gregorian date in the form of the list (((month day year) STRING)). Returns |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
256 nil if it is not visible in the current calendar window." |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
257 (let* ((islamic-date (calendar-islamic-from-absolute |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
272 (defun holiday-hebrew (month day string) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
273 "Holiday on MONTH, DAY (Hebrew) called STRING. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
274 If MONTH, DAY (Hebrew) is visible, the value returned is corresponding |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
275 Gregorian date in the form of the list (((month day year) STRING)). Returns |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
276 nil if it is not visible in the current calendar window." |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
277 (if (memq displayed-month;; This test is only to speed things up a bit; |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
278 (list ;; it works fine without the test too. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
279 (if (< 11 month) (- month 11) (+ month 1)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
280 (if (< 10 month) (- month 10) (+ month 2)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
281 (if (< 9 month) (- month 9) (+ month 3)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
282 (if (< 8 month) (- month 8) (+ month 4)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
283 (if (< 7 month) (- month 7) (+ month 5)))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
284 (let ((m1 displayed-month) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
285 (y1 displayed-year) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
286 (m2 displayed-month) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
287 (y2 displayed-year) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
288 (year)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
289 (increment-calendar-month m1 y1 -1) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
290 (increment-calendar-month m2 y2 1) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
291 (let* ((start-date (calendar-absolute-from-gregorian |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
292 (list m1 1 y1))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
293 (end-date (calendar-absolute-from-gregorian |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
294 (list m2 (calendar-last-day-of-month m2 y2) y2))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
295 (hebrew-start (calendar-hebrew-from-absolute start-date)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
296 (hebrew-end (calendar-hebrew-from-absolute end-date)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
297 (hebrew-y1 (extract-calendar-year hebrew-start)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
298 (hebrew-y2 (extract-calendar-year hebrew-end))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
299 (setq year (if (< 6 month) hebrew-y2 hebrew-y1)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
300 (let ((date (calendar-gregorian-from-absolute |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
301 (calendar-absolute-from-hebrew |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
302 (list month day year))))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
303 (if (calendar-date-is-visible-p date) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
304 (list (list date string)))))))) |
| 406 | 305 |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
306 (defun holiday-sexp (sexp string) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
307 "Sexp holiday for dates in the calendar window. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
308 SEXP is an expression in variable `year' evaluates to `date'. |
| 406 | 309 |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
310 STRING is an expression in `date' that evaluates to the holiday description |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
311 of `date'. |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
312 |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
313 If `date' is visible in the calendar window, the holiday STRING is on that |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
314 date. If date is nil, or if the date is not visible, there is no holiday." |
| 957 | 315 (let ((m displayed-month) |
| 316 (y displayed-year)) | |
| 317 (increment-calendar-month m y -1) | |
| 318 (filter-visible-calendar-holidays | |
| 319 (append | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
320 (let* ((year y) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
321 (date (eval sexp)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
322 (string (if date (eval string)))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
323 (list (list date string))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
324 (let* ((year (1+ y)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
325 (date (eval sexp)) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
326 (string (if date (eval string)))) |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
327 (list (list date string))))))) |
| 957 | 328 |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
329 (defun holiday-advent () |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
341 (defun holiday-easter-etc () |
| 406 | 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)) | |
|
4864
4bfa62882154
(holiday-easter-etc): Fix Ascension Day string.
Richard M. Stallman <rms@gnu.org>
parents:
3870
diff
changeset
|
392 "Ascension Day") |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
410 (defun holiday-greek-orthodox-easter () |
|
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
411 "Date of Easter according to the rule of the Council of Nicaea." |
| 957 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
433 (defun holiday-rosh-hashanah-etc () |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
492 (defun holiday-hanukkah () |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
525 (defun holiday-passover-etc () |
| 406 | 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 | |
|
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
606 (defun holiday-tisha-b-av-etc () |
| 406 | 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 | |
|
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
634 (and (car (car p)) |
|
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
635 (calendar-date-is-visible-p (car (car p))) |
|
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
636 (setq visible (append (list (car p)) visible))) |
| 406 | 637 (setq p (cdr p))) |
| 638 visible)) | |
| 584 | 639 |
| 640 (provide 'holidays) | |
| 641 | |
|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
642 ;;; holidays.el ends here |
