annotate lisp/calendar/calendar.el @ 143:50e7fedfe353

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