annotate lisp/calendar/calendar.el @ 90:99da576a67e7 xemacs-20-0

Import from CVS: tag xemacs-20-0
author cvs
date Mon, 13 Aug 2007 09:10:46 +0200
parents 54cc21c15cbb
children 34a5b81f86ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; calendar.el --- Calendar functions. -*-byte-compile-dynamic: t;-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Human-Keywords: calendar, Gregorian calendar, Julian calendar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Hebrew calendar, Islamic calendar, ISO calendar, Julian day number,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; diary, holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
25 ;; along with XEmacs; see the file COPYING. If not, write to the Free
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
26 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; This collection of functions implements a calendar window. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; generates a calendar for the current month, together with the previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; and coming months, or for any other three-month period. The calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; can be scrolled forward and backward in the window to show months in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; the past or future; the cursor can move forward and backward by days,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; weeks, or months, making it possible, for instance, to jump to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; date a specified number of days, weeks, or months from the date under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; the cursor. The user can display a list of holidays and other notable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; days for the period shown; the notable days can be marked on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; calendar, if desired. The user can also specify that dates having
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; corresponding diary entries (in a file that the user specifies) be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; marked; the diary entries for any date can be viewed in a separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; window. The diary and the notable days can be viewed independently of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; the calendar. Dates can be translated from the (usual) Gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; calendar to the day of the year/days remaining in year, to the ISO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; commercial calendar, to the Julian (old style) calendar, to the Hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; calendar, to the Islamic calendar, to the French Revolutionary calendar,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; to the Mayan calendar, and to the astronomical (Julian) day number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; When floating point is available, times of sunrise/sunset can be displayed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; as can the phases of the moon. Appointment notification for diary entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; is available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; The following files are part of the calendar/diary code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; cal-menu.el Menu support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; cal-x.el X-windows dedicated frame functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; diary-lib.el, diary-ins.el Diary functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; holidays.el Holiday functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; cal-french.el French Revolutionary calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; cal-mayan.el Mayan calendars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; cal-dst.el Daylight savings time rules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; solar.el Sunrise/sunset, equinoxes/solstices
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; lunar.el Phases of the moon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; appt.el Appointment notification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; Comments, corrections, and improvements should be sent to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; Edward M. Reingold Department of Computer Science
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Urbana, Illinois 61801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; GNU Emacs users too numerous to list pointed out a variety of problems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; with earlier forms of the `infinite' sliding calendar and suggested some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; of the features included in this package. Especially significant in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; regard was the suggestion of mark-diary-entries and view-diary-entries,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; together ideas for their implementation, by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; Michael S. Littman Cognitive Science Research Group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; (201) 829-5155 Bell Communications Research
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; mlittman@wind.bellcore.com 445 South St. Box 1961 (2L-331)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Morristown, NJ 07960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; The algorithms for the Hebrew calendar are those of the Rambam (Rabbi Moses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Maimonides), from his Mishneh Torah, as implemented by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; Nachum Dershowitz Department of Computer Science
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; (217) 333-4219 University of Illinois at Urbana-Champaign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; nachum@cs.uiuc.edu 1304 West Springfield Avenue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Urbana, Illinois 61801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; Technical details of all the calendrical calculations can be found in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; pages 899-928. ``Calendrical Calculations, Part II: Three Historical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; Calendars'' by E. M. Reingold, N. Dershowitz, and S. M. Clamen,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; pages 383-404.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Hard copies of these two papers can be obtained by sending email to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; the message BODY containing your mailing address (snail).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun calendar-version ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (message "Version 5.3, January 25, 1994"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar calendar-week-start-day 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "*The day of the week on which a week in the calendar begins.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 0 means Sunday (default), 1 means Monday, and so on.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defvar calendar-offset 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "*The offset of the principal month from the center of the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 0 means the principal month is in the center (default), -1 means on the left,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 +1 means on the right. Larger (or smaller) values push the principal month off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defvar view-diary-entries-initially nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "*Non-nil means display current date's diary entries on entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 The diary is displayed in another window when the calendar is first displayed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 if the current date is visible. The number of days of diary entries displayed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 is governed by the variable `number-of-diary-entries'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defvar number-of-diary-entries 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 "*Specifies how many days of diary entries are to be displayed initially.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 This variable affects the diary display when the command M-x diary is used,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 or if the value of the variable `view-diary-entries-initially' is t. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 example, if the default value 1 is used, then only the current day's diary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 entries will be displayed. If the value 2 is used, then both the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 day's and the next day's entries will be displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 The value can also be a vector such as [0 2 2 2 2 4 1]; this value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 says to display no diary entries on Sunday, the display the entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 for the current date and the day after on Monday through Thursday,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 display Friday through Monday's entries on Friday, and display only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 Saturday's entries on Saturday.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 This variable does not affect the diary display with the `d' command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 from the calendar; in that case, the prefix argument controls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 number of days of diary entries displayed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defvar mark-diary-entries-in-calendar nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "*Non-nil means mark dates with diary entries, in the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 The marking symbol is specified by the variable `diary-entry-marker'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defvar diary-entry-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (make-face 'diary-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (cond ((face-differs-from-default-p 'diary-face) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (t (set-face-foreground 'diary-face "red" 'global '(x color))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (set-face-highlight-p 'diary-face t 'global 'tty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; avoid a weird problem when byte-compiling appt.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; in batch mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if (and (not noninteractive) (fboundp 'x-make-font-bold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (let ((bfont (x-make-font-bold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (face-font-instance 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (mono-tag (list 'x 'mono))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (gray-tag (list 'x 'grayscale)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (if bfont
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (set-face-font 'diary-face bfont 'global mono-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (set-face-font 'diary-face bfont 'global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 gray-tag)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 'diary-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "*Used to mark dates that have diary entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 Can be either a single-character string or a face.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defvar calendar-today-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (make-face 'calendar-today-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (if (not (face-differs-from-default-p 'calendar-today-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (set-face-underline-p 'calendar-today-face t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 'calendar-today-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "*Used to mark today's date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 Can be either a single-character string or a face.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defvar calendar-holiday-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (make-face 'holiday-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (cond ((face-differs-from-default-p 'holiday-face) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (t (let ((color-tag (list 'x 'color))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (mono-tag (list 'x 'mono))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (gray-tag (list 'x 'grayscale)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (set-face-background 'holiday-face [default foreground] 'global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 mono-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (set-face-foreground 'holiday-face [default background] 'global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 mono-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (set-face-background 'holiday-face [default foreground] 'global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 gray-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (set-face-foreground 'holiday-face [default background] 'global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 gray-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (set-face-background 'holiday-face "pink" 'global color-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (set-face-reverse-p 'holiday-face t 'global 'tty))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 'holiday-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "*Used to mark notable dates in the calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 Can be either a single-character string or a face.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defvar view-calendar-holidays-initially nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 "*Non-nil means display holidays for current three month period on entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 The holidays are displayed in another window when the calendar is first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 displayed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defvar mark-holidays-in-calendar nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "*Non-nil means mark dates of holidays in the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 The marking symbol is specified by the variable `calendar-holiday-marker'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defvar all-hebrew-calendar-holidays nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "*If nil, show only major holidays from the Hebrew calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 This means only those Jewish holidays that appear on secular calendars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 If t, show all the holidays that would appear in a complete Hebrew calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defvar all-christian-calendar-holidays nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "*If nil, show only major holidays from the Christian calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 This means only those Christian holidays that appear on secular calendars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 If t, show all the holidays that would appear in a complete Christian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defvar all-islamic-calendar-holidays nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "*If nil, show only major holidays from the Islamic calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 This means only those Islamic holidays that appear on secular calendars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 If t, show all the holidays that would appear in a complete Islamic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (defvar calendar-load-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "*List of functions to be called after the calendar is first loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 This is the place to add key bindings to `calendar-mode-map'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (defvar initial-calendar-window-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 "*List of functions to be called when the calendar window is first opened.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 The functions invoked are called after the calendar window is opened, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 once opened is never called again. Leaving the calendar with the `q' command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 and reentering it will cause these functions to be called again.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defvar today-visible-calendar-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "*List of functions called whenever the current date is visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 This can be used, for example, to replace today's date with asterisks; a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 function `calendar-star-date' is included for this purpose:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq today-visible-calendar-hook 'calendar-star-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 It can also be used to mark the current date with `calendar-today-marker';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 a function is also provided for this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (setq today-visible-calendar-hook 'calendar-mark-today)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 The corresponding variable `today-invisible-calendar-hook' is the list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 functions called when the calendar function was called when the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 date is not visible in the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 Other than the use of the provided functions, the changing of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 characters in the calendar buffer by the hooks may cause the failure of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 functions that move by days and weeks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defvar today-invisible-calendar-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "*List of functions called whenever the current date is not visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 The corresponding variable `today-visible-calendar-hook' is the list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 functions called when the calendar function was called when the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 date is visible in the window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 Other than the use of the provided functions, the changing of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 characters in the calendar buffer by the hooks may cause the failure of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 functions that move by days and weeks.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar diary-file "~/diary"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "*Name of the file in which one's personal diary of dates is kept.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 The file's entries are lines in any of the forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 MONTH/DAY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 MONTH/DAY/YEAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 MONTHNAME DAY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 MONTHNAME DAY, YEAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 DAYNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 at the beginning of the line; the remainder of the line is the diary entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 string for that date. MONTH and DAY are one or two digit numbers, YEAR is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 a number and may be written in full or abbreviated to the final two digits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 If the date does not contain a year, it is generic and applies to any year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 DAYNAME entries apply to any date on which is on that day of the week.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 MONTHNAME and DAYNAME can be spelled in full, abbreviated to three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 characters (with or without a period), capitalized or not. Any of DAY,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 MONTH, or MONTHNAME, YEAR can be `*' which matches any day, month, or year,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 The European style (in which the day precedes the month) can be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 instead, if you execute `european-calendar' when in the calendar, or set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 `european-calendar-style' to t in your .emacs file. The European forms are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 DAY/MONTH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 DAY/MONTH/YEAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 DAY MONTHNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 DAY MONTHNAME YEAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 DAYNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 To revert to the default American style from the European style, execute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 `american-calendar' in the calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 A diary entry can be preceded by the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 `diary-nonmarking-symbol' (ordinarily `&') to make that entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 nonmarking--that is, it will not be marked on dates in the calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 window but will appear in a diary window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 Multiline diary entries are made by indenting lines after the first with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 either a TAB or one or more spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 Lines not in one the above formats are ignored. Here are some sample diary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 entries (in the default American style):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 12/22/1988 Twentieth wedding anniversary!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 &1/1. Happy New Year!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 10/22 Ruth's birthday.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 21: Payday
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 Tuesday--weekly meeting with grad students at 10am
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 Supowit, Shen, Bitner, and Kapoor to attend.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 1/13/89 Friday the thirteenth!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 &thu 4pm squash game with Lloyd.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 mar 16 Dad's birthday
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 April 15, 1989 Income tax due.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 &* 15 time cards due.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 If the first line of a diary entry consists only of the date or day name with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 no trailing blanks or punctuation, then that line is not displayed in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 diary window; only the continuation lines is shown. For example, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 single diary entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 02/11/1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 Bill Blattner visits Princeton today
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 2pm Cognitive Studies Committee meeting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 2:30-5:30 Lizzie at Lawrenceville for `Group Initiative'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 4:00pm Jamie Tappenden
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 7:30pm Dinner at George and Ed's for Alan Ryan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 7:30-10:00pm dance at Stewart Country Day School
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 will appear in the diary window without the date line at the beginning. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 facility allows the diary window to look neater, but can cause confusion if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 used with more than one day's entries displayed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 Diary entries can be based on Lisp sexps. For example, the diary entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 %%(diary-block 11 1 1990 11 10 1990) Vacation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 causes the diary entry \"Vacation\" to appear from November 1 through November
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 10, 1990. Other functions available are `diary-float', `diary-anniversary',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 `diary-cyclic', `diary-day-of-year', `diary-iso-date', `diary-french-date',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 `diary-hebrew-date', `diary-islamic-date', `diary-mayan-date',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 `diary-yahrzeit', `diary-sunrise-sunset', `diary-phases-of-moon',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 `diary-parasha', `diary-omer', `diary-rosh-hodesh', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 `diary-sabbath-candles'. See the documentation for the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 `list-sexp-diary-entries' for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Diary entries based on the Hebrew and/or the Islamic calendar are also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 possible, but because these are somewhat slow, they are ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 unless you set the `nongregorian-diary-listing-hook' and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 `nongregorian-diary-marking-hook' appropriately. See the documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 for these functions for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Diary files can contain directives to include the contents of other files; for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 details, see the documentation for the variable `list-diary-entries-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defvar diary-nonmarking-symbol "&"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "*Symbol indicating that a diary entry is not to be marked in the calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defvar hebrew-diary-entry-symbol "H"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "*Symbol indicating a diary entry according to the Hebrew calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar islamic-diary-entry-symbol "I"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "*Symbol indicating a diary entry according to the Islamic calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (defvar diary-include-string "#include"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "*The string indicating inclusion of another file of diary entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 See the documentation for the function `include-other-diary-files'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defvar sexp-diary-entry-symbol "%%"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "*The string used to indicate a sexp diary entry in diary-file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 See the documentation for the function `list-sexp-diary-entries'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defvar abbreviated-calendar-year t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "*Interpret a two-digit year DD in a diary entry as either 19DD or 20DD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 For the Gregorian calendar; similarly for the Hebrew and Islamic calendars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 If this variable is nil, years must be written in full.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (defvar european-calendar-style nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 "*Use the European style of dates in the diary and in any displays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 If this variable is t, a date 1/2/1990 would be interpreted as February 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 1990. The accepted European date styles are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 DAY/MONTH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 DAY/MONTH/YEAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 DAY MONTHNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 DAY MONTHNAME YEAR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 DAYNAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 Names can be capitalized or not, written in full, or abbreviated to three
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 characters with or without a period.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defvar american-date-diary-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 '((month "/" day "[^/0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (month "/" day "/" year "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (monthname " *" day "[^,0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (monthname " *" day ", *" year "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (dayname "\\W"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "*List of pseudo-patterns describing the American patterns of date used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 See the documentation of `diary-date-forms' for an explanation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (defvar european-date-diary-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 '((day "/" month "[^/0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (day "/" month "/" year "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (backup day " *" monthname "\\W+\\<[^*0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (day " *" monthname " *" year "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (dayname "\\W"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "*List of pseudo-patterns describing the European patterns of date used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 See the documentation of `diary-date-forms' for an explanation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (defvar diary-date-forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if european-calendar-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 european-date-diary-pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 american-date-diary-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 "*List of pseudo-patterns describing the forms of date used in the diary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 The patterns on the list must be MUTUALLY EXCLUSIVE and must should not match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 any portion of the diary entry itself, just the date component.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 A pseudo-pattern is a list of regular expressions and the keywords `month',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 `day', `year', `monthname', and `dayname'. The keyword `monthname' will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 match the name of the month, capitalized or not, or its three-letter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 abbreviation, followed by a period or not; it will also match `*'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 Similarly, `dayname' will match the name of the day, capitalized or not, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 its three-letter abbreviation, followed by a period or not. The keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 `month', `day', and `year' will match those numerical values, preceded by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 arbitrarily many zeros; they will also match `*'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 The matching of the diary entries with the date forms is done with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 standard syntax table from Fundamental mode, but with the `*' changed so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 that it is a word constituent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 If, to be mutually exclusive, a pseudo-pattern must match a portion of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 diary entry itself, the first element of the pattern MUST be `backup'. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 directive causes the date recognizer to back up to the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 current word of the diary entry, so in no case can the pattern match more than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 a portion of the first word of the diary entry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defvar european-calendar-display-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 '((if dayname (concat dayname ", ")) day " " monthname " " year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "*Pseudo-pattern governing the way a date appears in the European style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 See the documentation of calendar-date-display-form for an explanation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defvar american-calendar-display-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 '((if dayname (concat dayname ", ")) monthname " " day ", " year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 "*Pseudo-pattern governing the way a date appears in the American style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 See the documentation of `calendar-date-display-form' for an explanation.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (defvar calendar-date-display-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if european-calendar-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 european-calendar-display-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 american-calendar-display-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 "*Pseudo-pattern governing the way a date appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 Used by the function `calendar-date-string', a pseudo-pattern is a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 expressions that can involve the keywords `month', `day', and `year', all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 numbers in string form, and `monthname' and `dayname', both alphabetic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 strings. For example, the ISO standard would use the pseudo- pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 '(year \"-\" month \"-\" day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 while a typical American form would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 '(month \"/\" day \"/\" (substring year -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 '((format \"%9s, %9s %2s, %4s\" dayname monthname day year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 would give the usual American style in fixed-length fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 See the documentation of the function `calendar-date-string'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (defun european-calendar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 "Set the interpretation and display of dates to the European style."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (setq european-calendar-style t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq calendar-date-display-form european-calendar-display-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (setq diary-date-forms european-date-diary-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (update-calendar-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (defun american-calendar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 "Set the interpretation and display of dates to the American style."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (setq european-calendar-style nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (setq calendar-date-display-form american-calendar-display-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (setq diary-date-forms american-date-diary-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (update-calendar-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (defvar print-diary-entries-hook 'lpr-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 "*List of functions called after a temporary diary buffer is prepared.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 The buffer shows only the diary entries currently visible in the diary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 buffer. The default just does the printing. Other uses might include, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 example, rearranging the lines into order by day and time, saving the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 instead of deleting it, or changing the function used to do the printing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (defvar list-diary-entries-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 "*List of functions called after diary file is culled for relevant entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 It is to be used for diary entries that are not found in the diary file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 A function `include-other-diary-files' is provided for use as the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 this hook. This function enables you to use shared diary files together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 with your own. The files included are specified in the diary file by lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 #include \"filename\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 This is recursive; that is, #include directives in files thus included are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 obeyed. You can change the \"#include\" to some other string by changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 the variable `diary-include-string'. When you use `include-other-diary-files'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 as part of the list-diary-entries-hook, you will probably also want to use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 function `mark-included-diary-files' as part of `mark-diary-entries-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 For example, you could use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (setq list-diary-entries-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 '(include-other-diary-files sort-diary-entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq diary-display-hook 'fancy-diary-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 in your `.emacs' file to cause the fancy diary buffer to be displayed with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 diary entries from various included files, each day's entries sorted into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 lexicographic order.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (defvar diary-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "*List of functions called after the display of the diary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 Can be used for appointment notification.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (defvar diary-display-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 "*List of functions that handle the display of the diary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 If nil (the default), `simple-diary-display' is used. Use `ignore' for no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 diary display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Ordinarily, this just displays the diary buffer (with holidays indicated in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 the mode line), if there are any relevant entries. At the time these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 functions are called, the variable `diary-entries-list' is a list, in order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 by date, of all relevant diary entries in the form of ((MONTH DAY YEAR)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 STRING), where string is the diary entry for the given date. This can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 used, for example, a different buffer for display (perhaps combined with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 holidays), or produce hard copy output.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 A function `fancy-diary-display' is provided as an alternative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 choice for this hook; this function prepares a special noneditable diary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 buffer with the relevant diary entries that has neat day-by-day arrangement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 with headings. The fancy diary buffer will show the holidays unless the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 variable `holidays-in-diary-buffer' is set to nil. Ordinarily, the fancy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 diary buffer will not show days for which there are no diary entries, even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 if that day is a holiday; if you want such days to be shown in the fancy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 diary buffer, set the variable `diary-list-include-blanks' to t.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (defvar nongregorian-diary-listing-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "*List of functions called for listing diary file and included files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 As the files are processed for diary entries, these functions are used to cull
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 relevant entries. You can use either or both of `list-hebrew-diary-entries'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 and `list-islamic-diary-entries'. The documentation for these functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 describes the style of such diary entries.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defvar mark-diary-entries-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "*List of functions called after marking diary entries in the calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 A function `mark-included-diary-files' is also provided for use as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 mark-diary-entries-hook; it enables you to use shared diary files together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 with your own. The files included are specified in the diary file by lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 #include \"filename\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 This is recursive; that is, #include directives in files thus included are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 obeyed. You can change the \"#include\" to some other string by changing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 variable `diary-include-string'. When you use `mark-included-diary-files' as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 part of the mark-diary-entries-hook, you will probably also want to use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 function `include-other-diary-files' as part of `list-diary-entries-hook'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defvar nongregorian-diary-marking-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 "*List of functions called for marking diary file and included files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 As the files are processed for diary entries, these functions are used to cull
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 relevant entries. You can use either or both of `mark-hebrew-diary-entries'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 and `mark-islamic-diary-entries'. The documentation for these functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 describes the style of such diary entries.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (defvar diary-list-include-blanks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 "*If nil, do not include days with no diary entry in the list of diary entries.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
616 Such days will then not be shown in the fancy diary buffer, even if they
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 are holidays.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (defvar holidays-in-diary-buffer t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 "*Non-nil means include holidays in the diary display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 The holidays appear in the mode line of the diary buffer, or in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 fancy diary buffer next to the date. This slows down the diary functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 somewhat; setting it to nil makes the diary display faster.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (defvar calendar-mark-ring nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (defvar general-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 '((holiday-fixed 1 1 "New Year's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (holiday-float 1 1 3 "Martin Luther King Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (holiday-fixed 2 2 "Ground Hog Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (holiday-fixed 2 14 "Valentine's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (holiday-float 2 1 3 "President's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (holiday-fixed 3 17 "St. Patrick's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (holiday-fixed 4 1 "April Fool's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (holiday-float 5 0 2 "Mother's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (holiday-float 5 1 -1 "Memorial Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (holiday-fixed 6 14 "Flag Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (holiday-float 6 0 3 "Father's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (holiday-fixed 7 4 "Independence Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (holiday-float 9 1 1 "Labor Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (holiday-float 10 1 2 "Columbus Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (holiday-fixed 10 31 "Halloween")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (holiday-fixed 11 11 "Veteran's Day")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (holiday-float 11 4 4 "Thanksgiving"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 "*General holidays. Default value is for the United States.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
651 (put 'general-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
652
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defvar local-holidays nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 "*Local holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
659 (put 'local-holidays 'risky-local-variable t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (defvar other-holidays nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 "*User defined holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
666 (put 'other-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
667
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (defvar hebrew-holidays-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 '((holiday-rosh-hashanah-etc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (if all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (holiday-julian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (let* ((m displayed-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (y displayed-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (increment-calendar-month m y -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (let ((year (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (calendar-julian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (list m 1 y))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (if (zerop (% (1+ year) 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 21))) "\"Tal Umatar\" (evening)"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
687 (put 'hebrew-holidays-1 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
688
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (defvar hebrew-holidays-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 '((if all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (holiday-hanukkah)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (holiday-hebrew 9 25 "Hanukkah"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (if all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (holiday-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (let ((h-year (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (list displayed-month 28 displayed-year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (if (= (% (calendar-absolute-from-hebrew (list 10 10 h-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 11 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 "Tzom Teveth"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (if all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (holiday-hebrew 11 15 "Tu B'Shevat"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
710 (put 'hebrew-holidays-2 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
711
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (defvar hebrew-holidays-3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 '((if all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (holiday-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (let ((m displayed-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (y displayed-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (increment-calendar-month m y 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (let* ((h-year (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (list m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (calendar-last-day-of-month m y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 y)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (s-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (if (=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (% (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (list 7 1 h-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 6 (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (list 11 17 h-year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 6 (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (list 11 16 h-year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (day (extract-calendar-day s-s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 day))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 "Shabbat Shirah"))))
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
742 ;;;###autoload
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
743 (put 'hebrew-holidays-3 'risky-local-variable t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (defvar hebrew-holidays-4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 '((holiday-passover-etc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (if (and all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (let* ((m displayed-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (y displayed-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (increment-calendar-month m y -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (let ((year (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (calendar-julian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (list m 1 y))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (= 21 (% year 28)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (holiday-julian 3 26 "Kiddush HaHamah"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if all-hebrew-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (holiday-tisha-b-av-etc))))
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
761 ;;;###autoload
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
762 (put 'hebrew-holidays-4 'risky-local-variable t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (defvar hebrew-holidays (append hebrew-holidays-1 hebrew-holidays-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 hebrew-holidays-3 hebrew-holidays-4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 "*Jewish holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
771 (put 'hebrew-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
772
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (defvar christian-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 '((if all-christian-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (holiday-fixed 1 6 "Epiphany"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (holiday-easter-etc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (if all-christian-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (holiday-greek-orthodox-easter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (if all-christian-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (holiday-fixed 8 15 "Assumption"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (if all-christian-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (holiday-advent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (holiday-fixed 12 25 "Christmas")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (if all-christian-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (holiday-julian 12 25 "Eastern Orthodox Christmas")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 "*Christian holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
791 (put 'christian-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
792
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defvar islamic-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 '((holiday-islamic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 1 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (format "Islamic New Year %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (let ((m displayed-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (y displayed-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (increment-calendar-month m y 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (calendar-islamic-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 m (calendar-last-day-of-month m y) y)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (holiday-islamic 1 10 "Ashura"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (holiday-islamic 3 12 "Mulad-al-Nabi"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (holiday-islamic 7 26 "Shab-e-Mi'raj"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (holiday-islamic 8 15 "Shab-e-Bara't"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (holiday-islamic 9 1 "Ramadan Begins")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (holiday-islamic 9 27 "Shab-e Qadr"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (holiday-islamic 10 1 "Id-al-Fitr"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (if all-islamic-calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (holiday-islamic 12 10 "Id-al-Adha")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 "*Islamic holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
825 (put 'islamic-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
826
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defvar solar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 '((if (fboundp 'atan)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (solar-equinoxes-solstices))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (if (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (require 'cal-dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 'holiday-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 calendar-daylight-savings-starts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 '(format "Daylight Savings Time Begins %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (if (fboundp 'atan)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (solar-time-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (/ calendar-daylight-savings-starts-time (float 60))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 calendar-standard-time-zone-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 'holiday-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 calendar-daylight-savings-ends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 '(format "Daylight Savings Time Ends %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (if (fboundp 'atan)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (solar-time-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (/ calendar-daylight-savings-ends-time (float 60))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 calendar-daylight-time-zone-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 "*Sun-related holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 See the documentation for `calendar-holidays' for details.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;;;###autoload
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
856 (put 'solar-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
857
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
858 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (defvar calendar-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (append general-holidays local-holidays other-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 christian-holidays hebrew-holidays islamic-holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 solar-holidays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 "*List of notable days for the command M-x holidays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 Additional holidays are easy to add to the list, just put them in the list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 `other-holidays' in your .emacs file. Similarly, by setting any of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 `general-holidays', `local-holidays' `christian-holidays', `hebrew-holidays',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 `islamic-holidays', or `solar-holidays' to nil in your .emacs file, you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 eliminate unwanted categories of holidays. The intention is that (in the US)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 `local-holidays' be set in site-init.el and `other-holidays' be set by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 Entries on the list are expressions that return (possibly empty) lists of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 items of the form ((month day year) string) of a holiday in the in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 three-month period centered around `displayed-month' of `displayed-year'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 Several basic functions are provided for this purpose:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (holiday-fixed MONTH DAY STRING) is a fixed date on the Gregorian calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (holiday-float MONTH DAYNAME K STRING &optional day) is the Kth DAYNAME in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 MONTH on the Gregorian calendar (0 for Sunday,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 etc.); K<0 means count back from the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 month. An optional parameter DAY means the Kth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 DAYNAME after/before MONTH DAY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (holiday-hebrew MONTH DAY STRING) a fixed date on the Hebrew calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (holiday-islamic MONTH DAY STRING) a fixed date on the Islamic calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (holiday-julian MONTH DAY STRING) a fixed date on the Julian calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (holiday-sexp SEXP STRING) SEXP is a Gregorian-date-valued expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 in the variable `year'; if it evaluates to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 a visible date, that's the holiday; if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 evaluates to nil, there's no holiday. STRING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 is an expression in the variable `date'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 For example, to add Bastille Day, celebrated in France on July 14, add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (holiday-fixed 7 14 \"Bastille Day\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 to the list. To add Hurricane Supplication Day, celebrated in the Virgin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 Islands on the fourth Monday in August, add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (holiday-float 8 1 4 \"Hurricane Supplication Day\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 to the list (the last Monday would be specified with `-1' instead of `4').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 To add the last day of Hanukkah to the list, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (holiday-hebrew 10 2 \"Last day of Hanukkah\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 since the Hebrew months are numbered with 1 starting from Nisan, while to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 add the Islamic feast celebrating Mohammed's birthday use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (holiday-islamic 3 12 \"Mohammed's Birthday\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 since the Islamic months are numbered from 1 starting with Muharram. To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 add Thomas Jefferson's birthday, April 2, 1743 (Julian), use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (holiday-julian 4 2 \"Jefferson's Birthday\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 To include a holiday conditionally, use the sexp form or a conditional. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 example, to include American presidential elections, which occur on the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 Tuesday after the first Monday in November of years divisible by 4, add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (holiday-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (if (zerop (% year 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (1+ (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 1 (+ 6 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (list 11 1 year)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 \"US Presidential Election\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (if (zerop (% displayed-year 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (holiday-fixed 11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (extract-calendar-day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (1+ (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 1 (+ 6 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (list 11 1 displayed-year)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 \"US Presidential Election\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 to the list. To include the phases of the moon, add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (lunar-phases)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 to the holiday list, where `lunar-phases' is an Emacs-Lisp function that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 you've written to return a (possibly empty) list of the relevant VISIBLE dates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 with descriptive strings such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (((2 6 1989) \"New Moon\") ((2 12 1989) \"First Quarter Moon\") ... ).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
950 ;;;###autoload
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
951 (put 'calendar-holidays 'risky-local-variable t)
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
952
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (defconst calendar-buffer "*Calendar*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 "Name of the buffer used for the calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (defconst holiday-buffer "*Holidays*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 "Name of the buffer used for the displaying the holidays.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (defconst fancy-diary-buffer "*Fancy Diary Entries*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 "Name of the buffer used for the optional fancy display of the diary.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (defconst lunar-phases-buffer "*Phases of Moon*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 "Name of the buffer used for the lunar phases.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (defmacro increment-calendar-month (mon yr n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 "Move the variables MON and YR to the month and year by N months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 Forward if N is positive or backward if N is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (` (let (( macro-y (+ (* (, yr) 12) (, mon) -1 (, n) )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (setq (, mon) (1+ (% macro-y 12) ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (setq (, yr) (/ macro-y 12)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (defmacro calendar-for-loop (var from init to final do &rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "Execute a for loop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (` (let (( (, var) (1- (, init)) ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (while (>= (, final) (setq (, var) (1+ (, var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (,@ body)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (defmacro calendar-sum (index initial condition expression)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 "For INDEX = INITIAL et seq, as long as CONDITION holds, sum EXPRESSION."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (` (let (( (, index) (, initial))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (sum 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (while (, condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (setq sum (+ sum (, expression) ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (setq (, index) (1+ (, index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 sum)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;; The following are in-line for speed; they can be called thousands of times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;; when looking up holidays or processing the diary. Here, for example, are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;; the numbers of calls to calendar/diary/holiday functions in preparing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;; fancy diary display, for a moderately complex diary file, with functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;; used instead of macros. There were a total of 10000 such calls:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;; 1934 extract-calendar-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; 1852 extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; 1819 extract-calendar-day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; 845 calendar-leap-year-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; 837 calendar-day-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;; 775 calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; 346 calendar-last-day-of-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; 286 hebrew-calendar-last-day-of-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; 188 hebrew-calendar-leap-year-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; 180 hebrew-calendar-elapsed-days
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; 163 hebrew-calendar-last-month-of-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; 66 calendar-date-compare
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 ;; 65 hebrew-calendar-days-in-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 ;; 60 calendar-absolute-from-julian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ;; 50 calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 ;; 43 calendar-date-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ;; 38 calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 ;; .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;; .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 ;; The use of these seven macros eliminates the overhead of 92% of the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ;; calls; it's faster this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (defsubst extract-calendar-month (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 "Extract the month part of DATE which has the form (month day year)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (car date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (defsubst extract-calendar-day (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 "Extract the day part of DATE which has the form (month day year)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (car (cdr date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (defsubst extract-calendar-year (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 "Extract the year part of DATE which has the form (month day year)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (car (cdr (cdr date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (defsubst calendar-leap-year-p (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 "Returns t if YEAR is a Gregorian leap year."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (and (zerop (% year 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (or (not (zerop (% year 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (zerop (% year 400)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;; The foregoing is a bit faster, but not as clear as the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ;;(defsubst calendar-leap-year-p (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 ;; "Returns t if YEAR is a Gregorian leap year."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ;; (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 ;; (and (= (% year 4) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 ;; (/= (% year 100) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 ;; (= (% year 400) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (defsubst calendar-last-day-of-month (month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 "The last day in MONTH during YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (if (and (= month 2) (calendar-leap-year-p year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (aref [31 28 31 30 31 30 31 31 30 31 30 31] (1- month))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ;; An explanation of the calculation can be found in PascAlgorithms by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 ;; Edward and Ruth Reingold, Scott-Foresman/Little, Brown, 1988.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (defsubst calendar-day-number (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 "Return the day number within the year of the date DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 For example, (calendar-day-number '(1 1 1987)) returns the value 1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 while (calendar-day-number '(12 31 1980)) returns 366."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (let* ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (day-of-year (+ day (* 31 (1- month)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (if (> month 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (setq day-of-year (- day-of-year (/ (+ 23 (* 4 month)) 10)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (if (calendar-leap-year-p year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (setq day-of-year (1+ day-of-year)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 day-of-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (defsubst calendar-absolute-from-gregorian (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 The Gregorian date Sunday, December 31, 1 BC is imaginary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (let ((prior-years (1- (extract-calendar-year date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (+ (calendar-day-number date);; Days this year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (* 365 prior-years);; + Days in prior years
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (/ prior-years 4);; + Julian leap years
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (- (/ prior-years 100));; - century years
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (/ prior-years 400))));; + Gregorian leap years
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (defun calendar (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 "Display a three-month calendar in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 The three months appear side by side, with the current month in the middle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 surrounded by the previous and next months. The cursor is put on today's date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 If called with an optional prefix argument, prompts for month and year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 This function is suitable for execution in a .emacs file; appropriate setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 of the variable `view-diary-entries-initially' will cause the diary entries for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 the current date to be displayed in another window. The value of the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 `number-of-diary-entries' controls the number of days of diary entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 displayed upon initial display of the calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 An optional prefix argument ARG causes the calendar displayed to be ARG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 months in the future if ARG is positive or in the past if ARG is negative;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 in this case the cursor goes on the first day of the month.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 Once in the calendar window, future or past months can be moved into view.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 Arbitrary months can be displayed, or the calendar can be scrolled forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 or backward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 The cursor can be moved forward or backward by one day, one week, one month,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 or one year. All of these commands take prefix arguments which, when negative,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 cause movement in the opposite direction. For convenience, the digit keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 and the minus sign are automatically prefixes. The window is replotted as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 necessary to display the desired date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 Diary entries can be marked on the calendar or displayed in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 Use M-x describe-mode for details of the key bindings in the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 The Gregorian calendar is assumed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 After loading the calendar, the hooks given by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 `calendar-load-hook' are run. This is the place to add key bindings to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 calendar-mode-map.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 After preparing the calendar window initially, the hooks given by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 `initial-calendar-window-hook' are run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 The hooks given by the variable `today-visible-calendar-hook' are run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 everytime the calendar window gets scrolled, if the current date is visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 in the window. If it is not visible, the hooks given by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 `today-invisible-calendar-hook' are run. Thus, for example, setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 `today-visible-calendar-hook' to 'calendar-star-date will cause today's date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 to be replaced by asterisks to highlight it whenever it is in the window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (set-buffer (get-buffer-create calendar-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (calendar-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (let* ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (split-height-threshold 1000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (date (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (calendar-read-date t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (calendar-current-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (pop-to-buffer calendar-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (increment-calendar-month month year (- calendar-offset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (generate-calendar-window month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (if (and view-diary-entries-initially (calendar-date-is-visible-p date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (view-diary-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (if (vectorp number-of-diary-entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (aref number-of-diary-entries (calendar-day-of-week date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 number-of-diary-entries))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (let* ((diary-buffer (get-file-buffer diary-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (diary-window (if diary-buffer (get-buffer-window diary-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (split-height-threshold (if diary-window 2 1000)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (if view-calendar-holidays-initially
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (list-calendar-holidays)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (run-hooks 'initial-calendar-window-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (autoload 'view-diary-entries "diary-lib"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 "Prepare and display a buffer with diary entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 Searches your diary file for entries that match ARG days starting with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 the date indicated by the cursor position in the displayed three-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 calendar."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (autoload 'calendar-sunrise-sunset "solar"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 "Local time of sunrise and sunset for date under cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (autoload 'calendar-phases-of-moon "lunar"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 "Create a buffer of the phases of the moon for the current calendar window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (autoload 'calendar-print-french-date "cal-french"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 "Show the French Revolutionary calendar equivalent of the date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (autoload 'calendar-goto-french-date "cal-french"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 "Move cursor to French Revolutionary date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (autoload 'calendar-french-date-string "cal-french"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 "String of French Revolutionary date of Gregorian DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (autoload 'calendar-mayan-date-string "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 "String of Mayan date of Gregorian DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (autoload 'calendar-print-mayan-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 "Show the Mayan long count, Tzolkin, and Haab equivalents of the date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (autoload 'calendar-goto-mayan-long-count-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 "Move cursor to Mayan long count date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (autoload 'calendar-next-haab-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 "Move cursor to next instance of Mayan Haab date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (autoload 'calendar-previous-haab-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 "Move cursor to previous instance of Mayan Haab date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (autoload 'calendar-next-tzolkin-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 "Move cursor to next instance of Mayan Tzolkin date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (autoload 'calendar-previous-tzolkin-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 "Move cursor to previous instance of Mayan Tzolkin date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (autoload 'calendar-next-calendar-round-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 "Move cursor to next instance of Mayan Haab/Tzoklin combination."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (autoload 'calendar-previous-calendar-round-date "cal-mayan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 "Move cursor to previous instance of Mayan Haab/Tzoklin combination."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (autoload 'show-all-diary-entries "diary-lib"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 "Show all of the diary entries in the diary file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 This function gets rid of the selective display of the diary file so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 all entries, not just some, are visible. If there is no diary buffer, one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 is created."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (autoload 'mark-diary-entries "diary-lib"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 "Mark days in the calendar window that have diary entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 Each entry in diary file visible in the calendar window is marked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (autoload 'insert-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 "Insert a diary entry for the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (autoload 'insert-weekly-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 "Insert a weekly diary entry for the day of the week indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (autoload 'insert-monthly-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 "Insert a monthly diary entry for the day of the month indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (autoload 'insert-yearly-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 "Insert an annual diary entry for the day of the year indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (autoload 'insert-anniversary-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 "Insert an anniversary diary entry for the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (autoload 'insert-block-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 "Insert a block diary entry for the dates indicated by point and mark."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (autoload 'insert-cyclic-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 "Insert a cyclic diary entry starting at the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (autoload 'insert-hebrew-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 "Insert a diary entry for the Hebrew date corresponding to the date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (autoload 'insert-monthly-hebrew-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 "Insert a monthly diary entry for the day of the Hebrew month corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 to the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (autoload 'insert-yearly-hebrew-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 "Insert an annual diary entry for the day of the Hebrew year corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 to the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (autoload 'insert-islamic-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 "Insert a diary entry for the Islamic date corresponding to the date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (autoload 'insert-monthly-islamic-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 "Insert a monthly diary entry for the day of the Islamic month corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 to the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (autoload 'insert-yearly-islamic-diary-entry "diary-ins"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 "Insert an annual diary entry for the day of the Islamic year corresponding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 to the date indicated by point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (autoload 'list-calendar-holidays "holidays"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 "Create a buffer containing the holidays for the current calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 The holidays are those in the list `calendar-notable-days'. Returns t if any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 holidays are found, nil if not."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (autoload 'mark-calendar-holidays "holidays"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 "Mark notable days in the calendar window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (autoload 'calendar-cursor-holidays "holidays"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 "Find holidays for the date specified by the cursor in the calendar window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (defun generate-calendar-window (&optional mon yr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 "Generate the calendar window for the current date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 Or, for optional MON, YR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (let* ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (today (calendar-current-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (month (extract-calendar-month today))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (day (extract-calendar-day today))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (year (extract-calendar-year today))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (today-visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (or (not mon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (let ((offset (calendar-interval mon yr month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (and (<= offset 1) (>= offset -1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (day-in-week (calendar-day-of-week today)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (update-calendar-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (if mon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (generate-calendar mon yr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (generate-calendar month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (calendar-cursor-to-visible-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (if today-visible today (list displayed-month 1 displayed-year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (or (one-window-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (/= (frame-width) (window-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (shrink-window (- (window-height) 9)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (and mark-holidays-in-calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (mark-calendar-holidays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (sit-for 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (if mark-diary-entries-in-calendar (mark-diary-entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (if today-visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (run-hooks 'today-visible-calendar-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (run-hooks 'today-invisible-calendar-hook)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (defun generate-calendar (month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 "Generate a three-month Gregorian calendar centered around MONTH, YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (if (< (+ month (* 12 (1- year))) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (error "Months before February, 1 AD are not available."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (setq displayed-month month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (setq displayed-year year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (increment-calendar-month month year -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (calendar-for-loop i from 0 to 2 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (generate-calendar-month month year (+ 5 (* 25 i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (increment-calendar-month month year 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (defun generate-calendar-month (month year indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 "Produce a calendar for MONTH, YEAR on the Gregorian calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 The calendar is inserted in the buffer starting at the line on which point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 is currently located, but indented INDENT spaces. The indentation is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 from the first character on the line and does not disturb the first INDENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 characters on the line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (let* ((blank-days;; at start of month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (mod
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (- (calendar-day-of-week (list month 1 year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 calendar-week-start-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (last (calendar-last-day-of-month month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (calendar-insert-indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (calendar-string-spread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (list "" (format "%s %d" (calendar-month-name month) year) "") ? 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 indent t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (calendar-insert-indented "" indent);; Go to proper spot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (calendar-for-loop i from 0 to 6 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (insert (substring (aref calendar-day-name-array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (mod (+ calendar-week-start-day i) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 0 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (calendar-insert-indented "" 0 t);; Force onto following line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (calendar-insert-indented "" indent);; Go to proper spot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; Add blank days before the first of the month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (calendar-for-loop i from 1 to blank-days do (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; Put in the days of the month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (calendar-for-loop i from 1 to last do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (insert (format "%2d " i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (put-text-property (- (point) (if (< i 10) 2 3)) (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 'highlight t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (and (zerop (mod (+ i blank-days) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (/= i last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (calendar-insert-indented "" 0 t) ;; Force onto following line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (calendar-insert-indented "" indent)))));; Go to proper spot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (defun calendar-insert-indented (string indent &optional newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 "Insert STRING at column INDENT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 If the optional parameter NEWLINE is t, leave point at start of next line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 inserting a newline if there was no next line; otherwise, leave point after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 the inserted text. Value is always t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 ;; Try to move to that column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (move-to-column indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 ;; If line is too short, indent out to that column.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (if (< (current-column) indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (indent-to indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 ;; Advance to next line, if requested.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (if newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (defun redraw-calendar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 "Redraw the calendar display."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (let ((cursor-date (calendar-cursor-to-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (generate-calendar-window displayed-month displayed-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (calendar-cursor-to-visible-date cursor-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (defvar calendar-debug-sexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 "*Turn debugging on when evaluating a sexp in the diary or holiday list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (defvar calendar-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (if calendar-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (setq calendar-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (calendar-for-loop i from 0 to 9 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (define-key calendar-mode-map (int-to-string i) 'digit-argument))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (let ((l (list 'narrow-to-region 'mark-word 'mark-sexp 'mark-paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 'mark-defun 'mark-whole-buffer 'mark-page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 'downcase-region 'upcase-region 'kill-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 'copy-region-as-kill 'capitalize-region 'write-region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (while l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (substitute-key-definition (car l) 'calendar-not-implemented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 calendar-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (setq l (cdr l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (define-key calendar-mode-map "-" 'negative-argument)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (define-key calendar-mode-map "\C-x>" 'scroll-calendar-right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (define-key calendar-mode-map '[prior] 'scroll-calendar-right-three-months)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (define-key calendar-mode-map "\M-v" 'scroll-calendar-right-three-months)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (define-key calendar-mode-map "\C-x<" 'scroll-calendar-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (define-key calendar-mode-map '[next] 'scroll-calendar-left-three-months)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (define-key calendar-mode-map "\C-v" 'scroll-calendar-left-three-months)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (define-key calendar-mode-map "\C-b" 'calendar-backward-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (define-key calendar-mode-map "\C-p" 'calendar-backward-week)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (define-key calendar-mode-map "\M-{" 'calendar-backward-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (define-key calendar-mode-map "\C-x[" 'calendar-backward-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (define-key calendar-mode-map "\C-f" 'calendar-forward-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (define-key calendar-mode-map "\C-n" 'calendar-forward-week)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (define-key calendar-mode-map '[left] 'calendar-backward-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (define-key calendar-mode-map '[up] 'calendar-backward-week)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (define-key calendar-mode-map '[right] 'calendar-forward-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (define-key calendar-mode-map '[down] 'calendar-forward-week)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (define-key calendar-mode-map "\M-}" 'calendar-forward-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (define-key calendar-mode-map "\C-x]" 'calendar-forward-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (define-key calendar-mode-map "\C-a" 'calendar-beginning-of-week)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (define-key calendar-mode-map "\C-e" 'calendar-end-of-week)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (define-key calendar-mode-map "\M-a" 'calendar-beginning-of-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (define-key calendar-mode-map "\M-e" 'calendar-end-of-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (define-key calendar-mode-map "\M-<" 'calendar-beginning-of-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (define-key calendar-mode-map "\M->" 'calendar-end-of-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (define-key calendar-mode-map "\C-@" 'calendar-set-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;; Many people are used to typing C-SPC and getting C-@.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (define-key calendar-mode-map "\C- " 'calendar-set-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (define-key calendar-mode-map "\C-x\C-x" 'calendar-exchange-point-and-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (define-key calendar-mode-map "\M-=" 'calendar-count-days-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (define-key calendar-mode-map "gd" 'calendar-goto-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (define-key calendar-mode-map "gj" 'calendar-goto-julian-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (define-key calendar-mode-map "ga" 'calendar-goto-astro-day-number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (define-key calendar-mode-map "gh" 'calendar-goto-hebrew-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (define-key calendar-mode-map "gi" 'calendar-goto-islamic-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (define-key calendar-mode-map "gc" 'calendar-goto-iso-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (define-key calendar-mode-map "gf" 'calendar-goto-french-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (define-key calendar-mode-map "gml" 'calendar-goto-mayan-long-count-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (define-key calendar-mode-map "gmpc" 'calendar-previous-calendar-round-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (define-key calendar-mode-map "gmnc" 'calendar-next-calendar-round-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (define-key calendar-mode-map "gmph" 'calendar-previous-haab-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (define-key calendar-mode-map "gmnh" 'calendar-next-haab-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (define-key calendar-mode-map "gmpt" 'calendar-previous-tzolkin-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (define-key calendar-mode-map "gmnt" 'calendar-next-tzolkin-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (define-key calendar-mode-map "S" 'calendar-sunrise-sunset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (define-key calendar-mode-map "M" 'calendar-phases-of-moon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (define-key calendar-mode-map " " 'scroll-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (define-key calendar-mode-map "\C-c\C-l" 'redraw-calendar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (define-key calendar-mode-map "." 'calendar-goto-today)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (define-key calendar-mode-map "o" 'calendar-other-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (define-key calendar-mode-map "q" 'exit-calendar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (define-key calendar-mode-map "a" 'list-calendar-holidays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (define-key calendar-mode-map "h" 'calendar-cursor-holidays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (define-key calendar-mode-map "x" 'mark-calendar-holidays)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (define-key calendar-mode-map "u" 'calendar-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (define-key calendar-mode-map "m" 'mark-diary-entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (define-key calendar-mode-map "d" 'view-diary-entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (define-key calendar-mode-map "D" 'view-other-diary-entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (define-key calendar-mode-map "s" 'show-all-diary-entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (define-key calendar-mode-map "pd" 'calendar-print-day-of-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (define-key calendar-mode-map "pc" 'calendar-print-iso-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (define-key calendar-mode-map "pj" 'calendar-print-julian-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (define-key calendar-mode-map "pa" 'calendar-print-astro-day-number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (define-key calendar-mode-map "ph" 'calendar-print-hebrew-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (define-key calendar-mode-map "pi" 'calendar-print-islamic-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (define-key calendar-mode-map "pf" 'calendar-print-french-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 (define-key calendar-mode-map "pm" 'calendar-print-mayan-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (define-key calendar-mode-map "id" 'insert-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (define-key calendar-mode-map "iw" 'insert-weekly-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (define-key calendar-mode-map "im" 'insert-monthly-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (define-key calendar-mode-map "iy" 'insert-yearly-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (define-key calendar-mode-map "ia" 'insert-anniversary-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (define-key calendar-mode-map "ib" 'insert-block-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (define-key calendar-mode-map "ic" 'insert-cyclic-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (define-key calendar-mode-map "ihd" 'insert-hebrew-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (define-key calendar-mode-map "ihm" 'insert-monthly-hebrew-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (define-key calendar-mode-map "ihy" 'insert-yearly-hebrew-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (define-key calendar-mode-map "iid" 'insert-islamic-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (define-key calendar-mode-map "iim" 'insert-monthly-islamic-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (define-key calendar-mode-map "iiy" 'insert-yearly-islamic-diary-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (define-key calendar-mode-map "?" 'calendar-goto-info-node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (defun describe-calendar-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 "Create a help buffer with a brief description of the calendar-mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 "Calendar Mode:\nFor a complete description, type %s\n%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 "\\<calendar-mode-map>\\[describe-mode] from within the calendar")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (substitute-command-keys "\\{calendar-mode-map}")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (help-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (print-help-return-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 ;; Calendar mode is suitable only for specially formatted data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (put 'calendar-mode 'mode-class 'special)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (defvar calendar-mode-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 (substitute-command-keys "\\<calendar-mode-map>\\[scroll-calendar-left]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 "Calendar"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (substitute-command-keys "\\<calendar-mode-map>\\[calendar-goto-info-node] info/\\[calendar-other-month] other/\\[calendar-goto-today] today")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 '(calendar-date-string (calendar-current-date) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (substitute-command-keys "\\<calendar-mode-map>\\[scroll-calendar-right]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 "The mode line of the calendar buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (defun calendar-goto-info-node ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 "Go to the info node for the calendar."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (require 'info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (let ((where (Info-find-emacs-command-nodes 'calendar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (if (not where)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (error "Couldn't find documentation for the calendar.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (save-window-excursion (info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (pop-to-buffer "*info*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (Info-find-node (car (car where)) (car (cdr (car where)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (defun calendar-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 "A major mode for the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 For a complete description, type \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 \\<calendar-mode-map>\\[calendar-goto-info-node] from within the calendar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 \\<calendar-mode-map>\\{calendar-mode-map}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (setq major-mode 'calendar-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (setq mode-name "Calendar")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (use-local-map calendar-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (setq indent-tabs-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (update-calendar-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (if (and (string-match "XEmacs" emacs-version) current-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (require 'cal-xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (calendar-add-menus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (make-variable-buffer-local 'scroll-on-clipped-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (setq scroll-on-clipped-lines nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (make-local-variable 'calendar-mark-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (make-local-variable 'displayed-month);; Month in middle of window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (make-local-variable 'displayed-year));; Year in middle of window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (defun calendar-string-spread (strings char length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 "Concatenate list of STRINGS separated with copies of CHAR to fill LENGTH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 There must be at least 2 strings. The effect is like mapconcat but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 separating pieces are as balanced as possible. Each item of STRINGS is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 evaluated before concatenation so it can actually be an expression that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 evaluates to a string. If LENGTH is too short, the STRINGS are just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 concatenated and the result truncated."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ;; The algorithm is based on equation (3.25) on page 85 of Concrete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;; Mathematics by Ronald L. Graham, Donald E. Knuth, and Oren Patashnik,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ;; Addison-Wesley, Reading, MA, 1989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (let* ((strings (mapcar 'eval strings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (n (- length (length (apply 'concat strings))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 (m (1- (length strings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 (s (car strings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (strings (cdr strings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (while strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (setq s (concat s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (make-string (max 0 (/ (+ n i) m)) char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (car strings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (setq strings (cdr strings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (substring s 0 length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (defun update-calendar-mode-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 "Update the calendar mode line with the current date and date style."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (if (bufferp (get-buffer calendar-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (set-buffer calendar-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (setq mode-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (calendar-string-spread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 calendar-mode-line-format ? (frame-width))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (defun calendar-window-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 "List of all calendar-related windows."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (let ((calendar-buffers (calendar-buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (walk-windows '(lambda (w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (if (memq (window-buffer w) calendar-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (setq list (cons w list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (defun calendar-buffer-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 "List of all calendar-related buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (let* ((diary-buffer (get-file-buffer diary-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (buffers (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 fancy-diary-buffer diary-buffer calendar-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (buffer-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (setq b (car buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (setq b (cond ((stringp b) (get-buffer b))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 ((bufferp b) b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (if b (setq buffer-list (cons b buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (setq buffers (cdr buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (defun exit-calendar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 "Get out of the calendar window and hide it and related buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (let* ((diary-buffer (get-file-buffer diary-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (if (and diary-buffer (buffer-modified-p diary-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 (yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 "Diary modified; do you really want to exit the calendar? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ;; Need to do this multiple times because one time can replace some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; calendar-related buffers with other calendar-related buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 (mapcar (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (mapcar 'calendar-hide-window (calendar-window-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (calendar-window-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (defun calendar-hide-window (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 "Hide WINDOW if it is calendar-related."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (let ((buffer (if (window-live-p window) (window-buffer window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (if (memq buffer (calendar-buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ((and window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (eq 'icon (cdr (assoc 'visibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (frame-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (window-frame window))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ((and window-system (window-dedicated-p window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (iconify-frame (window-frame window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ((not (and (select-window window) (one-window-p window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (delete-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (t (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (bury-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (defun calendar-goto-today ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 "Reposition the calendar window so the current date is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (let ((today (calendar-current-date)));; The date might have changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (if (not (calendar-date-is-visible-p today))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (generate-calendar-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (update-calendar-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (calendar-cursor-to-visible-date today))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (defun calendar-forward-month (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 "Move the cursor forward ARG months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 Movement is backward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (let* ((cursor-date (calendar-cursor-to-date t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (month (extract-calendar-month cursor-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (day (extract-calendar-day cursor-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (year (extract-calendar-year cursor-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (increment-calendar-month month year arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (let ((last (calendar-last-day-of-month month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (if (< last day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (setq day last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;; Put the new month on the screen, if needed, and go to the new date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (let ((new-cursor-date (list month day year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (if (not (calendar-date-is-visible-p new-cursor-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (calendar-other-month month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (calendar-cursor-to-visible-date new-cursor-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (defun calendar-forward-year (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 "Move the cursor forward by ARG years.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 Movement is backward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (calendar-forward-month (* 12 arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (defun calendar-backward-month (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 "Move the cursor backward by ARG months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 Movement is forward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (calendar-forward-month (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (defun calendar-backward-year (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 "Move the cursor backward ARG years.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 Movement is forward is ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (calendar-forward-month (* -12 arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (defun scroll-calendar-left (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 "Scroll the displayed calendar left by ARG months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 If ARG is negative the calendar is scrolled right. Maintains the relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 position of the cursor with respect to the calendar as well as possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (let ((old-date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (today (calendar-current-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (if (/= arg 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (increment-calendar-month displayed-month displayed-year arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (generate-calendar-window displayed-month displayed-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (calendar-cursor-to-visible-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ((calendar-date-is-visible-p old-date) old-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ((calendar-date-is-visible-p today) today)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (t (list displayed-month 1 displayed-year))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (defun scroll-calendar-right (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 "Scroll the displayed calendar window right by ARG months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 If ARG is negative the calendar is scrolled left. Maintains the relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 position of the cursor with respect to the calendar as well as possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (scroll-calendar-left (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (defun scroll-calendar-left-three-months (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 "Scroll the displayed calendar window left by 3*ARG months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 If ARG is negative the calendar is scrolled right. Maintains the relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 position of the cursor with respect to the calendar as well as possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (scroll-calendar-left (* 3 arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (defun scroll-calendar-right-three-months (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 "Scroll the displayed calendar window right by 3*ARG months.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 If ARG is negative the calendar is scrolled left. Maintains the relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 position of the cursor with respect to the calendar as well as possible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (scroll-calendar-left (* -3 arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (defun calendar-current-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 "Returns the current date in a list (month day year)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (let ((s (current-time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (list (length (member (substring s 4 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 '("Dec" "Nov" "Oct" "Sep" "Aug" "Jul"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 "Jun" "May" "Apr" "Mar" "Feb" "Jan")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (string-to-number (substring s 8 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (string-to-number (substring s 20 24)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (defun calendar-cursor-to-date (&optional error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 "Returns a list (month day year) of current cursor position.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 If cursor is not on a specific date, signals an error if optional parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 ERROR is t, otherwise just returns nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;; #### This check is to avoid a race condition created by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 ;; pop-to-buffer's call to other-window interacting with the 19.13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 ;; changes allowing that to be in another frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (if (not (number-or-marker-p displayed-month))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (let* ((segment (/ (current-column) 25))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (month (% (+ displayed-month segment -1) 12))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (month (if (= 0 month) 12 month))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ((and (= 12 month) (= segment 0)) (1- displayed-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ((and (= 1 month) (= segment 2)) (1+ displayed-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (t displayed-year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (if (and (looking-at "[0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (< 2 (count-lines (point-min) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (re-search-backward "[^0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (list month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (string-to-int (buffer-substring (1+ (point)) (+ 4 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (if (looking-at "\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (re-search-backward "[^*]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (if (looking-at ".\\*\\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (list month calendar-starred-day year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (if error (error "Not on a date!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (if error (error "Not on a date!")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (defun calendar-cursor-to-nearest-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 "Move the cursor to the closest date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 The position of the cursor is unchanged if it is already on a date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 Returns the list (month day year) giving the cursor position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (let ((date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (column (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (if date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (if (> 3 (count-lines (point-min) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (goto-line 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (move-to-column column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (if (not (looking-at "[0-9]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (if (and (not (looking-at " *$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (or (< column 25)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (and (> column 27)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (< column 50))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (and (> column 52)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (< column 75))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (re-search-forward "[0-9]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (re-search-backward "[0-9]" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (calendar-cursor-to-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (defun calendar-forward-day (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 "Move the cursor forward ARG days.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 Moves backward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (if (/= 0 arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (let*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ((cursor-date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (cursor-date (if cursor-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 cursor-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (if (> arg 0) (setq arg (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (calendar-cursor-to-nearest-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (new-cursor-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (+ (calendar-absolute-from-gregorian cursor-date) arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (new-display-month (extract-calendar-month new-cursor-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (new-display-year (extract-calendar-year new-cursor-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 ;; Put the new month on the screen, if needed, and go to the new date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (if (not (calendar-date-is-visible-p new-cursor-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (calendar-other-month new-display-month new-display-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (calendar-cursor-to-visible-date new-cursor-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (defun calendar-backward-day (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 "Move the cursor back ARG days.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 Moves forward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (calendar-forward-day (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (defun calendar-forward-week (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 "Move the cursor forward ARG weeks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 Moves backward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (calendar-forward-day (* arg 7)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (defun calendar-backward-week (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 "Move the cursor back ARG weeks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 Moves forward if ARG is negative."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (calendar-forward-day (* arg -7)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (defun calendar-beginning-of-week (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 "Move the cursor back ARG calendar-week-start-day's."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (let ((day (calendar-day-of-week (calendar-cursor-to-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (calendar-backward-day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (if (= day calendar-week-start-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (* 7 arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (+ (mod (- day calendar-week-start-day) 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (* 7 (1- arg)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (defun calendar-end-of-week (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 "Move the cursor forward ARG calendar-week-start-day+6's."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (let ((day (calendar-day-of-week (calendar-cursor-to-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 (calendar-forward-day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (if (= day (mod (1- calendar-week-start-day) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (* 7 arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (+ (- 6 (mod (- day calendar-week-start-day) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (* 7 (1- arg)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (defun calendar-beginning-of-month (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 "Move the cursor backward ARG month beginnings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (let* ((date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (if (= day 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (calendar-backward-month arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (calendar-cursor-to-visible-date (list month 1 year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (calendar-backward-month (1- arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (defun calendar-end-of-month (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 "Move the cursor forward ARG month ends."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (let* ((date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (last-day (calendar-last-day-of-month month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (if (/= day last-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (calendar-cursor-to-visible-date (list month last-day year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (setq arg (1- arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (increment-calendar-month month year arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (let ((last-day (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 (calendar-last-day-of-month month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (if (not (calendar-date-is-visible-p last-day))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (calendar-other-month month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (calendar-cursor-to-visible-date last-day)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (defun calendar-beginning-of-year (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 "Move the cursor backward ARG year beginnings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (let* ((date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 (year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (jan-first (list 1 1 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 (if (and (= day 1) (= 1 month))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (calendar-backward-month (* 12 arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (if (and (= arg 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (calendar-date-is-visible-p jan-first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (calendar-cursor-to-visible-date jan-first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (calendar-other-month 1 (- year (1- arg)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (defun calendar-end-of-year (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 "Move the cursor forward ARG year beginnings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (calendar-cursor-to-nearest-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (let* ((date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (dec-31 (list 12 31 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (if (and (= day 31) (= 12 month))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (calendar-forward-month (* 12 arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (if (and (= arg 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (calendar-date-is-visible-p dec-31))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (calendar-cursor-to-visible-date dec-31)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (calendar-other-month 12 (- year (1- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (calendar-cursor-to-visible-date (list 12 31 displayed-year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 ;; The following version of calendar-gregorian-from-absolute is preferred for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 ;; reasons of clarity, BUT it's much slower than the version that follows it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 ;;(defun calendar-gregorian-from-absolute (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 ;; "Compute the list (month day year) corresponding to the absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 ;;The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 ;;Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 ;; (let* ((approx (/ date 366));; Approximation from below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 ;; (year ;; Search forward from the approximation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 ;; (+ approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 ;; (calendar-sum y approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 ;; (>= date (calendar-absolute-from-gregorian (list 1 1 (1+ y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 ;; 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 ;; (month ;; Search forward from January.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 ;; (1+ (calendar-sum m 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 ;; (> date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 ;; (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 ;; (list m (calendar-last-day-of-month m year) year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 ;; 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 ;; (day ;; Calculate the day by subtraction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 ;; (- date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 ;; (1- (calendar-absolute-from-gregorian (list month 1 year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 ;; (list month day year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (defun calendar-gregorian-from-absolute (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 "Compute the list (month day year) corresponding to the absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 ;; See the footnote on page 384 of ``Calendrical Calculations, Part II:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 ;; Three Historical Calendars'' by E. M. Reingold, N. Dershowitz, and S. M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 ;; Clamen, Software--Practice and Experience, Volume 23, Number 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 ;; (April, 1993), pages 383-404 for an explanation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (let* ((d0 (1- date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (n400 (/ d0 146097))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (d1 (% d0 146097))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (n100 (/ d1 36524))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (d2 (% d1 36524))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (n4 (/ d2 1461))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (d3 (% d2 1461))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (n1 (/ d3 365))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (day (1+ (% d3 365)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (year (+ (* 400 n400) (* 100 n100) (* n4 4) n1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (if (or (= n100 4) (= n1 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (list 12 31 year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (let ((year (1+ year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (month 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (while (let ((mdays (calendar-last-day-of-month month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (and (< mdays day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (setq day (- day mdays))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (setq month (1+ month)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (list month day year)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (defun calendar-cursor-to-visible-date (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 "Move the cursor to DATE that is on the screen."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (let* ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (first-of-month-weekday (calendar-day-of-week (list month 1 year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (goto-line (+ 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (/ (+ day -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (mod
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (- (calendar-day-of-week (list month 1 year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 calendar-week-start-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 7)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (move-to-column (+ 6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (* 25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (1+ (calendar-interval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 displayed-month displayed-year month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (* 3 (mod
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (- (calendar-day-of-week date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 calendar-week-start-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 7))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (defun calendar-other-month (month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 "Display a three-month calendar centered around MONTH and YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 (interactive (calendar-read-date 'noday))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (if (and (= month displayed-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (= year displayed-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (let ((old-date (calendar-cursor-to-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (today (calendar-current-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (generate-calendar-window month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (calendar-cursor-to-visible-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 ((calendar-date-is-visible-p old-date) old-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 ((calendar-date-is-visible-p today) today)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (t (list month 1 year)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 (defun calendar-set-mark (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 "Mark the date under the cursor, or jump to marked date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 With no prefix argument, push current date onto marked date ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 With argument, jump to mark, pop it, and put point at end of ring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (let ((date (calendar-cursor-to-date t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (if (null arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (setq calendar-mark-ring (cons date calendar-mark-ring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;; Since the top of the mark ring is the marked date in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 ;; calendar, the mark ring in the calendar is one longer than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;; in other buffers to get the same effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (if (> (length calendar-mark-ring) (1+ mark-ring-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (setcdr (nthcdr mark-ring-max calendar-mark-ring) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (message "Mark set"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (if (null calendar-mark-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (error "No mark set in this buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 (calendar-goto-date (car calendar-mark-ring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (setq calendar-mark-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (cdr (nconc calendar-mark-ring (list date))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (defun calendar-exchange-point-and-mark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 "Exchange the current cursor position with the marked date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (let ((mark (car calendar-mark-ring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (date (calendar-cursor-to-date t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (if (null mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (error "No mark set in this buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 (setq calendar-mark-ring (cons date (cdr calendar-mark-ring)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (calendar-goto-date mark))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (defun calendar-count-days-region ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 "Count the number of days (inclusive) between point and the mark."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (let* ((days (- (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (calendar-cursor-to-date t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (or (car calendar-mark-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (error "No mark set in this buffer")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (days (1+ (if (> days 0) days (- days)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (message "Region has %d day%s (inclusive)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 days (if (> days 1) "s" ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (defun calendar-not-implemented ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 "Not implemented."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (error "%s not available in the calendar"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 (global-key-binding (this-command-keys))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 (defun calendar-read (prompt acceptable &optional initial-contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 "Return an object read from the minibuffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 Prompt with the string PROMPT and use the function ACCEPTABLE to decide if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 entered item is acceptable. If non-nil, optional third arg INITIAL-CONTENTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 is a string to insert in the minibuffer before reading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (let ((value (read-minibuffer prompt initial-contents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (while (not (funcall acceptable value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (setq value (read-minibuffer prompt initial-contents)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 (defun calendar-read-date (&optional noday)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 "Prompt for Gregorian date. Returns a list (month day year).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 If optional NODAY is t, does not ask for day, but just returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (month nil year); if NODAY is any other non-nil value the value returned is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (month year) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (let* ((year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 "Year (>0): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 '(lambda (x) (> x 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (int-to-string (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (calendar-current-date)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (month-array calendar-month-name-array)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (month (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 "Month name: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (mapcar 'list (append month-array nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (calendar-make-alist month-array 1 'capitalize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (last (calendar-last-day-of-month month year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (if noday
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (if (eq noday t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (list month nil year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (list month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (list month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (calendar-read (format "Day (1-%d): " last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 '(lambda (x) (and (< 0 x) (<= x last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (defun calendar-goto-date (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 "Move cursor to DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (interactive (list (calendar-read-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (let ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (if (not (calendar-date-is-visible-p date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (calendar-other-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (if (and (= month 1) (= year 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (calendar-cursor-to-visible-date date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 (defun calendar-goto-julian-date (date &optional noecho)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 "Move cursor to Julian DATE; echo Julian date unless NOECHO is t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (let* ((today (calendar-current-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 (year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 "Julian calendar year (>0): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 '(lambda (x) (> x 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (calendar-julian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 today))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 (month-array calendar-month-name-array)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (month (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 (capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 "Julian calendar month name: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (mapcar 'list (append month-array nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 (calendar-make-alist month-array 1 'capitalize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 (last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 (if (and (zerop (% year 4)) (= month 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (aref [31 28 31 30 31 30 31 31 30 31 30 31] (1- month))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (day (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (format "Julian calendar day (%d-%d): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (if (and (= year 1) (= month 1)) 3 1) last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 '(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (and (< (if (and (= year 1) (= month 1)) 2 0) x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (<= x last))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (list (list month day year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (calendar-goto-date (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (calendar-absolute-from-julian date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (or noecho (calendar-print-julian-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (defun calendar-goto-hebrew-date (date &optional noecho)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 "Move cursor to Hebrew DATE; echo Hebrew date unless NOECHO is t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 (let* ((today (calendar-current-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 "Hebrew calendar year (>3760): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 '(lambda (x) (> x 3760))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 (calendar-absolute-from-gregorian today))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 (month-array (if (hebrew-calendar-leap-year-p year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 calendar-hebrew-month-name-array-leap-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 calendar-hebrew-month-name-array-common-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 (month (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 "Hebrew calendar month name: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 (mapcar 'list (append month-array nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (if (= year 3761)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 '(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (let ((m (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (car x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (calendar-make-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 month-array)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (< 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 (list m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (hebrew-calendar-last-day-of-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 m year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (calendar-make-alist month-array 1 'capitalize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (last (hebrew-calendar-last-day-of-month month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (first (if (and (= year 3761) (= month 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 18 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (day (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (format "Hebrew calendar day (%d-%d): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 first last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 '(lambda (x) (and (<= first x) (<= x last))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 (list (list month day year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (calendar-goto-date (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (calendar-absolute-from-hebrew date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (or noecho (calendar-print-hebrew-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (defun calendar-goto-islamic-date (date &optional noecho)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 "Move cursor to Islamic DATE; echo Islamic date unless NOECHO is t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 (let* ((today (calendar-current-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 "Islamic calendar year (>0): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 '(lambda (x) (> x 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (calendar-islamic-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (calendar-absolute-from-gregorian today))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 (month-array calendar-islamic-month-name-array)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 (month (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 "Islamic calendar month name: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (mapcar 'list (append month-array nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (calendar-make-alist month-array 1 'capitalize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (last (islamic-calendar-last-day-of-month month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (day (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (format "Islamic calendar day (1-%d): " last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 '(lambda (x) (and (< 0 x) (<= x last))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (list (list month day year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (calendar-goto-date (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (calendar-absolute-from-islamic date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (or noecho (calendar-print-islamic-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (defun calendar-goto-iso-date (date &optional noecho)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 "Move cursor to ISO DATE; echo ISO date unless NOECHO is t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 (let* ((today (calendar-current-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 "ISO calendar year (>0): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 '(lambda (x) (> x 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (int-to-string (extract-calendar-year today))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (no-weeks (extract-calendar-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (calendar-iso-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (1-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 1 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (list 1 4 (1+ year))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (week (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (format "ISO calendar week (1-%d): " no-weeks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 '(lambda (x) (and (> x 0) (<= x no-weeks)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 (day (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 "ISO day (1-7): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 '(lambda (x) (and (<= 1 x) (<= x 7))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (list (list week day year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 (calendar-goto-date (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (calendar-absolute-from-iso date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (or noecho (calendar-print-iso-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 (defun calendar-interval (mon1 yr1 mon2 yr2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 "The number of months difference between MON1, YR1 and MON2, YR2."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (+ (* 12 (- yr2 yr1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 (- mon2 mon1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 (defun calendar-day-name (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 "Returns a string with the name of the day of the week of DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 (aref calendar-day-name-array (calendar-day-of-week date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 (defvar calendar-day-name-array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 (defvar calendar-month-name-array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ["January" "February" "March" "April" "May" "June"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 "July" "August" "September" "October" "November" "December"])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 (defun calendar-make-alist (sequence &optional start-index filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 "Make an assoc list corresponding to SEQUENCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 Start at index 1, unless optional START-INDEX is provided.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 If FILTER is provided, apply it to each item in the list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (let ((index (if start-index (1- start-index) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 '(lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 (setq index (1+ index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 (cons (if filter (funcall filter x) x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 (append sequence nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 (defun calendar-month-name (month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 "The name of MONTH."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (aref calendar-month-name-array (1- month)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 (defun calendar-day-of-week (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 "Returns the day-of-the-week index of DATE, 0 for Sunday, 1 for Monday, etc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 (% (calendar-absolute-from-gregorian date) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 (defun calendar-unmark ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 "Delete all diary/holiday marks/highlighting from the calendar."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 (setq mark-holidays-in-calendar nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 (setq mark-diary-entries-in-calendar nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (redraw-calendar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (defun calendar-date-is-visible-p (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 "Returns t if DATE is legal and is visible in the calendar window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 (let ((gap (calendar-interval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 displayed-month displayed-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 (extract-calendar-month date) (extract-calendar-year date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 (and (calendar-date-is-legal-p date) (> 2 gap) (< -2 gap))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 (defun calendar-date-is-legal-p (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 "Returns t if DATE is a legal date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 (let ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 (and (<= 1 month) (<= month 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (<= 1 day) (<= day (calendar-last-day-of-month month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (<= 1 year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 (defun calendar-date-equal (date1 date2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 "Returns t if the DATE1 and DATE2 are the same."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (= (extract-calendar-month date1) (extract-calendar-month date2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 (= (extract-calendar-day date1) (extract-calendar-day date2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (= (extract-calendar-year date1) (extract-calendar-year date2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 (defun mark-visible-calendar-date (date &optional mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 "Mark DATE in the calendar window with MARK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 MARK is either a single-character string or a face.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 MARK defaults to diary-entry-marker."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 (if (calendar-date-is-legal-p date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 (set-buffer calendar-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 (calendar-cursor-to-visible-date date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 (let ((mark (or mark diary-entry-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (if (stringp mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 (insert mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 (forward-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (set-extent-property (make-extent (1- (point)) (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 'face mark))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (defun calendar-star-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 "Replace the date under the cursor in the calendar window with asterisks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 This function can be used with the today-visible-calendar-hook run after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 calendar window has been prepared."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (let ((buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (make-variable-buffer-local 'calendar-starred-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (setq calendar-starred-day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 (buffer-substring (point) (- (point) 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 (delete-char -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 (insert "**")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 (set-buffer-modified-p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (defun calendar-mark-today ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 "Mark the date under the cursor in the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 The date is marked with calendar-today-marker. This function can be used with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 the today-visible-calendar-hook run after the calendar window has been
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 prepared."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 (mark-visible-calendar-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (calendar-cursor-to-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 calendar-today-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (defun calendar-date-compare (date1 date2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 "Returns t if DATE1 is before DATE2, nil otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 The actual dates are in the car of DATE1 and DATE2."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 (< (calendar-absolute-from-gregorian (car date1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 (calendar-absolute-from-gregorian (car date2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (defun calendar-date-string (date &optional abbreviate nodayname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 "A string form of DATE, driven by the variable `calendar-date-display-form'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 An optional parameter ABBREVIATE, when t, causes the month and day names to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 abbreviated to three characters. An optional parameter NODAYNAME, when t,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 omits the name of the day of the week."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 (let* ((dayname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 (if nodayname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 (if abbreviate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 (substring (calendar-day-name date) 0 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 (calendar-day-name date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (monthname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (if abbreviate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (calendar-month-name month) 0 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (calendar-month-name month)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (day (int-to-string (extract-calendar-day date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 (month (int-to-string month))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (year (int-to-string (extract-calendar-year date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 (mapconcat 'eval calendar-date-display-form "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (defun calendar-dayname-on-or-before (dayname date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 "Returns the absolute date of the DAYNAME on or before absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 DAYNAME=0 means Sunday, DAYNAME=1 means Monday, and so on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 Note: Applying this function to d+6 gives us the DAYNAME on or after an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 absolute day d. Similarly, applying it to d+3 gives the DAYNAME nearest to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 absolute date d, applying it to d-1 gives the DAYNAME previous to absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 date d, and applying it to d+7 gives the DAYNAME following absolute date d."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (- date (% (- date dayname) 7)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 (defun calendar-nth-named-absday (n dayname month year &optional day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 "The absolute date of Nth DAYNAME in MONTH, YEAR before/after optional DAY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 A DAYNAME of 0 means Sunday, 1 means Monday, and so on. If N<0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 return the Nth DAYNAME before MONTH DAY, YEAR (inclusive).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 If N>0, return the Nth DAYNAME after MONTH DAY, YEAR (inclusive).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 (if (> n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 (+ (* 7 (1- n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 dayname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 (+ 6 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (list month (or day 1) year)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (+ (* 7 (1+ n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 dayname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (list month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (or day (calendar-last-day-of-month month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (defun calendar-nth-named-day (n dayname month year &optional day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 "The date of Nth DAYNAME in MONTH, YEAR before/after optional DAY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 A DAYNAME of 0 means Sunday, 1 means Monday, and so on. If N<0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 return the Nth DAYNAME before MONTH DAY, YEAR (inclusive).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 If N>0, return the Nth DAYNAME after MONTH DAY, YEAR (inclusive).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 (calendar-nth-named-absday n dayname month year day)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (defun calendar-day-of-year-string (&optional date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 "String of day number of year of Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 Defaults to today's date if DATE is not given."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (let* ((d (or date (calendar-current-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (year (extract-calendar-year d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (day (calendar-day-number d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (days-remaining (- (calendar-day-number (list 12 31 year)) day)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (format "Day %d of %d; %d day%s remaining in the year"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 day year days-remaining (if (= days-remaining 1) "" "s"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 (defun calendar-print-day-of-year ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 "Show day number in year/days remaining in year for date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (message (calendar-day-of-year-string (calendar-cursor-to-date t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 (defun calendar-absolute-from-iso (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 The `ISO year' corresponds approximately to the Gregorian year, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 weeks start on Monday and end on Sunday. The first week of the ISO year is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 the first such week in which at least 4 days are in a year. The ISO
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 commercial DATE has the form (week day year) in which week is in the range
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 1..52 and day is in the range 0..6 (1 = Monday, 2 = Tuesday, ..., 0 =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 Sunday). The Gregorian date Sunday, December 31, 1 BC is imaginary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (let* ((week (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (+ (calendar-dayname-on-or-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 1 (+ 3 (calendar-absolute-from-gregorian (list 1 1 year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (* 7 (1- week))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (if (= day 0) 6 (1- day)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (defun calendar-iso-from-absolute (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 "Compute the `ISO commercial date' corresponding to the absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 The ISO year corresponds approximately to the Gregorian year, but weeks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 start on Monday and end on Sunday. The first week of the ISO year is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 first such week in which at least 4 days are in a year. The ISO commercial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 date has the form (week day year) in which week is in the range 1..52 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 day is in the range 0..6 (1 = Monday, 2 = Tuesday, ..., 0 = Sunday). The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 absolute date is the number of days elapsed since the (imaginary) Gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (let* ((approx (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 (calendar-gregorian-from-absolute (- date 3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (year (+ approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 (calendar-sum y approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (>= date (calendar-absolute-from-iso (list 1 1 (1+ y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 (1+ (/ (- date (calendar-absolute-from-iso (list 1 1 year))) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 (% date 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (defun calendar-iso-date-string (&optional date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 "String of ISO date of Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 Defaults to today's date if DATE is not given."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (let* ((d (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (or date (calendar-current-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (day (% d 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (iso-date (calendar-iso-from-absolute d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (format "Day %s of week %d of %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (if (zerop day) 7 day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 (extract-calendar-month iso-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (extract-calendar-year iso-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (defun calendar-print-iso-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 "Show equivalent ISO date for the date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 (message "ISO date: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 (calendar-iso-date-string (calendar-cursor-to-date t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 (defun calendar-julian-from-absolute (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 "Compute the Julian (month day year) corresponding to the absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 (let* ((approx (/ (+ date 2) 366));; Approximation from below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (year ;; Search forward from the approximation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 (+ approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (calendar-sum y approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 (>= date (calendar-absolute-from-julian (list 1 1 (1+ y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 (month ;; Search forward from January.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 (1+ (calendar-sum m 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (> date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 (calendar-absolute-from-julian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (list m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (if (and (= m 2) (= (% year 4) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 (aref [31 28 31 30 31 30 31 31 30 31 30 31]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (1- m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 (day ;; Calculate the day by subtraction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 (- date (1- (calendar-absolute-from-julian (list month 1 year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (list month day year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (defun calendar-absolute-from-julian (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 The Gregorian date Sunday, December 31, 1 BC is imaginary."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 (let ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 (+ (calendar-day-number date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 (if (and (= (% year 100) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 (/= (% year 400) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (> month 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 1 0);; Correct for Julian but not Gregorian leap year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (* 365 (1- year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (/ (1- year) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 -2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (defun calendar-julian-date-string (&optional date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 "String of Julian date of Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 Defaults to today's date if DATE is not given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 Driven by the variable `calendar-date-display-form'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 (calendar-date-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 (calendar-julian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (or date (calendar-current-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 (defun calendar-print-julian-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 "Show the Julian calendar equivalent of the date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 (message "Julian date: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (calendar-julian-date-string (calendar-cursor-to-date t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 (defun islamic-calendar-leap-year-p (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 "Returns t if YEAR is a leap year on the Islamic calendar."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 (memq (% year 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (list 2 5 7 10 13 16 18 21 24 26 29)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (defun islamic-calendar-last-day-of-month (month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 "The last day in MONTH during YEAR on the Islamic calendar."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 ((memq month (list 1 3 5 7 9 11)) 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 ((memq month (list 2 4 6 8 10)) 29)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 (t (if (islamic-calendar-leap-year-p year) 30 29))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (defun islamic-calendar-day-number (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 "Return the day number within the year of the Islamic date DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (let* ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 (day (extract-calendar-day date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 (+ (* 30 (/ month 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 (* 29 (/ (1- month) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 day)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 (defun calendar-absolute-from-islamic (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 "Absolute date of Islamic DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 (let* ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 (year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 (y (% year 30))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (leap-years-in-cycle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 ((< y 3) 0) ((< y 6) 1) ((< y 8) 2) ((< y 11) 3) ((< y 14) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 ((< y 17) 5) ((< y 19) 6) ((< y 22) 7) ((< y 25) 8) ((< y 27) 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 (t 10))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 (+ (islamic-calendar-day-number date);; days so far this year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 (* (1- year) 354) ;; days in all non-leap years
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 (* 11 (/ year 30)) ;; leap days in complete cycles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 leap-years-in-cycle ;; leap days this cycle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 227014))) ;; days before start of calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (defun calendar-islamic-from-absolute (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 "Compute the Islamic date (month day year) corresponding to absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (if (< date 227015)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (list 0 0 0);; pre-Islamic date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 (let* ((approx (/ (- date 227014) 355));; Approximation from below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 (year ;; Search forward from the approximation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 (+ approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 (calendar-sum y approx
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (>= date (calendar-absolute-from-islamic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 (list 1 1 (1+ y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (month ;; Search forward from Muharram.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (1+ (calendar-sum m 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 (> date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (calendar-absolute-from-islamic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (list m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (islamic-calendar-last-day-of-month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 m year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 (day ;; Calculate the day by subtraction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (- date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 (1- (calendar-absolute-from-islamic (list month 1 year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 (list month day year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 (defvar calendar-islamic-month-name-array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 ["Muharram" "Safar" "Rabi I" "Rabi II" "Jumada I" "Jumada II"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 "Rajab" "Sha'ban" "Ramadan" "Shawwal" "Dhu al-Qada" "Dhu al-Hijjah"])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 (defun calendar-islamic-date-string (&optional date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 "String of Islamic date before sunset of Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 Returns the empty string if DATE is pre-Islamic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 Defaults to today's date if DATE is not given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 Driven by the variable `calendar-date-display-form'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (let ((calendar-month-name-array calendar-islamic-month-name-array)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 (islamic-date (calendar-islamic-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (or date (calendar-current-date))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (if (< (extract-calendar-year islamic-date) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 (calendar-date-string islamic-date nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 (defun calendar-print-islamic-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 "Show the Islamic calendar equivalent of the date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 (let ((i (calendar-islamic-date-string (calendar-cursor-to-date t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 (if (string-equal i "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 (message "Date is pre-Islamic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (message "Islamic date (until sunset): %s" i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (defun calendar-hebrew-from-absolute (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 "Compute the Hebrew date (month day year) corresponding to absolute DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 (let* ((greg-date (calendar-gregorian-from-absolute date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (month (aref [9 10 11 12 1 2 3 4 7 7 7 8]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (1- (extract-calendar-month greg-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (year (+ 3760 (extract-calendar-year greg-date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (while (>= date (calendar-absolute-from-hebrew (list 7 1 (1+ year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 (setq year (1+ year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (let ((length (hebrew-calendar-last-month-of-year year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 (while (> date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 (list month
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 (hebrew-calendar-last-day-of-month month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 (setq month (1+ (% month length)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 (setq day (1+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (- date (calendar-absolute-from-hebrew (list month 1 year)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 (list month day year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 (defun hebrew-calendar-leap-year-p (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 "t if YEAR is a Hebrew calendar leap year."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 (< (% (1+ (* 7 year)) 19) 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 (defun hebrew-calendar-last-month-of-year (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 "The last month of the Hebrew calendar YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 (if (hebrew-calendar-leap-year-p year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 12))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 (defun hebrew-calendar-last-day-of-month (month year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 "The last day of MONTH in YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 (if (or (memq month (list 2 4 6 10 13))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 (and (= month 12) (not (hebrew-calendar-leap-year-p year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 (and (= month 8) (not (hebrew-calendar-long-heshvan-p year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 (and (= month 9) (hebrew-calendar-short-kislev-p year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 30))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 (defun hebrew-calendar-elapsed-days (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 "Days from Sun. prior to start of Hebrew calendar to mean conjunction of Tishri of Hebrew YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 (let* ((months-elapsed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 (+ (* 235 (/ (1- year) 19));; Months in complete cycles so far.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (* 12 (% (1- year) 19)) ;; Regular months in this cycle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 (/ (1+ (* 7 (% (1- year) 19))) 19)));; Leap months this cycle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 (parts-elapsed (+ 204 (* 793 (% months-elapsed 1080))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 (hours-elapsed (+ 5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (* 12 months-elapsed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (* 793 (/ months-elapsed 1080))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 (/ parts-elapsed 1080)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 (parts ;; Conjunction parts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (+ (* 1080 (% hours-elapsed 24)) (% parts-elapsed 1080)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 (day ;; Conjunction day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 (+ 1 (* 29 months-elapsed) (/ hours-elapsed 24)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (alternative-day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 (if (or (>= parts 19440) ;; If the new moon is at or after midday,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (and (= (% day 7) 2);; ...or is on a Tuesday...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (>= parts 9924) ;; at 9 hours, 204 parts or later...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (not (hebrew-calendar-leap-year-p year)));; of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 ;; common year,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (and (= (% day 7) 1);; ...or is on a Monday...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 (>= parts 16789) ;; at 15 hours, 589 parts or later...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 (hebrew-calendar-leap-year-p (1- year))));; at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 ;; of a leap year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 ;; Then postpone Rosh HaShanah one day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 (1+ day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 day)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 (if ;; If Rosh HaShanah would occur on Sunday, Wednesday, or Friday
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 (memq (% alternative-day 7) (list 0 3 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ;; Then postpone it one (more) day and return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (1+ alternative-day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 ;; Else return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 alternative-day)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 (defun hebrew-calendar-days-in-year (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 "Number of days in Hebrew YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 (- (hebrew-calendar-elapsed-days (1+ year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 (hebrew-calendar-elapsed-days year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (defun hebrew-calendar-long-heshvan-p (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 "t if Heshvan is long in Hebrew YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 (= (% (hebrew-calendar-days-in-year year) 10) 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 (defun hebrew-calendar-short-kislev-p (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 "t if Kislev is short in Hebrew YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (= (% (hebrew-calendar-days-in-year year) 10) 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (defun calendar-absolute-from-hebrew (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 "Absolute date of Hebrew DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 The absolute date is the number of days elapsed since the (imaginary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 Gregorian date Sunday, December 31, 1 BC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 (let* ((month (extract-calendar-month date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 (year (extract-calendar-year date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (+ day ;; Days so far this month.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (if (< month 7);; before Tishri
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 ;; Then add days in prior months this year before and after Nisan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 (+ (calendar-sum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 m 7 (<= m (hebrew-calendar-last-month-of-year year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 (hebrew-calendar-last-day-of-month m year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (calendar-sum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 m 1 (< m month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 (hebrew-calendar-last-day-of-month m year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 ;; Else add days in prior months this year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 (calendar-sum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 m 7 (< m month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 (hebrew-calendar-last-day-of-month m year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (hebrew-calendar-elapsed-days year);; Days in prior years.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 -1373429))) ;; Days elapsed before absolute date 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 (defvar calendar-hebrew-month-name-array-common-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 ["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishri"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 "Heshvan" "Kislev" "Teveth" "Shevat" "Adar"])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 (defvar calendar-hebrew-month-name-array-leap-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 ["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishri"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 "Heshvan" "Kislev" "Teveth" "Shevat" "Adar I" "Adar II"])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 (defun calendar-hebrew-date-string (&optional date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 "String of Hebrew date before sunset of Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 Defaults to today's date if DATE is not given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 Driven by the variable `calendar-date-display-form'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 (let* ((hebrew-date (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 (or date (calendar-current-date)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 (calendar-month-name-array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (if (hebrew-calendar-leap-year-p (extract-calendar-year hebrew-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 calendar-hebrew-month-name-array-leap-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 calendar-hebrew-month-name-array-common-year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 (calendar-date-string hebrew-date nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 (defun calendar-print-hebrew-date ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 "Show the Hebrew calendar equivalent of the date under the cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 (message "Hebrew date (until sunset): %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 (calendar-hebrew-date-string (calendar-cursor-to-date t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 (defun hebrew-calendar-yahrzeit (death-date year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 "Absolute date of the anniversary of Hebrew DEATH-DATE in Hebrew YEAR."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 (let* ((death-day (extract-calendar-day death-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 (death-month (extract-calendar-month death-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 (death-year (extract-calendar-year death-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 ;; If it's Heshvan 30 it depends on the first anniversary; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 ;; that was not Heshvan 30, use the day before Kislev 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 ((and (= death-month 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 (= death-day 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 (not (hebrew-calendar-long-heshvan-p (1+ death-year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 (1- (calendar-absolute-from-hebrew (list 9 1 year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 ;; If it's Kislev 30 it depends on the first anniversary; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 ;; that was not Kislev 30, use the day before Teveth 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 ((and (= death-month 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 (= death-day 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 (hebrew-calendar-short-kislev-p (1+ death-year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 (1- (calendar-absolute-from-hebrew (list 10 1 year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 ;; If it's Adar II, use the same day in last month of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 ;; year (Adar or Adar II).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 ((= death-month 13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 (list (hebrew-calendar-last-month-of-year year) death-day year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 ;; If it's the 30th in Adar I and year is not a leap year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 ;; (so Adar has only 29 days), use the last day in Shevat.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 ((and (= death-day 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 (= death-month 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 (not (hebrew-calendar-leap-year-p year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 (calendar-absolute-from-hebrew (list 11 30 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 ;; In all other cases, use the normal anniversary of the date of death.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 (t (calendar-absolute-from-hebrew
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 (list death-month death-day year))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 (defun calendar-set-mode-line (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 "Set mode line to STR, centered, surrounded by dashes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 (setq mode-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 (calendar-string-spread (list "" str "") ?- (frame-width))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 (defun list-yahrzeit-dates (death-date start-year end-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 "List Yahrzeit dates for *Gregorian* DEATH-DATE from START-YEAR to END-YEAR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 When called interactively from the calendar window, the date of death is taken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 from the cursor position."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 (let* ((death-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 (if (equal (current-buffer) (get-buffer calendar-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 (calendar-cursor-to-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 (let* ((today (calendar-current-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 (year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 "Year of death (>0): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 '(lambda (x) (> x 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 (int-to-string (extract-calendar-year today))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 (month-array calendar-month-name-array)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 (month (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 (capitalize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 "Month of death (name): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 (mapcar 'list (append month-array nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 (calendar-make-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 month-array 1 'capitalize))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 (last (calendar-last-day-of-month month year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 (day (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 (format "Day of death (1-%d): " last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 '(lambda (x) (and (< 0 x) (<= x last))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 (list month day year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 (death-year (extract-calendar-year death-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 (start-year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 (format "Starting year of Yahrzeit table (>%d): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 death-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873 '(lambda (x) (> x death-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 (int-to-string (1+ death-year))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 (end-year (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 (format "Ending year of Yahrzeit table (>=%d): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 start-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878 '(lambda (x) (>= x start-year)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 (list death-date start-year end-year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 (message "Computing yahrzeits...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 (let* ((yahrzeit-buffer "*Yahrzeits*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 (h-date (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 (calendar-absolute-from-gregorian death-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884 (h-month (extract-calendar-month h-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 (h-day (extract-calendar-day h-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 (h-year (extract-calendar-year h-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 (set-buffer (get-buffer-create yahrzeit-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889 (calendar-set-mode-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 (format "Yahrzeit dates for %s = %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 (calendar-date-string death-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 (let ((calendar-month-name-array
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 (if (hebrew-calendar-leap-year-p h-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 calendar-hebrew-month-name-array-leap-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 calendar-hebrew-month-name-array-common-year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 (calendar-date-string h-date nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 (calendar-for-loop i from start-year to end-year do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 (calendar-date-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 (calendar-gregorian-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 (hebrew-calendar-yahrzeit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 h-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (extract-calendar-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 (calendar-hebrew-from-absolute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 (calendar-absolute-from-gregorian (list 1 1 i))))))) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 (display-buffer yahrzeit-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 (message "Computing yahrzeits...done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 (defun calendar-astro-date-string (&optional date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 "String of astronomical (Julian) day number of afternoon of Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 Defaults to today's date if DATE is not given."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 (+ 1721425 (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 (or date (calendar-current-date))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 (defun calendar-print-astro-day-number ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 "Show astronomical (Julian) day number of afternoon on date shown by cursor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 "Astronomical (Julian) day number after noon UTC: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 (calendar-astro-date-string (calendar-cursor-to-date t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 (defun calendar-goto-astro-day-number (daynumber &optional noecho)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 "Move cursor to astronomical (Julian) DAYNUMBER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 Echo astronomical (Julian) day number unless NOECHO is t."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 (interactive (list (calendar-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 "Astronomical (Julian) day number (>1721425): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 '(lambda (x) (> x 1721425)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 (calendar-goto-date (calendar-gregorian-from-absolute (- daynumber 1721425)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 (or noecho (calendar-print-astro-day-number)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 (run-hooks 'calendar-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 (provide 'calendar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 ;;; calendar.el ends here