Mercurial > emacs
annotate lisp/calendar/holidays.el @ 93258:16142d1d9f33
(redisplay_internal): Reset selected_frame earlier.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 26 Mar 2008 18:11:47 +0000 |
parents | a2947a0dab56 |
children | 2dae79a0ee9c |
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 | 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 | 8 ;; Keywords: holidays, calendar |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
9 |
406 | 10 ;; This file is part of GNU Emacs. |
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 | 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 | 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 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
406 | 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 | 29 ;; This collection of functions implements the holiday features as described |
30 ;; in calendar.el. | |
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 | 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 | 37 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold, |
38 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990), | |
957 | 39 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical |
40 ;; Calendars'' by E. M. Reingold, N. Dershowitz, and S. M. Clamen, | |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
41 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
957
diff
changeset
|
42 ;; pages 383-404. |
957 | 43 |
44 ;; Hard copies of these two papers can be obtained by sending email to | |
45 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and | |
46 ;; the message BODY containing your mailing address (snail). | |
406 | 47 |
793
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
48 ;;; Code: |
6fb68a1460a6
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
49 |
406 | 50 (require 'calendar) |
732 | 51 |
92842
aa76c7bffc0d
(hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents:
92650
diff
changeset
|
52 (eval-and-compile |
aa76c7bffc0d
(hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents:
92650
diff
changeset
|
53 (load "hol-loaddefs" nil 'quiet)) |
957 | 54 |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
55 ;;;###diary-autoload |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
56 (defun calendar-holiday-list () |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
57 "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
|
58 The holidays are those in the list `calendar-holidays'." |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
59 (let (holiday-list) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
60 (dolist (p calendar-holidays) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
61 (let* ((holidays |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
62 (if calendar-debug-sexp |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
63 (let ((stack-trace-on-error t)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
64 (eval p)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
65 (condition-case nil |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
66 (eval p) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
67 (error (beep) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
68 (message "Bad holiday list item: %s" p) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
69 (sleep-for 2)))))) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
70 (if holidays |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
71 (setq holiday-list (append holidays holiday-list))))) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
72 (setq holiday-list (sort holiday-list 'calendar-date-compare)))) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
73 |
92960
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
74 (defvar displayed-month) ; from generate-calendar |
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
75 (defvar displayed-year) |
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
76 |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
77 ;;;###cal-autoload |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
78 (defun calendar-list-holidays () |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
79 "Create a buffer containing the holidays for the current calendar window. |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
80 The holidays are those in the list `calendar-notable-days'. Returns t if any |
92960
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
81 holidays are found, otherwise nil." |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
82 (interactive) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
83 (message "Looking up holidays...") |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
84 (let ((holiday-list (calendar-holiday-list)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
85 (m1 displayed-month) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
86 (y1 displayed-year) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
87 (m2 displayed-month) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
88 (y2 displayed-year)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
89 (if (not holiday-list) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
90 (progn |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
91 (message "Looking up holidays...none found") |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
92 nil) |
93024
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
93 (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
|
94 (increment-calendar-month m1 y1 -1) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
95 (increment-calendar-month m2 y2 1) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
96 (calendar-set-mode-line |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
97 (if (= y1 y2) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
98 (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
|
99 (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
|
100 (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
|
101 (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
|
102 (insert |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
103 (mapconcat |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
104 (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
|
105 ": " (cadr x))) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
106 holiday-list "\n"))) |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
107 (message "Looking up holidays...done") |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
108 t))) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
109 |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
110 (define-obsolete-function-alias |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
111 '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
|
112 |
37631
00c265302412
(holidays): Add an autoload cookie. From Pavel Jank <Pavel@Janik.cz>.
Eli Zaretskii <eliz@gnu.org>
parents:
37001
diff
changeset
|
113 ;;;###autoload |
957 | 114 (defun holidays (&optional arg) |
406 | 115 "Display the holidays for last month, this month, and next month. |
92650 | 116 If called with an optional prefix argument ARG, prompts for month and year. |
406 | 117 This function is suitable for execution in a .emacs file." |
957 | 118 (interactive "P") |
406 | 119 (save-excursion |
957 | 120 (let* ((completion-ignore-case t) |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
121 (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
|
122 (calendar-current-date))) |
275845a98fa8
Use new form of calendar-read-date.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7639
diff
changeset
|
123 (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
|
124 (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
|
125 (calendar-list-holidays)))) |
406 | 126 |
84576
1b5ca22699c0
(holiday-list): Rename it back to `list-holidays', but leave
Glenn Morris <rgm@gnu.org>
parents:
84556
diff
changeset
|
127 ;; 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
|
128 ;; 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
|
129 ;;;###autoload |
93238
a2947a0dab56
(list-holidays): Make Y2 optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93228
diff
changeset
|
130 (defun list-holidays (y1 &optional y2 l label) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
131 "Display holidays for years Y1 to Y2 (inclusive). |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
132 |
69352 | 133 The optional list of holidays L defaults to `calendar-holidays'. |
69373 | 134 If you want to control what holidays are displayed, use a |
135 different list. For example, | |
136 | |
137 (list-holidays 2006 2006 | |
138 (append general-holidays local-holidays other-holidays)) | |
139 | |
140 will display holidays for the year 2006 defined in the 3 | |
141 mentioned lists, and nothing else. | |
142 | |
69352 | 143 When called interactively, this command offers a choice of |
144 holidays, based on the variables `solar-holidays' etc. See the | |
145 documentation of `calendar-holidays' for a list of the variables | |
146 that control the choices, as well as a description of the format | |
147 of a holiday list. | |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
148 |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
149 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
|
150 (interactive |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
151 (let* ((start-year (calendar-read |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
152 "Starting year of holidays (>0): " |
92596 | 153 (lambda (x) (> x 0)) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
154 (int-to-string (extract-calendar-year |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
155 (calendar-current-date))))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
156 (end-year (calendar-read |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
157 (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
|
158 start-year) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
159 (lambda (x) (>= x start-year)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
160 (int-to-string start-year))) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
161 (completion-ignore-case t) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
162 (lists |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
163 (list |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
164 (cons "All" calendar-holidays) |
93228
3f12945a840c
(list-holidays): Assume atan always bound.
Glenn Morris <rgm@gnu.org>
parents:
93024
diff
changeset
|
165 (cons "Equinoxes/Solstices" |
3f12945a840c
(list-holidays): Assume atan always bound.
Glenn Morris <rgm@gnu.org>
parents:
93024
diff
changeset
|
166 (list (list 'solar-equinoxes-solstices))) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
167 (if general-holidays (cons "General" general-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
168 (if local-holidays (cons "Local" local-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
169 (if other-holidays (cons "Other" other-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
170 (if christian-holidays (cons "Christian" christian-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
171 (if hebrew-holidays (cons "Hebrew" hebrew-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
172 (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
|
173 (if bahai-holidays (cons "Baha'i" bahai-holidays)) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
174 (if oriental-holidays (cons "Oriental" oriental-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
175 (if solar-holidays (cons "Solar" solar-holidays)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
176 (cons "Ask" nil))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
177 (choice (capitalize |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
178 (completing-read "List (TAB for choices): " lists nil t))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
179 (which (if (string-equal choice "Ask") |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
180 (eval (read-variable "Enter list name: ")) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
181 (cdr (assoc choice lists)))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
182 (name (if (string-equal choice "Equinoxes/Solstices") |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
183 choice |
17643
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
184 (if (member choice '("Ask" "")) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
37631
diff
changeset
|
185 "Holidays" |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
186 (format "%s Holidays" choice))))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
187 (list start-year end-year which name))) |
93238
a2947a0dab56
(list-holidays): Make Y2 optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93228
diff
changeset
|
188 (unless y2 (setq y2 y1)) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
189 (message "Computing holidays...") |
93238
a2947a0dab56
(list-holidays): Make Y2 optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93228
diff
changeset
|
190 (let* ((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
|
191 (title (or label "Holidays")) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
192 (holiday-list nil) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
193 (s (calendar-absolute-from-gregorian (list 2 1 y1))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
194 (e (calendar-absolute-from-gregorian (list 11 1 y2))) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
195 (d s) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
196 (never t) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
197 (displayed-month 2) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
198 (displayed-year y1)) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
199 (while (or never (<= d e)) |
93024
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
200 (setq holiday-list (append holiday-list (calendar-holiday-list)) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
201 never nil) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
202 (increment-calendar-month displayed-month displayed-year 3) |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
203 (setq d (calendar-absolute-from-gregorian |
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
204 (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
|
205 (save-excursion |
93024
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
206 (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
|
207 (calendar-set-mode-line |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
208 (if (= y1 y2) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
209 (format "%s for %s" title y1) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
210 (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
|
211 (insert |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
212 (mapconcat |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
213 (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
|
214 ": " (cadr x))) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
215 holiday-list "\n"))) |
17643
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
216 (message "Computing holidays...done")))) |
fd27882450bd
(list-holidays): Fix buffer title when list is
Richard M. Stallman <rms@gnu.org>
parents:
17388
diff
changeset
|
217 |
86294
7962d9c627d8
(holiday-list): Add autoload cookie.
Glenn Morris <rgm@gnu.org>
parents:
84606
diff
changeset
|
218 ;;;###autoload |
84576
1b5ca22699c0
(holiday-list): Rename it back to `list-holidays', but leave
Glenn Morris <rgm@gnu.org>
parents:
84556
diff
changeset
|
219 (defalias 'holiday-list 'list-holidays) |
17385
259d4c9aae0e
(list-holidays): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14687
diff
changeset
|
220 |
92842
aa76c7bffc0d
(hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents:
92650
diff
changeset
|
221 ;;;###diary-autoload |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
222 (defun calendar-check-holidays (date) |
406 | 223 "Check the list of holidays for any that occur on DATE. |
224 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
|
225 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
|
226 (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
|
227 (displayed-year (extract-calendar-year date)) |
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
228 (holiday-list)) |
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
229 (dolist (h (calendar-holiday-list)) |
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
230 (if (calendar-date-equal date (car h)) |
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
231 (setq holiday-list (append holiday-list (cdr h))))) |
406 | 232 holiday-list)) |
233 | |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
234 (define-obsolete-function-alias |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
235 '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
|
236 |
92842
aa76c7bffc0d
(hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents:
92650
diff
changeset
|
237 ;;;###cal-autoload |
406 | 238 (defun calendar-cursor-holidays () |
239 "Find holidays for the date specified by the cursor in the calendar window." | |
240 (interactive) | |
241 (message "Checking holidays...") | |
5831
7a4647230b22
(calendar-cursor-holidays): Use new error arg
Richard M. Stallman <rms@gnu.org>
parents:
5696
diff
changeset
|
242 (let* ((date (calendar-cursor-to-date t)) |
406 | 243 (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
|
244 (holiday-list (calendar-check-holidays date)) |
406 | 245 (holiday-string (mapconcat 'identity holiday-list "; ")) |
246 (msg (format "%s: %s" date-string holiday-string))) | |
247 (if (not holiday-list) | |
248 (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
|
249 (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
|
250 (message "%s" msg) |
93024
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
251 (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
|
252 (calendar-set-mode-line date-string) |
efee212e0b17
(calendar-list-holidays, list-holidays, calendar-cursor-holidays):
Glenn Morris <rgm@gnu.org>
parents:
92960
diff
changeset
|
253 (insert (mapconcat 'identity holiday-list "\n"))) |
406 | 254 (message "Checking holidays...done"))))) |
255 | |
92842
aa76c7bffc0d
(hol-loaddefs): Load this rather than explicit autoloads.
Glenn Morris <rgm@gnu.org>
parents:
92650
diff
changeset
|
256 ;;;###cal-autoload |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
257 (defun calendar-mark-holidays () |
406 | 258 "Mark notable days in the calendar window." |
259 (interactive) | |
260 (setq mark-holidays-in-calendar t) | |
261 (message "Marking holidays...") | |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
262 (dolist (holiday (calendar-holiday-list)) |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
263 (mark-visible-calendar-date (car holiday) calendar-holiday-marker)) |
406 | 264 (message "Marking holidays...done")) |
265 | |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
266 (define-obsolete-function-alias |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
267 'mark-calendar-holidays 'calendar-mark-holidays "23.1") |
406 | 268 |
269 ;; 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
|
270 ;; 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
|
271 ;; 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
|
272 ;; 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
|
273 ;; ((month day year) string) of VISIBLE dates in the calendar window. |
406 | 274 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
275 (defun holiday-fixed (month day string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
276 "Holiday on MONTH, DAY (Gregorian) called STRING. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
277 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
|
278 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
|
279 (let ((m displayed-month) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
280 (y displayed-year)) |
406 | 281 (increment-calendar-month m y (- 11 month)) |
282 (if (> m 9) | |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
283 (list (list (list month day y) string))))) |
406 | 284 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
285 (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
|
286 "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
|
287 If the Nth DAYNAME in MONTH is visible, the value returned is the list |
7639 | 288 \(((MONTH DAY year) STRING)). |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
289 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
290 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
|
291 |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
292 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
|
293 |
406 | 294 Returns nil if it is not visible in the current calendar window." |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
295 ;; This is messy because the holiday may be visible, while the date on which |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
296 ;; it is based is not. For example, the first Monday after December 30 may be |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
297 ;; visible when January is not. For large values of |n| the problem is more |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
298 ;; grotesque. If we didn't have to worry about such cases, we could just use |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
299 |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
300 ;; (let ((m displayed-month) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
301 ;; (y displayed-year)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
302 ;; (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
|
303 ;; (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
|
304 ;; (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
|
305 |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
306 ;; which is the way the function was originally written. |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
307 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
308 (let* ((m1 displayed-month) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
309 (y1 displayed-year) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
310 (m2 m1) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
311 (y2 y1)) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
312 (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
|
313 (increment-calendar-month m2 y2 1) |
92960
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
314 (let* ((d1 ; first possible base date for holiday |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
315 (+ (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
|
316 (* -7 n) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
317 (if (> n 0) 1 -7))) |
92960
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
318 (d2 ; last possible base date for holiday |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
319 (+ (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
|
320 (* -7 n) |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
321 (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
|
322 (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
|
323 (y2 (extract-calendar-year (calendar-gregorian-from-absolute d2))) |
92649 | 324 (y ; year of base date |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
325 (if (or (= y1 y2) (> month 9)) |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
326 y1 |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
327 y2)) |
92649 | 328 (d ; day of base date |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
329 (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
|
330 1 |
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
331 (calendar-last-day-of-month month y)))) |
92649 | 332 (date ; base date for holiday |
17891
6eb7095ca7ab
(holiday-float): Rewritten to fix bug when base date
Richard M. Stallman <rms@gnu.org>
parents:
17643
diff
changeset
|
333 (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
|
334 (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
|
335 (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
|
336 string)))))) |
406 | 337 |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
338 (defun holiday-filter-visible-calendar (l) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
339 "Return a list of all visible holidays of those on L." |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
340 (let ((visible ())) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
341 (dolist (p l) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
342 (and (car p) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
343 (calendar-date-is-visible-p (car p)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
344 (push p visible))) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
345 visible)) |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
346 |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
347 (define-obsolete-function-alias |
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
348 '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
|
349 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
350 (defun holiday-sexp (sexp string) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
351 "Sexp holiday for dates in the calendar window. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
352 SEXP is an expression in variable `year' evaluates to `date'. |
406 | 353 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
354 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
|
355 of `date'. |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
356 |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
357 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
|
358 date. If date is nil, or if the date is not visible, there is no holiday." |
957 | 359 (let ((m displayed-month) |
360 (y displayed-year)) | |
361 (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
|
362 (holiday-filter-visible-calendar |
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
363 (list |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
364 (let* ((year y) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
365 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
366 (string (if date (eval string)))) |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
367 (list date string)) |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
368 (let* ((year (1+ y)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
369 (date (eval sexp)) |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
370 (string (if date (eval string)))) |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
371 (list date string)))))) |
957 | 372 |
58810
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
373 (defun holiday-advent (&optional n string) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
374 "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
|
375 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
|
376 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
|
377 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
|
378 Nth day before or after advent. |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
379 |
58823
46becd97b4c5
Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents:
58810
diff
changeset
|
380 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
|
381 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
|
382 ;; Backwards compatibility layer. |
58810
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
383 (if (not n) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
384 (holiday-advent 0 "Advent") |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
385 (let ((year displayed-year) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
386 (month displayed-month)) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
387 (increment-calendar-month month year -1) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
388 (let ((advent (calendar-gregorian-from-absolute |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
389 (+ n |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
390 (calendar-dayname-on-or-before |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
391 0 |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
392 (calendar-absolute-from-gregorian |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
393 (list 12 3 year))))))) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
394 (if (calendar-date-is-visible-p advent) |
9fcc0f024a83
(holiday-advent): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
58808
diff
changeset
|
395 (list (list advent string))))))) |
406 | 396 |
58808
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
397 (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
|
398 "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
|
399 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
|
400 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
|
401 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
|
402 Nth day before or after Easter. |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
403 |
58823
46becd97b4c5
Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents:
58810
diff
changeset
|
404 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
|
405 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
|
406 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
|
407 is non-nil)." |
58823
46becd97b4c5
Fix spelling mistake in previous changes.
Glenn Morris <rgm@gnu.org>
parents:
58810
diff
changeset
|
408 ;; Backwards compatibility layer. |
58808
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
409 (if (not n) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
410 (let (res-list res) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
411 (dolist (elem (append |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
412 (if all-christian-calendar-holidays |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
413 '((-63 . "Septuagesima Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
414 (-56 . "Sexagesima Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
415 (-49 . "Shrove Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
416 (-48 . "Shrove Monday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
417 (-47 . "Shrove Tuesday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
418 (-14 . "Passion Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
419 (-7 . "Palm Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
420 (-3 . "Maundy Thursday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
421 (35 . "Rogation Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
422 (39 . "Ascension Day") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
423 (49 . "Pentecost (Whitsunday)") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
424 (50 . "Whitmonday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
425 (56 . "Trinity Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
426 (60 . "Corpus Christi"))) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
427 '((0 . "Easter Sunday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
428 (-2 . "Good Friday") |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
429 (-46 . "Ash Wednesday"))) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
430 res-list) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
431 ;; Filter out nil (not visible) values. |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
432 (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
|
433 (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
|
434 (let* ((century (1+ (/ displayed-year 100))) |
92649 | 435 (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
|
436 (% (+ 14 (* 11 (% displayed-year 19)) ; ...by Nicaean rule |
92649 | 437 (- ; ...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
|
438 (/ (* 3 century) 4)) |
92922
e5d9e1e9c1b4
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92842
diff
changeset
|
439 (/ ; ...corrected for Metonic cycle inaccuracy |
58808
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
440 (+ 5 (* 8 century)) 25) |
92960
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
441 (* 30 century)) ; keeps value positive |
58808
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
442 30)) |
92960
5a10f6dafd69
(displayed-month, displayed-year): Move declarations where needed.
Glenn Morris <rgm@gnu.org>
parents:
92922
diff
changeset
|
443 (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
|
444 (if (or (zerop shifted-epact) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
445 (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
|
446 (1+ shifted-epact) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
447 shifted-epact)) |
92649 | 448 (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
|
449 (- (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
|
450 adjusted-epact)) |
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
451 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))) |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
452 (holiday-filter-visible-calendar |
58808
7d719c317dab
(holiday-easter-etc): Make arguments optional for backwards
Glenn Morris <rgm@gnu.org>
parents:
57197
diff
changeset
|
453 (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
|
454 string)))))) |
406 | 455 |
86494
d3d37fadd367
(calendar-absolute-from-julian): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents:
86294
diff
changeset
|
456 ;; 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
|
457 (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
|
458 |
3870
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
459 (defun holiday-greek-orthodox-easter () |
4acdfdf2a7c9
* holidays.el (calendar-holiday-function-fixed,
Jim Blandy <jimb@redhat.com>
parents:
3728
diff
changeset
|
460 "Date of Easter according to the rule of the Council of Nicaea." |
957 | 461 (let ((m displayed-month) |
462 (y displayed-year)) | |
463 (increment-calendar-month m y 1) | |
464 (let* ((julian-year | |
465 (extract-calendar-year | |
466 (calendar-julian-from-absolute | |
467 (calendar-absolute-from-gregorian | |
468 (list m (calendar-last-day-of-month m y) y))))) | |
92649 | 469 (shifted-epact ; age of moon for April 5 |
957 | 470 (% (+ 14 |
471 (* 11 (% julian-year 19))) | |
472 30)) | |
92649 | 473 (paschal-moon ; day after full moon on or after March 21 |
957 | 474 (- (calendar-absolute-from-julian (list 4 19 julian-year)) |
475 shifted-epact)) | |
92649 | 476 (nicaean-easter ; Sunday following the Paschal moon |
957 | 477 (calendar-gregorian-from-absolute |
478 (calendar-dayname-on-or-before 0 (+ paschal-moon 7))))) | |
479 (if (calendar-date-is-visible-p nicaean-easter) | |
480 (list (list nicaean-easter "Pascha (Greek Orthodox Easter)")))))) | |
481 | |
584 | 482 (provide 'holidays) |
483 | |
84356
357b5ff720d4
(holiday-list, calendar-check-holidays, calendar-mark-holidays)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
78216
diff
changeset
|
484 ;; arch-tag: 48eb3117-75a7-4dbe-8fd9-873c3cbb0d37 |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
485 ;;; holidays.el ends here |