Mercurial > emacs
annotate lisp/calendar/holidays.el @ 17957:06f81684d7ea
Change copyright years.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 26 May 1997 21:41:50 +0000 |
parents | 6eb7095ca7ab |
children | d179de7ad92e |
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 | |
17388
5c4602f0c45d
(list-holidays): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
17385
diff
changeset
|
104 ;;;###autoload |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
105 (defun list-holidays (y1 y2 &optional l label) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
106 "Display holidays for years Y1 to Y2 (inclusive). |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
107 |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
108 The optional list of holidays L defaults to `calendar-holidays'. See the |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
109 documentation for that variable for a description of holiday lists. |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
110 |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
111 The optional LABEL is used to label the buffer created." |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
112 (interactive |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
113 (let* ((start-year (calendar-read |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
114 "Starting year of holidays (>0): " |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
115 '(lambda (x) (> x 0)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
116 (int-to-string (extract-calendar-year |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
117 (calendar-current-date))))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
118 (end-year (calendar-read |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
119 (format "Ending year (inclusive) of holidays (>=%s): " |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
120 start-year) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
121 '(lambda (x) (>= x start-year)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
122 (int-to-string start-year))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
123 (completion-ignore-case t) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
124 (lists |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
125 (list |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
126 (cons "All" calendar-holidays) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
127 (if (fboundp 'atan) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
128 (cons "Equinoxes/Solstices" |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
129 (list (list 'solar-equinoxes-solstices)))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
130 (if general-holidays (cons "General" general-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
131 (if local-holidays (cons "Local" local-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
132 (if other-holidays (cons "Other" other-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
133 (if christian-holidays (cons "Christian" christian-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
134 (if hebrew-holidays (cons "Hebrew" hebrew-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
135 (if islamic-holidays (cons "Islamic" islamic-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
136 (if oriental-holidays (cons "Oriental" oriental-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
137 (if solar-holidays (cons "Solar" solar-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
138 (cons "Ask" nil))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
139 (choice (capitalize |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
140 (completing-read "List (TAB for choices): " lists nil t))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
141 (which (if (string-equal choice "Ask") |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
142 (eval (read-variable "Enter list name: ")) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
143 (cdr (assoc choice lists)))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
144 (name (if (string-equal choice "Equinoxes/Solstices") |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
145 choice |
17643
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
146 (if (member choice '("Ask" "")) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
147 "Holidays" |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
148 (format "%s Holidays" choice))))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
149 (list start-year end-year which name))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
150 (message "Computing holidays...") |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
151 (let* ((holiday-buffer "*Holidays*") |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
152 (calendar-holidays (if l l calendar-holidays)) |
17643
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
153 (title (or label "Holidays")) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
154 (holiday-list nil) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
155 (s (calendar-absolute-from-gregorian (list 2 1 y1))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
156 (e (calendar-absolute-from-gregorian (list 11 1 y2))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
157 (d s) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
158 (never t) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
159 (displayed-month 2) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
160 (displayed-year y1)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
161 (while (or never (<= d e)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
162 (setq holiday-list (append holiday-list (calendar-holiday-list))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
163 (setq never nil) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
164 (increment-calendar-month displayed-month displayed-year 3) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
165 (setq d (calendar-absolute-from-gregorian |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
166 (list displayed-month 1 displayed-year)))) |
17643
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
167 (save-excursion |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
168 (set-buffer (get-buffer-create holiday-buffer)) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
169 (setq buffer-read-only nil) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
170 (calendar-set-mode-line |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
171 (if (= y1 y2) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
172 (format "%s for %s" title y1) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
173 (format "%s for %s-%s" title y1 y2))) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
174 (erase-buffer) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
175 (goto-char (point-min)) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
176 (insert |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
177 (mapconcat |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
178 '(lambda (x) (concat (calendar-date-string (car x)) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
179 ": " (car (cdr x)))) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
180 holiday-list "\n")) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
181 (goto-char (point-min)) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
182 (set-buffer-modified-p nil) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
183 (setq buffer-read-only t) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
184 (display-buffer holiday-buffer) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
185 (message "Computing holidays...done")))) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
186 |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
187 |
406 | 188 (defun check-calendar-holidays (date) |
189 "Check the list of holidays for any that occur on DATE. | |
190 The value returned is a list of strings of relevant holiday descriptions. | |
191 The holidays are those in the list calendar-holidays." | |
192 (let* ((displayed-month (extract-calendar-month date)) | |
193 (displayed-year (extract-calendar-year date)) | |
194 (h (calendar-holiday-list)) | |
195 (holiday-list)) | |
196 (while h | |
197 (if (calendar-date-equal date (car (car h))) | |
198 (setq holiday-list (append holiday-list (cdr (car h))))) | |
199 (setq h (cdr h))) | |
200 holiday-list)) | |
201 | |
202 (defun calendar-cursor-holidays () | |
203 "Find holidays for the date specified by the cursor in the calendar window." | |
204 (interactive) | |
205 (message "Checking holidays...") | |
5831
7a4647230b22
(calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents:
5696
diff
changeset
|
206 (let* ((date (calendar-cursor-to-date t)) |
406 | 207 (date-string (calendar-date-string date)) |
208 (holiday-list (check-calendar-holidays date)) | |
209 (holiday-string (mapconcat 'identity holiday-list "; ")) | |
210 (msg (format "%s: %s" date-string holiday-string))) | |
211 (if (not holiday-list) | |
212 (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
|
213 (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
|
214 (message "%s" msg) |
406 | 215 (set-buffer (get-buffer-create holiday-buffer)) |
216 (setq buffer-read-only nil) | |
957 | 217 (calendar-set-mode-line date-string) |
406 | 218 (erase-buffer) |
219 (insert (mapconcat 'identity holiday-list "\n")) | |
220 (goto-char (point-min)) | |
221 (set-buffer-modified-p nil) | |
222 (setq buffer-read-only t) | |
223 (display-buffer holiday-buffer) | |
224 (message "Checking holidays...done"))))) | |
225 | |
226 (defun mark-calendar-holidays () | |
227 "Mark notable days in the calendar window." | |
228 (interactive) | |
229 (setq mark-holidays-in-calendar t) | |
230 (message "Marking holidays...") | |
231 (let ((holiday-list (calendar-holiday-list))) | |
232 (while holiday-list | |
233 (mark-visible-calendar-date | |
234 (car (car holiday-list)) calendar-holiday-marker) | |
235 (setq holiday-list (cdr holiday-list)))) | |
236 (message "Marking holidays...done")) | |
237 | |
238 (defun list-calendar-holidays () | |
239 "Create a buffer containing the holidays for the current calendar window. | |
240 The holidays are those in the list calendar-notable-days. Returns t if any | |
241 holidays are found, nil if not." | |
242 (interactive) | |
243 (message "Looking up holidays...") | |
244 (let ((holiday-list (calendar-holiday-list)) | |
245 (m1 displayed-month) | |
246 (y1 displayed-year) | |
247 (m2 displayed-month) | |
248 (y2 displayed-year)) | |
249 (if (not holiday-list) | |
250 (progn | |
251 (message "Looking up holidays...none found") | |
252 nil) | |
253 (set-buffer (get-buffer-create holiday-buffer)) | |
254 (setq buffer-read-only nil) | |
255 (increment-calendar-month m1 y1 -1) | |
256 (increment-calendar-month m2 y2 1) | |
957 | 257 (calendar-set-mode-line |
5696
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
258 (if (= y1 y2) |
baab03aaf3b9
(list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents:
4864
diff
changeset
|
259 (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
|
260 (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
|
261 (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
|
262 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) |
406 | 263 (erase-buffer) |
264 (insert | |
265 (mapconcat | |
266 '(lambda (x) (concat (calendar-date-string (car x)) | |
267 ": " (car (cdr x)))) | |
268 holiday-list "\n")) | |
269 (goto-char (point-min)) | |
270 (set-buffer-modified-p nil) | |
271 (setq buffer-read-only t) | |
272 (display-buffer holiday-buffer) | |
273 (message "Looking up holidays...done") | |
274 t))) | |
275 | |
276 (defun calendar-holiday-list () | |
277 "Form the list of holidays that occur on dates in the calendar window. | |
278 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
|
279 (let ((p calendar-holidays) |
406 | 280 (holiday-list)) |
281 (while p | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
282 (let* ((holidays |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
283 (if calendar-debug-sexp |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
284 (let ((stack-trace-on-error t)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
285 (eval (car p))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
286 (condition-case nil |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
287 (eval (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
288 (error (beep) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
289 (message "Bad holiday list item: %s" (car p)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
290 (sleep-for 2)))))) |
406 | 291 (if holidays |
292 (setq holiday-list (append holidays holiday-list)))) | |
293 (setq p (cdr p))) | |
294 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) | |
295 | |
296 ;; 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
|
297 ;; 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
|
298 ;; 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
|
299 ;; 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
|
300 ;; ((month day year) string) of VISIBLE dates in the calendar window. |
406 | 301 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
302 (defun holiday-fixed (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
303 "Holiday on MONTH, DAY (Gregorian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
304 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
|
305 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
|
306 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
307 (y displayed-year)) |
406 | 308 (increment-calendar-month m y (- 11 month)) |
309 (if (> m 9) | |
310 (list (list (list month day y) string))))) | |
311 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
312 (defun holiday-float (month dayname n string &optional day) |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
313 "Holiday on MONTH, DAYNAME (Nth occurrence) called STRING. |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
314 If the Nth DAYNAME in MONTH is visible, the value returned is the list |
7639 | 315 \(((MONTH DAY year) STRING)). |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
316 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
317 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
|
318 |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
319 An optional parameter DAY means the Nth DAYNAME on or after/before MONTH DAY. |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
320 |
406 | 321 Returns nil if it is not visible in the current calendar window." |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
322 ;; This is messy because the holiday may be visible, while the date on which |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
323 ;; it is based is not. For example, the first Monday after December 30 may be |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
324 ;; visible when January is not. For large values of |n| the problem is more |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
325 ;; grotesque. If we didn't have to worry about such cases, we could just use |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
326 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
327 ;; (let ((m displayed-month) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
328 ;; (y displayed-year)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
329 ;; (increment-calendar-month m y (- 11 month)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
330 ;; (if (> m 9); month in year y is visible |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
331 ;; (list (list (calendar-nth-named-day n dayname month y day) string))))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
332 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
333 ;; which is the way the function was originally written. |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
334 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
335 (let* ((m1 displayed-month) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
336 (y1 displayed-year) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
337 (m2 m1) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
338 (y2 y1)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
339 (increment-calendar-month m1 y1 -1) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
340 (increment-calendar-month m2 y2 1) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
341 (let* ((d1; first possible base date for holiday |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
342 (+ (calendar-nth-named-absday 1 dayname m1 y1) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
343 (* -7 n) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
344 (if (> n 0) 1 -7))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
345 (d2; last possible base date for holiday |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
346 (+ (calendar-nth-named-absday -1 dayname m2 y2) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
347 (* -7 n) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
348 (if (> n 0) 7 -1))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
349 (y1 (extract-calendar-year (calendar-gregorian-from-absolute d1))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
350 (y2 (extract-calendar-year (calendar-gregorian-from-absolute d2))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
351 (y; year of base date |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
352 (if (or (= y1 y2) (> month 9)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
353 y1 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
354 y2)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
355 (d; day of base date |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
356 (or day (if (> n 0) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
357 1 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
358 (calendar-last-day-of-month month y)))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
359 (date; base date for holiday |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
360 (calendar-absolute-from-gregorian (list month d y)))) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
361 (if (and (<= d1 date) (<= date d2)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
362 (list (list (calendar-nth-named-day n dayname month y d) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
363 string)))))) |
406 | 364 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
365 (defun holiday-sexp (sexp string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
366 "Sexp holiday for dates in the calendar window. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
367 SEXP is an expression in variable `year' evaluates to `date'. |
406 | 368 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
369 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
|
370 of `date'. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
371 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
372 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
|
373 date. If date is nil, or if the date is not visible, there is no holiday." |
957 | 374 (let ((m displayed-month) |
375 (y displayed-year)) | |
376 (increment-calendar-month m y -1) | |
377 (filter-visible-calendar-holidays | |
378 (append | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
379 (let* ((year y) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
380 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
381 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
382 (list (list date string))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
383 (let* ((year (1+ y)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
384 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
385 (string (if date (eval string)))) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
386 (list (list date string))))))) |
957 | 387 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
388 (defun holiday-advent () |
406 | 389 "Date of Advent, if visible in calendar window." |
390 (let ((year displayed-year) | |
391 (month displayed-month)) | |
392 (increment-calendar-month month year -1) | |
393 (let ((advent (calendar-gregorian-from-absolute | |
394 (calendar-dayname-on-or-before 0 | |
395 (calendar-absolute-from-gregorian | |
396 (list 12 3 year)))))) | |
397 (if (calendar-date-is-visible-p advent) | |
398 (list (list advent "Advent")))))) | |
399 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
400 (defun holiday-easter-etc () |
406 | 401 "List of dates related to Easter, as visible in calendar window." |
402 (if (and (> displayed-month 5) (not all-christian-calendar-holidays)) | |
403 nil;; Ash Wednesday, Good Friday, and Easter are not visible. | |
404 (let* ((century (1+ (/ displayed-year 100))) | |
405 (shifted-epact ;; Age of moon for April 5... | |
406 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule | |
407 (- ;; ...corrected for the Gregorian century rule | |
408 (/ (* 3 century) 4)) | |
409 (/ ;; ...corrected for Metonic cycle inaccuracy. | |
410 (+ 5 (* 8 century)) 25) | |
411 (* 30 century));; Keeps value positive. | |
412 30)) | |
413 (adjusted-epact ;; Adjust for 29.5 day month. | |
414 (if (or (= shifted-epact 0) | |
415 (and (= shifted-epact 1) (< 10 (% displayed-year 19)))) | |
416 (1+ shifted-epact) | |
417 shifted-epact)) | |
418 (paschal-moon ;; Day after the full moon on or after March 21. | |
419 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year)) | |
420 adjusted-epact)) | |
421 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))) | |
422 (mandatory | |
423 (list | |
424 (list (calendar-gregorian-from-absolute abs-easter) | |
425 "Easter Sunday") | |
426 (list (calendar-gregorian-from-absolute (- abs-easter 2)) | |
427 "Good Friday") | |
428 (list (calendar-gregorian-from-absolute (- abs-easter 46)) | |
429 "Ash Wednesday"))) | |
430 (optional | |
431 (list | |
432 (list (calendar-gregorian-from-absolute (- abs-easter 63)) | |
433 "Septuagesima Sunday") | |
434 (list (calendar-gregorian-from-absolute (- abs-easter 56)) | |
435 "Sexagesima Sunday") | |
436 (list (calendar-gregorian-from-absolute (- abs-easter 49)) | |
437 "Shrove Sunday") | |
438 (list (calendar-gregorian-from-absolute (- abs-easter 48)) | |
439 "Shrove Monday") | |
440 (list (calendar-gregorian-from-absolute (- abs-easter 47)) | |
441 "Shrove Tuesday") | |
442 (list (calendar-gregorian-from-absolute (- abs-easter 14)) | |
443 "Passion Sunday") | |
444 (list (calendar-gregorian-from-absolute (- abs-easter 7)) | |
445 "Palm Sunday") | |
446 (list (calendar-gregorian-from-absolute (- abs-easter 3)) | |
447 "Maundy Thursday") | |
448 (list (calendar-gregorian-from-absolute (+ abs-easter 35)) | |
449 "Rogation Sunday") | |
450 (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
|
451 "Ascension Day") |
406 | 452 (list (calendar-gregorian-from-absolute (+ abs-easter 49)) |
453 "Pentecost (Whitsunday)") | |
454 (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
|
455 "Whitmonday") |
406 | 456 (list (calendar-gregorian-from-absolute (+ abs-easter 56)) |
457 "Trinity Sunday") | |
458 (list (calendar-gregorian-from-absolute (+ abs-easter 60)) | |
459 "Corpus Christi"))) | |
460 (output-list | |
461 (filter-visible-calendar-holidays mandatory))) | |
462 (if all-christian-calendar-holidays | |
463 (setq output-list | |
464 (append | |
465 (filter-visible-calendar-holidays optional) | |
466 output-list))) | |
467 output-list))) | |
468 | |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
469 (defun holiday-greek-orthodox-easter () |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
470 "Date of Easter according to the rule of the Council of Nicaea." |
957 | 471 (let ((m displayed-month) |
472 (y displayed-year)) | |
473 (increment-calendar-month m y 1) | |
474 (let* ((julian-year | |
475 (extract-calendar-year | |
476 (calendar-julian-from-absolute | |
477 (calendar-absolute-from-gregorian | |
478 (list m (calendar-last-day-of-month m y) y))))) | |
479 (shifted-epact ;; Age of moon for April 5. | |
480 (% (+ 14 | |
481 (* 11 (% julian-year 19))) | |
482 30)) | |
483 (paschal-moon ;; Day after full moon on or after March 21. | |
484 (- (calendar-absolute-from-julian (list 4 19 julian-year)) | |
485 shifted-epact)) | |
486 (nicaean-easter;; Sunday following the Paschal moon | |
487 (calendar-gregorian-from-absolute | |
488 (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) | |
489 (if (calendar-date-is-visible-p nicaean-easter) | |
490 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))) | |
491 | |
406 | 492 (defun filter-visible-calendar-holidays (l) |
493 "Return a list of all visible holidays of those on L." | |
494 (let ((visible) | |
495 (p l)) | |
496 (while p | |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
497 (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
|
498 (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
|
499 (setq visible (append (list (car p)) visible))) |
406 | 500 (setq p (cdr p))) |
501 visible)) | |
584 | 502 |
503 (provide 'holidays) | |
504 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
505 ;;; holidays.el ends here |