annotate lisp/calendar/holidays.el @ 93580:b6cea5b391eb

(calendar-holiday-list): Fix previous change. (holiday-filter-visible-calendar): Doc fix. Use mapcar. (holiday-easter-etc): Fix nesting of result. Tweak holiday order. Use calendar-date-is-visible-p, not holiday-filter-visible-calendar.
author Glenn Morris <rgm@gnu.org>
date Thu, 03 Apr 2008 04:09:31 +0000
parents 101c1d082feb
children f0a60a0ac089
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,
79703
974a828870fe Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78216
diff changeset
4 ;; 2004, 2005, 2006, 2007, 2008 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
78216
93e11478c954 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
6736
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
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
29 ;; See calendar.el.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
793
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
31 ;;; Code:
6fb68a1460a6 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
32
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 (require 'calendar)
732
a8d94735277e *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 660
diff changeset
34
92842
aa76c7bffc0d (hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents: 92650
diff changeset
35 (eval-and-compile
aa76c7bffc0d (hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents: 92650
diff changeset
36 (load "hol-loaddefs" nil 'quiet))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
37
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
38 ;;;###diary-autoload
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
39 (defun calendar-holiday-list ()
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
40 "Form the list of holidays that occur on dates in the calendar window.
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
41 The holidays are those in the list `calendar-holidays'."
93580
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
42 (let (res h)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
43 (sort
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
44 (dolist (p calendar-holidays res)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
45 (if (setq h (if calendar-debug-sexp
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
46 (let ((stack-trace-on-error t))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
47 (eval p))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
48 (condition-case nil
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
49 (eval p)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
50 (error (beep)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
51 (message "Bad holiday list item: %s" p)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
52 (sleep-for 2)))))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
53 (setq res (append h res))))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
54 'calendar-date-compare)))
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
55
92960
5a10f6dafd69 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92922
diff changeset
56 (defvar displayed-month) ; from generate-calendar
5a10f6dafd69 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92922
diff changeset
57 (defvar displayed-year)
5a10f6dafd69 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92922
diff changeset
58
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
59 ;;;###cal-autoload
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
60 (defun calendar-list-holidays ()
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
61 "Create a buffer containing the holidays for the current calendar window.
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
62 The holidays are those in the list `calendar-notable-days'.
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
63 Returns non-nil if any holidays are found."
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
64 (interactive)
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
65 (message "Looking up holidays...")
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
66 (let ((holiday-list (calendar-holiday-list))
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
67 (m1 displayed-month)
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
68 (y1 displayed-year)
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
69 (m2 displayed-month)
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
70 (y2 displayed-year))
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
71 (if (not holiday-list)
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
72 (message "Looking up holidays...none found")
93024
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
73 (calendar-in-read-only-buffer holiday-buffer
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
74 (increment-calendar-month m1 y1 -1)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
75 (increment-calendar-month m2 y2 1)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
76 (calendar-set-mode-line
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
77 (if (= y1 y2)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
78 (format "Notable Dates from %s to %s, %d%%-"
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
79 (calendar-month-name m1) (calendar-month-name m2) y2)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
80 (format "Notable Dates from %s, %d to %s, %d%%-"
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
81 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
82 (insert
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
83 (mapconcat
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
84 (lambda (x) (concat (calendar-date-string (car x))
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
85 ": " (cadr x)))
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
86 holiday-list "\n")))
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
87 (message "Looking up holidays...done"))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
88 holiday-list))
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
89
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
90 (define-obsolete-function-alias
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
91 'list-calendar-holidays 'calendar-list-holidays "23.1")
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
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.
92650
dd247175710f (holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92649
diff changeset
96 If called with an optional prefix argument ARG, prompts for month and year.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 This function is suitable for execution in a .emacs file."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
98 (interactive "P")
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (save-excursion
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
100 (let* ((completion-ignore-case t)
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
101 (date (if arg (calendar-read-date t)
9712
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
102 (calendar-current-date)))
275845a98fa8 Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7639
diff changeset
103 (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
104 (displayed-year (extract-calendar-year date)))
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
105 (calendar-list-holidays))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106
84576
1b5ca22699c0 (holiday-list): Rename it back to `list-holidays', but leave
Glenn Morris <rgm@gnu.org>
parents: 84556
diff changeset
107 ;; rms: "Emacs commands to display a list of something generally start
1b5ca22699c0 (holiday-list): Rename it back to `list-holidays', but leave
Glenn Morris <rgm@gnu.org>
parents: 84556
diff changeset
108 ;; with `list-'. Please make `list-holidays' the principal name."
17388
5c4602f0c45d (list-holidays): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 17385
diff changeset
109 ;;;###autoload
93238
a2947a0dab56 (list-holidays): Make Y2 optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93228
diff changeset
110 (defun list-holidays (y1 &optional y2 l label)
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
111 "Display holidays for years Y1 to Y2 (inclusive).
93282
2dae79a0ee9c (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 93238
diff changeset
112 Y2 defaults to Y1. The optional list of holidays L defaults to
2dae79a0ee9c (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 93238
diff changeset
113 `calendar-holidays'. If you want to control what holidays are
2dae79a0ee9c (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 93238
diff changeset
114 displayed, use a different list. For example,
69373
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
115
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
116 (list-holidays 2006 2006
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
117 (append general-holidays local-holidays other-holidays))
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
118
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
119 will display holidays for the year 2006 defined in the 3
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
120 mentioned lists, and nothing else.
380ad63f635b (list-holidays): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 69352
diff changeset
121
69352
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
122 When called interactively, this command offers a choice of
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
123 holidays, based on the variables `solar-holidays' etc. See the
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
124 documentation of `calendar-holidays' for a list of the variables
61d19d23dd13 (list-holidays): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
125 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
126 of a holiday list.
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
127
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
128 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
129 (interactive
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
130 (let* ((start-year (calendar-read
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
131 "Starting year of holidays (>0): "
92596
935f38ead725 Unquote lambda functions.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
132 (lambda (x) (> x 0))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
133 (int-to-string (extract-calendar-year
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
134 (calendar-current-date)))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
135 (end-year (calendar-read
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
136 (format "Ending year (inclusive) of holidays (>=%s): "
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
137 start-year)
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
138 (lambda (x) (>= x start-year))
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
139 (int-to-string start-year)))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
140 (completion-ignore-case t)
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
141 (lists
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
142 (list
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
143 (cons "All" calendar-holidays)
93228
3f12945a840c (list-holidays): Assume atan always bound.
Glenn Morris <rgm@gnu.org>
parents: 93024
diff changeset
144 (cons "Equinoxes/Solstices"
3f12945a840c (list-holidays): Assume atan always bound.
Glenn Morris <rgm@gnu.org>
parents: 93024
diff changeset
145 (list (list 'solar-equinoxes-solstices)))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
146 (if general-holidays (cons "General" general-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
147 (if local-holidays (cons "Local" local-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
148 (if other-holidays (cons "Other" other-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
149 (if christian-holidays (cons "Christian" christian-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
150 (if hebrew-holidays (cons "Hebrew" hebrew-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
151 (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
152 (if bahai-holidays (cons "Baha'i" bahai-holidays))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
153 (if oriental-holidays (cons "Oriental" oriental-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
154 (if solar-holidays (cons "Solar" solar-holidays))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
155 (cons "Ask" nil)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
156 (choice (capitalize
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
157 (completing-read "List (TAB for choices): " lists nil t)))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
158 (which (if (string-equal choice "Ask")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
159 (eval (read-variable "Enter list name: "))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
160 (cdr (assoc choice lists))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
161 (name (if (string-equal choice "Equinoxes/Solstices")
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
162 choice
17643
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
163 (if (member choice '("Ask" ""))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 37631
diff changeset
164 "Holidays"
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
165 (format "%s Holidays" choice)))))
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
166 (list start-year end-year which name)))
93238
a2947a0dab56 (list-holidays): Make Y2 optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 93228
diff changeset
167 (unless y2 (setq y2 y1))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
168 (message "Computing holidays...")
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
169 (let ((calendar-holidays (or l calendar-holidays))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
170 (title (or label "Holidays"))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
171 (s (calendar-absolute-from-gregorian (list 2 1 y1)))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
172 (e (calendar-absolute-from-gregorian (list 11 1 y2)))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
173 (displayed-month 2)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
174 (displayed-year y1)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
175 holiday-list)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
176 (while (<= s e)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
177 (setq holiday-list (append holiday-list (calendar-holiday-list)))
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
178 (increment-calendar-month displayed-month displayed-year 3)
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
179 (setq s (calendar-absolute-from-gregorian
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
180 (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
181 (save-excursion
93024
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
182 (calendar-in-read-only-buffer holiday-buffer
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
183 (calendar-set-mode-line
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
184 (if (= y1 y2)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
185 (format "%s for %s" title y1)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
186 (format "%s for %s-%s" title y1 y2)))
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
187 (insert
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
188 (mapconcat
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
189 (lambda (x) (concat (calendar-date-string (car x))
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
190 ": " (cadr x)))
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
191 holiday-list "\n")))
17643
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
192 (message "Computing holidays...done"))))
fd27882450bd (list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents: 17388
diff changeset
193
86294
7962d9c627d8 (holiday-list): Add autoload cookie.
Glenn Morris <rgm@gnu.org>
parents: 84606
diff changeset
194 ;;;###autoload
84576
1b5ca22699c0 (holiday-list): Rename it back to `list-holidays', but leave
Glenn Morris <rgm@gnu.org>
parents: 84556
diff changeset
195 (defalias 'holiday-list 'list-holidays)
17385
259d4c9aae0e (list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14687
diff changeset
196
92842
aa76c7bffc0d (hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents: 92650
diff changeset
197 ;;;###diary-autoload
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
198 (defun calendar-check-holidays (date)
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 "Check the list of holidays for any that occur on DATE.
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 The value returned is a list of strings of relevant holiday descriptions.
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
201 The holidays are those in the list `calendar-holidays'."
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
202 (let ((displayed-month (extract-calendar-month date))
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
203 (displayed-year (extract-calendar-year date))
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
204 holiday-list)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
205 (dolist (h (calendar-holiday-list) holiday-list)
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
206 (if (calendar-date-equal date (car h))
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
207 (setq holiday-list (append holiday-list (cdr h)))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
209 (define-obsolete-function-alias
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
210 'check-calendar-holidays 'calendar-check-holidays "23.1")
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
211
92842
aa76c7bffc0d (hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents: 92650
diff changeset
212 ;;;###cal-autoload
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (defun calendar-cursor-holidays ()
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 "Find holidays for the date specified by the cursor in the calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (message "Checking holidays...")
5831
7a4647230b22 (calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents: 5696
diff changeset
217 (let* ((date (calendar-cursor-to-date t))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (date-string (calendar-date-string date))
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
219 (holiday-list (calendar-check-holidays date))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (holiday-string (mapconcat 'identity holiday-list "; "))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (msg (format "%s: %s" date-string holiday-string)))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (if (not holiday-list)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (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
224 (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
225 (message "%s" msg)
93024
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
226 (calendar-in-read-only-buffer holiday-buffer
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
227 (calendar-set-mode-line date-string)
efee212e0b17 (calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents: 92960
diff changeset
228 (insert (mapconcat 'identity holiday-list "\n")))
406
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
92842
aa76c7bffc0d (hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents: 92650
diff changeset
231 ;;;###cal-autoload
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
232 (defun calendar-mark-holidays ()
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 "Mark notable days in the calendar window."
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (interactive)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (setq mark-holidays-in-calendar t)
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (message "Marking holidays...")
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
237 (dolist (holiday (calendar-holiday-list))
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
238 (mark-visible-calendar-date (car holiday) calendar-holiday-marker))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (message "Marking holidays...done"))
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
241 (define-obsolete-function-alias
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
242 'mark-calendar-holidays 'calendar-mark-holidays "23.1")
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 ;; 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
245 ;; 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
246 ;; 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
247 ;; 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
248 ;; ((month day year) string) of VISIBLE dates in the calendar window.
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
250 (defun holiday-fixed (month day string)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
251 "Holiday on MONTH, DAY (Gregorian) called STRING.
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
252 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
253 STRING)). Returns nil if it is not visible in the current calendar window."
93438
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
254 ;; This determines whether a given month is visible in the calendar.
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
255 ;; cf calendar-date-is-visible-p (which also checks the year part).
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
256 ;; The day is irrelevant since only full months are displayed.
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
257 ;; Since the calendar displays three months at a time, month N
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
258 ;; is visible if displayed-month = N-1, N, N+1.
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
259 ;; In particular, November is visible if d-m = 10, 11, 12.
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
260 ;; This is useful, because we can do a one-sided test:
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
261 ;; November is visible if d-m > 9. (Similarly, February is visible if
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
262 ;; d-m < 4.)
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
263 ;; To determine if December is visible, we can shift the calendar
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
264 ;; back a month and ask if November is visible; to determine if
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
265 ;; October is visible, we can shift it forward a month and ask if
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
266 ;; November is visible; etc.
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
267 (let ((m displayed-month)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
268 (y displayed-year))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (increment-calendar-month m y (- 11 month))
93438
03d6bc06ded0 (holiday-fixed): Comment.
Glenn Morris <rgm@gnu.org>
parents: 93412
diff changeset
270 (if (> m 9) ; is november visible?
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
271 (list (list (list month day y) string)))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
273 (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
274 "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
275 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
276 \(((MONTH DAY year) STRING)).
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
277
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
278 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
279
17891
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
280 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
281
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 Returns nil if it is not visible in the current calendar window."
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
283 ;; This is messy because the holiday may be visible, while the date
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
284 ;; on which it is based is not. For example, the first Monday after
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
285 ;; December 30 may be visible when January is not. For large values
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
286 ;; of |n| the problem is more grotesque. If we didn't have to worry
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
287 ;; about such cases, we could just use the original version of this
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
288 ;; function:
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
289 ;; (let ((m displayed-month)
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
290 ;; (y displayed-year))
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
291 ;; (increment-calendar-month m y (- 11 month))
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
292 ;; (if (> m 9); month in year y is visible
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
293 ;; (list (list (calendar-nth-named-day n dayname month y day) string)))))
17891
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
294 (let* ((m1 displayed-month)
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
295 (y1 displayed-year)
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
296 (m2 displayed-month)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
297 (y2 displayed-year)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
298 (d1 (progn ; first possible base date for holiday
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
299 (increment-calendar-month m1 y1 -1)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
300 (+ (calendar-nth-named-absday 1 dayname m1 y1)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
301 (* -7 n)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
302 (if (> n 0) 1 -7))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
303 (d2 ; last possible base date for holiday
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
304 (progn
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
305 (increment-calendar-month m2 y2 1)
17891
6eb7095ca7ab (holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents: 17643
diff changeset
306 (+ (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
307 (* -7 n)
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
308 (if (> n 0) 7 -1))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
309 (y1 (extract-calendar-year (calendar-gregorian-from-absolute d1)))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
310 (y2 (extract-calendar-year (calendar-gregorian-from-absolute d2)))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
311 (y ; year of base date
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
312 (if (or (= y1 y2) (> month 9))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
313 y1
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
314 y2))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
315 (d ; day of base date
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
316 (or day (if (> n 0)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
317 1
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
318 (calendar-last-day-of-month month y))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
319 (date ; base date for holiday
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
320 (calendar-absolute-from-gregorian (list month d y))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
321 (and (<= d1 date) (<= date d2)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
322 (list (list (calendar-nth-named-day n dayname month y d)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
323 string)))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324
93580
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
325 (defun holiday-filter-visible-calendar (hlist)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
326 "Filter list of holidays HLIST, and return only the visible ones.
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
327 HLIST is a list of elements of the form (DATE) TEXT."
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
328 (delq nil (mapcar (lambda (p)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
329 (and (car p) (calendar-date-is-visible-p (car p)) p))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
330 hlist)))
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
331
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
332 (define-obsolete-function-alias
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
333 'filter-visible-calendar-holidays 'holiday-filter-visible-calendar "23.1")
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
334
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
335 (defun holiday-sexp (sexp string)
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
336 "Sexp holiday for dates in the calendar window.
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
337 SEXP is an expression in variable `year' that is evaluated to
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
338 give `date'. STRING is an expression in `date' that evaluates to
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
339 the holiday description of `date'. If `date' is visible in the
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
340 calendar window, the holiday STRING is on that date. If date is
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
341 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
342 (let ((m displayed-month)
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
343 (y displayed-year)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
344 year date)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
345 (increment-calendar-month m y -1)
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
346 (holiday-filter-visible-calendar
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
347 (list
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
348 (progn
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
349 (setq year y
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
350 date (eval sexp))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
351 (list date (if date (eval string))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
352 (progn
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
353 (setq year (1+ y)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
354 date (eval sexp))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
355 (list date (if date (eval string))))))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
356
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
357
58810
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
358 (defun holiday-advent (&optional n string)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
359 "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
360 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
361 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
362 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
363 Nth day before or after advent.
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
364
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
365 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
366 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
367 ;; Backwards compatibility layer.
58810
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
368 (if (not n)
9fcc0f024a83 (holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 58808
diff changeset
369 (holiday-advent 0 "Advent")
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
370 (let* ((year displayed-year)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
371 (month displayed-month)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
372 (advent (progn
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
373 (increment-calendar-month month year -1)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
374 (calendar-gregorian-from-absolute
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
375 (+ n
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
376 (calendar-dayname-on-or-before
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
377 0
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
378 (calendar-absolute-from-gregorian
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
379 (list 12 3 year))))))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
380 (if (calendar-date-is-visible-p advent)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
381 (list (list advent string))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
383 (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
384 "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
385 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
386 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
387 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
388 Nth day before or after Easter.
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
389
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
390 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
391 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
392 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
393 is non-nil)."
58823
46becd97b4c5 Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents: 58810
diff changeset
394 ;; Backwards compatibility layer.
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
395 (if (not n)
93580
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
396 (apply 'append
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
397 (mapcar (lambda (e)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
398 (apply 'holiday-easter-etc e))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
399 ;; The combined list is not in order.
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
400 (append
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
401 (if all-christian-calendar-holidays
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
402 '((-63 "Septuagesima Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
403 (-56 "Sexagesima Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
404 (-49 "Shrove Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
405 (-48 "Shrove Monday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
406 (-47 "Shrove Tuesday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
407 (-14 "Passion Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
408 (-7 "Palm Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
409 (-3 "Maundy Thursday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
410 (35 "Rogation Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
411 (39 "Ascension Day")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
412 (49 "Pentecost (Whitsunday)")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
413 (50 "Whitmonday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
414 (56 "Trinity Sunday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
415 (60 "Corpus Christi")))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
416 '((-46 "Ash Wednesday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
417 (-2 "Good Friday")
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
418 (0 "Easter Sunday")))))
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
419 (let* ((century (1+ (/ displayed-year 100)))
92649
c2fdd87a190e Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92596
diff changeset
420 (shifted-epact ; age of moon for April 5...
92960
5a10f6dafd69 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92922
diff changeset
421 (% (+ 14 (* 11 (% displayed-year 19)) ; ...by Nicaean rule
92649
c2fdd87a190e Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92596
diff changeset
422 (- ; ...corrected for the Gregorian century rule
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
423 (/ (* 3 century) 4))
92922
e5d9e1e9c1b4 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92842
diff changeset
424 (/ ; ...corrected for Metonic cycle inaccuracy
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
425 (+ 5 (* 8 century)) 25)
92960
5a10f6dafd69 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92922
diff changeset
426 (* 30 century)) ; keeps value positive
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
427 30))
92960
5a10f6dafd69 (displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents: 92922
diff changeset
428 (adjusted-epact ; adjust for 29.5 day month
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
429 (if (or (zerop shifted-epact)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
430 (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
431 (1+ shifted-epact)
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
432 shifted-epact))
92649
c2fdd87a190e Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92596
diff changeset
433 (paschal-moon ; day after the full moon on or after March 21
58808
7d719c317dab (holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents: 57197
diff changeset
434 (- (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
435 adjusted-epact))
93580
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
436 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
437 (greg (calendar-gregorian-from-absolute (+ abs-easter n))))
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
438 (if (calendar-date-is-visible-p greg)
b6cea5b391eb (calendar-holiday-list): Fix previous change.
Glenn Morris <rgm@gnu.org>
parents: 93494
diff changeset
439 (list (list greg string))))))
406
bd0533ed9b5a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440
86494
d3d37fadd367 (calendar-absolute-from-julian): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 86294
diff changeset
441 ;; Prior call to calendar-julian-from-absolute will autoload cal-julian.
d3d37fadd367 (calendar-absolute-from-julian): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 86294
diff changeset
442 (declare-function calendar-absolute-from-julian "cal-julian" (date))
d3d37fadd367 (calendar-absolute-from-julian): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 86294
diff changeset
443
3870
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
444 (defun holiday-greek-orthodox-easter ()
4acdfdf2a7c9 * holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents: 3728
diff changeset
445 "Date of Easter according to the rule of the Council of Nicaea."
93494
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
446 (let* ((m displayed-month)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
447 (y displayed-year)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
448 (julian-year (progn
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
449 (increment-calendar-month m y 1)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
450 (extract-calendar-year
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
451 (calendar-julian-from-absolute
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
452 (calendar-absolute-from-gregorian
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
453 (list m (calendar-last-day-of-month m y) y))))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
454 (shifted-epact ; age of moon for April 5
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
455 (% (+ 14
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
456 (* 11 (% julian-year 19)))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
457 30))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
458 (paschal-moon ; day after full moon on or after March 21
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
459 (- (calendar-absolute-from-julian (list 4 19 julian-year))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
460 shifted-epact))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
461 (nicaean-easter ; Sunday following the Paschal moon
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
462 (calendar-gregorian-from-absolute
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
463 (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))))
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
464 (if (calendar-date-is-visible-p nicaean-easter)
101c1d082feb (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93438
diff changeset
465 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 846
diff changeset
466
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
467 (provide 'holidays)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 406
diff changeset
468
84356
357b5ff720d4 (holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78216
diff changeset
469 ;; arch-tag: 48eb3117-75a7-4dbe-8fd9-873c3cbb0d37
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
470 ;;; holidays.el ends here