]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/calendar.el
** offby1@blarg.net, Nov 5: calendar gets wrong end for Daylight Savings Time
[gnu-emacs] / lisp / calendar / calendar.el
index f01f4305708f7083934931b3be7d748ba82c7201..c5e7f85f51b73bb67b94a6508bd19e9000d67819 100644 (file)
@@ -213,12 +213,6 @@ If nil, make an icon of the frame.  If non-nil, delete the frame."
 ;; backward-compatibility alias
 (put 'holiday-face 'face-alias 'holiday)
 
-(eval-after-load "facemenu"
-  '(progn
-     (add-to-list 'facemenu-unlisted-faces 'diary)
-     (add-to-list 'facemenu-unlisted-faces 'calendar-today)
-     (add-to-list 'facemenu-unlisted-faces 'holiday)))
-
 (defcustom diary-entry-marker
   (if (not (display-color-p))
       "+"
@@ -574,11 +568,20 @@ are
 
 Names can be capitalized or not, written in full (as specified by the
 variable `calendar-day-name-array'), or abbreviated (as specified by
-`calendar-day-abbrev-array') with or without a period.  To take effect,
-this variable should be set before the calendar package and its associates
-are loaded.  Otherwise, use one of the functions `european-calendar' or
-`american-calendar' to force the appropriate update."
+`calendar-day-abbrev-array') with or without a period.
+
+Setting this variable directly does not take effect (if the
+calendar package is already loaded).  Rather, use either
+\\[customize] or the functions `european-calendar' and
+`american-calendar'."
   :type 'boolean
+  ;; Without :initialize (require 'calendar) throws an error because
+  ;; american-calendar is undefined at this point.
+  :initialize 'custom-initialize-default
+  :set (lambda (symbol value)
+         (if value
+             (european-calendar)
+           (american-calendar)))
   :group 'diary)
 
 ;;;###autoload
@@ -1190,9 +1193,20 @@ list `other-holidays' in your .emacs file.  Similarly, by setting any
 of `general-holidays', `local-holidays' `christian-holidays',
 `hebrew-holidays', `islamic-holidays', `bahai-holidays',
 `oriental-holidays', or `solar-holidays' to nil in your .emacs file,
-you can eliminate unwanted categories of holidays.  The intention is
-that (in the US) `local-holidays' be set in site-init.el and
-`other-holidays' be set by the user.
+you can eliminate unwanted categories of holidays.
+
+The aforementioned variables control the holiday choices offered
+by the function `list-holidays' when it is called interactively.
+
+They also initialize the default value of `calendar-holidays',
+which is the default list of holidays used by the function
+`list-holidays' in the non-interactive case.  Note that these
+variables have no effect on `calendar-holidays' after it has been
+set (e.g. after the calendar is loaded).  In that case, customize
+`calendar-holidays' directly.
+
+The intention is that (in the US) `local-holidays' be set in
+site-init.el and `other-holidays' be set by the user.
 
 Entries on the list are expressions that return (possibly empty) lists of
 items of the form ((month day year) string) of a holiday in the in the
@@ -1308,7 +1322,7 @@ A negative YR is interpreted as BC; -1 being 1 BC, and so on."
 The return value is a pair (MONTH . YEAR).
 MON defaults to `displayed-month'.  YR defaults to `displayed-year'."
   (unless mon (setq mon displayed-month))
-  (unless yr (setq mon displayed-year))
+  (unless yr (setq yr displayed-year))
   (increment-calendar-month mon yr n)
   (cons mon yr))
 
@@ -1363,6 +1377,7 @@ MON defaults to `displayed-month'.  YR defaults to `displayed-year'."
   "Extract the month part of DATE which has the form (month day year)."
   (car date))
 
+;; Note gives wrong answer for result of (calendar-read-date 'noday).
 (defsubst extract-calendar-day (date)
   "Extract the day part of DATE which has the form (month day year)."
   (car (cdr date)))
@@ -1576,6 +1591,19 @@ See the documentation of that function for more information."
          (calendar-only-one-frame-setup arg))
         (t (calendar-basic-setup arg))))
 
+(autoload 'diary-view-entries "diary-lib"
+  "Prepare and display a buffer with diary entries.
+Searches your diary file for entries that match ARG days starting with
+the date indicated by the cursor position in the displayed three-month
+calendar."
+  t)
+
+(autoload 'list-calendar-holidays "holidays"
+  "Create a buffer containing the holidays for the current calendar window.
+The holidays are those in the list `calendar-notable-days'.  Returns t if any
+holidays are found, nil if not."
+  t)
+
 (defun calendar-basic-setup (&optional arg)
   "Display a three-month calendar in another window.
 The three months appear side by side, with the current month in the middle
@@ -1628,6 +1656,9 @@ to be replaced by asterisks to highlight it whenever it is in the window."
                  (calendar-current-date)))
          (month (extract-calendar-month date))
          (year (extract-calendar-year date)))
+    ;; (calendar-read-date t) returns a date with day = nil, which is
+    ;; not a legal date for the visible test in the diary section.
+    (if arg (setcar (cdr date) 1))
     (pop-to-buffer calendar-buffer)
     (increment-calendar-month month year (- calendar-offset))
     (generate-calendar-window month year)
@@ -1640,13 +1671,6 @@ to be replaced by asterisks to highlight it whenever it is in the window."
         (list-calendar-holidays)))
   (run-hooks 'initial-calendar-window-hook))
 
-(autoload 'diary-view-entries "diary-lib"
-  "Prepare and display a buffer with diary entries.
-Searches your diary file for entries that match ARG days starting with
-the date indicated by the cursor position in the displayed three-month
-calendar."
-  t)
-
 (autoload 'view-other-diary-entries "diary-lib"
   "Prepare and display buffer of diary entries from an alternative diary file.
 Searches for entries that match ARG days, starting with the date indicated
@@ -1671,12 +1695,10 @@ D-FILE specifies the file to use as the diary file."
   t)
 
 (autoload 'calendar-french-date-string "cal-french"
-  "String of French Revolutionary date of Gregorian date."
-  t)
+  "String of French Revolutionary date of Gregorian date.")
 
 (autoload 'calendar-mayan-date-string "cal-mayan"
-  "String of Mayan date of Gregorian date."
-  t)
+  "String of Mayan date of Gregorian date.")
 
 (autoload 'calendar-print-mayan-date "cal-mayan"
   "Show the Mayan long count, Tzolkin, and Haab equivalents of the date under the cursor."
@@ -1719,8 +1741,7 @@ D-FILE specifies the file to use as the diary file."
  t)
 
 (autoload 'calendar-chinese-date-string "cal-china"
-  "String of Chinese date of Gregorian date."
-  t)
+  "String of Chinese date of Gregorian date.")
 
 (autoload 'calendar-absolute-from-astro  "cal-julian"
   "Absolute date of astronomical (Julian) day number D."
@@ -1730,8 +1751,7 @@ D-FILE specifies the file to use as the diary file."
   "Astronomical (Julian) day number of absolute date D.")
 
 (autoload 'calendar-astro-date-string "cal-julian"
-  "String of astronomical (Julian) day number of Gregorian date."
-  t)
+  "String of astronomical (Julian) day number of Gregorian date.")
 
 (autoload 'calendar-goto-astro-day-number "cal-julian"
    "Move cursor to astronomical (Julian) day number."
@@ -1772,8 +1792,7 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-iso-date-string "cal-iso"
-  "String of ISO date of Gregorian date."
-  t)
+  "String of ISO date of Gregorian date.")
 
 (autoload 'calendar-goto-islamic-date "cal-islam"
   "Move cursor to Islamic date."
@@ -1784,16 +1803,14 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-islamic-date-string "cal-islam"
-  "String of Islamic date of Gregorian date."
-  t)
+  "String of Islamic date of Gregorian date.")
 
 (autoload 'calendar-print-bahai-date "cal-bahai"
   "Show the Baha'i date equivalents of date."
   t)
 
 (autoload 'calendar-bahai-date-string "cal-bahai"
-  "String of Baha'i date of Gregorian date."
-  t)
+  "String of Baha'i date of Gregorian date.")
 
 (autoload 'calendar-goto-hebrew-date "cal-hebrew"
   "Move cursor to Hebrew date."
@@ -1804,8 +1821,7 @@ Driven by the variable `calendar-date-display-form'.")
   t)
 
 (autoload 'calendar-hebrew-date-string "cal-hebrew"
-  "String of Hebrew date of Gregorian date."
-  t)
+  "String of Hebrew date of Gregorian date.")
 
 (autoload 'calendar-goto-coptic-date "cal-coptic"
    "Move cursor to Coptic date."
@@ -1816,8 +1832,7 @@ Driven by the variable `calendar-date-display-form'.")
  t)
 
 (autoload 'calendar-coptic-date-string "cal-coptic"
-  "String of Coptic date of Gregorian date."
-  t)
+  "String of Coptic date of Gregorian date.")
 
 (autoload 'calendar-goto-ethiopic-date "cal-coptic"
    "Move cursor to Ethiopic date."
@@ -1828,8 +1843,7 @@ Driven by the variable `calendar-date-display-form'.")
  t)
 
 (autoload 'calendar-ethiopic-date-string "cal-coptic"
-  "String of Ethiopic date of Gregorian date."
-  t)
+  "String of Ethiopic date of Gregorian date.")
 
 (autoload 'calendar-goto-persian-date "cal-persia"
    "Move cursor to Persian date."
@@ -1840,10 +1854,9 @@ Driven by the variable `calendar-date-display-form'.")
  t)
 
 (autoload 'calendar-persian-date-string "cal-persia"
-  "String of Persian date of Gregorian date."
-  t)
+  "String of Persian date of Gregorian date.")
 
-(autoload 'show-all-diary-entries "diary-lib"
+(autoload 'diary-show-all-entries "diary-lib"
   "Show all of the diary entries in the diary file.
 This function gets rid of the selective display of the diary file so that
 all entries, not just some, are visible.  If there is no diary buffer, one
@@ -1856,8 +1869,7 @@ Each entry in diary file visible in the calendar window is marked."
   t)
 
 (autoload 'make-diary-entry "diary-lib"
-  "Insert a diary entry STRING which may be NONMARKING in FILE."
-  t)
+  "Insert a diary entry STRING which may be NONMARKING in FILE.")
 
 (autoload 'insert-diary-entry "diary-lib"
   "Insert a diary entry for the date indicated by point."
@@ -1933,78 +1945,84 @@ to the date indicated by point."
 to the date indicated by point."
   t)
 
-(autoload 'list-calendar-holidays "holidays"
-  "Create a buffer containing the holidays for the current calendar window.
-The holidays are those in the list `calendar-notable-days'.  Returns t if any
-holidays are found, nil if not."
-  t)
-
 (autoload 'cal-tex-cursor-month "cal-tex"
   "Make a buffer with LaTeX commands for the month cursor is on.
 Optional prefix argument specifies number of months to be produced.
-Calendar is condensed onto one page.")
+Calendar is condensed onto one page." t)
 
 (autoload 'cal-tex-cursor-month-landscape "cal-tex"
   "Make a buffer with LaTeX commands for the month cursor is on.
-Optional prefix argument specifies number of months to be produced.")
+Optional prefix argument specifies number of months to be produced." t)
 
 (autoload 'cal-tex-cursor-day "cal-tex"
-  "Make a buffer with LaTeX commands for the day cursor is on.")
+  "Make a buffer with LaTeX commands for the day cursor is on." t)
 
 (autoload 'cal-tex-cursor-week "cal-tex"
   "Make a buffer with LaTeX commands for a two-page one-week calendar.
 It applies to the week that point is in.
 Optional prefix argument specifies number of weeks.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-week2 "cal-tex"
   "Make a buffer with LaTeX commands for a two-page one-week calendar.
 It applies to the week that point is in.
 Optional prefix argument specifies number of weeks.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-week-iso "cal-tex"
   "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar.
 Optional prefix argument specifies number of weeks.
 Diary entries are included if `cal-tex-diary' is t.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-week-monday "cal-tex"
   "Make a buffer with LaTeX commands for a two-page one-week calendar.
 It applies to the week that point is in, and starts on Monday.
 Optional prefix argument specifies number of weeks.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-filofax-2week "cal-tex"
   "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor.
 Optional prefix argument specifies number of weeks.
 Diary entries are included if cal-tex-diary is t.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-filofax-week "cal-tex"
   "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
 Optional prefix argument specifies number of weeks.
 Weeks start on Monday.
 Diary entries are included if cal-tex-diary is t.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-filofax-daily "cal-tex"
   "Day-per-page Filofax style calendar for week indicated by cursor.
 Optional prefix argument specifies number of weeks.  Weeks start on Monday.
 Diary entries are included if `cal-tex-diary' is t.
-Holidays are included if `cal-tex-holidays' is t.")
+Holidays are included if `cal-tex-holidays' is t." t)
 
 (autoload 'cal-tex-cursor-year "cal-tex"
   "Make a buffer with LaTeX commands for a year's calendar.
-Optional prefix argument specifies number of years.")
+Optional prefix argument specifies number of years." t)
 
 (autoload 'cal-tex-cursor-year-landscape "cal-tex"
   "Make a buffer with LaTeX commands for a year's calendar (landscape).
-Optional prefix argument specifies number of years.")
+Optional prefix argument specifies number of years." t)
 
 (autoload 'cal-tex-cursor-filofax-year "cal-tex"
   "Make a buffer with LaTeX commands for a year's calendar (Filofax).
-Optional prefix argument specifies number of years.")
+Optional prefix argument specifies number of years." t)
+
+(autoload 'cal-html-cursor-month "cal-html"
+  "Write an HTML calendar file for numeric MONTH of four-digit YEAR.
+The output directory DIR is created if necessary.  Interactively,
+MONTH and YEAR are taken from the calendar cursor position.  Note
+that any existing output files are overwritten." t)
+
+(autoload 'cal-html-cursor-year "cal-html"
+  "Write HTML calendar files (index and monthly pages) for four-digit YEAR.
+The output directory DIR is created if necessary.  Interactively,
+YEAR is taken from the calendar cursor position.  Note that any
+existing output files are overwritten." t)
 
 (autoload 'mark-calendar-holidays "holidays"
   "Mark notable days in the calendar window."
@@ -2250,7 +2268,7 @@ movement commands will not work correctly."
     (define-key map "m"   'mark-diary-entries)
     (define-key map "d"   'diary-view-entries)
     (define-key map "D"   'view-other-diary-entries)
-    (define-key map "s"   'show-all-diary-entries)
+    (define-key map "s"   'diary-show-all-entries)
     (define-key map "pd"  'calendar-print-day-of-year)
     (define-key map "pC"  'calendar-print-chinese-date)
     (define-key map "pk"  'calendar-print-coptic-date)
@@ -2282,6 +2300,8 @@ movement commands will not work correctly."
     (define-key map "iBm" 'insert-monthly-bahai-diary-entry)
     (define-key map "iBy" 'insert-yearly-bahai-diary-entry)
     (define-key map "?"   'calendar-goto-info-node)
+    (define-key map "Hm" 'cal-html-cursor-month)
+    (define-key map "Hy" 'cal-html-cursor-year)
     (define-key map "tm" 'cal-tex-cursor-month)
     (define-key map "tM" 'cal-tex-cursor-month-landscape)
     (define-key map "td" 'cal-tex-cursor-day)
@@ -2886,7 +2906,11 @@ interpreted as BC; -1 being 1 BC, and so on."
         (day (extract-calendar-day date))
         (year (extract-calendar-year date)))
     (and (<= 1 month) (<= month 12)
-         (<= 1 day) (<= day (calendar-last-day-of-month month year))
+         ;; (calendar-read-date t) returns a date with day = nil.
+         ;; Should not be valid (?), since many funcs prob assume integer.
+         ;; (calendar-read-date 'noday) returns (month year), which
+         ;; currently results in extract-calendar-year returning nil.
+         day year (<= 1 day) (<= day (calendar-last-day-of-month month year))
          ;; BC dates left as non-valid, to suppress errors from
          ;; complex holiday algorithms not suitable for years BC.
          ;; Note there are side effects on calendar navigation.