• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/calendar/

Lines Matching +defs:calendar +defs:day +defs:abbrev +defs:array

0 ;;; calendar.el --- calendar functions
8 ;; Keywords: calendar
9 ;; Human-Keywords: calendar, Gregorian calendar, diary, holidays
30 ;; This collection of functions implements a calendar window. It
31 ;; generates a calendar for the current month, together with the
33 ;; The calendar can be scrolled forward and backward in the window to
39 ;; notable days can be marked on the calendar, if desired. The user
43 ;; notable days can be viewed independently of the calendar. Dates
44 ;; can be translated from the (usual) Gregorian calendar to the day of
45 ;; the year/days remaining in year, to the ISO commercial calendar, to
46 ;; the Julian (old style) calendar, to the Hebrew calendar, to the
47 ;; Islamic calendar, to the Baha'i calendar, to the French
48 ;; Revolutionary calendar, to the Mayan calendar, to the Chinese
49 ;; calendar, to the Coptic calendar, to the Ethiopic calendar, and to
50 ;; the astronomical (Julian) day number. When floating point is
55 ;; The following files are part of the calendar/diary code:
58 ;; cal-china.el Chinese calendar
61 ;; cal-hebrew.el Hebrew calendar
62 ;; cal-islam.el Islamic calendar
63 ;; cal-bahai.el Baha'i calendar
64 ;; cal-iso.el ISO calendar
68 ;; cal-move.el Movement in the calendar
69 ;; cal-persia.el Persian calendar
97 (defvar calendar-month-name-array)
98 (defvar calendar-starred-day)
100 (defun calendar-version ()
104 (defgroup calendar nil
110 :group 'calendar)
114 :group 'calendar)
117 "Holidays support in calendar."
118 :group 'calendar
119 :prefix "calendar-"
122 (defgroup chinese-calendar nil
123 "Chinese calendar support."
124 :group 'calendar)
126 (defgroup calendar-tex nil
127 "Options for printing calendar with LaTeX."
129 :group 'calendar)
131 (defgroup calendar-hooks nil
133 :prefix "calendar-"
134 :group 'calendar)
137 (defconst calendar-buffer "*Calendar*"
138 "Name of the buffer used for the calendar.")
141 (defcustom calendar-offset 0
142 "The offset of the principal month from the center of the calendar window.
147 :group 'calendar)
151 "Non-nil means display current date's diary entries on entry to calendar.
152 The diary is displayed in another window when the calendar is first displayed,
155 be overridden by the value of `calendar-setup'."
160 (defcustom mark-diary-entries-in-calendar nil
161 "Non-nil means mark dates with diary entries, in the calendar window.
167 (defcustom calendar-remove-frame-by-deleting nil
168 "Determine how the calendar mode removes a frame no longer needed.
191 (defface calendar-today
196 (put 'calendar-today-face 'face-alias 'calendar-today)
219 (defcustom calendar-today-marker
222 'calendar-today)
223 "How to mark today's date in the calendar.
225 Marking today's date is done only if you set up `today-visible-calendar-hook'
228 :group 'calendar)
230 (defcustom calendar-holiday-marker
234 "How to mark notable dates in the calendar.
237 :group 'calendar)
240 (defcustom view-calendar-holidays-initially nil
242 The holidays are displayed in another window when the calendar is first
248 (defcustom mark-holidays-in-calendar nil
249 "Non-nil means mark dates of holidays in the calendar window.
250 The marking symbol is specified by the variable `calendar-holiday-marker'."
255 (defcustom all-hebrew-calendar-holidays nil
256 "If nil, show only major holidays from the Hebrew calendar.
259 If t, show all the holidays that would appear in a complete Hebrew calendar."
264 (defcustom all-christian-calendar-holidays nil
265 "If nil, show only major holidays from the Christian calendar.
269 calendar."
274 (defcustom all-islamic-calendar-holidays nil
275 "If nil, show only major holidays from the Islamic calendar.
279 calendar."
289 (defcustom all-bahai-calendar-holidays nil
290 "If nil, show only major holidays from the Baha'i calendar.
294 calendar."
298 (defcustom calendar-mode-hook nil
299 "Hook run when entering `calendar-mode'."
301 :group 'calendar-hooks)
304 (defcustom calendar-load-hook nil
305 "List of functions to be called after the calendar is first loaded.
306 This is the place to add key bindings to `calendar-mode-map'."
308 :group 'calendar-hooks)
311 (defcustom initial-calendar-window-hook nil
312 "List of functions to be called when the calendar window is first opened.
313 The functions invoked are called after the calendar window is opened, but
314 once opened is never called again. Leaving the calendar with the `q' command
317 :group 'calendar-hooks)
320 (defcustom today-visible-calendar-hook nil
323 function `calendar-star-date' is included for this purpose:
324 (setq today-visible-calendar-hook 'calendar-star-date)
325 It can also be used to mark the current date with `calendar-today-marker';
327 (setq today-visible-calendar-hook 'calendar-mark-today)
329 The corresponding variable `today-invisible-calendar-hook' is the list of
330 functions called when the calendar function was called when the current
334 characters in the calendar buffer by the hooks may cause the failure of the
337 :group 'calendar-hooks)
340 (defcustom today-invisible-calendar-hook nil
343 The corresponding variable `today-visible-calendar-hook' is the list of
344 functions called when the calendar function was called when the current
348 characters in the calendar buffer by the hooks may cause the failure of the
351 :group 'calendar-hooks)
354 (defcustom calendar-move-hook nil
355 "List of functions called whenever the cursor moves in the calendar.
359 (add-hook 'calendar-move-hook (lambda () (diary-view-entries 1)))
363 :group 'calendar-hooks)
381 digits (if `abbreviated-calendar-year' is non-nil). MONTHNAME
383 `calendar-month-name-array' and `calendar-day-name-array'),
384 abbreviated (as specified by `calendar-month-abbrev-array' and
385 `calendar-day-abbrev-array') with or without a period,
387 `*' which matches any day, month, or year, respectively. If the
389 year. A DAYNAME entry applies to the appropriate day of the week
392 The European style (in which the day precedes the month) can be
393 used instead, if you execute `european-calendar' when in the
394 calendar, or set `european-calendar-style' to t in your .emacs
404 `american-calendar' in the calendar.
408 nonmarking--that is, it will not be marked on dates in the calendar
429 If the first line of a diary entry consists only of the date or day name with
444 used with more than one day's entries displayed.
452 `diary-anniversary', `diary-cyclic', `diary-day-of-year',
463 calendar are also possible, but because these are somewhat slow, they
475 "Symbol indicating that a diary entry is not to be marked in the calendar."
481 "Symbol indicating a diary entry according to the Hebrew calendar."
487 "Symbol indicating a diary entry according to the Islamic calendar."
493 "Symbol indicating a diary entry according to the Baha'i calendar."
547 (defcustom abbreviated-calendar-year t
549 For the Gregorian calendar; similarly for the Hebrew, Islamic and
556 (defcustom european-calendar-style nil
569 variable `calendar-day-name-array'), or abbreviated (as specified by
570 `calendar-day-abbrev-array') with or without a period.
573 calendar package is already loaded). Rather, use either
574 \\[customize] or the functions `european-calendar' and
575 `american-calendar'."
577 ;; Without :initialize (require 'calendar) throws an error because
578 ;; american-calendar is undefined at this point.
582 (european-calendar)
583 (american-calendar)))
588 '((month "/" day "[^/0-9]")
589 (month "/" day "/" year "[^0-9]")
590 (monthname " *" day "[^,0-9]")
591 (monthname " *" day ", *" year "[^0-9]")
608 '((day "/" month "[^/0-9]")
609 (day "/" month "/" year "[^0-9]")
610 (backup day " *" monthname "\\W+\\<\\([^*0-9]\\|\\([0-9]+[:aApP]\\)\\)")
611 (day " *" monthname " *" year "[^0-9]")
631 (if european-calendar-style
639 `day', `year', `monthname', and `dayname'. The keyword `monthname' will
640 match the name of the month (see `calendar-month-name-array'), capitalized
641 or not, or its user-specified abbreviation (see `calendar-month-abbrev-array'),
643 will match the name of the day (see `calendar-day-name-array'), capitalized or
644 not, or its user-specified abbreviation (see `calendar-day-abbrev-array'),
645 followed by a period or not. The keywords `month', `day', and `year' will
679 (defcustom european-calendar-display-form
680 '((if dayname (concat dayname ", ")) day " " monthname " " year)
682 See the documentation of `calendar-date-display-form' for an explanation."
684 :group 'calendar)
687 (defcustom american-calendar-display-form
688 '((if dayname (concat dayname ", ")) monthname " " day ", " year)
690 See the documentation of `calendar-date-display-form' for an explanation."
692 :group 'calendar)
694 (defcustom calendar-date-display-form
695 (if european-calendar-style
696 european-calendar-display-form
697 american-calendar-display-form)
700 Used by the function `calendar-date-string', a pseudo-pattern is a list of
701 expressions that can involve the keywords `month', `day', and `year', all
705 '(year \"-\" month \"-\" day)
709 '(month \"/\" day \"/\" (substring year -2))
713 '((format \"%9s, %9s %2s, %4s\" dayname monthname day year))
717 See the documentation of the function `calendar-date-string'."
719 :group 'calendar)
721 (defun european-calendar ()
724 (setq european-calendar-style t)
725 (setq calendar-date-display-form european-calendar-display-form)
727 (update-calendar-mode-line))
729 (defun american-calendar ()
732 (setq european-calendar-style nil)
733 (setq calendar-date-display-form american-calendar-display-form)
735 (update-calendar-mode-line))
742 example, rearranging the lines into order by day and time, saving the buffer
772 diary entries from various included files, each day's entries sorted into
803 buffer with the relevant diary entries that has neat day-by-day arrangement
807 if that day is a holiday; if you want such days to be shown in the fancy
831 "List of functions called after marking diary entries in the calendar.
878 (defvar calendar-mark-ring nil)
902 See the documentation for `calendar-holidays' for details."
913 See the documentation for `calendar-holidays' for details."
922 See the documentation for `calendar-holidays' for details."
931 See the documentation for `calendar-holidays' for details."
940 (if all-hebrew-calendar-holidays
946 (increment-calendar-month m y -1)
947 (let ((year (extract-calendar-year
948 (calendar-julian-from-absolute
949 (calendar-absolute-from-gregorian
959 '((if all-hebrew-calendar-holidays
962 (if all-hebrew-calendar-holidays
965 (let ((h-year (extract-calendar-year
966 (calendar-hebrew-from-absolute
967 (calendar-absolute-from-gregorian
969 (if (= (% (calendar-absolute-from-hebrew (list 10 10 h-year))
974 (if all-hebrew-calendar-holidays
981 '((if all-hebrew-calendar-holidays
986 (increment-calendar-month m y 1)
987 (let* ((h-year (extract-calendar-year
988 (calendar-hebrew-from-absolute
989 (calendar-absolute-from-gregorian
991 (calendar-last-day-of-month m y)
994 (calendar-hebrew-from-absolute
996 (% (calendar-absolute-from-hebrew
1000 (calendar-dayname-on-or-before
1001 6 (calendar-absolute-from-hebrew
1003 (calendar-dayname-on-or-before
1004 6 (calendar-absolute-from-hebrew
1006 (day (extract-calendar-day s-s)))
1007 day))
1015 (if (and all-hebrew-calendar-holidays
1019 (increment-calendar-month m y -1)
1020 (let ((year (extract-calendar-year
1021 (calendar-julian-from-absolute
1022 (calendar-absolute-from-gregorian
1026 (if all-hebrew-calendar-holidays
1035 See the documentation for `calendar-holidays' for details."
1043 '((if all-christian-calendar-holidays
1048 (if all-christian-calendar-holidays
1050 (if all-christian-calendar-holidays
1052 (if all-christian-calendar-holidays
1054 (if all-christian-calendar-holidays
1056 (if all-christian-calendar-holidays
1058 (if all-christian-calendar-holidays
1060 (if all-christian-calendar-holidays
1062 (if all-christian-calendar-holidays
1064 (if all-christian-calendar-holidays
1066 (if all-christian-calendar-holidays
1068 (if all-christian-calendar-holidays
1070 (if all-christian-calendar-holidays
1072 (if all-christian-calendar-holidays
1074 (if all-christian-calendar-holidays
1076 (if all-christian-calendar-holidays
1078 (if all-christian-calendar-holidays
1080 (if all-christian-calendar-holidays
1083 (if all-christian-calendar-holidays
1086 See the documentation for `calendar-holidays' for details."
1099 (increment-calendar-month m y 1)
1100 (extract-calendar-year
1101 (calendar-islamic-from-absolute
1102 (calendar-absolute-from-gregorian
1104 m (calendar-last-day-of-month m y) y)))))))
1105 (if all-islamic-calendar-holidays
1107 (if all-islamic-calendar-holidays
1109 (if all-islamic-calendar-holidays
1111 (if all-islamic-calendar-holidays
1114 (if all-islamic-calendar-holidays
1116 (if all-islamic-calendar-holidays
1118 (if all-islamic-calendar-holidays
1121 See the documentation for `calendar-holidays' for details."
1133 (if all-bahai-calendar-holidays
1135 (if all-bahai-calendar-holidays
1137 (if all-bahai-calendar-holidays
1139 (if all-bahai-calendar-holidays
1141 (if all-bahai-calendar-holidays
1143 (if all-bahai-calendar-holidays
1145 (if all-bahai-calendar-holidays
1148 (if all-bahai-calendar-holidays
1150 (if all-bahai-calendar-holidays
1158 (if all-bahai-calendar-holidays
1160 (if all-bahai-calendar-holidays
1163 See the documentation for `calendar-holidays' for details."
1178 calendar-daylight-savings-starts
1182 (/ calendar-daylight-savings-starts-time (float 60))
1183 calendar-standard-time-zone-name)
1187 calendar-daylight-savings-ends
1191 (/ calendar-daylight-savings-ends-time (float 60))
1192 calendar-daylight-time-zone-name)
1195 See the documentation for `calendar-holidays' for details."
1200 (put 'calendar-holidays 'risky-local-variable t)
1201 (defcustom calendar-holidays
1217 They also initialize the default value of `calendar-holidays',
1220 variables have no effect on `calendar-holidays' after it has been
1221 set (e.g. after the calendar is loaded). In that case, customize
1222 `calendar-holidays' directly.
1228 items of the form ((month day year) string) of a holiday in the in the
1232 (holiday-fixed MONTH DAY STRING) is a fixed date on the Gregorian calendar
1233 (holiday-float MONTH DAYNAME K STRING &optional day) is the Kth DAYNAME in
1234 MONTH on the Gregorian calendar (0 for Sunday,
1238 (holiday-hebrew MONTH DAY STRING) a fixed date on the Hebrew calendar
1239 (holiday-islamic MONTH DAY STRING) a fixed date on the Islamic calendar
1240 (holiday-bahai MONTH DAY STRING) a fixed date on the Baha'i calendar
1241 (holiday-julian MONTH DAY STRING) a fixed date on the Julian calendar
1258 To add the last day of Hanukkah to the list, use
1260 (holiday-hebrew 10 2 \"Last day of Hanukkah\")
1283 (calendar-gregorian-from-absolute
1284 (1+ (calendar-dayname-on-or-before
1285 1 (+ 6 (calendar-absolute-from-gregorian
1293 (extract-calendar-day
1294 (calendar-gregorian-from-absolute
1295 (1+ (calendar-dayname-on-or-before
1296 1 (+ 6 (calendar-absolute-from-gregorian
1324 (defmacro increment-calendar-month (mon yr n)
1336 (defun calendar-increment-month (n &optional mon yr)
1342 (increment-calendar-month mon yr n)
1345 (defmacro calendar-for-loop (var from init to final do &rest body)
1352 (defmacro calendar-sum (index initial condition expression)
1364 ;; the numbers of calls to calendar/diary/holiday functions in preparing the
1368 ;; 1934 extract-calendar-month
1369 ;; 1852 extract-calendar-year
1370 ;; 1819 extract-calendar-day
1371 ;; 845 calendar-leap-year-p
1372 ;; 837 calendar-day-number
1373 ;; 775 calendar-absolute-from-gregorian
1374 ;; 346 calendar-last-day-of-month
1375 ;; 286 hebrew-calendar-last-day-of-month
1376 ;; 188 hebrew-calendar-leap-year-p
1377 ;; 180 hebrew-calendar-elapsed-days
1378 ;; 163 hebrew-calendar-last-month-of-year
1379 ;; 66 calendar-date-compare
1380 ;; 65 hebrew-calendar-days-in-year
1381 ;; 60 calendar-absolute-from-julian
1382 ;; 50 calendar-absolute-from-hebrew
1383 ;; 43 calendar-date-equal
1384 ;; 38 calendar-gregorian-from-absolute
1392 (defsubst extract-calendar-month (date)
1393 "Extract the month part of DATE which has the form (month day year)."
1396 ;; Note gives wrong answer for result of (calendar-read-date 'noday).
1397 (defsubst extract-calendar-day (date)
1398 "Extract the day part of DATE which has the form (month day year)."
1401 (defsubst extract-calendar-year (date)
1402 "Extract the year part of DATE which has the form (month day year)."
1405 (defsubst calendar-leap-year-p (year)
1416 ;;(defsubst calendar-leap-year-p (year)
1423 (defsubst calendar-last-day-of-month (month year)
1424 "The last day in MONTH during YEAR."
1425 (if (and (= month 2) (calendar-leap-year-p year))
1432 (defsubst calendar-day-number (date)
1433 "Return the day number within the year of the date DATE.
1434 For example, (calendar-day-number '(1 1 1987)) returns the value 1,
1435 while (calendar-day-number '(12 31 1980)) returns 366."
1436 (let* ((month (extract-calendar-month date))
1437 (day (extract-calendar-day date))
1438 (year (extract-calendar-year date))
1439 (day-of-year (+ day (* 31 (1- month)))))
1442 (setq day-of-year (- day-of-year (/ (+ 23 (* 4 month)) 10)))
1443 (if (calendar-leap-year-p year)
1444 (setq day-of-year (1+ day-of-year)))))
1445 day-of-year))
1447 (defsubst calendar-absolute-from-gregorian (date)
1450 DATE is a list of the form (month day year). A negative year is
1453 (let ((year (extract-calendar-year date))
1459 (+ (calendar-day-number date) ; Days this year
1467 (- (calendar-day-number date)
1472 (calendar-day-number '(12 31 -1))))))) ; days in year 1 BC
1474 (autoload 'calendar-goto-today "cal-move"
1475 "Reposition the calendar window so the current date is visible."
1478 (autoload 'calendar-forward-month "cal-move"
1482 (autoload 'calendar-forward-year "cal-move"
1486 (autoload 'calendar-backward-month "cal-move"
1490 (autoload 'calendar-backward-year "cal-move"
1494 (autoload 'scroll-calendar-left "cal-move"
1495 "Scroll the displayed calendar left by ARG months."
1498 (autoload 'scroll-calendar-right "cal-move"
1499 "Scroll the displayed calendar window right by ARG months."
1502 (autoload 'scroll-calendar-left-three-months "cal-move"
1503 "Scroll the displayed calendar window left by 3*ARG months."
1506 (autoload 'scroll-calendar-right-three-months "cal-move"
1507 "Scroll the displayed calendar window right by 3*ARG months."
1510 (autoload 'calendar-cursor-to-nearest-date "cal-move"
1514 (autoload 'calendar-forward-day "cal-move"
1518 (autoload 'calendar-backward-day "cal-move"
1522 (autoload 'calendar-forward-week "cal-move"
1526 (autoload 'calendar-backward-week "cal-move"
1530 (autoload 'calendar-beginning-of-week "cal-move"
1531 "Move the cursor back ARG calendar-week-start-day's."
1534 (autoload 'calendar-end-of-week "cal-move"
1535 "Move the cursor forward ARG calendar-week-start-day+6's."
1538 (autoload 'calendar-beginning-of-month "cal-move"
1542 (autoload 'calendar-end-of-month "cal-move"
1546 (autoload 'calendar-beginning-of-year "cal-move"
1550 (autoload 'calendar-end-of-year "cal-move"
1554 (autoload 'calendar-cursor-to-visible-date "cal-move"
1558 (autoload 'calendar-goto-date "cal-move"
1562 (autoload 'calendar-goto-day-of-year "cal-move"
1563 "Move cursor to day of year."
1566 (autoload 'calendar-only-one-frame-setup "cal-x"
1567 "Start calendar and display it in a dedicated frame.")
1569 (autoload 'calendar-one-frame-setup "cal-x"
1570 "Start calendar and display it in a dedicated frame together with the diary.")
1572 (autoload 'calendar-two-frame-setup "cal-x"
1573 "Start calendar and diary in separate, dedicated frames.")
1576 (defcustom calendar-setup nil
1577 "The frame setup of the calendar.
1578 The choices are: `one-frame' (calendar and diary together in one separate,
1579 dedicated frame); `two-frames' (calendar and diary in separate, dedicated
1580 frames); `calendar-only' (calendar in a separate, dedicated frame); with
1584 (const :tag "calendar and diary in separate frame" one-frame)
1585 (const :tag "calendar and diary each in own frame" two-frames)
1586 (const :tag "calendar in separate frame" calendar-only)
1588 :group 'calendar)
1590 (defcustom calendar-minimum-window-height 8
1591 "Minimum height `generate-calendar-window' should use for calendar window."
1594 :group 'calendar)
1597 (defun calendar (&optional arg)
1598 "Choose between the one frame, two frame, or basic calendar displays.
1601 The original function `calendar' has been renamed `calendar-basic-setup'.
1604 (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
1605 ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
1606 ((equal calendar-setup 'calendar-only)
1607 (calendar-only-one-frame-setup arg))
1608 (t (calendar-basic-setup arg))))
1614 calendar."
1617 (autoload 'list-calendar-holidays "holidays"
1618 "Create a buffer containing the holidays for the current calendar window.
1619 The holidays are those in the list `calendar-notable-days'. Returns t if any
1623 (defun calendar-basic-setup (&optional arg)
1624 "Display a three-month calendar in another window.
1634 displayed upon initial display of the calendar.
1636 Once in the calendar window, future or past months can be moved into view.
1637 Arbitrary months can be displayed, or the calendar can be scrolled forward
1640 The cursor can be moved forward or backward by one day, one week, one month,
1646 Diary entries can be marked on the calendar or displayed in another window.
1648 Use \\[describe-mode] for details of the key bindings in the calendar window.
1650 The Gregorian calendar is assumed.
1652 After loading the calendar, the hooks given by the variable
1653 `calendar-load-hook' are run. This is the place to add key bindings to the
1654 calendar-mode-map.
1656 After preparing the calendar window initially, the hooks given by the variable
1657 `initial-calendar-window-hook' are run.
1659 The hooks given by the variable `today-visible-calendar-hook' are run
1660 every time the calendar window gets scrolled, if the current date is visible
1662 `today-invisible-calendar-hook' are run. Thus, for example, setting
1663 `today-visible-calendar-hook' to 'calendar-star-date will cause today's date
1666 (set-buffer (get-buffer-create calendar-buffer))
1667 (calendar-mode)
1671 (calendar-read-date t)
1672 (calendar-current-date)))
1673 (month (extract-calendar-month date))
1674 (year (extract-calendar-year date)))
1675 ;; (calendar-read-date t) returns a date with day = nil, which is
1678 (pop-to-buffer calendar-buffer)
1679 (increment-calendar-month month year (- calendar-offset))
1680 (generate-calendar-window month year)
1681 (if (and view-diary-entries-initially (calendar-date-is-visible-p date))
1686 (if view-calendar-holidays-initially
1687 (list-calendar-holidays)))
1688 (run-hooks 'initial-calendar-window-hook))
1693 by the cursor position in the displayed three-month calendar.
1697 (autoload 'calendar-sunrise-sunset "solar"
1701 (autoload 'calendar-phases-of-moon "lunar"
1702 "Create a buffer of the phases of the moon for the current calendar window."
1705 (autoload 'calendar-print-french-date "cal-french"
1706 "Show the French Revolutionary calendar equivalent of the date under the cursor."
1709 (autoload 'calendar-goto-french-date "cal-french"
1713 (autoload 'calendar-french-date-string "cal-french"
1716 (autoload 'calendar-mayan-date-string "cal-mayan"
1719 (autoload 'calendar-print-mayan-date "cal-mayan"
1723 (autoload 'calendar-goto-mayan-long-count-date "cal-mayan"
1727 (autoload 'calendar-next-haab-date "cal-mayan"
1731 (autoload 'calendar-previous-haab-date "cal-mayan"
1735 (autoload 'calendar-next-tzolkin-date "cal-mayan"
1739 (autoload 'calendar-previous-tzolkin-date "cal-mayan"
1743 (autoload 'calendar-next-calendar-round-date "cal-mayan"
1747 (autoload 'calendar-previous-calendar-round-date "cal-mayan"
1751 (autoload 'calendar-goto-chinese-date "cal-china"
1755 (autoload 'calendar-print-chinese-date "cal-china"
1759 (autoload 'calendar-chinese-date-string "cal-china"
1762 (autoload 'calendar-absolute-from-astro "cal-julian"
1763 "Absolute date of astronomical (Julian) day number D."
1766 (autoload 'calendar-astro-from-absolute "cal-julian"
1767 "Astronomical (Julian) day number of absolute date D.")
1769 (autoload 'calendar-astro-date-string "cal-julian"
1770 "String of astronomical (Julian) day number of Gregorian date.")
1772 (autoload 'calendar-goto-astro-day-number "cal-julian"
1773 "Move cursor to astronomical (Julian) day number."
1776 (autoload 'calendar-print-astro-day-number "cal-julian"
1780 (autoload 'calendar-julian-from-absolute "cal-julian"
1781 "Compute the Julian (month day year) corresponding to the absolute DATE.
1785 (autoload 'calendar-goto-julian-date "cal-julian"
1789 (autoload 'calendar-print-julian-date "cal-julian"
1790 "Show the Julian calendar equivalent of the date under the cursor."
1793 (autoload 'calendar-julian-date-string "cal-julian"
1796 Driven by the variable `calendar-date-display-form'.")
1798 (autoload 'calendar-goto-iso-date "cal-iso"
1802 (autoload 'calendar-goto-iso-week "cal-iso"
1806 (autoload 'calendar-print-iso-date "cal-iso"
1810 (autoload 'calendar-iso-date-string "cal-iso"
1813 (autoload 'calendar-goto-islamic-date "cal-islam"
1817 (autoload 'calendar-print-islamic-date "cal-islam"
1821 (autoload 'calendar-islamic-date-string "cal-islam"
1824 (autoload 'calendar-print-bahai-date "cal-bahai"
1828 (autoload 'calendar-bahai-date-string "cal-bahai"
1831 (autoload 'calendar-goto-hebrew-date "cal-hebrew"
1835 (autoload 'calendar-print-hebrew-date "cal-hebrew"
1839 (autoload 'calendar-hebrew-date-string "cal-hebrew"
1842 (autoload 'calendar-goto-coptic-date "cal-coptic"
1846 (autoload 'calendar-print-coptic-date "cal-coptic"
1850 (autoload 'calendar-coptic-date-string "cal-coptic"
1853 (autoload 'calendar-goto-ethiopic-date "cal-coptic"
1857 (autoload 'calendar-print-ethiopic-date "cal-coptic"
1861 (autoload 'calendar-ethiopic-date-string "cal-coptic"
1864 (autoload 'calendar-goto-persian-date "cal-persia"
1868 (autoload 'calendar-print-persian-date "cal-persia"
1872 (autoload 'calendar-persian-date-string "cal-persia"
1883 "Mark days in the calendar window that have diary entries.
1884 Each entry in diary file visible in the calendar window is marked."
1895 "Insert a weekly diary entry for the day of the week indicated by point."
1900 "Insert a monthly diary entry for the day of the month indicated by point."
1904 "Insert an annual diary entry for the day of the year indicated by point."
1925 "Insert a monthly diary entry for the day of the Hebrew month corresponding
1930 "Insert an annual diary entry for the day of the Hebrew year corresponding
1940 "Insert a monthly diary entry for the day of the Islamic month corresponding
1945 "Insert an annual diary entry for the day of the Islamic year corresponding
1955 "Insert a monthly diary entry for the day of the Baha'i month corresponding
1960 "Insert an annual diary entry for the day of the Baha'i year corresponding
1973 (autoload 'cal-tex-cursor-day "cal-tex"
1974 "Make a buffer with LaTeX commands for the day cursor is on." t)
1977 "Make a buffer with LaTeX commands for a two-page one-week calendar.
1983 "Make a buffer with LaTeX commands for a two-page one-week calendar.
1989 "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar.
1995 "Make a buffer with LaTeX commands for a two-page one-week calendar.
2001 "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor.
2007 "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
2014 "Day-per-page Filofax style calendar for week indicated by cursor.
2020 "Make a buffer with LaTeX commands for a year's calendar.
2024 "Make a buffer with LaTeX commands for a year's calendar (landscape).
2028 "Make a buffer with LaTeX commands for a year's calendar (Filofax).
2032 "Write an HTML calendar file for numeric MONTH of four-digit YEAR.
2034 MONTH and YEAR are taken from the calendar cursor position. Note
2038 "Write HTML calendar files (index and monthly pages) for four-digit YEAR.
2040 YEAR is taken from the calendar cursor position. Note that any
2043 (autoload 'mark-calendar-holidays "holidays"
2044 "Mark notable days in the calendar window."
2047 (autoload 'calendar-cursor-holidays "holidays"
2048 "Find holidays for the date specified by the cursor in the calendar window."
2051 (defun generate-calendar-window (&optional mon yr)
2052 "Generate the calendar window for the current date.
2055 (today (calendar-current-date))
2056 (month (extract-calendar-month today))
2057 (day (extract-calendar-day today))
2058 (year (extract-calendar-year today))
2061 (let ((offset (calendar-interval mon yr month year)))
2063 (day-in-week (calendar-day-of-week today))
2064 (in-calendar-window (eq (window-buffer (selected-window))
2065 (get-buffer calendar-buffer))))
2066 (update-calendar-mode-line)
2068 (generate-calendar mon yr)
2069 (generate-calendar month year))
2070 (calendar-cursor-to-visible-date
2074 ;; window displaying the calendar
2075 (when in-calendar-window
2080 ;; Adjust the window to exactly fit the displayed calendar
2081 (fit-window-to-buffer nil nil calendar-minimum-window-height))
2086 (and mark-holidays-in-calendar
2087 ;;; (calendar-date-is-legal-p today) ; useful for BC dates
2088 (mark-calendar-holidays)
2089 (and in-calendar-window (sit-for 0)))
2091 (if mark-diary-entries-in-calendar (mark-diary-entries))
2093 (run-hooks 'today-visible-calendar-hook)
2094 (run-hooks 'today-invisible-calendar-hook)))))
2096 (defun generate-calendar (month year)
2097 "Generate a three-month Gregorian calendar centered around MONTH, YEAR."
2100 ;;; stands, almost all other calendar functions (eg holidays) would
2107 (increment-calendar-month month year -1)
2108 (calendar-for-loop i from 0 to 2 do
2109 (generate-calendar-month month year (+ 5 (* 25 i)))
2110 (increment-calendar-month month year 1)))
2112 (defun generate-calendar-month (month year indent)
2113 "Produce a calendar for MONTH, YEAR on the Gregorian calendar.
2114 The calendar is inserted at the top of the buffer in which point is currently
2120 (- (calendar-day-of-week (list month 1 year))
2121 calendar-week-start-day)
2123 (last (calendar-last-day-of-month month year)))
2125 (calendar-insert-indented
2126 (calendar-string-spread
2127 (list (format "%s %d" (calendar-month-name month) year)) ? 20)
2129 (calendar-insert-indented "" indent);; Go to proper spot
2130 ;; Use the first two characters of each day to head the columns.
2131 (calendar-for-loop i from 0 to 6 do
2134 (calendar-day-name (mod (+ calendar-week-start-day i) 7) nil t)))
2139 (calendar-insert-indented "" 0 t);; Force onto following line
2140 (calendar-insert-indented "" indent);; Go to proper spot
2142 (calendar-for-loop i from 1 to blank-days do (insert " "))
2144 (calendar-for-loop i from 1 to last do
2152 (calendar-insert-indented "" 0 t) ;; Force onto following line
2153 (calendar-insert-indented "" indent)))));; Go to proper spot
2155 (defun calendar-insert-indented (string indent &optional newline)
2175 (defun redraw-calendar ()
2176 "Redraw the calendar display, if `calendar-buffer' is live."
2178 (if (get-buffer calendar-buffer)
2179 (with-current-buffer calendar-buffer
2180 (let ((cursor-date (calendar-cursor-to-nearest-date)))
2181 (generate-calendar-window displayed-month displayed-year)
2182 (calendar-cursor-to-visible-date cursor-date)))))
2185 (defcustom calendar-week-start-day 0
2186 "The day of the week on which a week in the calendar begins.
2190 after starting `calendar', you should call `redraw-calendar' to
2191 update the calendar display to reflect the change, otherwise
2194 ;; Change the initialize so that if you reload calendar.el, it will not
2196 ;; calendar.elc" because of the "byte-compile-dynamic").
2200 (redraw-calendar))
2201 :group 'calendar)
2203 (defcustom calendar-debug-sexp nil
2206 :group 'calendar)
2208 (defvar calendar-mode-map nil)
2209 (if calendar-mode-map
2217 (define-key map (vector 'remap c) 'calendar-not-implemented))
2218 (define-key map "<" 'scroll-calendar-right)
2219 (define-key map "\C-x<" 'scroll-calendar-right)
2220 (define-key map [prior] 'scroll-calendar-right-three-months)
2221 (define-key map "\ev" 'scroll-calendar-right-three-months)
2222 (define-key map ">" 'scroll-calendar-left)
2223 (define-key map "\C-x>" 'scroll-calendar-left)
2224 (define-key map [next] 'scroll-calendar-left-three-months)
2225 (define-key map "\C-v" 'scroll-calendar-left-three-months)
2226 (define-key map "\C-b" 'calendar-backward-day)
2227 (define-key map "\C-p" 'calendar-backward-week)
2228 (define-key map "\e{" 'calendar-backward-month)
2229 (define-key map "\C-x[" 'calendar-backward-year)
2230 (define-key map "\C-f" 'calendar-forward-day)
2231 (define-key map "\C-n" 'calendar-forward-week)
2232 (define-key map [left] 'calendar-backward-day)
2233 (define-key map [up] 'calendar-backward-week)
2234 (define-key map [right] 'calendar-forward-day)
2235 (define-key map [down] 'calendar-forward-week)
2236 (define-key map "\e}" 'calendar-forward-month)
2237 (define-key map "\C-x]" 'calendar-forward-year)
2238 (define-key map "\C-a" 'calendar-beginning-of-week)
2239 (define-key map "\C-e" 'calendar-end-of-week)
2240 (define-key map "\ea" 'calendar-beginning-of-month)
2241 (define-key map "\ee" 'calendar-end-of-month)
2242 (define-key map "\e<" 'calendar-beginning-of-year)
2243 (define-key map "\e>" 'calendar-end-of-year)
2244 (define-key map "\C-@" 'calendar-set-mark)
2246 (define-key map [?\C- ] 'calendar-set-mark)
2247 (define-key map "\C-x\C-x" 'calendar-exchange-point-and-mark)
2248 (define-key map "\e=" 'calendar-count-days-region)
2249 (define-key map "gd" 'calendar-goto-date)
2250 (define-key map "gD" 'calendar-goto-day-of-year)
2251 (define-key map "gj" 'calendar-goto-julian-date)
2252 (define-key map "ga" 'calendar-goto-astro-day-number)
2253 (define-key map "gh" 'calendar-goto-hebrew-date)
2254 (define-key map "gi" 'calendar-goto-islamic-date)
2255 (define-key map "gb" 'calendar-goto-bahai-date)
2256 (define-key map "gC" 'calendar-goto-chinese-date)
2257 (define-key map "gk" 'calendar-goto-coptic-date)
2258 (define-key map "ge" 'calendar-goto-ethiopic-date)
2259 (define-key map "gp" 'calendar-goto-persian-date)
2260 (define-key map "gc" 'calendar-goto-iso-date)
2261 (define-key map "gw" 'calendar-goto-iso-week)
2262 (define-key map "gf" 'calendar-goto-french-date)
2263 (define-key map "gml" 'calendar-goto-mayan-long-count-date)
2264 (define-key map "gmpc" 'calendar-previous-calendar-round-date)
2265 (define-key map "gmnc" 'calendar-next-calendar-round-date)
2266 (define-key map "gmph" 'calendar-previous-haab-date)
2267 (define-key map "gmnh" 'calendar-next-haab-date)
2268 (define-key map "gmpt" 'calendar-previous-tzolkin-date)
2269 (define-key map "gmnt" 'calendar-next-tzolkin-date)
2272 (define-key map "S" 'calendar-sunrise-sunset)
2273 (define-key map "M" 'calendar-phases-of-moon)
2276 (define-key map "\C-c\C-l" 'redraw-calendar)
2277 (define-key map "." 'calendar-goto-today)
2278 (define-key map "o" 'calendar-other-month)
2279 (define-key map "q" 'exit-calendar)
2280 (define-key map "a" 'list-calendar-holidays)
2281 (define-key map "h" 'calendar-cursor-holidays)
2282 (define-key map "x" 'mark-calendar-holidays)
2283 (define-key map "u" 'calendar-unmark)
2288 (define-key map "pd" 'calendar-print-day-of-year)
2289 (define-key map "pC" 'calendar-print-chinese-date)
2290 (define-key map "pk" 'calendar-print-coptic-date)
2291 (define-key map "pe" 'calendar-print-ethiopic-date)
2292 (define-key map "pp" 'calendar-print-persian-date)
2293 (define-key map "pc" 'calendar-print-iso-date)
2294 (define-key map "pj" 'calendar-print-julian-date)
2295 (define-key map "pa" 'calendar-print-astro-day-number)
2296 (define-key map "ph" 'calendar-print-hebrew-date)
2297 (define-key map "pi" 'calendar-print-islamic-date)
2298 (define-key map "pb" 'calendar-print-bahai-date)
2299 (define-key map "pf" 'calendar-print-french-date)
2300 (define-key map "pm" 'calendar-print-mayan-date)
2301 (define-key map "po" 'calendar-print-other-dates)
2318 (define-key map "?" 'calendar-goto-info-node)
2323 (define-key map "td" 'cal-tex-cursor-day)
2334 (setq calendar-mode-map map)
2335 ;; Require cal-menu after initializing calendar-mode-map because it uses it.
2338 (defun describe-calendar-mode ()
2339 "Create a help buffer with a brief description of the `calendar-mode'."
2341 (help-setup-xref (list #'describe-calendar-mode) (interactive-p))
2347 "\\<calendar-mode-map>\\[describe-mode] from within the calendar")
2348 (substitute-command-keys "\\{calendar-mode-map}")))
2352 (put 'calendar-mode 'mode-class 'special)
2354 (defvar calendar-mode-line-format
2360 'mouse-scroll-calendar-right))
2365 "\\<calendar-mode-map>\\[calendar-goto-info-node] info")
2368 'keymap (make-mode-line-mouse-map 'mouse-1 'calendar-goto-info-node))
2372 " \\<calendar-mode-map>\\[calendar-other-month] other")
2376 'mouse-1 'mouse-calendar-other-month))
2380 "\\<calendar-mode-map>\\[calendar-goto-today] today")
2383 'keymap (make-mode-line-mouse-map 'mouse-1 #'calendar-goto-today)))
2384 '(calendar-date-string (calendar-current-date) t)
2389 'mouse-1 'mouse-scroll-calendar-left)))
2390 "The mode line of the calendar buffer.
2396 value that has the Hebrew date, the day number/days remaining in the year,
2397 and the ISO week/year numbers in the mode. When calendar-move-hook is set to
2398 'update-calendar-mode-line, these mode line shows these values for the date
2403 '(calendar-hebrew-date-string date)
2404 '(let* ((year (extract-calendar-year date))
2405 (d (calendar-day-number date))
2407 (- (calendar-day-number (list 12 31 year)) d)))
2409 '(let* ((d (calendar-absolute-from-gregorian date))
2410 (iso-date (calendar-iso-from-absolute d)))
2412 (extract-calendar-month iso-date)
2413 (extract-calendar-year iso-date)))
2417 (defun mouse-scroll-calendar-left (event)
2418 "Scroll the displayed calendar left by one month.
2420 with respect to the calendar as well as possible."
2424 (scroll-calendar-left 1)))
2426 (defun mouse-scroll-calendar-right (event)
2427 "Scroll the displayed calendar right by one month.
2429 with respect to the calendar as well as possible."
2433 (scroll-calendar-right 1)))
2435 (defun mouse-calendar-other-month (event)
2436 "Display a three-month calendar centered around a specified month and year."
2440 (call-interactively 'calendar-other-month)))
2442 (defun calendar-goto-info-node ()
2443 "Go to the info node for the calendar."
2447 (Info-find-emacs-command-nodes 'calendar))))
2449 (error "Couldn't find documentation for the calendar")
2456 (defun calendar-mode ()
2457 "A major mode for the calendar window.
2460 \\<calendar-mode-map>\\[calendar-goto-info-node] from within the calendar.
2462 \\<calendar-mode-map>\\{calendar-mode-map}"
2464 (setq major-mode 'calendar-mode)
2466 (use-local-map calendar-mode-map)
2469 (update-calendar-mode-line)
2471 (make-local-variable 'calendar-mark-ring)
2475 '(calendar-font-lock-keywords t))
2476 (run-mode-hooks 'calendar-mode-hook))
2478 (defun calendar-string-spread (strings char length)
2503 (defun update-calendar-mode-line ()
2504 "Update the calendar mode line with the current date and date style."
2505 (if (bufferp (get-buffer calendar-buffer))
2506 (with-current-buffer calendar-buffer
2508 (calendar-string-spread
2510 (calendar-cursor-to-nearest-date)
2511 (error (calendar-current-date)))))
2512 (mapcar 'eval calendar-mode-line-format))
2516 (defun calendar-window-list ()
2517 "List of all calendar-related windows."
2518 (let ((calendar-buffers (calendar-buffer-list))
2521 (if (memq (window-buffer w) calendar-buffers)
2526 (defun calendar-buffer-list ()
2527 "List of all calendar-related buffers."
2530 fancy-diary-buffer diary-buffer calendar-buffer
2540 (defun exit-calendar ()
2541 "Get out of the calendar window and hide it and related buffers."
2547 "Diary modified; do you really want to exit the calendar? "))
2549 ;; calendar-related buffers with other calendar-related buffers
2551 (mapcar 'calendar-hide-window (calendar-window-list)))
2552 (calendar-window-list)))))
2554 (defun calendar-hide-window (window)
2555 "Hide WINDOW if it is calendar-related."
2557 (if (memq buffer (calendar-buffer-list))
2565 (if calendar-remove-frame-by-deleting
2573 (defun calendar-current-date ()
2574 "Return the current date in a list (month day year)."
2578 (defun calendar-cursor-to-date (&optional error)
2579 "Return a list (month day year) of current cursor position.
2602 (list month calendar-starred-day year)
2607 ;; The following version of calendar-gregorian-from-absolute is preferred for
2610 ;;(defun calendar-gregorian-from-absolute (date)
2611 ;; "Compute the list (month day year) corresponding to the absolute DATE.
2617 ;; (calendar-sum y approx
2618 ;; (>= date (calendar-absolute-from-gregorian (list 1 1 (1+ y))))
2621 ;; (1+ (calendar-sum m 1
2623 ;; (calendar-absolute-from-gregorian
2624 ;; (list m (calendar-last-day-of-month m year) year)))
2626 ;; (day ;; Calculate the day by subtraction.
2628 ;; (1- (calendar-absolute-from-gregorian (list month 1 year))))))
2629 ;; (list month day year)))
2631 (defun calendar-gregorian-from-absolute (date)
2632 "Compute the list (month day year) corresponding to the absolute DATE.
2648 (day (1+ (% d3 365)))
2654 (while (let ((mdays (calendar-last-day-of-month month year)))
2655 (and (< mdays day)
2656 (setq day (- day mdays))))
2658 (list month day year)))))
2660 (defun calendar-other-month (month year)
2661 "Display a three-month calendar centered around MONTH and YEAR."
2662 (interactive (calendar-read-date 'noday))
2666 (let ((old-date (calendar-cursor-to-date))
2667 (today (calendar-current-date)))
2668 (generate-calendar-window month year)
2669 (calendar-cursor-to-visible-date
2671 ((calendar-date-is-visible-p old-date) old-date)
2672 ((calendar-date-is-visible-p today) today)
2675 (defun calendar-set-mark (arg)
2680 (let ((date (calendar-cursor-to-date t)))
2683 (push date calendar-mark-ring)
2685 ;; calendar, the mark ring in the calendar is one longer than
2687 (if (> (length calendar-mark-ring) (1+ mark-ring-max))
2688 (setcdr (nthcdr mark-ring-max calendar-mark-ring) nil))
2690 (if (null calendar-mark-ring)
2692 (calendar-goto-date (car calendar-mark-ring))
2693 (setq calendar-mark-ring
2694 (cdr (nconc calendar-mark-ring (list date))))))))
2696 (defun calendar-exchange-point-and-mark ()
2699 (let ((mark (car calendar-mark-ring))
2700 (date (calendar-cursor-to-date t)))
2703 (setq calendar-mark-ring (cons date (cdr calendar-mark-ring)))
2704 (calendar-goto-date mark))))
2706 (defun calendar-count-days-region ()
2709 (let* ((days (- (calendar-absolute-from-gregorian
2710 (calendar-cursor-to-date t))
2711 (calendar-absolute-from-gregorian
2712 (or (car calendar-mark-ring)
2715 (message "Region has %d day%s (inclusive)"
2718 (defun calendar-not-implemented ()
2721 (error "%s not available in the calendar"
2724 (defun calendar-read (prompt acceptable &optional initial-contents)
2734 (defun calendar-read-date (&optional noday)
2735 "Prompt for Gregorian date. Return a list (month day year).
2736 If optional NODAY is t, does not ask for day, but just returns
2739 (let* ((year (calendar-read
2742 (int-to-string (extract-calendar-year
2743 (calendar-current-date)))))
2744 (month-array calendar-month-name-array)
2749 (mapcar 'list (append month-array nil))
2751 (calendar-make-alist month-array 1) t)))
2752 (last (calendar-last-day-of-month month year)))
2758 (calendar-read (format "Day (1-%d): " last)
2762 (defun calendar-interval (mon1 yr1 mon2 yr2)
2771 (defvar calendar-abbrev-length 3
2772 "*Length of abbreviations to be used for day and month names.
2773 See also `calendar-day-abbrev-array' and `calendar-month-abbrev-array'.")
2775 (defvar calendar-day-name-array
2777 "*Array of capitalized strings giving, in order, the day names.
2779 day columns in the calendar. See also the variable
2780 `calendar-day-abbrev-array'.")
2782 (defvar calendar-day-abbrev-array
2784 "*Array of capitalized strings giving the abbreviated day names.
2786 in `calendar-day-name-array'. These abbreviations may be used
2789 you may use such in the diary file. If any element of this array
2791 `calendar-abbrev-length' characters of the corresponding full name.")
2793 (defvar calendar-month-name-array
2797 See also the variable `calendar-month-abbrev-array'.")
2799 (defvar calendar-month-abbrev-array
2803 in `calendar-month-name-array'. These abbreviations are used in
2804 the calendar menu entries, and can also be used in the diary
2807 element of this array is nil, then the abbreviation will be
2808 constructed as the first `calendar-abbrev-length' characters of the
2811 (defun calendar-abbrev-construct (abbrev full &optional period)
2812 "Internal calendar function to return a complete abbreviation array.
2813 ABBREV is an array of abbreviations, FULL the corresponding array
2814 of full names. The return value is the ABBREV array, with any nil
2818 (let (elem array name)
2821 elem (or (aref abbrev i)
2823 (min calendar-abbrev-length (length name))))
2825 array (append array (list elem))))
2826 (vconcat array)))
2828 (defvar calendar-font-lock-keywords
2829 `((,(concat (regexp-opt (mapcar 'identity calendar-month-name-array) t)
2833 (list (substring (aref calendar-day-name-array 6) 0 2)
2834 (substring (aref calendar-day-name-array 0) 0 2)))
2837 ;; First two chars of each day are used in the calendar.
2838 (,(regexp-opt (mapcar (lambda (x) (substring x 0 2)) calendar-day-name-array))
2842 (defun calendar-day-name (date &optional abbrev absolute)
2843 "Return a string with the name of the day of the week of DATE.
2846 be an integer in the range 0 to 6 corresponding to the day of the
2847 week. Day names are taken from the variable `calendar-day-name-array',
2849 the variable `calendar-day-abbrev-array' is used."
2850 (aref (if abbrev
2851 (calendar-abbrev-construct calendar-day-abbrev-array
2852 calendar-day-name-array)
2853 calendar-day-name-array)
2854 (if absolute date (calendar-day-of-week date))))
2856 (defun calendar-make-alist (sequence &optional start-index filter abbrevs)
2860 is supplied, the function `calendar-abbrev-construct' is used to
2867 (aseq (if abbrevs (calendar-abbrev-construct abbrevs sequence)))
2868 (aseqp (if abbrevs (calendar-abbrev-construct abbrevs sequence
2885 (defun calendar-month-name (month &optional abbrev)
2888 variable `calendar-month-name-array', unless the optional
2890 `calendar-month-abbrev-array' is used."
2891 (aref (if abbrev
2892 (calendar-abbrev-construct calendar-month-abbrev-array
2893 calendar-month-name-array)
2894 calendar-month-name-array)
2897 (defun calendar-day-of-week (date)
2898 "Return the day-of-the-week index of DATE, 0 for Sunday, 1 for Monday, etc.
2899 DATE is a list of the form (month day year). A negative year is
2901 (mod (calendar-absolute-from-gregorian date) 7))
2903 (defun calendar-unmark ()
2904 "Delete all diary/holiday marks/highlighting from the calendar."
2906 (setq mark-holidays-in-calendar nil)
2907 (setq mark-diary-entries-in-calendar nil)
2908 (redraw-calendar))
2910 (defun calendar-date-is-visible-p (date)
2911 "Return t if DATE is valid and is visible in the calendar window."
2912 (let ((gap (calendar-interval
2914 (extract-calendar-month date) (extract-calendar-year date))))
2915 (and (calendar-date-is-legal-p date) (> 2 gap) (< -2 gap))))
2917 (defun calendar-date-is-legal-p (date)
2919 (let ((month (extract-calendar-month date))
2920 (day (extract-calendar-day date))
2921 (year (extract-calendar-year date)))
2923 ;; (calendar-read-date t) returns a date with day = nil.
2925 ;; (calendar-read-date 'noday) returns (month year), which
2926 ;; currently results in extract-calendar-year returning nil.
2927 day year (<= 1 day) (<= day (calendar-last-day-of-month month year))
2930 ;; Note there are side effects on calendar navigation.
2933 (defun calendar-date-equal (date1 date2)
2936 (= (extract-calendar-month date1) (extract-calendar-month date2))
2937 (= (extract-calendar-day date1) (extract-calendar-day date2))
2938 (= (extract-calendar-year date1) (extract-calendar-year date2))))
2940 (defun mark-visible-calendar-date (date &optional mark)
2941 "Mark DATE in the calendar window with MARK.
2944 (if (calendar-date-is-legal-p date)
2945 (with-current-buffer calendar-buffer
2947 (calendar-cursor-to-visible-date date)
2990 (defun calendar-star-date ()
2991 "Replace the date under the cursor in the calendar window with asterisks.
2992 This function can be used with the `today-visible-calendar-hook' run after the
2993 calendar window has been prepared."
2997 (set (make-local-variable 'calendar-starred-day)
3007 (defun calendar-mark-today ()
3008 "Mark the date under the cursor in the calendar window.
3009 The date is marked with `calendar-today-marker'. This function can be used with
3010 the `today-visible-calendar-hook' run after the calendar window has been
3012 (mark-visible-calendar-date
3013 (calendar-cursor-to-date)
3014 calendar-today-marker))
3016 (defun calendar-date-compare (date1 date2)
3019 (< (calendar-absolute-from-gregorian (car date1))
3020 (calendar-absolute-from-gregorian (car date2))))
3022 (defun calendar-date-string (date &optional abbreviate nodayname)
3023 "A string form of DATE, driven by the variable `calendar-date-display-form'.
3025 and day names to be abbreviated as specified by
3026 `calendar-month-abbrev-array' and `calendar-day-abbrev-array',
3028 name of the day of the week."
3031 (calendar-day-name date abbreviate)))
3032 (month (extract-calendar-month date))
3033 (monthname (calendar-month-name month abbreviate))
3034 (day (int-to-string (extract-calendar-day date)))
3036 (year (int-to-string (extract-calendar-year date))))
3037 (mapconcat 'eval calendar-date-display-form "")))
3039 (defun calendar-dayname-on-or-before (dayname date)
3044 absolute day d. Similarly, applying it to d+3 gives the DAYNAME nearest to
3049 (defun calendar-nth-named-absday (n dayname month year &optional day)
3055 If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise."
3058 (calendar-dayname-on-or-before
3060 (+ 6 (calendar-absolute-from-gregorian
3061 (list month (or day 1) year)))))
3063 (calendar-dayname-on-or-before
3065 (calendar-absolute-from-gregorian
3067 (or day (calendar-last-day-of-month month year))
3070 (defun calendar-nth-named-day (n dayname month year &optional day)
3076 If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise."
3077 (calendar-gregorian-from-absolute
3078 (calendar-nth-named-absday n dayname month year day)))
3080 (defun calendar-day-of-year-string (&optional date)
3081 "String of day number of year of Gregorian DATE.
3083 (let* ((d (or date (calendar-current-date)))
3084 (year (extract-calendar-year d))
3085 (day (calendar-day-number d))
3086 (days-remaining (- (calendar-day-number (list 12 31 year)) day)))
3087 (format "Day %d of %d; %d day%s remaining in the year"
3088 day year days-remaining (if (= days-remaining 1) "" "s"))))
3090 (defun calendar-print-other-dates ()
3093 (let* ((date (calendar-cursor-to-date t)))
3097 (calendar-set-mode-line
3098 (concat (calendar-date-string date) " (Gregorian)"))
3104 (calendar-day-of-year-string date) "\n"
3105 (format "ISO date: %s\n" (calendar-iso-date-string date))
3107 (calendar-julian-date-string date))
3108 (format "Astronomical (Julian) day number (at noon UTC): %s.0\n"
3109 (calendar-astro-date-string date))
3111 (calendar-absolute-from-gregorian date))
3113 (calendar-hebrew-date-string date))
3115 (calendar-persian-date-string date))
3116 (let ((i (calendar-islamic-date-string date)))
3119 (let ((b (calendar-bahai-date-string date)))
3123 (calendar-chinese-date-string date))
3124 (let ((c (calendar-coptic-date-string date)))
3127 (let ((e (calendar-ethiopic-date-string date)))
3130 (let ((f (calendar-french-date-string date)))
3134 (calendar-mayan-date-string date)))))
3139 (defun calendar-print-day-of-year ()
3140 "Show day number in year/days remaining in year for date under the cursor."
3142 (message (calendar-day-of-year-string (calendar-cursor-to-date t))))
3144 (defun calendar-set-mode-line (str)
3152 ,(calendar-string-spread (list str) ?- (- width 6))
3154 (calendar-string-spread (list str) ?- width)))))
3156 (defun calendar-mod (m n)
3160 (run-hooks 'calendar-load-hook)
3162 (provide 'calendar)
3169 ;;; calendar.el ends here