annotate lisp/calendar/holidays.el @ 37631:00c265302412

(holidays): Add an autoload cookie. From Pavel Jank <Pavel@Janik.cz>.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 09 May 2001 15:11:07 +0000
parents 69ed032fdcce
children 0d8b17d428b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
3 ;; Copyright (C) 1989, 90, 92, 93, 94, 1997 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
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
6 ;; Keywords: holidays, calendar
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
7
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13669
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13669
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13669
diff changeset
23 ;; Boston, MA 02111-1307, USA.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 ;; This collection of functions implements the holiday features as described
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;; in calendar.el.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
30 ;; Technical details of all the calendrical calculations can be found in
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
31 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
32 ;; Cambridge University Press (1997).
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
34 ;; An earlier version of the technical details appeared in
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
37 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
38 ;; 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
39 ;; 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
40 ;; pages 383-404.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
41
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
42 ;; Hard copies of these two papers can be obtained by sending email to
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
43 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
44 ;; the message BODY containing your mailing address (snail).
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
46 ;; Comments, corrections, and improvements should be sent to
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
47 ;; Edward M. Reingold Department of Computer Science
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
48 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
49 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
50 ;; Urbana, Illinois 61801
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
51
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
52 ;;; Code:
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
53
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (require 'calendar)
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 660
diff changeset
55
13043
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
56 (autoload 'holiday-julian "cal-julian"
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
57 "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
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-hebrew "cal-hebrew"
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
61 "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
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-rosh-hashanah-etc "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 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
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-hanukkah "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 Hanukkah, 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-passover-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 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
74 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
75
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
76 (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
77 "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
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-islamic "cal-islam"
13043
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
81 "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
82 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
83
14687
0d4ff7e4d6a3 Use the new file names in autoloads.
Karl Heuer <kwzh@gnu.org>
parents: 14318
diff changeset
84 (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
85 "Date of Chinese New Year."
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
86 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
87
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
88 (autoload 'solar-equinoxes-solstices "solar"
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
89 "Date and time of equinoxes and solstices, if visible in the calendar window.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
90 Requires floating point."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
91 t)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
92
37631
00c265302412 (holidays): Add an autoload cookie. From Pavel Jank <Pavel@Janik.cz>.
Eli Zaretskii <eliz@gnu.org>
parents: 37001
diff changeset
93 ;;;###autoload
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
94 (defun holidays (&optional arg)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 "Display the holidays for last month, this month, and next month.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
96 If called with an optional prefix argument, prompts for month and year.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
97
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 This function is suitable for execution in a .emacs file."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
99 (interactive "P")
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (save-excursion
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
101 (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
102 (date (if arg
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
103 (calendar-read-date t)
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
104 (calendar-current-date)))
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
105 (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
106 (displayed-year (extract-calendar-year date)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (list-calendar-holidays))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108
17388
5c4602f0c45d (list-holidays): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 17385
diff changeset
109 ;;;###autoload
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
110 (defun list-holidays (y1 y2 &optional l label)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
111 "Display holidays for years Y1 to Y2 (inclusive).
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
112
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
113 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
114 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
115
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
116 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
117 (interactive
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
118 (let* ((start-year (calendar-read
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
119 "Starting year of holidays (>0): "
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
120 '(lambda (x) (> x 0))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
121 (int-to-string (extract-calendar-year
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
122 (calendar-current-date)))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
123 (end-year (calendar-read
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
124 (format "Ending year (inclusive) of holidays (>=%s): "
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
125 start-year)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
126 '(lambda (x) (>= x start-year))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
127 (int-to-string start-year)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
128 (completion-ignore-case t)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
129 (lists
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
130 (list
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
131 (cons "All" calendar-holidays)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
132 (if (fboundp 'atan)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
133 (cons "Equinoxes/Solstices"
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
134 (list (list 'solar-equinoxes-solstices))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
135 (if general-holidays (cons "General" general-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
136 (if local-holidays (cons "Local" local-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
137 (if other-holidays (cons "Other" other-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
138 (if christian-holidays (cons "Christian" christian-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
139 (if hebrew-holidays (cons "Hebrew" hebrew-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
140 (if islamic-holidays (cons "Islamic" islamic-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
141 (if oriental-holidays (cons "Oriental" oriental-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
142 (if solar-holidays (cons "Solar" solar-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
143 (cons "Ask" nil)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
144 (choice (capitalize
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
145 (completing-read "List (TAB for choices): " lists nil t)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
146 (which (if (string-equal choice "Ask")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
147 (eval (read-variable "Enter list name: "))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
148 (cdr (assoc choice lists))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
149 (name (if (string-equal choice "Equinoxes/Solstices")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
150 choice
17643
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
151 (if (member choice '("Ask" ""))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
152 "Holidays"
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
153 (format "%s Holidays" choice)))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
154 (list start-year end-year which name)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
155 (message "Computing holidays...")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
156 (let* ((holiday-buffer "*Holidays*")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
157 (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
158 (title (or label "Holidays"))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
159 (holiday-list nil)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
160 (s (calendar-absolute-from-gregorian (list 2 1 y1)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
161 (e (calendar-absolute-from-gregorian (list 11 1 y2)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
162 (d s)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
163 (never t)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
164 (displayed-month 2)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
165 (displayed-year y1))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
166 (while (or never (<= d e))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
167 (setq holiday-list (append holiday-list (calendar-holiday-list)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
168 (setq never nil)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
169 (increment-calendar-month displayed-month displayed-year 3)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
170 (setq d (calendar-absolute-from-gregorian
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
171 (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
172 (save-excursion
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
173 (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
174 (setq buffer-read-only nil)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
175 (calendar-set-mode-line
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
176 (if (= y1 y2)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
177 (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
178 (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
179 (erase-buffer)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
180 (goto-char (point-min))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
181 (insert
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
182 (mapconcat
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
183 '(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
184 ": " (car (cdr x))))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
185 holiday-list "\n"))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
186 (goto-char (point-min))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
187 (set-buffer-modified-p nil)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
188 (setq buffer-read-only t)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
189 (display-buffer holiday-buffer)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
190 (message "Computing holidays...done"))))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
191
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
192
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (defun check-calendar-holidays (date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 "Check the list of holidays for any that occur on DATE.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 The value returned is a list of strings of relevant holiday descriptions.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 The holidays are those in the list calendar-holidays."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (let* ((displayed-month (extract-calendar-month date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (displayed-year (extract-calendar-year date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (h (calendar-holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (while h
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (if (calendar-date-equal date (car (car h)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (setq holiday-list (append holiday-list (cdr (car h)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (setq h (cdr h)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (defun calendar-cursor-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 "Find holidays for the date specified by the cursor in the calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (message "Checking holidays...")
5831
7a4647230b22 (calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents: 5696
diff changeset
211 (let* ((date (calendar-cursor-to-date t))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (date-string (calendar-date-string date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (holiday-list (check-calendar-holidays date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (holiday-string (mapconcat 'identity holiday-list "; "))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (msg (format "%s: %s" date-string holiday-string)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (if (not holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (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
218 (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
219 (message "%s" msg)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (set-buffer (get-buffer-create holiday-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (setq buffer-read-only nil)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
222 (calendar-set-mode-line date-string)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (insert (mapconcat 'identity holiday-list "\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (display-buffer holiday-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (message "Checking holidays...done")))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (defun mark-calendar-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 "Mark notable days in the calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (setq mark-holidays-in-calendar t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (message "Marking holidays...")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (let ((holiday-list (calendar-holiday-list)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (while holiday-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (mark-visible-calendar-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (car (car holiday-list)) calendar-holiday-marker)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (setq holiday-list (cdr holiday-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (message "Marking holidays...done"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (defun list-calendar-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 "Create a buffer containing the holidays for the current calendar window.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 The holidays are those in the list calendar-notable-days. Returns t if any
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 holidays are found, nil if not."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (message "Looking up holidays...")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (let ((holiday-list (calendar-holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (m1 displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (y1 displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (m2 displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (y2 displayed-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (if (not holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (progn
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (message "Looking up holidays...none found")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (set-buffer (get-buffer-create holiday-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (setq buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (increment-calendar-month m1 y1 -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (increment-calendar-month m2 y2 1)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
262 (calendar-set-mode-line
5696
baab03aaf3b9 (list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents: 4864
diff changeset
263 (if (= y1 y2)
baab03aaf3b9 (list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents: 4864
diff changeset
264 (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
265 (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
266 (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
267 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (insert
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (mapconcat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 '(lambda (x) (concat (calendar-date-string (car x))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 ": " (car (cdr x))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 holiday-list "\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (display-buffer holiday-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (message "Looking up holidays...done")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 t)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (defun calendar-holiday-list ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 "Form the list of holidays that occur on dates in the calendar window.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 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
284 (let ((p calendar-holidays)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (while p
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
287 (let* ((holidays
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
288 (if calendar-debug-sexp
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
289 (let ((stack-trace-on-error t))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
290 (eval (car p)))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
291 (condition-case nil
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
292 (eval (car p))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
293 (error (beep)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
294 (message "Bad holiday list item: %s" (car p))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
295 (sleep-for 2))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (if holidays
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (setq holiday-list (append holidays holiday-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (setq p (cdr p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (setq holiday-list (sort holiday-list 'calendar-date-compare))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 ;; 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
302 ;; 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
303 ;; 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
304 ;; 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
305 ;; ((month day year) string) of VISIBLE dates in the calendar window.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
307 (defun holiday-fixed (month day string)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
308 "Holiday on MONTH, DAY (Gregorian) called STRING.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
309 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
310 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
311 (let ((m displayed-month)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
312 (y displayed-year))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (increment-calendar-month m y (- 11 month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (if (> m 9)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (list (list (list month day y) string)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
317 (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
318 "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
319 If the Nth DAYNAME in MONTH is visible, the value returned is the list
7639
67b7d1ea7b2e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
320 \(((MONTH DAY year) STRING)).
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
321
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
322 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
323
17891
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
324 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
325
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 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
327 ;; 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
328 ;; 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
329 ;; 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
330 ;; 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
331
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
332 ;; (let ((m displayed-month)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
333 ;; (y displayed-year))
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
334 ;; (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
335 ;; (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
336 ;; (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
337
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
338 ;; 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
339
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
340 (let* ((m1 displayed-month)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
341 (y1 displayed-year)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
342 (m2 m1)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
343 (y2 y1))
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
344 (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
345 (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
346 (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
347 (+ (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
348 (* -7 n)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
349 (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
350 (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
351 (+ (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
352 (* -7 n)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
353 (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
354 (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
355 (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
356 (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
357 (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
358 y1
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
359 y2))
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
360 (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
361 (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
362 1
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
363 (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
364 (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
365 (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
366 (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
367 (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
368 string))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
370 (defun holiday-sexp (sexp string)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
371 "Sexp holiday for dates in the calendar window.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
372 SEXP is an expression in variable `year' evaluates to `date'.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
374 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
375 of `date'.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
376
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
377 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
378 date. If date is nil, or if the date is not visible, there is no holiday."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
379 (let ((m displayed-month)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
380 (y displayed-year))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
381 (increment-calendar-month m y -1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
382 (filter-visible-calendar-holidays
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
383 (append
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
384 (let* ((year y)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
385 (date (eval sexp))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
386 (string (if date (eval string))))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
387 (list (list date string)))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
388 (let* ((year (1+ y))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
389 (date (eval sexp))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
390 (string (if date (eval string))))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
391 (list (list date string)))))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
392
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
393 (defun holiday-advent ()
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 "Date of Advent, if visible in calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (let ((year displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 (month displayed-month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 (increment-calendar-month month year -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (let ((advent (calendar-gregorian-from-absolute
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (calendar-dayname-on-or-before 0
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (calendar-absolute-from-gregorian
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (list 12 3 year))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (if (calendar-date-is-visible-p advent)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (list (list advent "Advent"))))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
405 (defun holiday-easter-etc ()
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 "List of dates related to Easter, as visible in calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (if (and (> displayed-month 5) (not all-christian-calendar-holidays))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 nil;; Ash Wednesday, Good Friday, and Easter are not visible.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (let* ((century (1+ (/ displayed-year 100)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (shifted-epact ;; Age of moon for April 5...
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (- ;; ...corrected for the Gregorian century rule
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (/ (* 3 century) 4))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (/ ;; ...corrected for Metonic cycle inaccuracy.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (+ 5 (* 8 century)) 25)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (* 30 century));; Keeps value positive.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 30))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (adjusted-epact ;; Adjust for 29.5 day month.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (if (or (= shifted-epact 0)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 (1+ shifted-epact)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 shifted-epact))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (paschal-moon ;; Day after the full moon on or after March 21.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 adjusted-epact))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (mandatory
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (list (calendar-gregorian-from-absolute abs-easter)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 "Easter Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (list (calendar-gregorian-from-absolute (- abs-easter 2))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 "Good Friday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (list (calendar-gregorian-from-absolute (- abs-easter 46))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 "Ash Wednesday")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (optional
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (list (calendar-gregorian-from-absolute (- abs-easter 63))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 "Septuagesima Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (list (calendar-gregorian-from-absolute (- abs-easter 56))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 "Sexagesima Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (list (calendar-gregorian-from-absolute (- abs-easter 49))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 "Shrove Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (list (calendar-gregorian-from-absolute (- abs-easter 48))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 "Shrove Monday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (list (calendar-gregorian-from-absolute (- abs-easter 47))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 "Shrove Tuesday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (list (calendar-gregorian-from-absolute (- abs-easter 14))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 "Passion Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (list (calendar-gregorian-from-absolute (- abs-easter 7))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 "Palm Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (list (calendar-gregorian-from-absolute (- abs-easter 3))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 "Maundy Thursday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (list (calendar-gregorian-from-absolute (+ abs-easter 35))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 "Rogation Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (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
456 "Ascension Day")
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (list (calendar-gregorian-from-absolute (+ abs-easter 49))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458 "Pentecost (Whitsunday)")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (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
460 "Whitmonday")
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (list (calendar-gregorian-from-absolute (+ abs-easter 56))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 "Trinity Sunday")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (list (calendar-gregorian-from-absolute (+ abs-easter 60))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 "Corpus Christi")))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (output-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (filter-visible-calendar-holidays mandatory)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (if all-christian-calendar-holidays
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (setq output-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (append
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 (filter-visible-calendar-holidays optional)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 output-list)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 output-list)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
474 (defun holiday-greek-orthodox-easter ()
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
475 "Date of Easter according to the rule of the Council of Nicaea."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
476 (let ((m displayed-month)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
477 (y displayed-year))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
478 (increment-calendar-month m y 1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
479 (let* ((julian-year
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
480 (extract-calendar-year
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
481 (calendar-julian-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
482 (calendar-absolute-from-gregorian
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
483 (list m (calendar-last-day-of-month m y) y)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
484 (shifted-epact ;; Age of moon for April 5.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
485 (% (+ 14
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
486 (* 11 (% julian-year 19)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
487 30))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
488 (paschal-moon ;; Day after full moon on or after March 21.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
489 (- (calendar-absolute-from-julian (list 4 19 julian-year))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
490 shifted-epact))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
491 (nicaean-easter;; Sunday following the Paschal moon
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
492 (calendar-gregorian-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
493 (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
494 (if (calendar-date-is-visible-p nicaean-easter)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
495 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)"))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
496
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 (defun filter-visible-calendar-holidays (l)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 "Return a list of all visible holidays of those on L."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 (let ((visible)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 (p l))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (while p
2945
2c1f0215fcc3 * holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents: 957
diff changeset
502 (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
503 (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
504 (setq visible (append (list (car p)) visible)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (setq p (cdr p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 visible))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
507
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
508 (provide 'holidays)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
509
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
510 ;;; holidays.el ends here