Mercurial > emacs
annotate lisp/calendar/holidays.el @ 5784:9c3be8e0d2ef
(Fsubstitute_command_keys): Pass keymap as that arg
to Fwhere_is_internal. Init keymap from Voverriding_local_map.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 04 Feb 1994 23:09:25 +0000 |
parents | baab03aaf3b9 |
children | 7a4647230b22 |
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 |
5696
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
158 (if (= y1 y2) |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
159 (format "Notable Dates from %s to %s, %d%%-" |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
160 (calendar-month-name m1) (calendar-month-name m2) y2) |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
161 (format "Notable Dates from %s, %d to %s, %d%%-" |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
162 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) |
406 | 163 (erase-buffer) |
164 (insert | |
165 (mapconcat | |
166 '(lambda (x) (concat (calendar-date-string (car x)) | |
167 ": " (car (cdr x)))) | |
168 holiday-list "\n")) | |
169 (goto-char (point-min)) | |
170 (set-buffer-modified-p nil) | |
171 (setq buffer-read-only t) | |
172 (display-buffer holiday-buffer) | |
173 (message "Looking up holidays...done") | |
174 t))) | |
175 | |
176 (defun calendar-holiday-list () | |
177 "Form the list of holidays that occur on dates in the calendar window. | |
178 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
|
179 (let ((p calendar-holidays) |
406 | 180 (holiday-list)) |
181 (while p | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
182 (let* ((holidays |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
183 (if calendar-debug-sexp |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
184 (let ((stack-trace-on-error t)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
185 (eval (car p))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
186 (condition-case nil |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
187 (eval (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
188 (error (beep) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
189 (message "Bad holiday list item: %s" (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
190 (sleep-for 2)))))) |
406 | 191 (if holidays |
192 (setq holiday-list (append holidays holiday-list)))) | |
193 (setq p (cdr p))) | |
194 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) | |
195 | |
196 ;; 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
|
197 ;; 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
|
198 ;; 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
|
199 ;; 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
|
200 ;; ((month day year) string) of VISIBLE dates in the calendar window. |
406 | 201 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
202 (defun holiday-fixed (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
203 "Holiday on MONTH, DAY (Gregorian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
204 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
|
205 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
|
206 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
207 (y displayed-year)) |
406 | 208 (increment-calendar-month m y (- 11 month)) |
209 (if (> m 9) | |
210 (list (list (list month day y) string))))) | |
211 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
212 (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
|
213 "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
|
214 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
|
215 (((MONTH DAY year) STRING)). |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
216 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
217 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
|
218 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
219 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
|
220 |
406 | 221 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
|
222 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
223 (y displayed-year)) |
406 | 224 (increment-calendar-month m y (- 11 month)) |
225 (if (> m 9) | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
226 (list (list (calendar-nth-named-day n dayname month y day) string))))) |
406 | 227 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
228 (defun holiday-julian (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
229 "Holiday on MONTH, DAY (Julian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 (let ((m1 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
234 (y1 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
235 (m2 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
236 (y2 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
237 (year)) |
406 | 238 (increment-calendar-month m1 y1 -1) |
239 (increment-calendar-month m2 y2 1) | |
240 (let* ((start-date (calendar-absolute-from-gregorian | |
241 (list m1 1 y1))) | |
242 (end-date (calendar-absolute-from-gregorian | |
243 (list m2 (calendar-last-day-of-month m2 y2) y2))) | |
244 (julian-start (calendar-julian-from-absolute start-date)) | |
245 (julian-end (calendar-julian-from-absolute end-date)) | |
246 (julian-y1 (extract-calendar-year julian-start)) | |
247 (julian-y2 (extract-calendar-year julian-end))) | |
248 (setq year (if (< 10 month) julian-y1 julian-y2)) | |
249 (let ((date (calendar-gregorian-from-absolute | |
250 (calendar-absolute-from-julian | |
251 (list month day year))))) | |
252 (if (calendar-date-is-visible-p date) | |
253 (list (list date string))))))) | |
254 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
255 (defun holiday-islamic (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
256 "Holiday on MONTH, DAY (Islamic) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 (let* ((islamic-date (calendar-islamic-from-absolute |
406 | 261 (calendar-absolute-from-gregorian |
262 (list displayed-month 15 displayed-year)))) | |
263 (m (extract-calendar-month islamic-date)) | |
264 (y (extract-calendar-year islamic-date)) | |
265 (date)) | |
266 (if (< m 1) | |
267 nil;; Islamic calendar doesn't apply. | |
268 (increment-calendar-month m y (- 10 month)) | |
269 (if (> m 7);; Islamic date might be visible | |
270 (let ((date (calendar-gregorian-from-absolute | |
271 (calendar-absolute-from-islamic (list month day y))))) | |
272 (if (calendar-date-is-visible-p date) | |
273 (list (list date string)))))))) | |
274 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
275 (defun holiday-hebrew (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
276 "Holiday on MONTH, DAY (Hebrew) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 (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
|
281 (list ;; it works fine without the test too. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
282 (if (< 11 month) (- month 11) (+ month 1)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
283 (if (< 10 month) (- month 10) (+ month 2)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
284 (if (< 9 month) (- month 9) (+ month 3)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
285 (if (< 8 month) (- month 8) (+ month 4)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
286 (if (< 7 month) (- month 7) (+ month 5)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
287 (let ((m1 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
288 (y1 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
289 (m2 displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
290 (y2 displayed-year) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
291 (year)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
292 (increment-calendar-month m1 y1 -1) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
293 (increment-calendar-month m2 y2 1) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
294 (let* ((start-date (calendar-absolute-from-gregorian |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
295 (list m1 1 y1))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
296 (end-date (calendar-absolute-from-gregorian |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
297 (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
|
298 (hebrew-start (calendar-hebrew-from-absolute start-date)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
299 (hebrew-end (calendar-hebrew-from-absolute end-date)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
300 (hebrew-y1 (extract-calendar-year hebrew-start)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
301 (hebrew-y2 (extract-calendar-year hebrew-end))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
302 (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
|
303 (let ((date (calendar-gregorian-from-absolute |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
304 (calendar-absolute-from-hebrew |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
305 (list month day year))))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
306 (if (calendar-date-is-visible-p date) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
307 (list (list date string)))))))) |
406 | 308 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
309 (defun holiday-sexp (sexp string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
310 "Sexp holiday for dates in the calendar window. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
311 SEXP is an expression in variable `year' evaluates to `date'. |
406 | 312 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
313 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
|
314 of `date'. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
315 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
316 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
|
317 date. If date is nil, or if the date is not visible, there is no holiday." |
957 | 318 (let ((m displayed-month) |
319 (y displayed-year)) | |
320 (increment-calendar-month m y -1) | |
321 (filter-visible-calendar-holidays | |
322 (append | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
323 (let* ((year y) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
324 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
325 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
326 (list (list date string))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
327 (let* ((year (1+ y)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
328 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
329 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
330 (list (list date string))))))) |
957 | 331 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
332 (defun holiday-advent () |
406 | 333 "Date of Advent, if visible in calendar window." |
334 (let ((year displayed-year) | |
335 (month displayed-month)) | |
336 (increment-calendar-month month year -1) | |
337 (let ((advent (calendar-gregorian-from-absolute | |
338 (calendar-dayname-on-or-before 0 | |
339 (calendar-absolute-from-gregorian | |
340 (list 12 3 year)))))) | |
341 (if (calendar-date-is-visible-p advent) | |
342 (list (list advent "Advent")))))) | |
343 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
344 (defun holiday-easter-etc () |
406 | 345 "List of dates related to Easter, as visible in calendar window." |
346 (if (and (> displayed-month 5) (not all-christian-calendar-holidays)) | |
347 nil;; Ash Wednesday, Good Friday, and Easter are not visible. | |
348 (let* ((century (1+ (/ displayed-year 100))) | |
349 (shifted-epact ;; Age of moon for April 5... | |
350 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule | |
351 (- ;; ...corrected for the Gregorian century rule | |
352 (/ (* 3 century) 4)) | |
353 (/ ;; ...corrected for Metonic cycle inaccuracy. | |
354 (+ 5 (* 8 century)) 25) | |
355 (* 30 century));; Keeps value positive. | |
356 30)) | |
357 (adjusted-epact ;; Adjust for 29.5 day month. | |
358 (if (or (= shifted-epact 0) | |
359 (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) | |
360 (1+ shifted-epact) | |
361 shifted-epact)) | |
362 (paschal-moon ;; Day after the full moon on or after March 21. | |
363 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) | |
364 adjusted-epact)) | |
365 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) | |
366 (mandatory | |
367 (list | |
368 (list (calendar-gregorian-from-absolute abs-easter) | |
369 "Easter Sunday") | |
370 (list (calendar-gregorian-from-absolute (- abs-easter 2)) | |
371 "Good Friday") | |
372 (list (calendar-gregorian-from-absolute (- abs-easter 46)) | |
373 "Ash Wednesday"))) | |
374 (optional | |
375 (list | |
376 (list (calendar-gregorian-from-absolute (- abs-easter 63)) | |
377 "Septuagesima Sunday") | |
378 (list (calendar-gregorian-from-absolute (- abs-easter 56)) | |
379 "Sexagesima Sunday") | |
380 (list (calendar-gregorian-from-absolute (- abs-easter 49)) | |
381 "Shrove Sunday") | |
382 (list (calendar-gregorian-from-absolute (- abs-easter 48)) | |
383 "Shrove Monday") | |
384 (list (calendar-gregorian-from-absolute (- abs-easter 47)) | |
385 "Shrove Tuesday") | |
386 (list (calendar-gregorian-from-absolute (- abs-easter 14)) | |
387 "Passion Sunday") | |
388 (list (calendar-gregorian-from-absolute (- abs-easter 7)) | |
389 "Palm Sunday") | |
390 (list (calendar-gregorian-from-absolute (- abs-easter 3)) | |
391 "Maundy Thursday") | |
392 (list (calendar-gregorian-from-absolute (+ abs-easter 35)) | |
393 "Rogation Sunday") | |
394 (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
|
395 "Ascension Day") |
406 | 396 (list (calendar-gregorian-from-absolute (+ abs-easter 49)) |
397 "Pentecost (Whitsunday)") | |
398 (list (calendar-gregorian-from-absolute (+ abs-easter 50)) | |
399 "Whitmunday") | |
400 (list (calendar-gregorian-from-absolute (+ abs-easter 56)) | |
401 "Trinity Sunday") | |
402 (list (calendar-gregorian-from-absolute (+ abs-easter 60)) | |
403 "Corpus Christi"))) | |
404 (output-list | |
405 (filter-visible-calendar-holidays mandatory))) | |
406 (if all-christian-calendar-holidays | |
407 (setq output-list | |
408 (append | |
409 (filter-visible-calendar-holidays optional) | |
410 output-list))) | |
411 output-list))) | |
412 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
413 (defun holiday-greek-orthodox-easter () |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
414 "Date of Easter according to the rule of the Council of Nicaea." |
957 | 415 (let ((m displayed-month) |
416 (y displayed-year)) | |
417 (increment-calendar-month m y 1) | |
418 (let* ((julian-year | |
419 (extract-calendar-year | |
420 (calendar-julian-from-absolute | |
421 (calendar-absolute-from-gregorian | |
422 (list m (calendar-last-day-of-month m y) y))))) | |
423 (shifted-epact ;; Age of moon for April 5. | |
424 (% (+ 14 | |
425 (* 11 (% julian-year 19))) | |
426 30)) | |
427 (paschal-moon ;; Day after full moon on or after March 21. | |
428 (- (calendar-absolute-from-julian (list 4 19 julian-year)) | |
429 shifted-epact)) | |
430 (nicaean-easter;; Sunday following the Paschal moon | |
431 (calendar-gregorian-from-absolute | |
432 (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) | |
433 (if (calendar-date-is-visible-p nicaean-easter) | |
434 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))) | |
435 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
436 (defun holiday-rosh-hashanah-etc () |
406 | 437 "List of dates related to Rosh Hashanah, as visible in calendar window." |
438 (if (or (< displayed-month 8) | |
439 (> displayed-month 11)) | |
440 nil;; None of the dates is visible | |
441 (let* ((abs-r-h (calendar-absolute-from-hebrew | |
442 (list 7 1 (+ displayed-year 3761)))) | |
443 (mandatory | |
444 (list | |
445 (list (calendar-gregorian-from-absolute abs-r-h) | |
446 (format "Rosh HaShanah %d" (+ 3761 displayed-year))) | |
447 (list (calendar-gregorian-from-absolute (+ abs-r-h 9)) | |
448 "Yom Kippur") | |
449 (list (calendar-gregorian-from-absolute (+ abs-r-h 14)) | |
450 "Sukkot") | |
451 (list (calendar-gregorian-from-absolute (+ abs-r-h 21)) | |
452 "Shemini Atzeret") | |
453 (list (calendar-gregorian-from-absolute (+ abs-r-h 22)) | |
454 "Simchat Torah"))) | |
455 (optional | |
456 (list | |
457 (list (calendar-gregorian-from-absolute | |
458 (calendar-dayname-on-or-before 6 (- abs-r-h 4))) | |
459 "Selichot (night)") | |
460 (list (calendar-gregorian-from-absolute (1- abs-r-h)) | |
461 "Erev Rosh HaShannah") | |
462 (list (calendar-gregorian-from-absolute (1+ abs-r-h)) | |
463 "Rosh HaShanah (second day)") | |
464 (list (calendar-gregorian-from-absolute | |
465 (if (= (% abs-r-h 7) 4) (+ abs-r-h 3) (+ abs-r-h 2))) | |
466 "Tzom Gedaliah") | |
467 (list (calendar-gregorian-from-absolute | |
468 (calendar-dayname-on-or-before 6 (+ 7 abs-r-h))) | |
469 "Shabbat Shuvah") | |
470 (list (calendar-gregorian-from-absolute (+ abs-r-h 8)) | |
471 "Erev Yom Kippur") | |
472 (list (calendar-gregorian-from-absolute (+ abs-r-h 13)) | |
473 "Erev Sukkot") | |
474 (list (calendar-gregorian-from-absolute (+ abs-r-h 15)) | |
475 "Sukkot (second day)") | |
476 (list (calendar-gregorian-from-absolute (+ abs-r-h 16)) | |
477 "Hol Hamoed Sukkot (first day)") | |
478 (list (calendar-gregorian-from-absolute (+ abs-r-h 17)) | |
479 "Hol Hamoed Sukkot (second day)") | |
480 (list (calendar-gregorian-from-absolute (+ abs-r-h 18)) | |
481 "Hol Hamoed Sukkot (third day)") | |
482 (list (calendar-gregorian-from-absolute (+ abs-r-h 19)) | |
483 "Hol Hamoed Sukkot (fourth day)") | |
484 (list (calendar-gregorian-from-absolute (+ abs-r-h 20)) | |
485 "Hoshannah Rabbah"))) | |
486 (output-list | |
487 (filter-visible-calendar-holidays mandatory))) | |
488 (if all-hebrew-calendar-holidays | |
489 (setq output-list | |
490 (append | |
491 (filter-visible-calendar-holidays optional) | |
492 output-list))) | |
493 output-list))) | |
494 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
495 (defun holiday-hanukkah () |
406 | 496 "List of dates related to Hanukkah, as visible in calendar window." |
497 (if (memq displayed-month;; This test is only to speed things up a bit; | |
498 '(10 11 12 1 2));; it works fine without the test too. | |
499 (let ((m displayed-month) | |
500 (y displayed-year)) | |
501 (increment-calendar-month m y 1) | |
502 (let* ((h-y (extract-calendar-year | |
503 (calendar-hebrew-from-absolute | |
504 (calendar-absolute-from-gregorian | |
505 (list m (calendar-last-day-of-month m y) y))))) | |
506 (abs-h (calendar-absolute-from-hebrew (list 9 25 h-y)))) | |
507 (filter-visible-calendar-holidays | |
508 (list | |
509 (list (calendar-gregorian-from-absolute (1- abs-h)) | |
510 "Erev Hanukkah") | |
511 (list (calendar-gregorian-from-absolute abs-h) | |
512 "Hanukkah (first day)") | |
513 (list (calendar-gregorian-from-absolute (1+ abs-h)) | |
514 "Hanukkah (second day)") | |
515 (list (calendar-gregorian-from-absolute (+ abs-h 2)) | |
516 "Hanukkah (third day)") | |
517 (list (calendar-gregorian-from-absolute (+ abs-h 3)) | |
518 "Hanukkah (fourth day)") | |
519 (list (calendar-gregorian-from-absolute (+ abs-h 4)) | |
520 "Hanukkah (fifth day)") | |
521 (list (calendar-gregorian-from-absolute (+ abs-h 5)) | |
522 "Hanukkah (sixth day)") | |
523 (list (calendar-gregorian-from-absolute (+ abs-h 6)) | |
524 "Hanukkah (seventh day)") | |
525 (list (calendar-gregorian-from-absolute (+ abs-h 7)) | |
526 "Hanukkah (eighth day)"))))))) | |
527 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
528 (defun holiday-passover-etc () |
406 | 529 "List of dates related to Passover, as visible in calendar window." |
530 (if (< 7 displayed-month) | |
531 nil;; None of the dates is visible | |
532 (let* ((abs-p (calendar-absolute-from-hebrew | |
533 (list 1 15 (+ displayed-year 3760)))) | |
534 (mandatory | |
535 (list | |
536 (list (calendar-gregorian-from-absolute abs-p) | |
537 "Passover") | |
538 (list (calendar-gregorian-from-absolute (+ abs-p 50)) | |
539 "Shavuot"))) | |
540 (optional | |
541 (list | |
542 (list (calendar-gregorian-from-absolute | |
543 (calendar-dayname-on-or-before 6 (- abs-p 43))) | |
544 "Shabbat Shekalim") | |
545 (list (calendar-gregorian-from-absolute | |
546 (calendar-dayname-on-or-before 6 (- abs-p 30))) | |
547 "Shabbat Zachor") | |
548 (list (calendar-gregorian-from-absolute | |
549 (if (= (% abs-p 7) 2) (- abs-p 33) (- abs-p 31))) | |
550 "Fast of Esther") | |
551 (list (calendar-gregorian-from-absolute (- abs-p 31)) | |
552 "Erev Purim") | |
553 (list (calendar-gregorian-from-absolute (- abs-p 30)) | |
554 "Purim") | |
555 (list (calendar-gregorian-from-absolute | |
556 (if (zerop (% abs-p 7)) (- abs-p 28) (- abs-p 29))) | |
557 "Shushan Purim") | |
558 (list (calendar-gregorian-from-absolute | |
559 (- (calendar-dayname-on-or-before 6 (- abs-p 14)) 7)) | |
560 "Shabbat Parah") | |
561 (list (calendar-gregorian-from-absolute | |
562 (calendar-dayname-on-or-before 6 (- abs-p 14))) | |
563 "Shabbat HaHodesh") | |
564 (list (calendar-gregorian-from-absolute | |
565 (calendar-dayname-on-or-before 6 (1- abs-p))) | |
566 "Shabbat HaGadol") | |
567 (list (calendar-gregorian-from-absolute (1- abs-p)) | |
568 "Erev Passover") | |
569 (list (calendar-gregorian-from-absolute (1+ abs-p)) | |
570 "Passover (second day)") | |
571 (list (calendar-gregorian-from-absolute (+ abs-p 2)) | |
572 "Hol Hamoed Passover (first day)") | |
573 (list (calendar-gregorian-from-absolute (+ abs-p 3)) | |
574 "Hol Hamoed Passover (second day)") | |
575 (list (calendar-gregorian-from-absolute (+ abs-p 4)) | |
576 "Hol Hamoed Passover (third day)") | |
577 (list (calendar-gregorian-from-absolute (+ abs-p 5)) | |
578 "Hol Hamoed Passover (fourth day)") | |
579 (list (calendar-gregorian-from-absolute (+ abs-p 6)) | |
580 "Passover (seventh day)") | |
581 (list (calendar-gregorian-from-absolute (+ abs-p 7)) | |
582 "Passover (eighth day)") | |
583 (list (calendar-gregorian-from-absolute (+ abs-p 12)) | |
584 "Yom HaShoah") | |
585 (list (calendar-gregorian-from-absolute | |
586 (if (zerop (% abs-p 7)) | |
587 (+ abs-p 18) | |
588 (if (= (% abs-p 7) 6) | |
589 (+ abs-p 19) | |
590 (+ abs-p 20)))) | |
591 "Yom HaAtzma'ut") | |
592 (list (calendar-gregorian-from-absolute (+ abs-p 33)) | |
593 "Lag BaOmer") | |
594 (list (calendar-gregorian-from-absolute (+ abs-p 43)) | |
595 "Yom Yerushalim") | |
596 (list (calendar-gregorian-from-absolute (+ abs-p 49)) | |
597 "Erev Shavuot") | |
598 (list (calendar-gregorian-from-absolute (+ abs-p 51)) | |
599 "Shavuot (second day)"))) | |
600 (output-list | |
601 (filter-visible-calendar-holidays mandatory))) | |
602 (if all-hebrew-calendar-holidays | |
603 (setq output-list | |
604 (append | |
605 (filter-visible-calendar-holidays optional) | |
606 output-list))) | |
607 output-list))) | |
608 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
609 (defun holiday-tisha-b-av-etc () |
406 | 610 "List of dates around Tisha B'Av, as visible in calendar window." |
611 (if (or (< displayed-month 5) | |
612 (> displayed-month 9)) | |
613 nil;; None of the dates is visible | |
614 (let* ((abs-t-a (calendar-absolute-from-hebrew | |
615 (list 5 9 (+ displayed-year 3760))))) | |
616 | |
617 (filter-visible-calendar-holidays | |
618 (list | |
619 (list (calendar-gregorian-from-absolute | |
620 (if (= (% abs-t-a 7) 6) (- abs-t-a 20) (- abs-t-a 21))) | |
621 "Tzom Tammuz") | |
622 (list (calendar-gregorian-from-absolute | |
623 (calendar-dayname-on-or-before 6 abs-t-a)) | |
624 "Shabbat Hazon") | |
625 (list (calendar-gregorian-from-absolute | |
626 (if (= (% abs-t-a 7) 6) (1+ abs-t-a) abs-t-a)) | |
627 "Tisha B'Av") | |
628 (list (calendar-gregorian-from-absolute | |
629 (calendar-dayname-on-or-before 6 (+ abs-t-a 7))) | |
630 "Shabbat Nahamu")))))) | |
631 | |
632 (defun filter-visible-calendar-holidays (l) | |
633 "Return a list of all visible holidays of those on L." | |
634 (let ((visible) | |
635 (p l)) | |
636 (while p | |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
637 (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
|
638 (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
|
639 (setq visible (append (list (car p)) visible))) |
406 | 640 (setq p (cdr p))) |
641 visible)) | |
584 | 642 |
643 (provide 'holidays) | |
644 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
645 ;;; holidays.el ends here |