Mercurial > emacs
annotate lisp/calendar/holidays.el @ 15456:64addbeb9e96
(LD_SWITCH_SYSTEM): Use no space after -L and -R.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 19 Jun 1996 21:15:58 +0000 |
parents | 0d4ff7e4d6a3 |
children | 259d4c9aae0e |
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 |
14169 | 3 ;; Copyright (C) 1989, 1990, 1992, 1993, 1994 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 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
13 ;; any later version. |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
14 |
406 | 15 ;; GNU Emacs is distributed in the hope that it will be useful, |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
18 ;; GNU General Public License for more details. |
406 | 19 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5831
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
406 | 24 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
25 ;;; Commentary: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
26 |
406 | 27 ;; This collection of functions implements the holiday features as described |
28 ;; in calendar.el. | |
29 | |
30 ;; Comments, corrections, and improvements should be sent to | |
31 ;; Edward M. Reingold Department of Computer Science | |
32 ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
33 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
34 ;; Urbana, Illinois 61801 | |
35 | |
36 ;; Technical details of all the calendrical calculations can be found in | |
37 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, | |
38 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990), | |
957 | 39 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical |
40 ;; 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
|
41 ;; 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
|
42 ;; pages 383-404. |
957 | 43 |
44 ;; Hard copies of these two papers can be obtained by sending email to | |
45 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and | |
46 ;; the message BODY containing your mailing address (snail). | |
406 | 47 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
48 ;;; Code: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
49 |
406 | 50 (require 'calendar) |
732 | 51 |
13043
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
52 (autoload 'holiday-julian "cal-julian" |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
53 "Holiday on MONTH, DAY (Julian) called STRING." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
54 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
55 |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
56 (autoload 'holiday-hebrew "cal-hebrew" |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
57 "Holiday on MONTH, DAY (Hebrew) called STRING." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
58 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
59 |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
60 (autoload 'holiday-rosh-hashanah-etc "cal-hebrew" |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
61 "List of dates related to Rosh Hashanah, as visible in calendar window." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
62 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
63 |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
64 (autoload 'holiday-hanukkah "cal-hebrew" |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
65 "List of dates related to Hanukkah, as visible in calendar window." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
66 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
67 |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
68 (autoload 'holiday-passover-etc "cal-hebrew" |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
69 "List of dates related to Passover, as visible in calendar window." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
70 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
71 |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
72 (autoload 'holiday-tisha-b-av-etc "cal-hebrew" |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
73 "List of dates around Tisha B'Av, as visible in calendar window." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
74 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
75 |
14687
0d4ff7e4d6a3
Use the new file names in autoloads.
Karl Heuer <kwzh@gnu.org>
parents:
14318
diff
changeset
|
76 (autoload 'holiday-islamic "cal-islam" |
13043
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
77 "Holiday on MONTH, DAY (Islamic) called STRING." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
78 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
79 |
14687
0d4ff7e4d6a3
Use the new file names in autoloads.
Karl Heuer <kwzh@gnu.org>
parents:
14318
diff
changeset
|
80 (autoload 'holiday-chinese-new-year "cal-china" |
13043
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
81 "Date of Chinese New Year." |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
82 t) |
2072d3ab4119
Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
9712
diff
changeset
|
83 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
84 (autoload 'solar-equinoxes-solstices "solar" |
957 | 85 "Date and time of equinoxes and solstices, if visible in the calendar window. |
86 Requires floating point." | |
87 t) | |
88 | |
89 (defun holidays (&optional arg) | |
406 | 90 "Display the holidays for last month, this month, and next month. |
957 | 91 If called with an optional prefix argument, prompts for month and year. |
92 | |
406 | 93 This function is suitable for execution in a .emacs file." |
957 | 94 (interactive "P") |
406 | 95 (save-excursion |
957 | 96 (let* ((completion-ignore-case t) |
9712
275845a98fa8
Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7639
diff
changeset
|
97 (date (if arg |
275845a98fa8
Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7639
diff
changeset
|
98 (calendar-read-date t) |
275845a98fa8
Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7639
diff
changeset
|
99 (calendar-current-date))) |
275845a98fa8
Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7639
diff
changeset
|
100 (displayed-month (extract-calendar-month date)) |
275845a98fa8
Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7639
diff
changeset
|
101 (displayed-year (extract-calendar-year date))) |
406 | 102 (list-calendar-holidays)))) |
103 | |
104 (defun check-calendar-holidays (date) | |
105 "Check the list of holidays for any that occur on DATE. | |
106 The value returned is a list of strings of relevant holiday descriptions. | |
107 The holidays are those in the list calendar-holidays." | |
108 (let* ((displayed-month (extract-calendar-month date)) | |
109 (displayed-year (extract-calendar-year date)) | |
110 (h (calendar-holiday-list)) | |
111 (holiday-list)) | |
112 (while h | |
113 (if (calendar-date-equal date (car (car h))) | |
114 (setq holiday-list (append holiday-list (cdr (car h))))) | |
115 (setq h (cdr h))) | |
116 holiday-list)) | |
117 | |
118 (defun calendar-cursor-holidays () | |
119 "Find holidays for the date specified by the cursor in the calendar window." | |
120 (interactive) | |
121 (message "Checking holidays...") | |
5831
7a4647230b22
(calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents:
5696
diff
changeset
|
122 (let* ((date (calendar-cursor-to-date t)) |
406 | 123 (date-string (calendar-date-string date)) |
124 (holiday-list (check-calendar-holidays date)) | |
125 (holiday-string (mapconcat 'identity holiday-list "; ")) | |
126 (msg (format "%s: %s" date-string holiday-string))) | |
127 (if (not holiday-list) | |
128 (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
|
129 (if (<= (length msg) (frame-width)) |
14318
faae84d059c1
(calendar-cursor-holidays): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
130 (message "%s" msg) |
406 | 131 (set-buffer (get-buffer-create holiday-buffer)) |
132 (setq buffer-read-only nil) | |
957 | 133 (calendar-set-mode-line date-string) |
406 | 134 (erase-buffer) |
135 (insert (mapconcat 'identity holiday-list "\n")) | |
136 (goto-char (point-min)) | |
137 (set-buffer-modified-p nil) | |
138 (setq buffer-read-only t) | |
139 (display-buffer holiday-buffer) | |
140 (message "Checking holidays...done"))))) | |
141 | |
142 (defun mark-calendar-holidays () | |
143 "Mark notable days in the calendar window." | |
144 (interactive) | |
145 (setq mark-holidays-in-calendar t) | |
146 (message "Marking holidays...") | |
147 (let ((holiday-list (calendar-holiday-list))) | |
148 (while holiday-list | |
149 (mark-visible-calendar-date | |
150 (car (car holiday-list)) calendar-holiday-marker) | |
151 (setq holiday-list (cdr holiday-list)))) | |
152 (message "Marking holidays...done")) | |
153 | |
154 (defun list-calendar-holidays () | |
155 "Create a buffer containing the holidays for the current calendar window. | |
156 The holidays are those in the list calendar-notable-days. Returns t if any | |
157 holidays are found, nil if not." | |
158 (interactive) | |
159 (message "Looking up holidays...") | |
160 (let ((holiday-list (calendar-holiday-list)) | |
161 (m1 displayed-month) | |
162 (y1 displayed-year) | |
163 (m2 displayed-month) | |
164 (y2 displayed-year)) | |
165 (if (not holiday-list) | |
166 (progn | |
167 (message "Looking up holidays...none found") | |
168 nil) | |
169 (set-buffer (get-buffer-create holiday-buffer)) | |
170 (setq buffer-read-only nil) | |
171 (increment-calendar-month m1 y1 -1) | |
172 (increment-calendar-month m2 y2 1) | |
957 | 173 (calendar-set-mode-line |
5696
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
174 (if (= y1 y2) |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
175 (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
|
176 (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
|
177 (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
|
178 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) |
406 | 179 (erase-buffer) |
180 (insert | |
181 (mapconcat | |
182 '(lambda (x) (concat (calendar-date-string (car x)) | |
183 ": " (car (cdr x)))) | |
184 holiday-list "\n")) | |
185 (goto-char (point-min)) | |
186 (set-buffer-modified-p nil) | |
187 (setq buffer-read-only t) | |
188 (display-buffer holiday-buffer) | |
189 (message "Looking up holidays...done") | |
190 t))) | |
191 | |
192 (defun calendar-holiday-list () | |
193 "Form the list of holidays that occur on dates in the calendar window. | |
194 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
|
195 (let ((p calendar-holidays) |
406 | 196 (holiday-list)) |
197 (while p | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
198 (let* ((holidays |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
199 (if calendar-debug-sexp |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
200 (let ((stack-trace-on-error t)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
201 (eval (car p))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
202 (condition-case nil |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
203 (eval (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
204 (error (beep) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
205 (message "Bad holiday list item: %s" (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
206 (sleep-for 2)))))) |
406 | 207 (if holidays |
208 (setq holiday-list (append holidays holiday-list)))) | |
209 (setq p (cdr p))) | |
210 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) | |
211 | |
212 ;; 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
|
213 ;; 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
|
214 ;; 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
|
215 ;; 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
|
216 ;; ((month day year) string) of VISIBLE dates in the calendar window. |
406 | 217 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
218 (defun holiday-fixed (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
219 "Holiday on MONTH, DAY (Gregorian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
220 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
|
221 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
|
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) | |
226 (list (list (list month day y) string))))) | |
227 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
228 (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
|
229 "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
|
230 If the Nth DAYNAME in MONTH is visible, the value returned is the list |
7639 | 231 \(((MONTH DAY year) STRING)). |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
232 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
233 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
|
234 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
235 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
|
236 |
406 | 237 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
|
238 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
239 (y displayed-year)) |
406 | 240 (increment-calendar-month m y (- 11 month)) |
241 (if (> m 9) | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
242 (list (list (calendar-nth-named-day n dayname month y day) string))))) |
406 | 243 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
244 (defun holiday-sexp (sexp string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
245 "Sexp holiday for dates in the calendar window. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
246 SEXP is an expression in variable `year' evaluates to `date'. |
406 | 247 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
248 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
|
249 of `date'. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
250 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
251 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
|
252 date. If date is nil, or if the date is not visible, there is no holiday." |
957 | 253 (let ((m displayed-month) |
254 (y displayed-year)) | |
255 (increment-calendar-month m y -1) | |
256 (filter-visible-calendar-holidays | |
257 (append | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
258 (let* ((year y) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
259 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
260 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
261 (list (list date string))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
262 (let* ((year (1+ y)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
263 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
264 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
265 (list (list date string))))))) |
957 | 266 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
267 (defun holiday-advent () |
406 | 268 "Date of Advent, if visible in calendar window." |
269 (let ((year displayed-year) | |
270 (month displayed-month)) | |
271 (increment-calendar-month month year -1) | |
272 (let ((advent (calendar-gregorian-from-absolute | |
273 (calendar-dayname-on-or-before 0 | |
274 (calendar-absolute-from-gregorian | |
275 (list 12 3 year)))))) | |
276 (if (calendar-date-is-visible-p advent) | |
277 (list (list advent "Advent")))))) | |
278 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
279 (defun holiday-easter-etc () |
406 | 280 "List of dates related to Easter, as visible in calendar window." |
281 (if (and (> displayed-month 5) (not all-christian-calendar-holidays)) | |
282 nil;; Ash Wednesday, Good Friday, and Easter are not visible. | |
283 (let* ((century (1+ (/ displayed-year 100))) | |
284 (shifted-epact ;; Age of moon for April 5... | |
285 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule | |
286 (- ;; ...corrected for the Gregorian century rule | |
287 (/ (* 3 century) 4)) | |
288 (/ ;; ...corrected for Metonic cycle inaccuracy. | |
289 (+ 5 (* 8 century)) 25) | |
290 (* 30 century));; Keeps value positive. | |
291 30)) | |
292 (adjusted-epact ;; Adjust for 29.5 day month. | |
293 (if (or (= shifted-epact 0) | |
294 (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) | |
295 (1+ shifted-epact) | |
296 shifted-epact)) | |
297 (paschal-moon ;; Day after the full moon on or after March 21. | |
298 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) | |
299 adjusted-epact)) | |
300 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) | |
301 (mandatory | |
302 (list | |
303 (list (calendar-gregorian-from-absolute abs-easter) | |
304 "Easter Sunday") | |
305 (list (calendar-gregorian-from-absolute (- abs-easter 2)) | |
306 "Good Friday") | |
307 (list (calendar-gregorian-from-absolute (- abs-easter 46)) | |
308 "Ash Wednesday"))) | |
309 (optional | |
310 (list | |
311 (list (calendar-gregorian-from-absolute (- abs-easter 63)) | |
312 "Septuagesima Sunday") | |
313 (list (calendar-gregorian-from-absolute (- abs-easter 56)) | |
314 "Sexagesima Sunday") | |
315 (list (calendar-gregorian-from-absolute (- abs-easter 49)) | |
316 "Shrove Sunday") | |
317 (list (calendar-gregorian-from-absolute (- abs-easter 48)) | |
318 "Shrove Monday") | |
319 (list (calendar-gregorian-from-absolute (- abs-easter 47)) | |
320 "Shrove Tuesday") | |
321 (list (calendar-gregorian-from-absolute (- abs-easter 14)) | |
322 "Passion Sunday") | |
323 (list (calendar-gregorian-from-absolute (- abs-easter 7)) | |
324 "Palm Sunday") | |
325 (list (calendar-gregorian-from-absolute (- abs-easter 3)) | |
326 "Maundy Thursday") | |
327 (list (calendar-gregorian-from-absolute (+ abs-easter 35)) | |
328 "Rogation Sunday") | |
329 (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
|
330 "Ascension Day") |
406 | 331 (list (calendar-gregorian-from-absolute (+ abs-easter 49)) |
332 "Pentecost (Whitsunday)") | |
333 (list (calendar-gregorian-from-absolute (+ abs-easter 50)) | |
13669
e411b827878f
(holiday-easter-etc): Fix misspelling of "Whitmonday".
Paul Eggert <eggert@twinsun.com>
parents:
13043
diff
changeset
|
334 "Whitmonday") |
406 | 335 (list (calendar-gregorian-from-absolute (+ abs-easter 56)) |
336 "Trinity Sunday") | |
337 (list (calendar-gregorian-from-absolute (+ abs-easter 60)) | |
338 "Corpus Christi"))) | |
339 (output-list | |
340 (filter-visible-calendar-holidays mandatory))) | |
341 (if all-christian-calendar-holidays | |
342 (setq output-list | |
343 (append | |
344 (filter-visible-calendar-holidays optional) | |
345 output-list))) | |
346 output-list))) | |
347 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
348 (defun holiday-greek-orthodox-easter () |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
349 "Date of Easter according to the rule of the Council of Nicaea." |
957 | 350 (let ((m displayed-month) |
351 (y displayed-year)) | |
352 (increment-calendar-month m y 1) | |
353 (let* ((julian-year | |
354 (extract-calendar-year | |
355 (calendar-julian-from-absolute | |
356 (calendar-absolute-from-gregorian | |
357 (list m (calendar-last-day-of-month m y) y))))) | |
358 (shifted-epact ;; Age of moon for April 5. | |
359 (% (+ 14 | |
360 (* 11 (% julian-year 19))) | |
361 30)) | |
362 (paschal-moon ;; Day after full moon on or after March 21. | |
363 (- (calendar-absolute-from-julian (list 4 19 julian-year)) | |
364 shifted-epact)) | |
365 (nicaean-easter;; Sunday following the Paschal moon | |
366 (calendar-gregorian-from-absolute | |
367 (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) | |
368 (if (calendar-date-is-visible-p nicaean-easter) | |
369 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))) | |
370 | |
406 | 371 (defun filter-visible-calendar-holidays (l) |
372 "Return a list of all visible holidays of those on L." | |
373 (let ((visible) | |
374 (p l)) | |
375 (while p | |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
376 (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
|
377 (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
|
378 (setq visible (append (list (car p)) visible))) |
406 | 379 (setq p (cdr p))) |
380 visible)) | |
584 | 381 |
382 (provide 'holidays) | |
383 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
384 ;;; holidays.el ends here |