annotate lisp/calendar/holidays.el @ 69352:61d19d23dd13

(list-holidays): Doc fix.
author Glenn Morris <rgm@gnu.org>
date Fri, 10 Mar 2006 08:04:27 +0000
parents 8daf7d9a0771
children 380ad63f635b 494bf720eaf0
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
67465
a55ee709ec8d Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents: 65919
diff changeset
3 ;; Copyright (C) 1989, 1990, 1992, 1993, 1994, 1997, 2001, 2002, 2003,
68721
8daf7d9a0771 Add 2006 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 67465
diff changeset
4 ;; 2004, 2005, 2006 Free Software Foundation, Inc.
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
5
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
65919
5c09efcfc1d9 Update maintainer email address.
Glenn Morris <rgm@gnu.org>
parents: 64085
diff changeset
7 ;; Maintainer: Glenn Morris <rgm@gnu.org>
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
8 ;; Keywords: holidays, calendar
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
9
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
6736
3e1323443b1a Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 5831
diff changeset
12 ;; 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
13 ;; 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
14 ;; 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
15 ;; any later version.
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
16
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; 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
18 ;; 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
19 ;; 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
20 ;; GNU General Public License for more details.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
6736
3e1323443b1a Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 5831
diff changeset
22 ;; 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
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 61148
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 61148
diff changeset
25 ;; Boston, MA 02110-1301, USA.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
27 ;;; Commentary:
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
28
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; This collection of functions implements the holiday features as described
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;; in calendar.el.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
32 ;; Technical details of all the calendrical calculations can be found in
61148
7f7db25577d9 Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents: 58823
diff changeset
33 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
7f7db25577d9 Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents: 58823
diff changeset
34 ;; and Nachum Dershowitz, Cambridge University Press (2001).
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
36 ;; An earlier version of the technical details appeared in
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
39 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
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
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
43
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
44 ;; 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
45 ;; 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
46 ;; the message BODY containing your mailing address (snail).
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
48 ;; 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
49 ;; Edward M. Reingold Department of Computer Science
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
50 ;; (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
51 ;; 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
52 ;; Urbana, Illinois 61801
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17891
diff changeset
53
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
54 ;;; Code:
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
55
52112
e7d0572ccca5 (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
56 (defvar displayed-month)
e7d0572ccca5 (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
57 (defvar displayed-year)
e7d0572ccca5 (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
58
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (require 'calendar)
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 660
diff changeset
60
13043
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
61 (autoload 'holiday-julian "cal-julian"
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
62 "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
63 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
64
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
65 (autoload 'holiday-hebrew "cal-hebrew"
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
66 "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
67 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
68
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
69 (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
70 "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
71 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
72
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
73 (autoload 'holiday-hanukkah "cal-hebrew"
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
74 "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
75 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
76
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
77 (autoload 'holiday-passover-etc "cal-hebrew"
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
78 "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
79 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
80
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
81 (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
82 "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
83 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
84
14687
0d4ff7e4d6a3 Use the new file names in autoloads.
Karl Heuer <kwzh@gnu.org>
parents: 14318
diff changeset
85 (autoload 'holiday-islamic "cal-islam"
13043
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
86 "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
87 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
88
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
89 (autoload 'holiday-bahai "cal-bahai"
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
90 "Holiday on MONTH, DAY (Baha'i) called STRING."
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
91 t)
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
92
14687
0d4ff7e4d6a3 Use the new file names in autoloads.
Karl Heuer <kwzh@gnu.org>
parents: 14318
diff changeset
93 (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
94 "Date of Chinese New Year."
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
95 t)
2072d3ab4119 Moved stuff to other files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 9712
diff changeset
96
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
97 (autoload 'solar-equinoxes-solstices "solar"
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
98 "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
99 Requires floating point."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
100 t)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
101
37631
00c265302412 (holidays): Add an autoload cookie. From Pavel Jank <Pavel@Janik.cz>.
Eli Zaretskii <eliz@gnu.org>
parents: 37001
diff changeset
102 ;;;###autoload
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
103 (defun holidays (&optional arg)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 "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
105 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
106
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 This function is suitable for execution in a .emacs file."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
108 (interactive "P")
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (save-excursion
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
110 (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
111 (date (if arg
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
112 (calendar-read-date t)
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
113 (calendar-current-date)))
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
114 (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
115 (displayed-year (extract-calendar-year date)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 (list-calendar-holidays))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117
17388
5c4602f0c45d (list-holidays): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 17385
diff changeset
118 ;;;###autoload
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
119 (defun list-holidays (y1 y2 &optional l label)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
120 "Display holidays for years Y1 to Y2 (inclusive).
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
121
69352
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
122 The optional list of holidays L defaults to `calendar-holidays'.
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
123 When called interactively, this command offers a choice of
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
124 holidays, based on the variables `solar-holidays' etc. See the
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
125 documentation of `calendar-holidays' for a list of the variables
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
126 that control the choices, as well as a description of the format
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
127 of a holiday list.
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
128
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
129 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
130 (interactive
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
131 (let* ((start-year (calendar-read
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
132 "Starting year of holidays (>0): "
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
133 '(lambda (x) (> x 0))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
134 (int-to-string (extract-calendar-year
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
135 (calendar-current-date)))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
136 (end-year (calendar-read
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
137 (format "Ending year (inclusive) of holidays (>=%s): "
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
138 start-year)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
139 '(lambda (x) (>= x start-year))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
140 (int-to-string start-year)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
141 (completion-ignore-case t)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
142 (lists
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
143 (list
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
144 (cons "All" calendar-holidays)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
145 (if (fboundp 'atan)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
146 (cons "Equinoxes/Solstices"
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
147 (list (list 'solar-equinoxes-solstices))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
148 (if general-holidays (cons "General" general-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
149 (if local-holidays (cons "Local" local-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
150 (if other-holidays (cons "Other" other-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
151 (if christian-holidays (cons "Christian" christian-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
152 (if hebrew-holidays (cons "Hebrew" hebrew-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
153 (if islamic-holidays (cons "Islamic" islamic-holidays))
55431
b278cb498cc8 2004-05-08 John Wiegley <johnw@newartisans.com>
John Wiegley <johnw@newartisans.com>
parents: 52401
diff changeset
154 (if bahai-holidays (cons "Baha'i" bahai-holidays))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
155 (if oriental-holidays (cons "Oriental" oriental-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
156 (if solar-holidays (cons "Solar" solar-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
157 (cons "Ask" nil)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
158 (choice (capitalize
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
159 (completing-read "List (TAB for choices): " lists nil t)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
160 (which (if (string-equal choice "Ask")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
161 (eval (read-variable "Enter list name: "))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
162 (cdr (assoc choice lists))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
163 (name (if (string-equal choice "Equinoxes/Solstices")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
164 choice
17643
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
165 (if (member choice '("Ask" ""))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 37631
diff changeset
166 "Holidays"
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
167 (format "%s Holidays" choice)))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
168 (list start-year end-year which name)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
169 (message "Computing holidays...")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
170 (let* ((holiday-buffer "*Holidays*")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
171 (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
172 (title (or label "Holidays"))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
173 (holiday-list nil)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
174 (s (calendar-absolute-from-gregorian (list 2 1 y1)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
175 (e (calendar-absolute-from-gregorian (list 11 1 y2)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
176 (d s)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
177 (never t)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
178 (displayed-month 2)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
179 (displayed-year y1))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
180 (while (or never (<= d e))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
181 (setq holiday-list (append holiday-list (calendar-holiday-list)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
182 (setq never nil)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
183 (increment-calendar-month displayed-month displayed-year 3)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
184 (setq d (calendar-absolute-from-gregorian
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
185 (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
186 (save-excursion
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
187 (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
188 (setq buffer-read-only nil)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
189 (calendar-set-mode-line
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
190 (if (= y1 y2)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
191 (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
192 (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
193 (erase-buffer)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
194 (goto-char (point-min))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
195 (insert
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
196 (mapconcat
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
197 '(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
198 ": " (car (cdr x))))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
199 holiday-list "\n"))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
200 (goto-char (point-min))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
201 (set-buffer-modified-p nil)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
202 (setq buffer-read-only t)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
203 (display-buffer holiday-buffer)
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
204 (message "Computing holidays...done"))))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
205
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
206
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (defun check-calendar-holidays (date)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 "Check the list of holidays for any that occur on DATE.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 The value returned is a list of strings of relevant holiday descriptions.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 The holidays are those in the list calendar-holidays."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (let* ((displayed-month (extract-calendar-month date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (displayed-year (extract-calendar-year date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (h (calendar-holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (while h
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (if (calendar-date-equal date (car (car h)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (setq holiday-list (append holiday-list (cdr (car h)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (setq h (cdr h)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (defun calendar-cursor-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 "Find holidays for the date specified by the cursor in the calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (message "Checking holidays...")
5831
7a4647230b22 (calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents: 5696
diff changeset
225 (let* ((date (calendar-cursor-to-date t))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (date-string (calendar-date-string date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (holiday-list (check-calendar-holidays date))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (holiday-string (mapconcat 'identity holiday-list "; "))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (msg (format "%s: %s" date-string holiday-string)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (if (not holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (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
232 (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
233 (message "%s" msg)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (set-buffer (get-buffer-create holiday-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (setq buffer-read-only nil)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
236 (calendar-set-mode-line date-string)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (insert (mapconcat 'identity holiday-list "\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (display-buffer holiday-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (message "Checking holidays...done")))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (defun mark-calendar-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 "Mark notable days in the calendar window."
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 (setq mark-holidays-in-calendar t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (message "Marking holidays...")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (let ((holiday-list (calendar-holiday-list)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (while holiday-list
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (mark-visible-calendar-date
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (car (car holiday-list)) calendar-holiday-marker)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (setq holiday-list (cdr holiday-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (message "Marking holidays...done"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (defun list-calendar-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 "Create a buffer containing the holidays for the current calendar window.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 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
260 holidays are found, nil if not."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (message "Looking up holidays...")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (let ((holiday-list (calendar-holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (m1 displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (y1 displayed-year)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (m2 displayed-month)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (y2 displayed-year))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (if (not holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (progn
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (message "Looking up holidays...none found")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (set-buffer (get-buffer-create holiday-buffer))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (setq buffer-read-only nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (increment-calendar-month m1 y1 -1)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (increment-calendar-month m2 y2 1)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
276 (calendar-set-mode-line
5696
baab03aaf3b9 (list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents: 4864
diff changeset
277 (if (= y1 y2)
baab03aaf3b9 (list-calendar-holidays): Fix mode line.
Richard M. Stallman <rms@gnu.org>
parents: 4864
diff changeset
278 (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
279 (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
280 (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
281 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (erase-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (insert
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (mapconcat
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 '(lambda (x) (concat (calendar-date-string (car x))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 ": " (car (cdr x))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 holiday-list "\n"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (goto-char (point-min))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 (set-buffer-modified-p nil)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (setq buffer-read-only t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (display-buffer holiday-buffer)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (message "Looking up holidays...done")
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 t)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (defun calendar-holiday-list ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 "Form the list of holidays that occur on dates in the calendar window.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 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
298 (let ((p calendar-holidays)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (holiday-list))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (while p
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
301 (let* ((holidays
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
302 (if calendar-debug-sexp
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
303 (let ((stack-trace-on-error t))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
304 (eval (car p)))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
305 (condition-case nil
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
306 (eval (car p))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
307 (error (beep)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
308 (message "Bad holiday list item: %s" (car p))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
309 (sleep-for 2))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (if holidays
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (setq holiday-list (append holidays holiday-list))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (setq p (cdr p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (setq holiday-list (sort holiday-list 'calendar-date-compare))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 ;; 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
316 ;; 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
317 ;; 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
318 ;; 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
319 ;; ((month day year) string) of VISIBLE dates in the calendar window.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
321 (defun holiday-fixed (month day string)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
322 "Holiday on MONTH, DAY (Gregorian) called STRING.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
323 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
324 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
325 (let ((m displayed-month)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
326 (y displayed-year))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (increment-calendar-month m y (- 11 month))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (if (> m 9)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (list (list (list month day y) string)))))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
331 (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
332 "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
333 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
334 \(((MONTH DAY year) STRING)).
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
335
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
336 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
337
17891
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
338 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
339
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 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
341 ;; 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
342 ;; 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
343 ;; 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
344 ;; 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
345
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
346 ;; (let ((m displayed-month)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
347 ;; (y displayed-year))
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
348 ;; (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
349 ;; (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
350 ;; (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
351
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
352 ;; 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
353
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
354 (let* ((m1 displayed-month)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
355 (y1 displayed-year)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
356 (m2 m1)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
357 (y2 y1))
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
358 (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
359 (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
360 (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
361 (+ (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
362 (* -7 n)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
363 (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
364 (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
365 (+ (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
366 (* -7 n)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
367 (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
368 (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
369 (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
370 (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
371 (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
372 y1
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
373 y2))
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
374 (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
375 (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
376 1
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
377 (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
378 (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
379 (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
380 (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
381 (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
382 string))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
384 (defun holiday-sexp (sexp string)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
385 "Sexp holiday for dates in the calendar window.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
386 SEXP is an expression in variable `year' evaluates to `date'.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
388 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
389 of `date'.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
390
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
391 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
392 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
393 (let ((m displayed-month)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
394 (y displayed-year))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
395 (increment-calendar-month m y -1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
396 (filter-visible-calendar-holidays
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
397 (append
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
398 (let* ((year y)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
399 (date (eval sexp))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
400 (string (if date (eval string))))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
401 (list (list date string)))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
402 (let* ((year (1+ y))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
403 (date (eval sexp))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
404 (string (if date (eval string))))
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
405 (list (list date string)))))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
406
58810
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
407 (defun holiday-advent (&optional n string)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
408 "Date of Nth day after advent (named STRING), if visible in calendar window.
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
409 Negative values of N are interpreted as days before advent.
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
410 STRING is used purely for display purposes. The return value has
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
411 the form ((MONTH DAY YEAR) STRING), where the date is that of the
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
412 Nth day before or after advent.
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
413
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
414 For backwards compatibility, if this function is called with no
58810
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
415 arguments, then it returns the value appropriate for advent itself."
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
416 ;; Backwards compatibility layer.
58810
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
417 (if (not n)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
418 (holiday-advent 0 "Advent")
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
419 (let ((year displayed-year)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
420 (month displayed-month))
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
421 (increment-calendar-month month year -1)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
422 (let ((advent (calendar-gregorian-from-absolute
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
423 (+ n
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
424 (calendar-dayname-on-or-before
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
425 0
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
426 (calendar-absolute-from-gregorian
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
427 (list 12 3 year)))))))
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
428 (if (calendar-date-is-visible-p advent)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
429 (list (list advent string)))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
431 (defun holiday-easter-etc (&optional n string)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
432 "Date of Nth day after Easter (named STRING), if visible in calendar window.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
433 Negative values of N are interpreted as days before Easter.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
434 STRING is used purely for display purposes. The return value has
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
435 the form ((MONTH DAY YEAR) STRING), where the date is that of the
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
436 Nth day before or after Easter.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
437
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
438 For backwards compatibility, if this function is called with no
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
439 arguments, then it returns a list of \"standard\" Easter-related
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
440 holidays (with more entries if `all-christian-calendar-holidays'
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
441 is non-nil)."
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
442 ;; Backwards compatibility layer.
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
443 (if (not n)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
444 (let (res-list res)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
445 (dolist (elem (append
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
446 (if all-christian-calendar-holidays
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
447 '((-63 . "Septuagesima Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
448 (-56 . "Sexagesima Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
449 (-49 . "Shrove Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
450 (-48 . "Shrove Monday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
451 (-47 . "Shrove Tuesday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
452 (-14 . "Passion Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
453 (-7 . "Palm Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
454 (-3 . "Maundy Thursday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
455 (35 . "Rogation Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
456 (39 . "Ascension Day")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
457 (49 . "Pentecost (Whitsunday)")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
458 (50 . "Whitmonday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
459 (56 . "Trinity Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
460 (60 . "Corpus Christi")))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
461 '((0 . "Easter Sunday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
462 (-2 . "Good Friday")
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
463 (-46 . "Ash Wednesday")))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
464 res-list)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
465 ;; Filter out nil (not visible) values.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
466 (if (setq res (holiday-easter-etc (car elem) (cdr elem)))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
467 (setq res-list (append res res-list)))))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
468 (let* ((century (1+ (/ displayed-year 100)))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
469 (shifted-epact ;; Age of moon for April 5...
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
470 (% (+ 14 (* 11 (% displayed-year 19)) ;; ...by Nicaean rule
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
471 (- ;; ...corrected for the Gregorian century rule
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
472 (/ (* 3 century) 4))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
473 (/ ;; ...corrected for Metonic cycle inaccuracy.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
474 (+ 5 (* 8 century)) 25)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
475 (* 30 century)) ;; Keeps value positive.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
476 30))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
477 (adjusted-epact ;; Adjust for 29.5 day month.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
478 (if (or (zerop shifted-epact)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
479 (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
480 (1+ shifted-epact)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
481 shifted-epact))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
482 (paschal-moon ;; Day after the full moon on or after March 21.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
483 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
484 adjusted-epact))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
485 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
486 (filter-visible-calendar-holidays
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
487 (list (list (calendar-gregorian-from-absolute (+ abs-easter n))
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
488 string))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
490 (defun holiday-greek-orthodox-easter ()
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
491 "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
492 (let ((m displayed-month)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
493 (y displayed-year))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
494 (increment-calendar-month m y 1)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
495 (let* ((julian-year
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
496 (extract-calendar-year
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
497 (calendar-julian-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
498 (calendar-absolute-from-gregorian
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
499 (list m (calendar-last-day-of-month m y) y)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
500 (shifted-epact ;; Age of moon for April 5.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
501 (% (+ 14
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
502 (* 11 (% julian-year 19)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
503 30))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
504 (paschal-moon ;; Day after full moon on or after March 21.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
505 (- (calendar-absolute-from-julian (list 4 19 julian-year))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
506 shifted-epact))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
507 (nicaean-easter;; Sunday following the Paschal moon
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
508 (calendar-gregorian-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
509 (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
510 (if (calendar-date-is-visible-p nicaean-easter)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
511 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)"))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
512
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 (defun filter-visible-calendar-holidays (l)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 "Return a list of all visible holidays of those on L."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (let ((visible)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 (p l))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (while p
2945
2c1f0215fcc3 * holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents: 957
diff changeset
518 (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
519 (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
520 (setq visible (append (list (car p)) visible)))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (setq p (cdr p)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 visible))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
523
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
524 (provide 'holidays)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
525
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52112
diff changeset
526 ;;; arch-tag: 48eb3117-75a7-4dbe-8fd9-873c3cbb0d37
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
527 ;;; holidays.el ends here