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