calendar.el 121 KB
Newer Older
1
;;; calendar.el --- calendar functions
Eric S. Raymond's avatar
Eric S. Raymond committed
2

3
;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
Glenn Morris's avatar
Glenn Morris committed
4
;;	2000, 2001, 2003, 2004 Free Software Foundation, Inc.
Eric S. Raymond's avatar
Eric S. Raymond committed
5

Eric S. Raymond's avatar
Eric S. Raymond committed
6
;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
Glenn Morris's avatar
Glenn Morris committed
7
;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk>
Eric S. Raymond's avatar
Eric S. Raymond committed
8
;; Keywords: calendar
9
;; Human-Keywords: calendar, Gregorian calendar, diary, holidays
Eric S. Raymond's avatar
Eric S. Raymond committed
10

Richard M. Stallman's avatar
Richard M. Stallman committed
11 12
;; This file is part of GNU Emacs.

Richard M. Stallman's avatar
Richard M. Stallman committed
13 14 15 16 17
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

Richard M. Stallman's avatar
Richard M. Stallman committed
18
;; GNU Emacs is distributed in the hope that it will be useful,
Richard M. Stallman's avatar
Richard M. Stallman committed
19 20 21 22 23
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
Erik Naggum's avatar
Erik Naggum committed
24 25 26
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
Richard M. Stallman's avatar
Richard M. Stallman committed
27

Eric S. Raymond's avatar
Eric S. Raymond committed
28 29
;;; Commentary:

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
;; This collection of functions implements a calendar window.  It
;; generates a calendar for the current month, together with the
;; previous and coming months, or for any other three-month period.
;; The calendar can be scrolled forward and backward in the window to
;; show months in the past or future; the cursor can move forward and
;; backward by days, weeks, or months, making it possible, for
;; instance, to jump to the date a specified number of days, weeks, or
;; months from the date under the cursor.  The user can display a list
;; of holidays and other notable days for the period shown; the
;; notable days can be marked on the calendar, if desired.  The user
;; can also specify that dates having corresponding diary entries (in
;; a file that the user specifies) be marked; the diary entries for
;; any date can be viewed in a separate window.  The diary and the
;; notable days can be viewed independently of the calendar.  Dates
;; can be translated from the (usual) Gregorian calendar to the day of
;; the year/days remaining in year, to the ISO commercial calendar, to
;; the Julian (old style) calendar, to the Hebrew calendar, to the
;; Islamic calendar, to the Baha'i calendar, to the French
;; Revolutionary calendar, to the Mayan calendar, to the Chinese
;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to
;; the astronomical (Julian) day number.  When floating point is
;; available, times of sunrise/sunset can be displayed, as can the
;; phases of the moon.  Appointment notification for diary entries is
53
;; available.  Calendar printing via LaTeX is available.
Jim Blandy's avatar
Jim Blandy committed
54 55 56

;; The following files are part of the calendar/diary code:

57
;;       appt.el                       Appointment notification
58
;;       cal-china.el                  Chinese calendar
59 60 61
;;       cal-coptic.el                 Coptic/Ethiopic calendars
;;       cal-dst.el                    Daylight savings time rules
;;       cal-hebrew.el                 Hebrew calendar
62
;;       cal-islam.el                  Islamic calendar
63
;;       cal-bahai.el                  Baha'i calendar
64 65 66
;;       cal-iso.el                    ISO calendar
;;       cal-julian.el                 Julian/astronomical calendars
;;       cal-mayan.el                  Mayan calendars
67
;;       cal-menu.el                   Menu support
68
;;       cal-move.el                   Movement in the calendar
69
;;       cal-persia.el                 Persian calendar
70
;;       cal-tex.el                    Calendars in LaTeX
71
;;       cal-x.el                      X-windows dedicated frame functions
Richard M. Stallman's avatar
Richard M. Stallman committed
72
;;       diary-lib.el                  Diary functions
Jim Blandy's avatar
Jim Blandy committed
73 74
;;       holidays.el                   Holiday functions
;;       lunar.el                      Phases of the moon
75
;;       solar.el                      Sunrise/sunset, equinoxes/solstices
Richard M. Stallman's avatar
Richard M. Stallman committed
76 77

;; Technical details of all the calendrical calculations can be found in
78 79
;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
;; Cambridge University Press (1997).
Jim Blandy's avatar
Jim Blandy committed
80

81
;; An earlier version of the technical details appeared in
Richard M. Stallman's avatar
Richard M. Stallman committed
82 83
;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
Jim Blandy's avatar
Jim Blandy committed
84 85
;; pages 899-928.  ``Calendrical Calculations, Part II: Three Historical
;; Calendars'' by E. M. Reingold,  N. Dershowitz, and S. M. Clamen,
86 87
;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993),
;; pages 383-404.
Jim Blandy's avatar
Jim Blandy committed
88 89 90 91

;; Hard copies of these two papers can be obtained by sending email to
;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and
;; the message BODY containing your mailing address (snail).
Richard M. Stallman's avatar
Richard M. Stallman committed
92

93 94 95 96 97 98
;; Comments, corrections, and improvements should be sent to
;;  Edward M. Reingold               Department of Computer Science
;;  (217) 333-6733                   University of Illinois at Urbana-Champaign
;;  reingold@cs.uiuc.edu             1304 West Springfield Avenue
;;                                   Urbana, Illinois 61801

Eric S. Raymond's avatar
Eric S. Raymond committed
99
;;; Code:
Richard M. Stallman's avatar
Richard M. Stallman committed
100

101
(eval-when-compile
102 103 104 105 106
  (defvar displayed-month)
  (defvar displayed-year)
  (defvar calendar-month-name-array)
  (defvar calendar-starred-day))

Richard M. Stallman's avatar
Richard M. Stallman committed
107 108
(defun calendar-version ()
  (interactive)
109
  (message "Version 6, October 12, 1995"))
Richard M. Stallman's avatar
Richard M. Stallman committed
110

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
(defgroup calendar nil
  "Calendar and time management support."
  :group 'applications)

(defgroup diary nil
  "Emacs diary."
  :group 'calendar)

(defgroup appt nil
  "Appointment notification."
  :group 'calendar)

(defgroup holidays nil
  "Holidays support in calendar."
  :group 'calendar
  :prefix "calendar-"
  :group 'local)

(defgroup chinese-calendar nil
  "Chinese calendar support."
  :group 'calendar)

(defgroup calendar-tex nil
  "Options for printing calendar with LaTeX."
  :prefix "cal-tex-"
  :group 'calendar)

(defgroup calendar-hooks nil
  "Calendar hooks."
  :prefix "calendar-"
  :group 'calendar)


144
;;;###autoload
145
(defcustom calendar-week-start-day 0
146
  "*The day of the week on which a week in the calendar begins.
147 148 149
0 means Sunday (default), 1 means Monday, and so on."
  :type 'integer
  :group 'calendar)
150

151
;;;###autoload
152
(defcustom calendar-offset 0
153 154 155
  "*The offset of the principal month from the center of the calendar window.
0 means the principal month is in the center (default), -1 means on the left,
+1 means on the right.  Larger (or smaller) values push the principal month off
156 157 158
the screen."
  :type 'integer
  :group 'calendar)
159

Jim Blandy's avatar
Jim Blandy committed
160
;;;###autoload
161
(defcustom view-diary-entries-initially nil
Glenn Morris's avatar
Glenn Morris committed
162
  "*Non-nil means display current date's diary entries on entry to calendar.
Richard M. Stallman's avatar
Richard M. Stallman committed
163 164
The diary is displayed in another window when the calendar is first displayed,
if the current date is visible.  The number of days of diary entries displayed
Glenn Morris's avatar
Glenn Morris committed
165 166
is governed by the variable `number-of-diary-entries'.  This variable can
be overridden by the value of `calendar-setup'."
167 168
  :type 'boolean
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
169

Jim Blandy's avatar
Jim Blandy committed
170
;;;###autoload
171
(defcustom number-of-diary-entries 1
Richard M. Stallman's avatar
Richard M. Stallman committed
172
  "*Specifies how many days of diary entries are to be displayed initially.
Stefan Monnier's avatar
Stefan Monnier committed
173
This variable affects the diary display when the command \\[diary] is used,
Richard M. Stallman's avatar
Richard M. Stallman committed
174 175 176
or if the value of the variable `view-diary-entries-initially' is t.  For
example, if the default value 1 is used, then only the current day's diary
entries will be displayed.  If the value 2 is used, then both the current
Richard M. Stallman's avatar
Richard M. Stallman committed
177 178 179 180 181 182 183 184 185 186
day's and the next day's entries will be displayed.

The value can also be a vector such as [0 2 2 2 2 4 1]; this value
says to display no diary entries on Sunday, the display the entries
for the current date and the day after on Monday through Thursday,
display Friday through Monday's entries on Friday, and display only
Saturday's entries on Saturday.

This variable does not affect the diary display with the `d' command
from the calendar; in that case, the prefix argument controls the
187 188 189 190 191 192 193 194 195 196 197
number of days of diary entries displayed."
  :type '(choice (integer :tag "Entries")
		 (vector :value [0 0 0 0 0 0 0]
			 (integer :tag "Sunday")
			 (integer :tag "Monday")
			 (integer :tag "Tuesday")
			 (integer :tag "Wednesday")
			 (integer :tag "Thursday")
			 (integer :tag "Friday")
			 (integer :tag "Saturday")))
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
198

Jim Blandy's avatar
Jim Blandy committed
199
;;;###autoload
200
(defcustom mark-diary-entries-in-calendar nil
Richard M. Stallman's avatar
Richard M. Stallman committed
201
  "*Non-nil means mark dates with diary entries, in the calendar window.
202 203 204
The marking symbol is specified by the variable `diary-entry-marker'."
  :type 'boolean
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
205

206 207 208 209 210 211 212
;;;###autoload
(defcustom calendar-remove-frame-by-deleting nil
  "*Determine how the calendar mode removes a frame no longer needed.
If nil, make an icon of the frame.  If non-nil, delete the frame."
  :type 'boolean
  :group 'view)

213 214
(defvar diary-face 'diary-face
  "Face name to use for diary entries.")
215 216
(defface diary-face
  '((((class color) (background light))
ShengHuo ZHU's avatar
ShengHuo ZHU committed
217
     :foreground "red")
218
    (((class color) (background dark))
ShengHuo ZHU's avatar
ShengHuo ZHU committed
219
     :foreground "yellow")
220
    (t
221
     :weight bold))
222 223 224 225 226 227 228 229 230 231
  "Face for highlighting diary entries."
  :group 'diary)

(defface calendar-today-face
  '((t (:underline t)))
  "Face for indicating today's date."
  :group 'diary)

(defface holiday-face
  '((((class color) (background light))
ShengHuo ZHU's avatar
ShengHuo ZHU committed
232
     :background "pink")
233
    (((class color) (background dark))
ShengHuo ZHU's avatar
ShengHuo ZHU committed
234
     :background "chocolate4")
235
    (t
ShengHuo ZHU's avatar
ShengHuo ZHU committed
236
     :inverse-video t))
237 238
  "Face for indicating dates that have holidays."
  :group 'diary)
239

240 241 242 243 244 245
(eval-after-load "facemenu"
  '(progn
     (add-to-list 'facemenu-unlisted-faces 'diary-face)
     (add-to-list 'facemenu-unlisted-faces 'calendar-today-face)
     (add-to-list 'facemenu-unlisted-faces 'holiday-face)))

246
(defcustom diary-entry-marker
247
  (if (not (display-color-p))
248 249
      "+"
    'diary-face)
250 251
  "*How to mark dates that have diary entries.
The value can be either a single-character string or a face."
252 253
  :type '(choice string face)
  :group 'diary)
254

255
(defcustom calendar-today-marker
256
  (if (not (display-color-p))
257 258
      "="
    'calendar-today-face)
259 260 261 262
  "*How to mark today's date in the calendar.
The value can be either a single-character string or a face.
Marking today's date is done only if you set up `today-visible-calendar-hook'
to request that."
263 264
  :type '(choice string face)
  :group 'calendar)
265

266
(defcustom calendar-holiday-marker
267
  (if (not (display-color-p))
268 269
      "*"
    'holiday-face)
270 271
  "*How to mark notable dates in the calendar.
The value can be either a single-character string or a face."
272 273
  :type '(choice string face)
  :group 'calendar)
Richard M. Stallman's avatar
Richard M. Stallman committed
274

Jim Blandy's avatar
Jim Blandy committed
275
;;;###autoload
276
(defcustom view-calendar-holidays-initially nil
Richard M. Stallman's avatar
Richard M. Stallman committed
277
  "*Non-nil means display holidays for current three month period on entry.
278
The holidays are displayed in another window when the calendar is first
279 280 281
displayed."
  :type 'boolean
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
282

Jim Blandy's avatar
Jim Blandy committed
283
;;;###autoload
284
(defcustom mark-holidays-in-calendar nil
Richard M. Stallman's avatar
Richard M. Stallman committed
285
  "*Non-nil means mark dates of holidays in the calendar window.
286 287 288
The marking symbol is specified by the variable `calendar-holiday-marker'."
  :type 'boolean
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
289

Jim Blandy's avatar
Jim Blandy committed
290
;;;###autoload
291
(defcustom all-hebrew-calendar-holidays nil
292
  "*If nil, show only major holidays from the Hebrew calendar.
Richard M. Stallman's avatar
Richard M. Stallman committed
293
This means only those Jewish holidays that appear on secular calendars.
294

295 296 297
If t, show all the holidays that would appear in a complete Hebrew calendar."
  :type 'boolean
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
298

Jim Blandy's avatar
Jim Blandy committed
299
;;;###autoload
300
(defcustom all-christian-calendar-holidays nil
301
  "*If nil, show only major holidays from the Christian calendar.
Richard M. Stallman's avatar
Richard M. Stallman committed
302
This means only those Christian holidays that appear on secular calendars.
303

Richard M. Stallman's avatar
Richard M. Stallman committed
304
If t, show all the holidays that would appear in a complete Christian
305 306 307
calendar."
  :type 'boolean
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
308

Jim Blandy's avatar
Jim Blandy committed
309
;;;###autoload
310
(defcustom all-islamic-calendar-holidays nil
311
  "*If nil, show only major holidays from the Islamic calendar.
Richard M. Stallman's avatar
Richard M. Stallman committed
312
This means only those Islamic holidays that appear on secular calendars.
313

Richard M. Stallman's avatar
Richard M. Stallman committed
314
If t, show all the holidays that would appear in a complete Islamic
315 316 317
calendar."
  :type 'boolean
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
318

319 320
(defcustom diary-file-name-prefix-function (function (lambda (str) str))
  "*The function that will take a diary file name and return the desired prefix."
321
  :type 'function
322 323
  :group 'diary)

324 325 326 327 328 329 330 331 332 333
;;;###autoload
(defcustom all-bahai-calendar-holidays nil
  "*If nil, show only major holidays from the Baha'i calendar.
These are the days on which work and school must be suspended.

If t, show all the holidays that would appear in a complete Baha'i
calendar."
  :type 'boolean
  :group 'holidays)

Jim Blandy's avatar
Jim Blandy committed
334
;;;###autoload
335
(defcustom calendar-load-hook nil
Jim Blandy's avatar
Jim Blandy committed
336
  "*List of functions to be called after the calendar is first loaded.
337 338 339
This is the place to add key bindings to `calendar-mode-map'."
  :type 'hook
  :group 'calendar-hooks)
Jim Blandy's avatar
Jim Blandy committed
340 341

;;;###autoload
342
(defcustom initial-calendar-window-hook nil
Richard M. Stallman's avatar
Richard M. Stallman committed
343 344 345
  "*List of functions to be called when the calendar window is first opened.
The functions invoked are called after the calendar window is opened, but
once opened is never called again.  Leaving the calendar with the `q' command
346 347 348
and reentering it will cause these functions to be called again."
  :type 'hook
  :group 'calendar-hooks)
Richard M. Stallman's avatar
Richard M. Stallman committed
349

Jim Blandy's avatar
Jim Blandy committed
350
;;;###autoload
351
(defcustom today-visible-calendar-hook nil
Richard M. Stallman's avatar
Richard M. Stallman committed
352 353 354 355
  "*List of functions called whenever the current date is visible.
This can be used, for example, to replace today's date with asterisks; a
function `calendar-star-date' is included for this purpose:
    (setq today-visible-calendar-hook 'calendar-star-date)
Richard M. Stallman's avatar
Richard M. Stallman committed
356
It can also be used to mark the current date with `calendar-today-marker';
357
a function is also provided for this:
Richard M. Stallman's avatar
Richard M. Stallman committed
358 359 360 361 362 363 364 365
    (setq today-visible-calendar-hook 'calendar-mark-today)

The corresponding variable `today-invisible-calendar-hook' is the list of
functions called when the calendar function was called when the current
date is not visible in the window.

Other than the use of the provided functions, the changing of any
characters in the calendar buffer by the hooks may cause the failure of the
366 367 368
functions that move by days and weeks."
  :type 'hook
  :group 'calendar-hooks)
Richard M. Stallman's avatar
Richard M. Stallman committed
369

Jim Blandy's avatar
Jim Blandy committed
370
;;;###autoload
371
(defcustom today-invisible-calendar-hook nil
Richard M. Stallman's avatar
Richard M. Stallman committed
372 373 374 375 376 377 378 379
  "*List of functions called whenever the current date is not visible.

The corresponding variable `today-visible-calendar-hook' is the list of
functions called when the calendar function was called when the current
date is visible in the window.

Other than the use of the provided functions, the changing of any
characters in the calendar buffer by the hooks may cause the failure of the
380 381 382
functions that move by days and weeks."
  :type 'hook
  :group 'calendar-hooks)
Richard M. Stallman's avatar
Richard M. Stallman committed
383

384 385 386 387
;;;###autoload
(defcustom calendar-move-hook nil
  "*List of functions called whenever the cursor moves in the calendar.

388
For example,
389 390 391 392 393 394 395

  (add-hook 'calendar-move-hook (lambda () (view-diary-entries 1)))

redisplays the diary for whatever date the cursor is moved to."
  :type 'hook
  :group 'calendar-hooks)

Jim Blandy's avatar
Jim Blandy committed
396
;;;###autoload
397
(defcustom diary-file "~/diary"
Richard M. Stallman's avatar
Richard M. Stallman committed
398 399
  "*Name of the file in which one's personal diary of dates is kept.

400 401
The file's entries are lines beginning with any of the forms
specified by the variable `american-date-diary-pattern', by default:
Richard M. Stallman's avatar
Richard M. Stallman committed
402 403 404 405 406 407 408

            MONTH/DAY
            MONTH/DAY/YEAR
            MONTHNAME DAY
            MONTHNAME DAY, YEAR
            DAYNAME

409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
with the remainder of the line being the diary entry string for
that date.  MONTH and DAY are one or two digit numbers, YEAR is a
number and may be written in full or abbreviated to the final two
digits (if `abbreviated-calendar-year' is non-nil).  MONTHNAME
and DAYNAME can be spelled in full (as specified by the variables
`calendar-month-name-array' and `calendar-day-name-array'),
abbreviated (as specified by `calendar-month-abbrev-array' and
`calendar-day-abbrev-array') with or without a period,
capitalized or not.  Any of DAY, MONTH, or MONTHNAME, YEAR can be
`*' which matches any day, month, or year, respectively. If the
date does not contain a year, it is generic and applies to any
year.  A DAYNAME entry applies to the appropriate day of the week
in every week.

The European style (in which the day precedes the month) can be
used instead, if you execute `european-calendar' when in the
calendar, or set `european-calendar-style' to t in your .emacs
file.  The European forms (see `european-date-diary-pattern') are
Richard M. Stallman's avatar
Richard M. Stallman committed
427 428 429 430 431 432 433 434 435 436

            DAY/MONTH
            DAY/MONTH/YEAR
            DAY MONTHNAME
            DAY MONTHNAME YEAR
            DAYNAME

To revert to the default American style from the European style, execute
`american-calendar' in the calendar.

Richard M. Stallman's avatar
Richard M. Stallman committed
437 438 439 440
A diary entry can be preceded by the character
`diary-nonmarking-symbol' (ordinarily `&') to make that entry
nonmarking--that is, it will not be marked on dates in the calendar
window but will appear in a diary window.
Richard M. Stallman's avatar
Richard M. Stallman committed
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460

Multiline diary entries are made by indenting lines after the first with
either a TAB or one or more spaces.

Lines not in one the above formats are ignored.  Here are some sample diary
entries (in the default American style):

     12/22/1988 Twentieth wedding anniversary!!
     &1/1. Happy New Year!
     10/22 Ruth's birthday.
     21: Payday
     Tuesday--weekly meeting with grad students at 10am
              Supowit, Shen, Bitner, and Kapoor to attend.
     1/13/89 Friday the thirteenth!!
     &thu 4pm squash game with Lloyd.
     mar 16 Dad's birthday
     April 15, 1989 Income tax due.
     &* 15 time cards due.

If the first line of a diary entry consists only of the date or day name with
Richard M. Stallman's avatar
Richard M. Stallman committed
461 462
no trailing blanks or punctuation, then that line is not displayed in the
diary window; only the continuation lines is shown.  For example, the
Richard M. Stallman's avatar
Richard M. Stallman committed
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
single diary entry

     02/11/1989
      Bill Blattner visits Princeton today
      2pm Cognitive Studies Committee meeting
      2:30-5:30 Lizzie at Lawrenceville for `Group Initiative'
      4:00pm Jamie Tappenden
      7:30pm Dinner at George and Ed's for Alan Ryan
      7:30-10:00pm dance at Stewart Country Day School

will appear in the diary window without the date line at the beginning.  This
facility allows the diary window to look neater, but can cause confusion if
used with more than one day's entries displayed.

Diary entries can be based on Lisp sexps.  For example, the diary entry

      %%(diary-block 11 1 1990 11 10 1990) Vacation

481 482 483 484 485
causes the diary entry \"Vacation\" to appear from November 1 through
November 10, 1990.  Other functions available are `diary-float',
`diary-anniversary', `diary-cyclic', `diary-day-of-year',
`diary-iso-date', `diary-french-date', `diary-hebrew-date',
`diary-islamic-date', `diary-bahai-date', `diary-mayan-date',
486
`diary-chinese-date', `diary-coptic-date', `diary-ethiopic-date',
487
`diary-persian-date', `diary-yahrzeit', `diary-sunrise-sunset',
488 489 490 491
`diary-phases-of-moon', `diary-parasha', `diary-omer',
`diary-rosh-hodesh', and `diary-sabbath-candles'.  See the
documentation for the function `list-sexp-diary-entries' for more
details.
Richard M. Stallman's avatar
Richard M. Stallman committed
492

493 494 495 496 497
Diary entries based on the Hebrew, the Islamic and/or the Baha'i
calendar are also possible, but because these are somewhat slow, they
are ignored unless you set the `nongregorian-diary-listing-hook' and
the `nongregorian-diary-marking-hook' appropriately.  See the
documentation for these functions for details.
Richard M. Stallman's avatar
Richard M. Stallman committed
498 499

Diary files can contain directives to include the contents of other files; for
500 501 502
details, see the documentation for the variable `list-diary-entries-hook'."
  :type 'file
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
503

Jim Blandy's avatar
Jim Blandy committed
504
;;;###autoload
505 506 507 508
(defcustom diary-nonmarking-symbol "&"
  "*Symbol indicating that a diary entry is not to be marked in the calendar."
  :type 'string
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
509

Jim Blandy's avatar
Jim Blandy committed
510
;;;###autoload
511 512 513 514
(defcustom hebrew-diary-entry-symbol "H"
  "*Symbol indicating a diary entry according to the Hebrew calendar."
  :type 'string
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
515

Jim Blandy's avatar
Jim Blandy committed
516
;;;###autoload
517 518 519 520
(defcustom islamic-diary-entry-symbol "I"
  "*Symbol indicating a diary entry according to the Islamic calendar."
  :type 'string
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
521

522 523 524 525 526 527
;;;###autoload
(defcustom bahai-diary-entry-symbol "B"
  "*Symbol indicating a diary entry according to the Baha'i calendar."
  :type 'string
  :group 'diary)

Jim Blandy's avatar
Jim Blandy committed
528
;;;###autoload
529
(defcustom diary-include-string "#include"
530
  "*The string indicating inclusion of another file of diary entries.
531 532 533
See the documentation for the function `include-other-diary-files'."
  :type 'string
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
534

535 536 537 538 539
(defcustom diary-glob-file-regexp-prefix "^\\#"
  "*The regular expression that gets pre-pended to each of the attribute-regexp's for file-wide specifiers."
  :type 'regexp
  :group 'diary)

540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
(defcustom diary-face-attrs
  '((" *\\[foreground:\\([-a-z]+\\)\\]$" 1 :foreground string)
    (" *\\[background:\\([-a-z]+\\)\\]$" 1 :background string)
    (" *\\[width:\\([-a-z]+\\)\\]$" 1 :width symbol)
    (" *\\[height:\\([-0-9a-z]+\\)\\]$" 1 :height int)
    (" *\\[weight:\\([-a-z]+\\)\\]$" 1 :weight symbol)
    (" *\\[slant:\\([-a-z]+\\)\\]$" 1 :slant symbol)
    (" *\\[underline:\\([-a-z]+\\)\\]$" 1 :underline stringtnil)
    (" *\\[overline:\\([-a-z]+\\)\\]$" 1 :overline stringtnil)
    (" *\\[strike-through:\\([-a-z]+\\)\\]$" 1 :strike-through stringtnil)
    (" *\\[inverse-video:\\([-a-z]+\\)\\]$" 1 :inverse-video tnil)
    (" *\\[face:\\([-0-9a-z]+\\)\\]$" 1 :face string)
    (" *\\[font:\\([-a-z0-9]+\\)\\]$" 1 :font string)
    ;; Unsupported.
;;;    (" *\\[box:\\([-a-z]+\\)\\]$" 1 :box)
;;;    (" *\\[stipple:\\([-a-z]+\\)\\]$" 1 :stipple)
    )
  "*A list of (regexp regnum attr attrtype) lists where the
regexp says how to find the tag, the regnum says which
parenthetical sub-regexp this regexp looks for, and the attr says
which attribute of the face (or that this _is_ a face) is being
modified."
562 563 564 565
  :type 'sexp
  :group 'diary)

(defcustom diary-file-name-prefix nil
566
  "If non-nil each diary entry is prefixed with the name of the file where it is defined."
567 568 569
  :type 'boolean
  :group 'diary)

Jim Blandy's avatar
Jim Blandy committed
570
;;;###autoload
571
(defcustom sexp-diary-entry-symbol "%%"
Stefan Monnier's avatar
Stefan Monnier committed
572
  "*The string used to indicate a sexp diary entry in `diary-file'.
573 574 575
See the documentation for the function `list-sexp-diary-entries'."
  :type 'string
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
576

Jim Blandy's avatar
Jim Blandy committed
577
;;;###autoload
578
(defcustom abbreviated-calendar-year t
579
  "*Interpret a two-digit year DD in a diary entry as either 19DD or 20DD.
580 581 582
For the Gregorian calendar; similarly for the Hebrew, Islamic and
Baha'i calendars.  If this variable is nil, years must be written in
full."
583 584
  :type 'boolean
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
585

Jim Blandy's avatar
Jim Blandy committed
586
;;;###autoload
587
(defcustom european-calendar-style nil
588 589
  "*Use the European style of dates in the diary and in any displays.
If this variable is t, a date 1/2/1990 would be interpreted as February 1,
590 591
1990.  The default European date styles (see `european-date-diary-pattern')
are
Richard M. Stallman's avatar
Richard M. Stallman committed
592 593 594 595 596 597 598

            DAY/MONTH
            DAY/MONTH/YEAR
            DAY MONTHNAME
            DAY MONTHNAME YEAR
            DAYNAME

599 600
Names can be capitalized or not, written in full (as specified by the
variable `calendar-day-name-array'), or abbreviated (as specified by
Glenn Morris's avatar
Glenn Morris committed
601 602 603 604
`calendar-day-abbrev-array') with or without a period.  To take effect,
this variable should be set before the calendar package and its associates
are loaded.  Otherwise, use one of the functions `european-calendar' or
`american-calendar' to force the appropriate update."
605 606
  :type 'boolean
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
607

Jim Blandy's avatar
Jim Blandy committed
608
;;;###autoload
609
(defcustom american-date-diary-pattern
Richard M. Stallman's avatar
Richard M. Stallman committed
610 611 612 613 614 615
  '((month "/" day "[^/0-9]")
    (month "/" day "/" year "[^0-9]")
    (monthname " *" day "[^,0-9]")
    (monthname " *" day ", *" year "[^0-9]")
    (dayname "\\W"))
  "*List of pseudo-patterns describing the American patterns of date used.
616 617 618 619 620 621 622 623 624 625 626
See the documentation of `diary-date-forms' for an explanation."
  :type '(repeat (choice (cons :tag "Backup"
			       :value (backup . nil)
			       (const backup)
			       (repeat (list :inline t :format "%v"
					     (symbol :tag "Keyword")
					     (choice symbol regexp))))
			 (repeat (list :inline t :format "%v"
				       (symbol :tag "Keyword")
				       (choice symbol regexp)))))
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
627

Jim Blandy's avatar
Jim Blandy committed
628
;;;###autoload
629
(defcustom european-date-diary-pattern
Richard M. Stallman's avatar
Richard M. Stallman committed
630 631
  '((day "/" month "[^/0-9]")
    (day "/" month "/" year "[^0-9]")
632
    (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)")
Richard M. Stallman's avatar
Richard M. Stallman committed
633 634 635
    (day " *" monthname " *" year "[^0-9]")
    (dayname "\\W"))
  "*List of pseudo-patterns describing the European patterns of date used.
636 637 638 639 640 641 642 643 644 645 646 647 648
See the documentation of `diary-date-forms' for an explanation."
  :type '(repeat (choice (cons :tag "Backup"
			       :value (backup . nil)
			       (const backup)
			       (repeat (list :inline t :format "%v"
					     (symbol :tag "Keyword")
					     (choice symbol regexp))))
			 (repeat (list :inline t :format "%v"
				       (symbol :tag "Keyword")
				       (choice symbol regexp)))))
  :group 'diary)

(defcustom diary-date-forms
Richard M. Stallman's avatar
Richard M. Stallman committed
649 650 651 652
  (if european-calendar-style
      european-date-diary-pattern
    american-date-diary-pattern)
  "*List of pseudo-patterns describing the forms of date used in the diary.
Juanma Barranquero's avatar
Juanma Barranquero committed
653
The patterns on the list must be MUTUALLY EXCLUSIVE and should not match
Richard M. Stallman's avatar
Richard M. Stallman committed
654 655 656 657
any portion of the diary entry itself, just the date component.

A pseudo-pattern is a list of regular expressions and the keywords `month',
`day', `year', `monthname', and `dayname'.  The keyword `monthname' will
658 659 660 661 662 663 664 665
match the name of the month (see `calendar-month-name-array'), capitalized
or not, or its user-specified abbreviation (see `calendar-month-abbrev-array'),
followed by a period or not; it will also match `*'.  Similarly, `dayname'
will match the name of the day (see `calendar-day-name-array'), capitalized or
not, or its user-specified abbreviation (see `calendar-day-abbrev-array'),
followed by a period or not.  The keywords `month', `day', and `year' will
match those numerical values, preceded by arbitrarily many zeros; they will
also match `*'.
Richard M. Stallman's avatar
Richard M. Stallman committed
666 667 668 669 670 671 672

The matching of the diary entries with the date forms is done with the
standard syntax table from Fundamental mode, but with the `*' changed so
that it is a word constituent.

If, to be mutually exclusive, a pseudo-pattern must match a portion of the
diary entry itself, the first element of the pattern MUST be `backup'.  This
Jim Blandy's avatar
Jim Blandy committed
673 674
directive causes the date recognizer to back up to the beginning of the
current word of the diary entry, so in no case can the pattern match more than
675 676 677 678 679 680 681 682 683 684 685
a portion of the first word of the diary entry."
  :type '(repeat (choice (cons :tag "Backup"
			       :value (backup . nil)
			       (const backup)
			       (repeat (list :inline t :format "%v"
					     (symbol :tag "Keyword")
					     (choice symbol regexp))))
			 (repeat (list :inline t :format "%v"
				       (symbol :tag "Keyword")
				       (choice symbol regexp)))))
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
686

Jim Blandy's avatar
Jim Blandy committed
687
;;;###autoload
688
(defcustom european-calendar-display-form
Jim Blandy's avatar
Jim Blandy committed
689
  '((if dayname (concat dayname ", ")) day " " monthname " " year)
690
  "*Pseudo-pattern governing the way a date appears in the European style.
691
See the documentation of `calendar-date-display-form' for an explanation."
692 693
  :type 'sexp
  :group 'calendar)
Richard M. Stallman's avatar
Richard M. Stallman committed
694

Jim Blandy's avatar
Jim Blandy committed
695
;;;###autoload
696
(defcustom american-calendar-display-form
Jim Blandy's avatar
Jim Blandy committed
697
  '((if dayname (concat dayname ", ")) monthname " " day ", " year)
698
  "*Pseudo-pattern governing the way a date appears in the American style.
699 700 701
See the documentation of `calendar-date-display-form' for an explanation."
  :type 'sexp
  :group 'calendar)
Richard M. Stallman's avatar
Richard M. Stallman committed
702

703
(defcustom calendar-date-display-form
Richard M. Stallman's avatar
Richard M. Stallman committed
704 705 706
  (if european-calendar-style
      european-calendar-display-form
    american-calendar-display-form)
707 708 709 710 711 712
  "*Pseudo-pattern governing the way a date appears.

Used by the function `calendar-date-string', a pseudo-pattern is a list of
expressions that can involve the keywords `month', `day', and `year', all
numbers in string form, and `monthname' and `dayname', both alphabetic
strings.  For example, the ISO standard would use the pseudo- pattern
Richard M. Stallman's avatar
Richard M. Stallman committed
713 714 715 716 717 718 719 720 721 722 723 724 725

       '(year \"-\" month \"-\" day)

while a typical American form would be

       '(month \"/\" day \"/\" (substring year -2))

and

       '((format \"%9s, %9s %2s, %4s\" dayname monthname day year))

would give the usual American style in fixed-length fields.

726 727 728
See the documentation of the function `calendar-date-string'."
  :type 'sexp
  :group 'calendar)
Richard M. Stallman's avatar
Richard M. Stallman committed
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745

(defun european-calendar ()
  "Set the interpretation and display of dates to the European style."
  (interactive)
  (setq european-calendar-style t)
  (setq calendar-date-display-form european-calendar-display-form)
  (setq diary-date-forms european-date-diary-pattern)
  (update-calendar-mode-line))

(defun american-calendar ()
  "Set the interpretation and display of dates to the American style."
  (interactive)
  (setq european-calendar-style nil)
  (setq calendar-date-display-form american-calendar-display-form)
  (setq diary-date-forms american-date-diary-pattern)
  (update-calendar-mode-line))

Jim Blandy's avatar
Jim Blandy committed
746
;;;###autoload
747
(defcustom print-diary-entries-hook 'lpr-buffer
748 749 750 751
  "*List of functions called after a temporary diary buffer is prepared.
The buffer shows only the diary entries currently visible in the diary
buffer.  The default just does the printing.  Other uses might include, for
example, rearranging the lines into order by day and time, saving the buffer
752 753 754
instead of deleting it, or changing the function used to do the printing."
  :type 'hook
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
755

Jim Blandy's avatar
Jim Blandy committed
756
;;;###autoload
757
(defcustom list-diary-entries-hook nil
758 759
  "*List of functions called after diary file is culled for relevant entries.
It is to be used for diary entries that are not found in the diary file.
Richard M. Stallman's avatar
Richard M. Stallman committed
760 761 762

A function `include-other-diary-files' is provided for use as the value of
this hook.  This function enables you to use shared diary files together
Richard M. Stallman's avatar
Richard M. Stallman committed
763
with your own.  The files included are specified in the diary file by lines
Richard M. Stallman's avatar
Richard M. Stallman committed
764 765 766 767 768 769 770 771
of the form

        #include \"filename\"

This is recursive; that is, #include directives in files thus included are
obeyed.  You can change the \"#include\" to some other string by changing
the variable `diary-include-string'.  When you use `include-other-diary-files'
as part of the list-diary-entries-hook, you will probably also want to use the
Richard M. Stallman's avatar
Richard M. Stallman committed
772
function `mark-included-diary-files' as part of `mark-diary-entries-hook'.
Richard M. Stallman's avatar
Richard M. Stallman committed
773 774 775 776

For example, you could use

     (setq list-diary-entries-hook
Jim Blandy's avatar
Jim Blandy committed
777
       '(include-other-diary-files sort-diary-entries))
Richard M. Stallman's avatar
Richard M. Stallman committed
778 779
     (setq diary-display-hook 'fancy-diary-display)

Richard M. Stallman's avatar
Richard M. Stallman committed
780
in your `.emacs' file to cause the fancy diary buffer to be displayed with
Richard M. Stallman's avatar
Richard M. Stallman committed
781
diary entries from various included files, each day's entries sorted into
782 783
lexicographic order."
  :type 'hook
784
  :options '(include-other-diary-files sort-diary-entries)
785
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
786

Jim Blandy's avatar
Jim Blandy committed
787
;;;###autoload
788
(defcustom diary-hook nil
789
  "*List of functions called after the display of the diary.
790 791 792
Can be used for appointment notification."
  :type 'hook
  :group 'diary)
793 794

;;;###autoload
795
(defcustom diary-display-hook nil
Richard M. Stallman's avatar
Richard M. Stallman committed
796
  "*List of functions that handle the display of the diary.
Richard M. Stallman's avatar
Richard M. Stallman committed
797
If nil (the default), `simple-diary-display' is used.  Use `ignore' for no
798
diary display.
Richard M. Stallman's avatar
Richard M. Stallman committed
799 800 801 802 803 804

Ordinarily, this just displays the diary buffer (with holidays indicated in
the mode line), if there are any relevant entries.  At the time these
functions are called, the variable `diary-entries-list' is a list, in order
by date, of all relevant diary entries in the form of ((MONTH DAY YEAR)
STRING), where string is the diary entry for the given date.  This can be
805 806
used, for example, a different buffer for display (perhaps combined with
holidays), or produce hard copy output.
Richard M. Stallman's avatar
Richard M. Stallman committed
807 808 809 810 811 812 813 814

A function `fancy-diary-display' is provided as an alternative
choice for this hook; this function prepares a special noneditable diary
buffer with the relevant diary entries that has neat day-by-day arrangement
with headings.  The fancy diary buffer will show the holidays unless the
variable `holidays-in-diary-buffer' is set to nil.  Ordinarily, the fancy
diary buffer will not show days for which there are no diary entries, even
if that day is a holiday; if you want such days to be shown in the fancy
815 816
diary buffer, set the variable `diary-list-include-blanks' to t."
  :type 'hook
817
  :options '(fancy-diary-display)
818
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
819

Jim Blandy's avatar
Jim Blandy committed
820
;;;###autoload
821
(defcustom nongregorian-diary-listing-hook nil
822
  "*List of functions called for listing diary file and included files.
823 824 825 826
As the files are processed for diary entries, these functions are used
to cull relevant entries.  You can use either or both of
`list-hebrew-diary-entries', `list-islamic-diary-entries' and
`list-bahai-diary-entries'.  The documentation for these functions
827 828
describes the style of such diary entries."
  :type 'hook
829 830 831
  :options '(list-hebrew-diary-entries
	     list-islamic-diary-entries
	     list-bahai-diary-entries)
832
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
833

Jim Blandy's avatar
Jim Blandy committed
834
;;;###autoload
835
(defcustom mark-diary-entries-hook nil
Richard M. Stallman's avatar
Richard M. Stallman committed
836 837 838
  "*List of functions called after marking diary entries in the calendar.

A function `mark-included-diary-files' is also provided for use as the
Stefan Monnier's avatar
Stefan Monnier committed
839
`mark-diary-entries-hook'; it enables you to use shared diary files together
Richard M. Stallman's avatar
Richard M. Stallman committed
840
with your own.  The files included are specified in the diary file by lines
Richard M. Stallman's avatar
Richard M. Stallman committed
841 842 843 844 845 846
of the form
        #include \"filename\"
This is recursive; that is, #include directives in files thus included are
obeyed.  You can change the \"#include\" to some other string by changing the
variable `diary-include-string'.  When you use `mark-included-diary-files' as
part of the mark-diary-entries-hook, you will probably also want to use the
847 848
function `include-other-diary-files' as part of `list-diary-entries-hook'."
  :type 'hook
849
  :options '(mark-included-diary-files)
850
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
851

Jim Blandy's avatar
Jim Blandy committed
852
;;;###autoload
853
(defcustom nongregorian-diary-marking-hook nil
854
  "*List of functions called for marking diary file and included files.
855 856 857 858
As the files are processed for diary entries, these functions are used
to cull relevant entries.  You can use either or both of
`mark-hebrew-diary-entries', `mark-islamic-diary-entries' and
`mark-bahai-diary-entries'.  The documentation for these functions
859 860
describes the style of such diary entries."
  :type 'hook
861 862 863
  :options '(mark-hebrew-diary-entries
	     mark-islamic-diary-entries
	     mark-bahai-diary-entries)
864
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
865

Jim Blandy's avatar
Jim Blandy committed
866
;;;###autoload
867
(defcustom diary-list-include-blanks nil
868
  "*If nil, do not include days with no diary entry in the list of diary entries.
869
Such days will then not be shown in the fancy diary buffer, even if they
870 871 872
are holidays."
  :type 'boolean
  :group 'diary)
Richard M. Stallman's avatar
Richard M. Stallman committed
873

Jim Blandy's avatar
Jim Blandy committed
874
;;;###autoload
875
(defcustom holidays-in-diary-buffer t
Richard M. Stallman's avatar
Richard M. Stallman committed
876 877
  "*Non-nil means include holidays in the diary display.
The holidays appear in the mode line of the diary buffer, or in the
878
fancy diary buffer next to the date.  This slows down the diary functions
879 880 881
somewhat; setting it to nil makes the diary display faster."
  :type 'boolean
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
882

883 884
(defvar calendar-mark-ring nil)

Richard M. Stallman's avatar
Richard M. Stallman committed
885 886
;;;###autoload
(put 'general-holidays 'risky-local-variable t)
Jim Blandy's avatar
Jim Blandy committed
887
;;;###autoload
888
(defcustom general-holidays
889 890
  '((holiday-fixed 1 1 "New Year's Day")
    (holiday-float 1 1 3 "Martin Luther King Day")
Edward M. Reingold's avatar
Edward M. Reingold committed
891
    (holiday-fixed 2 2 "Groundhog Day")
892 893 894
    (holiday-fixed 2 14 "Valentine's Day")
    (holiday-float 2 1 3 "President's Day")
    (holiday-fixed 3 17 "St. Patrick's Day")
Edward M. Reingold's avatar
Edward M. Reingold committed
895
    (holiday-fixed 4 1 "April Fools' Day")
896 897 898 899 900 901 902 903 904 905 906
    (holiday-float 5 0 2 "Mother's Day")
    (holiday-float 5 1 -1 "Memorial Day")
    (holiday-fixed 6 14 "Flag Day")
    (holiday-float 6 0 3 "Father's Day")
    (holiday-fixed 7 4 "Independence Day")
    (holiday-float 9 1 1 "Labor Day")
    (holiday-float 10 1 2 "Columbus Day")
    (holiday-fixed 10 31 "Halloween")
    (holiday-fixed 11 11 "Veteran's Day")
    (holiday-float 11 4 4 "Thanksgiving"))
  "*General holidays.  Default value is for the United States.
907 908 909
See the documentation for `calendar-holidays' for details."
  :type 'sexp
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
910

911 912 913
;;;###autoload
(put 'oriental-holidays 'risky-local-variable t)
;;;###autoload
914
(defcustom oriental-holidays
915 916 917
  '((if (fboundp 'atan)
	(holiday-chinese-new-year)))
  "*Oriental holidays.
918 919 920
See the documentation for `calendar-holidays' for details."
  :type 'sexp
  :group 'holidays)
921

Richard M. Stallman's avatar
Richard M. Stallman committed
922 923
;;;###autoload
(put 'local-holidays 'risky-local-variable t)
Jim Blandy's avatar
Jim Blandy committed
924
;;;###autoload
925
(defcustom local-holidays nil
Jim Blandy's avatar
Jim Blandy committed
926
  "*Local holidays.
927 928 929
See the documentation for `calendar-holidays' for details."
  :type 'sexp
  :group 'holidays)
Jim Blandy's avatar
Jim Blandy committed
930

Richard M. Stallman's avatar
Richard M. Stallman committed
931 932
;;;###autoload
(put 'other-holidays 'risky-local-variable t)
Jim Blandy's avatar
Jim Blandy committed
933
;;;###autoload
934
(defcustom other-holidays nil
Jim Blandy's avatar
Jim Blandy committed
935
  "*User defined holidays.
936 937 938
See the documentation for `calendar-holidays' for details."
  :type 'sexp
  :group 'holidays)
Richard M. Stallman's avatar
Richard M. Stallman committed
939

Richard M. Stallman's avatar
Richard M. Stallman committed
940 941
;;;###autoload
(put 'hebrew-holidays-1 'risky-local-variable t)
Jim Blandy's avatar
Jim Blandy committed
942
;;;###autoload
943
(defvar hebrew-holidays-1
944
  '((holiday-rosh-hashanah-etc)
Richard M. Stallman's avatar
Richard M. Stallman committed
945
    (if all-hebrew-calendar-holidays
946 947 948 949 950 951 952 953 954 955 956 957
        (holiday-julian
         11
         (let* ((m displayed-month)
                (y displayed-year)
                (year))
           (increment-calendar-month m y -1)
           (let ((year (extract-calendar-year
                        (calendar-julian-from-absolute
                         (calendar-absolute-from-gregorian
                          (list m 1 y))))))
             (if (zerop (% (1+ year) 4))
                 22
958 959
               21))) "\"Tal Umatar\" (evening)"))))

Richard M. Stallman's avatar
Richard M. Stallman committed
960 961
;;;###autoload
(put 'hebrew-holidays-2 'risky-local-variable t)
962 963 964
;;;###autoload
(defvar hebrew-holidays-2
  '((if all-hebrew-calendar-holidays
965 966
        (holiday-hanukkah)
      (holiday-hebrew 9 25 "Hanukkah"))
Richard M. Stallman's avatar
Richard M. Stallman committed
967
    (if all-hebrew-calendar-holidays
968 969 970 971 972 973 974 975 976 977 978
      (holiday-hebrew
       10
       (let ((h-year (extract-calendar-year
                      (calendar-hebrew-from-absolute
                       (calendar-absolute-from-gregorian
                        (list displayed-month 28 displayed-year))))))
         (if (= (% (calendar-absolute-from-hebrew (list 10 10 h-year))
                   7)
                6)
             11 10))
       "Tzom Teveth"))
Richard M. Stallman's avatar
Richard M. Stallman committed
979
    (if all-hebrew-calendar-holidays
980 981
        (holiday-hebrew 11 15 "Tu B'Shevat"))))

Richard M. Stallman's avatar
Richard M. Stallman committed
982 983
;;;###autoload
(put 'hebrew-holidays-3 'risky-local-variable t)
984
;;;###autoload
985
(defvar hebrew-holidays-3
986
  '((if all-hebrew-calendar-holidays
987
        (holiday-hebrew
Richard M. Stallman's avatar
Richard M. Stallman committed
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
         11
         (let ((m displayed-month)
               (y displayed-year))
           (increment-calendar-month m y 1)
           (let* ((h-year (extract-calendar-year
                           (calendar-hebrew-from-absolute
                            (calendar-absolute-from-gregorian
                             (list m
                                   (calendar-last-day-of-month m y)
                                   y)))))
                  (s-s
                   (calendar-hebrew-from-absolute
                    (if (=
                         (% (calendar-absolute-from-hebrew
                             (list 7 1 h-year))
                            7)
                         6)
                        (calendar-dayname-on-or-before
                         6 (calendar-absolute-from-hebrew
                            (list 11 17 h-year)))
                      (calendar-dayname-on-or-before
                       6 (calendar-absolute-from-hebrew
                          (list 11 16 h-year))))))
                  (day (extract-calendar-day s-s)))
             day))
1013 1014
         "Shabbat Shirah"))))

Richard M. Stallman's avatar
Richard M. Stallman committed
1015 1016
;;;###autoload
(put 'hebrew-holidays-4 'risky-local-variable t)
1017 1018 1019
;;;###autoload
(defvar hebrew-holidays-4
  '((holiday-passover-etc)
Richard M. Stallman's avatar
Richard M. Stallman committed
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
    (if (and all-hebrew-calendar-holidays
             (let* ((m displayed-month)
                    (y displayed-year)
                    (year))
               (increment-calendar-month m y -1)
               (let ((year (extract-calendar-year
                            (calendar-julian-from-absolute
                             (calendar-absolute-from-gregorian
                              (list m 1 y))))))
                 (= 21 (% year 28)))))
1030
        (holiday-julian 3 26 "Kiddush HaHamah"))
Richard M. Stallman's avatar
Richard M. Stallman committed
1031
    (if all-hebrew-calendar-holidays
1032 1033
        (holiday-tisha-b-av-etc))))

Richard M. Stallman's avatar
Richard M. Stallman committed
1034 1035
;;;###autoload
(put 'hebrew-holidays 'risky-local-variable t)