PageRenderTime 68ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/xemacs-packages-extra-20110502/xemacs-packages/calendar/calendar.el

#
Emacs Lisp | 3255 lines | 2512 code | 404 blank | 339 comment | 172 complexity | a0d5ad6b25150721e8883a931678832b MD5 | raw file
Possible License(s): MPL-2.0, LGPL-2.1, GPL-2.0, MPL-2.0-no-copyleft-exception

Large files files are truncated, but you can click here to view the full file

  1. ;;; calendar.el --- calendar functions
  2. ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
  3. ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  4. ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
  5. ;; Maintainer: Glenn Morris <rgm@gnu.org>
  6. ;; Keywords: calendar
  7. ;; Human-Keywords: calendar, Gregorian calendar, diary, holidays
  8. ;; This file is part of XEmacs.
  9. ;; XEmacs is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13. ;; XEmacs is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with XEmacs; see the file COPYING. If not, write to the
  19. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. ;; Boston, MA 02110-1301, USA.
  21. ;;; Synched up with: FSF Emacs 22 CVS 2007-03-30
  22. ;;; Commentary:
  23. ;; This collection of functions implements a calendar window. It
  24. ;; generates a calendar for the current month, together with the
  25. ;; previous and coming months, or for any other three-month period.
  26. ;; The calendar can be scrolled forward and backward in the window to
  27. ;; show months in the past or future; the cursor can move forward and
  28. ;; backward by days, weeks, or months, making it possible, for
  29. ;; instance, to jump to the date a specified number of days, weeks, or
  30. ;; months from the date under the cursor. The user can display a list
  31. ;; of holidays and other notable days for the period shown; the
  32. ;; notable days can be marked on the calendar, if desired. The user
  33. ;; can also specify that dates having corresponding diary entries (in
  34. ;; a file that the user specifies) be marked; the diary entries for
  35. ;; any date can be viewed in a separate window. The diary and the
  36. ;; notable days can be viewed independently of the calendar. Dates
  37. ;; can be translated from the (usual) Gregorian calendar to the day of
  38. ;; the year/days remaining in year, to the ISO commercial calendar, to
  39. ;; the Julian (old style) calendar, to the Hebrew calendar, to the
  40. ;; Islamic calendar, to the Baha'i calendar, to the French
  41. ;; Revolutionary calendar, to the Mayan calendar, to the Chinese
  42. ;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to
  43. ;; the astronomical (Julian) day number. When floating point is
  44. ;; available, times of sunrise/sunset can be displayed, as can the
  45. ;; phases of the moon. Appointment notification for diary entries is
  46. ;; available. Calendar printing via LaTeX is available.
  47. ;; The following files are part of the calendar/diary code:
  48. ;; appt.el Appointment notification
  49. ;; cal-china.el Chinese calendar
  50. ;; cal-coptic.el Coptic/Ethiopic calendars
  51. ;; cal-dst.el Daylight saving time rules
  52. ;; cal-hebrew.el Hebrew calendar
  53. ;; cal-islam.el Islamic calendar
  54. ;; cal-bahai.el Baha'i calendar
  55. ;; cal-iso.el ISO calendar
  56. ;; cal-julian.el Julian/astronomical calendars
  57. ;; cal-mayan.el Mayan calendars
  58. ;; cal-menu.el Menu support
  59. ;; cal-move.el Movement in the calendar
  60. ;; cal-persia.el Persian calendar
  61. ;; cal-tex.el Calendars in LaTeX
  62. ;; cal-x.el X-windows dedicated frame functions
  63. ;; diary-lib.el Diary functions
  64. ;; holidays.el Holiday functions
  65. ;; cal-french.el French Revolutionary calendar
  66. ;; lunar.el Phases of the moon
  67. ;; solar.el Sunrise/sunset, equinoxes/solstices
  68. ;; Technical details of all the calendrical calculations can be found in
  69. ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
  70. ;; and Nachum Dershowitz, Cambridge University Press (2001).
  71. ;; An earlier version of the technical details appeared in
  72. ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
  73. ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
  74. ;; pages 899-928, and in ``Calendrical Calculations, Part II: Three Historical
  75. ;; Calendars'' by E. M. Reingold, N. Dershowitz, and S. M. Clamen,
  76. ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993),
  77. ;; pages 383-404.
  78. ;; Hard copies of these two papers can be obtained by sending email to
  79. ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and
  80. ;; the message BODY containing your mailing address (snail).
  81. ;; Comments, corrections, and improvements should be sent to
  82. ;; Edward M. Reingold Department of Computer Science
  83. ;; (217) 333-6733 University of Illinois at Urbana-Champaign
  84. ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
  85. ;; Urbana, Illinois 61801
  86. ;;; Code:
  87. (eval-and-compile
  88. (require 'cal-compat))
  89. (defvar displayed-month)
  90. (defvar displayed-year)
  91. (defvar calendar-month-name-array)
  92. (defvar calendar-starred-day)
  93. (defun calendar-version ()
  94. (interactive)
  95. (message "Version 6, October 12, 1995"))
  96. (defgroup calendar nil
  97. "Calendar and time management support."
  98. :group 'applications)
  99. (defgroup diary nil
  100. "Emacs diary."
  101. :group 'calendar)
  102. (defgroup appt nil
  103. "Appointment notification."
  104. :tag "Appointments"
  105. :group 'calendar)
  106. (defgroup holidays nil
  107. "Holidays support in calendar."
  108. :group 'calendar
  109. :prefix "calendar-"
  110. :group 'local)
  111. (defgroup chinese-calendar nil
  112. "Chinese calendar support."
  113. :group 'calendar)
  114. (defgroup calendar-tex nil
  115. "Options for printing calendar with LaTeX."
  116. :prefix "cal-tex-"
  117. :group 'calendar)
  118. (defgroup calendar-hooks nil
  119. "Calendar hooks."
  120. :prefix "calendar-"
  121. :group 'calendar)
  122. ;;;###autoload
  123. (defconst calendar-buffer "*Calendar*"
  124. "Name of the buffer used for the calendar.")
  125. ;;;###autoload
  126. (defcustom calendar-offset 0
  127. "The offset of the principal month from the center of the calendar window.
  128. 0 means the principal month is in the center (default), -1 means on the left,
  129. +1 means on the right. Larger (or smaller) values push the principal month off
  130. the screen."
  131. :type 'integer
  132. :group 'calendar)
  133. ;;;###autoload
  134. (defcustom view-diary-entries-initially nil
  135. "Non-nil means display current date's diary entries on entry to calendar.
  136. The diary is displayed in another window when the calendar is first displayed,
  137. if the current date is visible. The number of days of diary entries displayed
  138. is governed by the variable `number-of-diary-entries'. This variable can
  139. be overridden by the value of `calendar-setup'."
  140. :type 'boolean
  141. :group 'diary)
  142. ;;;###autoload
  143. (defcustom mark-diary-entries-in-calendar nil
  144. "Non-nil means mark dates with diary entries, in the calendar window.
  145. The marking symbol is specified by the variable `diary-entry-marker'."
  146. :type 'boolean
  147. :group 'diary)
  148. ;;;###autoload
  149. (defcustom calendar-remove-frame-by-deleting nil
  150. "Determine how the calendar mode removes a frame no longer needed.
  151. If nil, make an icon of the frame. If non-nil, delete the frame."
  152. :type 'boolean
  153. :group 'view)
  154. (defvar diary-face 'diary
  155. "Face name to use for diary entries.")
  156. (defface diary
  157. '((((class color) (background light))
  158. (:foreground "red"))
  159. (((class color) (background dark))
  160. (:foreground "yellow"))
  161. (t
  162. (:bold t)))
  163. "Face for highlighting diary entries."
  164. :group 'diary)
  165. ;; backward-compatibility alias
  166. (put 'diary-face 'face-alias 'diary)
  167. (defface calendar-today-face
  168. '((t (:underline t)))
  169. "Face for indicating today's date."
  170. :group 'diary)
  171. ;; backward-compatibility alias
  172. (defface holiday-face
  173. '((((class color) (background light))
  174. (:background "pink"))
  175. (((class color) (background dark))
  176. (:background "chocolate4"))
  177. (t
  178. (:inverse-video t)))
  179. "Face for indicating dates that have holidays."
  180. :group 'diary)
  181. ;; backward-compatibility alias
  182. (defcustom diary-entry-marker
  183. (if (not (display-color-p))
  184. "+"
  185. 'diary)
  186. "How to mark dates that have diary entries.
  187. The value can be either a single-character string or a face."
  188. :type '(choice string face)
  189. :group 'diary)
  190. (defcustom calendar-today-marker
  191. (if (not (display-color-p))
  192. "="
  193. 'calendar-today-face)
  194. "How to mark today's date in the calendar.
  195. The value can be either a single-character string or a face.
  196. Marking today's date is done only if you set up `today-visible-calendar-hook'
  197. to request that."
  198. :type '(choice string face)
  199. :group 'calendar)
  200. (defcustom calendar-holiday-marker
  201. (if (not (display-color-p))
  202. "*"
  203. 'holiday-face)
  204. "How to mark notable dates in the calendar.
  205. The value can be either a single-character string or a face."
  206. :type '(choice string face)
  207. :group 'calendar)
  208. ;;;###autoload
  209. (defcustom view-calendar-holidays-initially nil
  210. "Non-nil means display holidays for current three month period on entry.
  211. The holidays are displayed in another window when the calendar is first
  212. displayed."
  213. :type 'boolean
  214. :group 'holidays)
  215. ;;;###autoload
  216. (defcustom mark-holidays-in-calendar nil
  217. "Non-nil means mark dates of holidays in the calendar window.
  218. The marking symbol is specified by the variable `calendar-holiday-marker'."
  219. :type 'boolean
  220. :group 'holidays)
  221. ;;;###autoload
  222. (defcustom all-hebrew-calendar-holidays nil
  223. "If nil, show only major holidays from the Hebrew calendar.
  224. This means only those Jewish holidays that appear on secular calendars.
  225. If t, show all the holidays that would appear in a complete Hebrew calendar."
  226. :type 'boolean
  227. :group 'holidays)
  228. ;;;###autoload
  229. (defcustom all-christian-calendar-holidays nil
  230. "If nil, show only major holidays from the Christian calendar.
  231. This means only those Christian holidays that appear on secular calendars.
  232. If t, show all the holidays that would appear in a complete Christian
  233. calendar."
  234. :type 'boolean
  235. :group 'holidays)
  236. ;;;###autoload
  237. (defcustom all-islamic-calendar-holidays nil
  238. "If nil, show only major holidays from the Islamic calendar.
  239. This means only those Islamic holidays that appear on secular calendars.
  240. If t, show all the holidays that would appear in a complete Islamic
  241. calendar."
  242. :type 'boolean
  243. :group 'holidays)
  244. (defcustom diary-file-name-prefix-function (function (lambda (str) str))
  245. "The function that will take a diary file name and return the desired prefix."
  246. :type 'function
  247. :group 'diary)
  248. ;;;###autoload
  249. (defcustom all-bahai-calendar-holidays nil
  250. "If nil, show only major holidays from the Baha'i calendar.
  251. These are the days on which work and school must be suspended.
  252. If t, show all the holidays that would appear in a complete Baha'i
  253. calendar."
  254. :type 'boolean
  255. :group 'holidays)
  256. (defcustom calendar-mode-hook nil
  257. "Hook run when entering `calendar-mode'."
  258. :type 'hook
  259. :group 'calendar-hooks)
  260. ;;;###autoload
  261. (defcustom calendar-load-hook nil
  262. "List of functions to be called after the calendar is first loaded.
  263. This is the place to add key bindings to `calendar-mode-map'."
  264. :type 'hook
  265. :group 'calendar-hooks)
  266. ;;;###autoload
  267. (defcustom initial-calendar-window-hook nil
  268. "List of functions to be called when the calendar window is first opened.
  269. The functions invoked are called after the calendar window is opened, but
  270. once opened is never called again. Leaving the calendar with the `q' command
  271. and reentering it will cause these functions to be called again."
  272. :type 'hook
  273. :group 'calendar-hooks)
  274. ;;;###autoload
  275. (defcustom today-visible-calendar-hook nil
  276. "List of functions called whenever the current date is visible.
  277. This can be used, for example, to replace today's date with asterisks; a
  278. function `calendar-star-date' is included for this purpose:
  279. (setq today-visible-calendar-hook 'calendar-star-date)
  280. It can also be used to mark the current date with `calendar-today-marker';
  281. a function is also provided for this:
  282. (setq today-visible-calendar-hook 'calendar-mark-today)
  283. The corresponding variable `today-invisible-calendar-hook' is the list of
  284. functions called when the calendar function was called when the current
  285. date is not visible in the window.
  286. Other than the use of the provided functions, the changing of any
  287. characters in the calendar buffer by the hooks may cause the failure of the
  288. functions that move by days and weeks."
  289. :type 'hook
  290. :group 'calendar-hooks)
  291. ;;;###autoload
  292. (defcustom today-invisible-calendar-hook nil
  293. "List of functions called whenever the current date is not visible.
  294. The corresponding variable `today-visible-calendar-hook' is the list of
  295. functions called when the calendar function was called when the current
  296. date is visible in the window.
  297. Other than the use of the provided functions, the changing of any
  298. characters in the calendar buffer by the hooks may cause the failure of the
  299. functions that move by days and weeks."
  300. :type 'hook
  301. :group 'calendar-hooks)
  302. ;;;###autoload
  303. (defcustom calendar-move-hook nil
  304. "List of functions called whenever the cursor moves in the calendar.
  305. For example,
  306. (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1)))
  307. redisplays the diary for whatever date the cursor is moved to."
  308. :type 'hook
  309. :group 'calendar-hooks)
  310. ;;;###autoload
  311. (defcustom diary-file "~/diary"
  312. "Name of the file in which one's personal diary of dates is kept.
  313. The file's entries are lines beginning with any of the forms
  314. specified by the variable `american-date-diary-pattern', by default:
  315. MONTH/DAY
  316. MONTH/DAY/YEAR
  317. MONTHNAME DAY
  318. MONTHNAME DAY, YEAR
  319. DAYNAME
  320. with the remainder of the line being the diary entry string for
  321. that date. MONTH and DAY are one or two digit numbers, YEAR is a
  322. number and may be written in full or abbreviated to the final two
  323. digits (if `abbreviated-calendar-year' is non-nil). MONTHNAME
  324. and DAYNAME can be spelled in full (as specified by the variables
  325. `calendar-month-name-array' and `calendar-day-name-array'),
  326. abbreviated (as specified by `calendar-month-abbrev-array' and
  327. `calendar-day-abbrev-array') with or without a period,
  328. capitalized or not. Any of DAY, MONTH, or MONTHNAME, YEAR can be
  329. `*' which matches any day, month, or year, respectively. If the
  330. date does not contain a year, it is generic and applies to any
  331. year. A DAYNAME entry applies to the appropriate day of the week
  332. in every week.
  333. The European style (in which the day precedes the month) can be
  334. used instead, if you execute `european-calendar' when in the
  335. calendar, or set `european-calendar-style' to t in your .emacs
  336. file. The European forms (see `european-date-diary-pattern') are
  337. DAY/MONTH
  338. DAY/MONTH/YEAR
  339. DAY MONTHNAME
  340. DAY MONTHNAME YEAR
  341. DAYNAME
  342. To revert to the default American style from the European style, execute
  343. `american-calendar' in the calendar.
  344. A diary entry can be preceded by the character
  345. `diary-nonmarking-symbol' (ordinarily `&') to make that entry
  346. nonmarking--that is, it will not be marked on dates in the calendar
  347. window but will appear in a diary window.
  348. Multiline diary entries are made by indenting lines after the first with
  349. either a TAB or one or more spaces.
  350. Lines not in one the above formats are ignored. Here are some sample diary
  351. entries (in the default American style):
  352. 12/22/1988 Twentieth wedding anniversary!!
  353. &1/1. Happy New Year!
  354. 10/22 Ruth's birthday.
  355. 21: Payday
  356. Tuesday--weekly meeting with grad students at 10am
  357. Supowit, Shen, Bitner, and Kapoor to attend.
  358. 1/13/89 Friday the thirteenth!!
  359. &thu 4pm squash game with Lloyd.
  360. mar 16 Dad's birthday
  361. April 15, 1989 Income tax due.
  362. &* 15 time cards due.
  363. If the first line of a diary entry consists only of the date or day name with
  364. no trailing blanks or punctuation, then that line is not displayed in the
  365. diary window; only the continuation lines is shown. For example, the
  366. single diary entry
  367. 02/11/1989
  368. Bill Blattner visits Princeton today
  369. 2pm Cognitive Studies Committee meeting
  370. 2:30-5:30 Lizzie at Lawrenceville for `Group Initiative'
  371. 4:00pm Jamie Tappenden
  372. 7:30pm Dinner at George and Ed's for Alan Ryan
  373. 7:30-10:00pm dance at Stewart Country Day School
  374. will appear in the diary window without the date line at the beginning. This
  375. facility allows the diary window to look neater, but can cause confusion if
  376. used with more than one day's entries displayed.
  377. Diary entries can be based on Lisp sexps. For example, the diary entry
  378. %%(diary-block 11 1 1990 11 10 1990) Vacation
  379. causes the diary entry \"Vacation\" to appear from November 1 through
  380. November 10, 1990. Other functions available are `diary-float',
  381. `diary-anniversary', `diary-cyclic', `diary-day-of-year',
  382. `diary-iso-date', `diary-french-date', `diary-hebrew-date',
  383. `diary-islamic-date', `diary-bahai-date', `diary-mayan-date',
  384. `diary-chinese-date', `diary-coptic-date', `diary-ethiopic-date',
  385. `diary-persian-date', `diary-yahrzeit', `diary-sunrise-sunset',
  386. `diary-phases-of-moon', `diary-parasha', `diary-omer',
  387. `diary-rosh-hodesh', and `diary-sabbath-candles'. See the
  388. documentation for the function `list-sexp-diary-entries' for more
  389. details.
  390. Diary entries based on the Hebrew, the Islamic and/or the Baha'i
  391. calendar are also possible, but because these are somewhat slow, they
  392. are ignored unless you set the `nongregorian-diary-listing-hook' and
  393. the `nongregorian-diary-marking-hook' appropriately. See the
  394. documentation for these functions for details.
  395. Diary files can contain directives to include the contents of other files; for
  396. details, see the documentation for the variable `list-diary-entries-hook'."
  397. :type 'file
  398. :group 'diary)
  399. ;;;###autoload
  400. (defcustom diary-nonmarking-symbol "&"
  401. "Symbol indicating that a diary entry is not to be marked in the calendar."
  402. :type 'string
  403. :group 'diary)
  404. ;;;###autoload
  405. (defcustom hebrew-diary-entry-symbol "H"
  406. "Symbol indicating a diary entry according to the Hebrew calendar."
  407. :type 'string
  408. :group 'diary)
  409. ;;;###autoload
  410. (defcustom islamic-diary-entry-symbol "I"
  411. "Symbol indicating a diary entry according to the Islamic calendar."
  412. :type 'string
  413. :group 'diary)
  414. ;;;###autoload
  415. (defcustom bahai-diary-entry-symbol "B"
  416. "Symbol indicating a diary entry according to the Baha'i calendar."
  417. :type 'string
  418. :group 'diary)
  419. ;;;###autoload
  420. (defcustom diary-include-string "#include"
  421. "The string indicating inclusion of another file of diary entries.
  422. See the documentation for the function `include-other-diary-files'."
  423. :type 'string
  424. :group 'diary)
  425. (defcustom diary-glob-file-regexp-prefix "^\\#"
  426. "The regular expression that gets pre-pended to each of the attribute-regexp's for file-wide specifiers."
  427. :type 'regexp
  428. :group 'diary)
  429. (defcustom diary-face-attrs
  430. '((" *\\[foreground:\\([-a-z]+\\)\\]$" 1 :foreground string)
  431. (" *\\[background:\\([-a-z]+\\)\\]$" 1 :background string)
  432. (" *\\[width:\\([-a-z]+\\)\\]$" 1 :width symbol)
  433. (" *\\[height:\\([-0-9a-z]+\\)\\]$" 1 :height int)
  434. (" *\\[weight:\\([-a-z]+\\)\\]$" 1 :weight symbol)
  435. (" *\\[slant:\\([-a-z]+\\)\\]$" 1 :slant symbol)
  436. ;; XEmacs change, we don't support underline faces
  437. (" *\\[underline:\\([-a-z]+\\)\\]$" 1 :underline tnil)
  438. (" *\\[overline:\\([-a-z]+\\)\\]$" 1 :overline stringtnil)
  439. (" *\\[strike-through:\\([-a-z]+\\)\\]$" 1 :strike-through stringtnil)
  440. (" *\\[inverse-video:\\([-a-z]+\\)\\]$" 1 :inverse-video tnil)
  441. (" *\\[face:\\([-0-9a-z]+\\)\\]$" 1 :face string)
  442. (" *\\[font:\\([-a-z0-9]+\\)\\]$" 1 :font string)
  443. ;; Unsupported.
  444. ;;; (" *\\[box:\\([-a-z]+\\)\\]$" 1 :box)
  445. ;;; (" *\\[stipple:\\([-a-z]+\\)\\]$" 1 :stipple)
  446. )
  447. "A list of (regexp regnum attr attrtype) lists where the
  448. regexp says how to find the tag, the regnum says which
  449. parenthetical sub-regexp this regexp looks for, and the attr says
  450. which attribute of the face (or that this _is_ a face) is being
  451. modified."
  452. :type 'sexp
  453. :group 'diary)
  454. (defcustom diary-file-name-prefix nil
  455. "If non-nil each diary entry is prefixed with the name of the file where it is defined."
  456. :type 'boolean
  457. :group 'diary)
  458. ;;;###autoload
  459. (defcustom sexp-diary-entry-symbol "%%"
  460. "The string used to indicate a sexp diary entry in `diary-file'.
  461. See the documentation for the function `list-sexp-diary-entries'."
  462. :type 'string
  463. :group 'diary)
  464. ;;;###autoload
  465. (defcustom abbreviated-calendar-year t
  466. "Interpret a two-digit year DD in a diary entry as either 19DD or 20DD.
  467. For the Gregorian calendar; similarly for the Hebrew, Islamic and
  468. Baha'i calendars. If this variable is nil, years must be written in
  469. full."
  470. :type 'boolean
  471. :group 'diary)
  472. ;;;###autoload
  473. (defcustom european-calendar-style nil
  474. "Use the European style of dates in the diary and in any displays.
  475. If this variable is t, a date 1/2/1990 would be interpreted as February 1,
  476. 1990. The default European date styles (see `european-date-diary-pattern')
  477. are
  478. DAY/MONTH
  479. DAY/MONTH/YEAR
  480. DAY MONTHNAME
  481. DAY MONTHNAME YEAR
  482. DAYNAME
  483. Names can be capitalized or not, written in full (as specified by the
  484. variable `calendar-day-name-array'), or abbreviated (as specified by
  485. `calendar-day-abbrev-array') with or without a period.
  486. Setting this variable directly does not take effect (if the
  487. calendar package is already loaded). Rather, use either
  488. \\[customize] or the functions `european-calendar' and
  489. `american-calendar'."
  490. :type 'boolean
  491. ;; Without :initialize (require 'calendar) throws an error because
  492. ;; american-calendar is undefined at this point.
  493. :initialize 'custom-initialize-default
  494. :set (lambda (symbol value)
  495. (if value
  496. (european-calendar)
  497. (american-calendar)))
  498. :group 'diary)
  499. ;;;###autoload
  500. (defcustom american-date-diary-pattern
  501. '((month "/" day "[^/0-9]")
  502. (month "/" day "/" year "[^0-9]")
  503. (monthname " *" day "[^,0-9]")
  504. (monthname " *" day ", *" year "[^0-9]")
  505. (dayname "\\W"))
  506. "List of pseudo-patterns describing the American patterns of date used.
  507. See the documentation of `diary-date-forms' for an explanation."
  508. :type '(repeat (choice (cons :tag "Backup"
  509. :value (backup . nil)
  510. (const backup)
  511. (repeat (list :inline t :format "%v"
  512. (symbol :tag "Keyword")
  513. (choice symbol regexp))))
  514. (repeat (list :inline t :format "%v"
  515. (symbol :tag "Keyword")
  516. (choice symbol regexp)))))
  517. :group 'diary)
  518. ;;;###autoload
  519. (defcustom european-date-diary-pattern
  520. '((day "/" month "[^/0-9]")
  521. (day "/" month "/" year "[^0-9]")
  522. (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)")
  523. (day " *" monthname " *" year "[^0-9]")
  524. (dayname "\\W"))
  525. "List of pseudo-patterns describing the European patterns of date used.
  526. See the documentation of `diary-date-forms' for an explanation."
  527. :type '(repeat (choice (cons :tag "Backup"
  528. :value (backup . nil)
  529. (const backup)
  530. (repeat (list :inline t :format "%v"
  531. (symbol :tag "Keyword")
  532. (choice symbol regexp))))
  533. (repeat (list :inline t :format "%v"
  534. (symbol :tag "Keyword")
  535. (choice symbol regexp)))))
  536. :group 'diary)
  537. (defcustom diary-date-forms
  538. (if european-calendar-style
  539. european-date-diary-pattern
  540. american-date-diary-pattern)
  541. "List of pseudo-patterns describing the forms of date used in the diary.
  542. The patterns on the list must be MUTUALLY EXCLUSIVE and should not match
  543. any portion of the diary entry itself, just the date component.
  544. A pseudo-pattern is a list of regular expressions and the keywords `month',
  545. `day', `year', `monthname', and `dayname'. The keyword `monthname' will
  546. match the name of the month (see `calendar-month-name-array'), capitalized
  547. or not, or its user-specified abbreviation (see `calendar-month-abbrev-array'),
  548. followed by a period or not; it will also match `*'. Similarly, `dayname'
  549. will match the name of the day (see `calendar-day-name-array'), capitalized or
  550. not, or its user-specified abbreviation (see `calendar-day-abbrev-array'),
  551. followed by a period or not. The keywords `month', `day', and `year' will
  552. match those numerical values, preceded by arbitrarily many zeros; they will
  553. also match `*'.
  554. The matching of the diary entries with the date forms is done with the
  555. standard syntax table from Fundamental mode, but with the `*' changed so
  556. that it is a word constituent.
  557. If, to be mutually exclusive, a pseudo-pattern must match a portion of the
  558. diary entry itself, the first element of the pattern MUST be `backup'. This
  559. directive causes the date recognizer to back up to the beginning of the
  560. current word of the diary entry, so in no case can the pattern match more than
  561. a portion of the first word of the diary entry."
  562. :type '(repeat (choice (cons :tag "Backup"
  563. :value (backup . nil)
  564. (const backup)
  565. (repeat (list :inline t :format "%v"
  566. (symbol :tag "Keyword")
  567. (choice symbol regexp))))
  568. (repeat (list :inline t :format "%v"
  569. (symbol :tag "Keyword")
  570. (choice symbol regexp)))))
  571. :group 'diary)
  572. ;;;###autoload
  573. (defcustom european-calendar-display-form
  574. '((if dayname (concat dayname ", ")) day " " monthname " " year)
  575. "Pseudo-pattern governing the way a date appears in the European style.
  576. See the documentation of `calendar-date-display-form' for an explanation."
  577. :type 'sexp
  578. :group 'calendar)
  579. ;;;###autoload
  580. (defcustom american-calendar-display-form
  581. '((if dayname (concat dayname ", ")) monthname " " day ", " year)
  582. "Pseudo-pattern governing the way a date appears in the American style.
  583. See the documentation of `calendar-date-display-form' for an explanation."
  584. :type 'sexp
  585. :group 'calendar)
  586. (defcustom calendar-date-display-form
  587. (if european-calendar-style
  588. european-calendar-display-form
  589. american-calendar-display-form)
  590. "Pseudo-pattern governing the way a date appears.
  591. Used by the function `calendar-date-string', a pseudo-pattern is a list of
  592. expressions that can involve the keywords `month', `day', and `year', all
  593. numbers in string form, and `monthname' and `dayname', both alphabetic
  594. strings. For example, the ISO standard would use the pseudo- pattern
  595. '(year \"-\" month \"-\" day)
  596. while a typical American form would be
  597. '(month \"/\" day \"/\" (substring year -2))
  598. and
  599. '((format \"%9s, %9s %2s, %4s\" dayname monthname day year))
  600. would give the usual American style in fixed-length fields.
  601. See the documentation of the function `calendar-date-string'."
  602. :type 'sexp
  603. :group 'calendar)
  604. (defun european-calendar ()
  605. "Set the interpretation and display of dates to the European style."
  606. (interactive)
  607. (setq european-calendar-style t)
  608. (setq calendar-date-display-form european-calendar-display-form)
  609. (setq diary-date-forms european-date-diary-pattern)
  610. (update-calendar-mode-line))
  611. (defun american-calendar ()
  612. "Set the interpretation and display of dates to the American style."
  613. (interactive)
  614. (setq european-calendar-style nil)
  615. (setq calendar-date-display-form american-calendar-display-form)
  616. (setq diary-date-forms american-date-diary-pattern)
  617. (update-calendar-mode-line))
  618. ;;;###autoload
  619. (defcustom print-diary-entries-hook 'lpr-buffer
  620. "List of functions called after a temporary diary buffer is prepared.
  621. The buffer shows only the diary entries currently visible in the diary
  622. buffer. The default just does the printing. Other uses might include, for
  623. example, rearranging the lines into order by day and time, saving the buffer
  624. instead of deleting it, or changing the function used to do the printing."
  625. :type 'hook
  626. :group 'diary)
  627. ;;;###autoload
  628. (defcustom list-diary-entries-hook nil
  629. "List of functions called after diary file is culled for relevant entries.
  630. It is to be used for diary entries that are not found in the diary file.
  631. A function `include-other-diary-files' is provided for use as the value of
  632. this hook. This function enables you to use shared diary files together
  633. with your own. The files included are specified in the diary file by lines
  634. of the form
  635. #include \"filename\"
  636. This is recursive; that is, #include directives in files thus included are
  637. obeyed. You can change the \"#include\" to some other string by changing
  638. the variable `diary-include-string'. When you use `include-other-diary-files'
  639. as part of the list-diary-entries-hook, you will probably also want to use the
  640. function `mark-included-diary-files' as part of `mark-diary-entries-hook'.
  641. For example, you could use
  642. (setq list-diary-entries-hook
  643. '(include-other-diary-files sort-diary-entries))
  644. (setq diary-display-hook 'fancy-diary-display)
  645. in your `.emacs' file to cause the fancy diary buffer to be displayed with
  646. diary entries from various included files, each day's entries sorted into
  647. lexicographic order."
  648. :type 'hook
  649. :options '(include-other-diary-files sort-diary-entries)
  650. :group 'diary)
  651. ;;;###autoload
  652. (defcustom diary-hook nil
  653. "List of functions called after the display of the diary.
  654. Can be used for appointment notification."
  655. :type 'hook
  656. :group 'diary)
  657. (autoload 'diary-set-maybe-redraw "diary-lib")
  658. ;;;###autoload
  659. (defcustom diary-display-hook nil
  660. "List of functions that handle the display of the diary.
  661. If nil (the default), `simple-diary-display' is used. Use `ignore' for no
  662. diary display.
  663. Ordinarily, this just displays the diary buffer (with holidays indicated in
  664. the mode line), if there are any relevant entries. At the time these
  665. functions are called, the variable `diary-entries-list' is a list, in order
  666. by date, of all relevant diary entries in the form of ((MONTH DAY YEAR)
  667. STRING), where string is the diary entry for the given date. This can be
  668. used, for example, a different buffer for display (perhaps combined with
  669. holidays), or produce hard copy output.
  670. A function `fancy-diary-display' is provided as an alternative
  671. choice for this hook; this function prepares a special noneditable diary
  672. buffer with the relevant diary entries that has neat day-by-day arrangement
  673. with headings. The fancy diary buffer will show the holidays unless the
  674. variable `holidays-in-diary-buffer' is set to nil. Ordinarily, the fancy
  675. diary buffer will not show days for which there are no diary entries, even
  676. if that day is a holiday; if you want such days to be shown in the fancy
  677. diary buffer, set the variable `diary-list-include-blanks' to t."
  678. :type 'hook
  679. :options '(fancy-diary-display)
  680. :initialize 'custom-initialize-default
  681. :set 'diary-set-maybe-redraw
  682. :group 'diary)
  683. ;;;###autoload
  684. (defcustom nongregorian-diary-listing-hook nil
  685. "List of functions called for listing diary file and included files.
  686. As the files are processed for diary entries, these functions are used
  687. to cull relevant entries. You can use either or both of
  688. `list-hebrew-diary-entries', `list-islamic-diary-entries' and
  689. `list-bahai-diary-entries'. The documentation for these functions
  690. describes the style of such diary entries."
  691. :type 'hook
  692. :options '(list-hebrew-diary-entries
  693. list-islamic-diary-entries
  694. list-bahai-diary-entries)
  695. :group 'diary)
  696. ;;;###autoload
  697. (defcustom mark-diary-entries-hook nil
  698. "List of functions called after marking diary entries in the calendar.
  699. A function `mark-included-diary-files' is also provided for use as the
  700. `mark-diary-entries-hook'; it enables you to use shared diary files together
  701. with your own. The files included are specified in the diary file by lines
  702. of the form
  703. #include \"filename\"
  704. This is recursive; that is, #include directives in files thus included are
  705. obeyed. You can change the \"#include\" to some other string by changing the
  706. variable `diary-include-string'. When you use `mark-included-diary-files' as
  707. part of the mark-diary-entries-hook, you will probably also want to use the
  708. function `include-other-diary-files' as part of `list-diary-entries-hook'."
  709. :type 'hook
  710. :options '(mark-included-diary-files)
  711. :group 'diary)
  712. ;;;###autoload
  713. (defcustom nongregorian-diary-marking-hook nil
  714. "List of functions called for marking diary file and included files.
  715. As the files are processed for diary entries, these functions are used
  716. to cull relevant entries. You can use either or both of
  717. `mark-hebrew-diary-entries', `mark-islamic-diary-entries' and
  718. `mark-bahai-diary-entries'. The documentation for these functions
  719. describes the style of such diary entries."
  720. :type 'hook
  721. :options '(mark-hebrew-diary-entries
  722. mark-islamic-diary-entries
  723. mark-bahai-diary-entries)
  724. :group 'diary)
  725. ;;;###autoload
  726. (defcustom diary-list-include-blanks nil
  727. "If nil, do not include days with no diary entry in the list of diary entries.
  728. Such days will then not be shown in the fancy diary buffer, even if they
  729. are holidays."
  730. :type 'boolean
  731. :group 'diary)
  732. ;;;###autoload
  733. (defcustom holidays-in-diary-buffer t
  734. "Non-nil means include holidays in the diary display.
  735. The holidays appear in the mode line of the diary buffer, or in the
  736. fancy diary buffer next to the date. This slows down the diary functions
  737. somewhat; setting it to nil makes the diary display faster."
  738. :type 'boolean
  739. :group 'holidays)
  740. (defvar calendar-mark-ring nil)
  741. ;;;###autoload
  742. (put 'general-holidays 'risky-local-variable t)
  743. ;;;###autoload
  744. (defcustom general-holidays
  745. '((holiday-fixed 1 1 "New Year's Day")
  746. (holiday-float 1 1 3 "Martin Luther King Day")
  747. (holiday-fixed 2 2 "Groundhog Day")
  748. (holiday-fixed 2 14 "Valentine's Day")
  749. (holiday-float 2 1 3 "President's Day")
  750. (holiday-fixed 3 17 "St. Patrick's Day")
  751. (holiday-fixed 4 1 "April Fools' Day")
  752. (holiday-float 5 0 2 "Mother's Day")
  753. (holiday-float 5 1 -1 "Memorial Day")
  754. (holiday-fixed 6 14 "Flag Day")
  755. (holiday-float 6 0 3 "Father's Day")
  756. (holiday-fixed 7 4 "Independence Day")
  757. (holiday-float 9 1 1 "Labor Day")
  758. (holiday-float 10 1 2 "Columbus Day")
  759. (holiday-fixed 10 31 "Halloween")
  760. (holiday-fixed 11 11 "Veteran's Day")
  761. (holiday-float 11 4 4 "Thanksgiving"))
  762. "General holidays. Default value is for the United States.
  763. See the documentation for `calendar-holidays' for details."
  764. :type 'sexp
  765. :group 'holidays)
  766. ;;;###autoload
  767. (put 'oriental-holidays 'risky-local-variable t)
  768. ;;;###autoload
  769. (defcustom oriental-holidays
  770. '((if (fboundp 'atan)
  771. (holiday-chinese-new-year)))
  772. "Oriental holidays.
  773. See the documentation for `calendar-holidays' for details."
  774. :type 'sexp
  775. :group 'holidays)
  776. ;;;###autoload
  777. (put 'local-holidays 'risky-local-variable t)
  778. ;;;###autoload
  779. (defcustom local-holidays nil
  780. "Local holidays.
  781. See the documentation for `calendar-holidays' for details."
  782. :type 'sexp
  783. :group 'local
  784. :group 'holidays)
  785. ;;;###autoload
  786. (put 'other-holidays 'risky-local-variable t)
  787. ;;;###autoload
  788. (defcustom other-holidays nil
  789. "User defined holidays.
  790. See the documentation for `calendar-holidays' for details."
  791. :type 'sexp
  792. :group 'holidays)
  793. ;;;###autoload
  794. (put 'hebrew-holidays-1 'risky-local-variable t)
  795. ;;;###autoload
  796. (defvar hebrew-holidays-1
  797. '((holiday-rosh-hashanah-etc)
  798. (if all-hebrew-calendar-holidays
  799. (holiday-julian
  800. 11
  801. (let* ((m displayed-month)
  802. (y displayed-year)
  803. (year))
  804. (increment-calendar-month m y -1)
  805. (let ((year (extract-calendar-year
  806. (calendar-julian-from-absolute
  807. (calendar-absolute-from-gregorian
  808. (list m 1 y))))))
  809. (if (zerop (% (1+ year) 4))
  810. 22
  811. 21))) "\"Tal Umatar\" (evening)"))))
  812. ;;;###autoload
  813. (put 'hebrew-holidays-2 'risky-local-variable t)
  814. ;;;###autoload
  815. (defvar hebrew-holidays-2
  816. '((if all-hebrew-calendar-holidays
  817. (holiday-hanukkah)
  818. (holiday-hebrew 9 25 "Hanukkah"))
  819. (if all-hebrew-calendar-holidays
  820. (holiday-hebrew
  821. 10
  822. (let ((h-year (extract-calendar-year
  823. (calendar-hebrew-from-absolute
  824. (calendar-absolute-from-gregorian
  825. (list displayed-month 28 displayed-year))))))
  826. (if (= (% (calendar-absolute-from-hebrew (list 10 10 h-year))
  827. 7)
  828. 6)
  829. 11 10))
  830. "Tzom Teveth"))
  831. (if all-hebrew-calendar-holidays
  832. (holiday-hebrew 11 15 "Tu B'Shevat"))))
  833. ;;;###autoload
  834. (put 'hebrew-holidays-3 'risky-local-variable t)
  835. ;;;###autoload
  836. (defvar hebrew-holidays-3
  837. '((if all-hebrew-calendar-holidays
  838. (holiday-hebrew
  839. 11
  840. (let ((m displayed-month)
  841. (y displayed-year))
  842. (increment-calendar-month m y 1)
  843. (let* ((h-year (extract-calendar-year
  844. (calendar-hebrew-from-absolute
  845. (calendar-absolute-from-gregorian
  846. (list m
  847. (calendar-last-day-of-month m y)
  848. y)))))
  849. (s-s
  850. (calendar-hebrew-from-absolute
  851. (if (=
  852. (% (calendar-absolute-from-hebrew
  853. (list 7 1 h-year))
  854. 7)
  855. 6)
  856. (calendar-dayname-on-or-before
  857. 6 (calendar-absolute-from-hebrew
  858. (list 11 17 h-year)))
  859. (calendar-dayname-on-or-before
  860. 6 (calendar-absolute-from-hebrew
  861. (list 11 16 h-year))))))
  862. (day (extract-calendar-day s-s)))
  863. day))
  864. "Shabbat Shirah"))))
  865. ;;;###autoload
  866. (put 'hebrew-holidays-4 'risky-local-variable t)
  867. ;;;###autoload
  868. (defvar hebrew-holidays-4
  869. '((holiday-passover-etc)
  870. (if (and all-hebrew-calendar-holidays
  871. (let* ((m displayed-month)
  872. (y displayed-year)
  873. (year))
  874. (increment-calendar-month m y -1)
  875. (let ((year (extract-calendar-year
  876. (calendar-julian-from-absolute
  877. (calendar-absolute-from-gregorian
  878. (list m 1 y))))))
  879. (= 21 (% year 28)))))
  880. (holiday-julian 3 26 "Kiddush HaHamah"))
  881. (if all-hebrew-calendar-holidays
  882. (holiday-tisha-b-av-etc))))
  883. ;;;###autoload
  884. (put 'hebrew-holidays 'risky-local-variable t)
  885. ;;;###autoload
  886. (defcustom hebrew-holidays (append hebrew-holidays-1 hebrew-holidays-2
  887. hebrew-holidays-3 hebrew-holidays-4)
  888. "Jewish holidays.
  889. See the documentation for `calendar-holidays' for details."
  890. :type 'sexp
  891. :group 'holidays)
  892. ;;;###autoload
  893. (put 'christian-holidays 'risky-local-variable t)
  894. ;;;###autoload
  895. (defcustom christian-holidays
  896. '((if all-christian-calendar-holidays
  897. (holiday-fixed 1 6 "Epiphany"))
  898. (holiday-easter-etc 0 "Easter Sunday")
  899. (holiday-easter-etc -2 "Good Friday")
  900. (holiday-easter-etc -46 "Ash Wednesday")
  901. (if all-christian-calendar-holidays
  902. (holiday-easter-etc -63 "Septuagesima Sunday"))
  903. (if all-christian-calendar-holidays
  904. (holiday-easter-etc -56 "Sexagesima Sunday"))
  905. (if all-christian-calendar-holidays
  906. (holiday-easter-etc -49 "Shrove Sunday"))
  907. (if all-christian-calendar-holidays
  908. (holiday-easter-etc -48 "Shrove Monday"))
  909. (if all-christian-calendar-holidays
  910. (holiday-easter-etc -47 "Shrove Tuesday"))
  911. (if all-christian-calendar-holidays
  912. (holiday-easter-etc -14 "Passion Sunday"))
  913. (if all-christian-calendar-holidays
  914. (holiday-easter-etc -7 "Palm Sunday"))
  915. (if all-christian-calendar-holidays
  916. (holiday-easter-etc -3 "Maundy Thursday"))
  917. (if all-christian-calendar-holidays
  918. (holiday-easter-etc 35 "Rogation Sunday"))
  919. (if all-christian-calendar-holidays
  920. (holiday-easter-etc 39 "Ascension Day"))
  921. (if all-christian-calendar-holidays
  922. (holiday-easter-etc 49 "Pentecost (Whitsunday)"))
  923. (if all-christian-calendar-holidays
  924. (holiday-easter-etc 50 "Whitmonday"))
  925. (if all-christian-calendar-holidays
  926. (holiday-easter-etc 56 "Trinity Sunday"))
  927. (if all-christian-calendar-holidays
  928. (holiday-easter-etc 60 "Corpus Christi"))
  929. (if all-christian-calendar-holidays
  930. (holiday-greek-orthodox-easter))
  931. (if all-christian-calendar-holidays
  932. (holiday-fixed 8 15 "Assumption"))
  933. (if all-christian-calendar-holidays
  934. (holiday-advent 0 "Advent"))
  935. (holiday-fixed 12 25 "Christmas")
  936. (if all-christian-calendar-holidays
  937. (holiday-julian 12 25 "Eastern Orthodox Christmas")))
  938. "Christian holidays.
  939. See the documentation for `calendar-holidays' for details."
  940. :type 'sexp
  941. :group 'holidays)
  942. ;;;###autoload
  943. (put 'islamic-holidays 'risky-local-variable t)
  944. ;;;###autoload
  945. (defcustom islamic-holidays
  946. '((holiday-islamic
  947. 1 1
  948. (format "Islamic New Year %d"
  949. (let ((m displayed-month)
  950. (y displayed-year))
  951. (increment-calendar-month m y 1)
  952. (extract-calendar-year
  953. (calendar-islamic-from-absolute
  954. (calendar-absolute-from-gregorian
  955. (list
  956. m (calendar-last-day-of-month m y) y)))))))
  957. (if all-islamic-calendar-holidays
  958. (holiday-islamic 1 10 "Ashura"))
  959. (if all-islamic-calendar-holidays
  960. (holiday-islamic 3 12 "Mulad-al-Nabi"))
  961. (if all-islamic-calendar-holidays
  962. (holiday-islamic 7 26 "Shab-e-Mi'raj"))
  963. (if all-islamic-calendar-holidays
  964. (holiday-islamic 8 15 "Shab-e-Bara't"))
  965. (holiday-islamic 9 1 "Ramadan Begins")
  966. (if all-islamic-calendar-holidays
  967. (holiday-islamic 9 27 "Shab-e Qadr"))
  968. (if all-islamic-calendar-holidays
  969. (holiday-islamic 10 1 "Id-al-Fitr"))
  970. (if all-islamic-calendar-holidays
  971. (holiday-islamic 12 10 "Id-al-Adha")))
  972. "Islamic holidays.
  973. See the documentation for `calendar-holidays' for details."
  974. :type 'sexp
  975. :group 'holidays)
  976. ;;;###autoload
  977. (put 'bahai-holidays 'risky-local-variable t)
  978. ;;;###autoload
  979. (defcustom bahai-holidays
  980. '((holiday-fixed
  981. 3 21
  982. (format "Baha'i New Year (Naw-Ruz) %d" (- displayed-year (1- 1844))))
  983. (holiday-fixed 4 21 "First Day of Ridvan")
  984. (if all-bahai-calendar-holidays
  985. (holiday-fixed 4 22 "Second Day of Ridvan"))
  986. (if all-bahai-calendar-holidays
  987. (holiday-fixed 4 23 "Third Day of Ridvan"))
  988. (if all-bahai-calendar-holidays
  989. (holiday-fixed 4 24 "Fourth Day of Ridvan"))
  990. (if all-bahai-calendar-holidays
  991. (holiday-fixed 4 25 "Fifth Day of Ridvan"))
  992. (if all-bahai-calendar-holidays
  993. (holiday-fixed 4 26 "Sixth Day of Ridvan"))
  994. (if all-bahai-calendar-holidays
  995. (holiday-fixed 4 27 "Seventh Day of Ridvan"))
  996. (if all-bahai-calendar-holidays
  997. (holiday-fixed 4 28 "Eighth Day of Ridvan"))
  998. (holiday-fixed 4 29 "Ninth Day of Ridvan")
  999. (if all-bahai-calendar-holidays
  1000. (holiday-fixed 4 30 "Tenth Day of Ridvan"))
  1001. (if all-bahai-calendar-holidays
  1002. (holiday-fixed 5 1 "Eleventh Day of Ridvan"))
  1003. (holiday-fixed 5 2 "Twelfth Day of Ridvan")
  1004. (holiday-fixed 5 23 "Declaration of the Bab")
  1005. (holiday-fixed 5 29 "Ascension of Baha'u'llah")
  1006. (holiday-fixed 7 9 "Martyrdom of the Bab")
  1007. (holiday-fixed 10 20 "Birth of the Bab")
  1008. (holiday-fixed 11 12 "Birth of Baha'u'llah")
  1009. (if all-bahai-calendar-holidays
  1010. (holiday-fixed 11 26 "Day of the Covenant"))
  1011. (if all-bahai-calendar-holidays
  1012. (holiday-fixed 11 28 "Ascension of `Abdu'l-Baha")))
  1013. "Baha'i holidays.
  1014. See the documentation for `calendar-holidays' for details."
  1015. :type 'sexp
  1016. :group 'holidays)
  1017. ;;;###autoload
  1018. (put 'solar-holidays 'risky-local-variable t)
  1019. ;;;###autoload
  1020. (defcustom solar-holidays
  1021. '((if (fboundp 'atan)
  1022. (solar-equinoxes-solstices))
  1023. (if (progn
  1024. (require 'cal-dst)
  1025. t)
  1026. (funcall
  1027. 'holiday-sexp
  1028. calendar-daylight-savings-starts
  1029. '(format "Daylight Saving Time Begins %s"
  1030. (if (fboundp 'atan)
  1031. (solar-time-string
  1032. (/ calendar-daylight-savings-starts-time (float 60))
  1033. calendar-standard-time-zone-name)
  1034. ""))))
  1035. (funcall
  1036. 'holiday-sexp
  1037. calendar-daylight-savings-ends
  1038. '(format "Daylight Saving Time Ends %s"
  1039. (if (fboundp 'atan)
  1040. (solar-time-string
  1041. (/ calendar-daylight-savings-ends-time (float 60))
  1042. calendar-daylight-time-zone-name)
  1043. ""))))
  1044. "Sun-related holidays.
  1045. See the documentation for `calendar-holidays' for details."
  1046. :type 'sexp
  1047. :group 'holidays)
  1048. ;;;###autoload
  1049. (put 'calendar-holidays 'risky-local-variable t)
  1050. (defcustom calendar-holidays
  1051. (append general-holidays local-holidays other-holidays
  1052. christian-holidays hebrew-holidays islamic-holidays
  1053. bahai-holidays oriental-holidays solar-holidays)
  1054. "List of notable days for the command \\[holidays].
  1055. Additional holidays are easy to add to the list, just put them in the
  1056. list `other-holidays' in your .emacs file. Similarly, by setting any
  1057. of `general-holidays', `local-holidays' `christian-holidays',
  1058. `hebrew-holidays', `islamic-holidays', `bahai-holidays',
  1059. `oriental-holidays', or `solar-holidays' to nil in your .emacs file,
  1060. you can eliminate unwanted categories of holidays.
  1061. The aforementioned variables control the holiday choices offered
  1062. by the function `list-holidays' when it is called interactively.
  1063. They also initialize the default value of `calendar-holidays',
  1064. which is the default list of holidays used by the function
  1065. `list-holidays' in the non-interactive case. Note that these
  1066. variables have no effect on `calendar-holidays' after it has been
  1067. set (e.g. after the calendar is loaded). In that case, customize
  1068. `calendar-holidays' directly.
  1069. The intention is that (in the US) `local-holidays' be set in
  1070. site-init.el and `other-holidays' be set by the user.
  1071. Entries on the list are expressions that return (possibly empty) lists of
  1072. items of the form ((month day year) string) of a holiday in the in the
  1073. three-month period centered around `displayed-month' of `displayed-year'.
  1074. Several basic functions are provided for this purpose:
  1075. (holiday-fixed MONTH DAY STRING) is a fixed date on the Gregorian calendar
  1076. (holiday-float MONTH DAYNAME K STRING &optional day) is the Kth DAYNAME in
  1077. MONTH on the Gregorian calendar (0 for Sunday,
  1078. etc.); K<0 means count back from the end of the
  1079. month. An optional parameter DAY means the Kth
  1080. DAYNAME after/before MONTH DAY.
  1081. (holiday-hebrew MONTH DAY STRING) a fixed date on the Hebrew calendar
  1082. (holiday-islamic MONTH DAY STRING) a fixed date on the Islamic calendar
  1083. (holiday-bahai MONTH DAY STRING) a fixed date on the Baha'i calendar
  1084. (holiday-julian MONTH DAY STRING) a fixed date on the Julian calendar
  1085. (holiday-sexp SEXP STRING) SEXP is a Gregorian-date-valued expression
  1086. in the variable `year'; if it evaluates to
  1087. a visible date, that's the holiday; if it
  1088. evaluates to nil, there's no holiday. STRING
  1089. is an expression in the variable `date'.
  1090. For example, to add Bastille Day, celebrated in France on July 14, add
  1091. (holiday-fixed 7 14 \"Bastille Day\")
  1092. to the list. To add Hurricane Supplication Day, celebrated in the Virgin
  1093. Islands on the fourth Monday in August, add
  1094. (holiday-float 8 1 4 \"Hurricane Supplication Day\")
  1095. to the list (the last Monday would be specified with `-1' instead of `4').
  1096. To add the last day of Hanukkah to the list, use
  1097. (holiday-hebrew 10 2 \"Last day of Hanukkah\")
  1098. since the Hebrew months are numbered with 1 starting from Nisan, while to
  1099. add the Islamic feast celebrating Mohammed's birthday use
  1100. (holiday-islamic 3 12 \"Mohammed's Birthday\")
  1101. since the Islamic months are numbered from 1 starting with Muharram. To
  1102. add an entry for the Baha'i festival of Ridvan, use
  1103. (holiday-bahai 2 13 \"Festival of Ridvan\")
  1104. since the Baha'i months are numbered from 1 starting with Baha. To
  1105. add Thomas Jefferson's birthday, April 2, 1743 (Julian), use
  1106. (holiday-julian 4 2 \"Jefferson's Birthday\")
  1107. To include a holiday conditionally, use the sexp form or a conditional. For
  1108. example, to include American presidential elections, which occur on the first
  1109. Tuesday after the first Monday in November of years divisible by 4, add
  1110. (holiday-sexp
  1111. '(if (zerop (% year 4))
  1112. (calendar-gregorian-from-absolute
  1113. (1+ (calendar-dayname-on-or-before
  1114. 1 (+ 6 (calendar-absolute-from-gregorian
  1115. (list 11 1 year)))))))
  1116. \"US Presidential Election\")
  1117. or
  1118. (if (zerop (% displayed-year 4))
  1119. (holiday-fixed 11
  1120. (extract-calendar-day
  1121. (calendar-gregorian-from-absolute
  1122. (1+ (calendar-dayname-on-or-before
  1123. 1 (+ 6 (calendar-absolute-from-gregorian
  1124. (list 11 1 displayed-year)))))))
  1125. \"US Presidential Election\"))
  1126. to the list. To include the phases of the moon, add
  1127. (lunar-phases)
  1128. to the holiday list, where `lunar-phases' is an Emacs-Lisp function that
  1129. you've written to return a (possibly empty) list of the relevant VISIBLE dates
  1130. with descriptive strings such as
  1131. (((2 6 1989) \"New Moo…

Large files files are truncated, but you can click here to view the full file