]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/calendar.el
Add doc strings CORRECTLY!
[gnu-emacs] / lisp / calendar / calendar.el
index 7432882108ca4837d6954a7f95c06232db47a8d3..14827bc63197cbcc70ab3db319b345ade233ec13 100644 (file)
 ;;       lunar.el                      Phases of the moon
 ;;       solar.el                      Sunrise/sunset, equinoxes/solstices
 
-;; Comments, corrections, and improvements should be sent to
-;;  Edward M. Reingold               Department of Computer Science
-;;  (217) 333-6733                   University of Illinois at Urbana-Champaign
-;;  reingold@cs.uiuc.edu             1304 West Springfield Avenue
-;;                                   Urbana, Illinois 61801
-
 ;; Technical details of all the calendrical calculations can be found in
+;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
+;; Cambridge University Press (1997).
 
+;; An earlier version of the technical details appeared in
 ;; ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
 ;; Software--Practice and Experience, Volume 20, Number 9 (September, 1990),
 ;; pages 899-928.  ``Calendrical Calculations, Part II: Three Historical
 ;; reingold@cs.uiuc.edu with the SUBJECT "send-paper-cal" (no quotes) and
 ;; the message BODY containing your mailing address (snail).
 
+;; Comments, corrections, and improvements should be sent to
+;;  Edward M. Reingold               Department of Computer Science
+;;  (217) 333-6733                   University of Illinois at Urbana-Champaign
+;;  reingold@cs.uiuc.edu             1304 West Springfield Avenue
+;;                                   Urbana, Illinois 61801
+
 ;;; Code:
 
 (defun calendar-version ()
@@ -191,7 +194,8 @@ The marking symbol is specified by the variable `diary-entry-marker'."
 (when window-system
   (add-to-list 'facemenu-unlisted-faces 'diary-face)
   (defface diary-face
-    '(((:class color) (:foreground "red"))
+    '((((class color))
+       (:foreground "red"))
       (t (:bold t)))
     "Face for highlighting diary entries."
     :group 'diary)
@@ -204,7 +208,8 @@ The marking symbol is specified by the variable `diary-entry-marker'."
 
   (add-to-list 'facemenu-unlisted-faces 'holiday-face)
   (defface holiday-face
-    '(((:class color) (:background "pink"))
+    '((((class color))
+       (:background "pink"))
       (t (:inverse-video t)))
     "Face for indicating dates that have holidays."
     :group 'diary))
@@ -737,7 +742,7 @@ describes the style of such diary entries."
 ;;;###autoload
 (defcustom diary-list-include-blanks nil
   "*If nil, do not include days with no diary entry in the list of diary entries.
-Such days will then not be shown in the the fancy diary buffer, even if they
+Such days will then not be shown in the fancy diary buffer, even if they
 are holidays."
   :type 'boolean
   :group 'diary)
@@ -759,7 +764,7 @@ somewhat; setting it to nil makes the diary display faster."
 (defcustom general-holidays
   '((holiday-fixed 1 1 "New Year's Day")
     (holiday-float 1 1 3 "Martin Luther King Day")
-    (holiday-fixed 2 2 "Ground Hog Day")
+    (holiday-fixed 2 2 "Groundhog Day")
     (holiday-fixed 2 14 "Valentine's Day")
     (holiday-float 2 1 3 "President's Day")
     (holiday-fixed 3 17 "St. Patrick's Day")
@@ -1104,6 +1109,9 @@ with descriptive strings such as
 (defconst fancy-diary-buffer "*Fancy Diary Entries*"
   "Name of the buffer used for the optional fancy display of the diary.")
 
+(defconst other-calendars-buffer "*Other Calendars*"
+  "Name of the buffer used for the display of date on other calendars.")
+
 (defconst lunar-phases-buffer "*Phases of Moon*"
   "Name of the buffer used for the lunar phases.")
 
@@ -1500,11 +1508,14 @@ Gregorian date Sunday, December 31, 1 BC.")
   "Move cursor to Julian DATE; echo Julian date unless NOECHO is t."
   t)
 
+(autoload 'calendar-print-julian-date "cal-julian"
+  "Show the Julian calendar equivalent of the date under the cursor."
+  t)
+
 (autoload 'calendar-julian-date-string "cal-julian"
   "String of Julian date of Gregorian DATE.
 Defaults to today's date if DATE is not given.
-Driven by the variable `calendar-date-display-form'."
-  t)
+Driven by the variable `calendar-date-display-form'.")
 
 (autoload 'calendar-goto-iso-date "cal-iso"
   "Move cursor to ISO date."
@@ -1704,6 +1715,12 @@ Weeks start on Monday.
 Diary entries are included if cal-tex-diary is t.
 Holidays are included if `cal-tex-holidays' is 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.")
+
 (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.")
@@ -1879,7 +1896,7 @@ the inserted text.  Value is always t."
   (define-key calendar-mode-map "\e>"   'calendar-end-of-year)
   (define-key calendar-mode-map "\C-@"  'calendar-set-mark)
   ;; Many people are used to typing C-SPC and getting C-@.
-  (define-key calendar-mode-map [?\C-\ ] 'calendar-set-mark)
+  (define-key calendar-mode-map [?\C- ] 'calendar-set-mark)
   (define-key calendar-mode-map "\C-x\C-x" 'calendar-exchange-point-and-mark)
   (define-key calendar-mode-map "\e=" 'calendar-count-days-region)
   (define-key calendar-mode-map "gd"  'calendar-goto-date)
@@ -1900,6 +1917,8 @@ the inserted text.  Value is always t."
   (define-key calendar-mode-map "gmnh" 'calendar-next-haab-date)
   (define-key calendar-mode-map "gmpt" 'calendar-previous-tzolkin-date)
   (define-key calendar-mode-map "gmnt" 'calendar-next-tzolkin-date)
+  (define-key calendar-mode-map "A"   'appt-add)
+  (define-key calendar-mode-map "D"   'appt-delete)
   (define-key calendar-mode-map "S"   'calendar-sunrise-sunset)
   (define-key calendar-mode-map "M"   'calendar-phases-of-moon)
   (define-key calendar-mode-map " "   'scroll-other-window)
@@ -1927,6 +1946,7 @@ the inserted text.  Value is always t."
   (define-key calendar-mode-map "pi"  'calendar-print-islamic-date)
   (define-key calendar-mode-map "pf"  'calendar-print-french-date)
   (define-key calendar-mode-map "pm"  'calendar-print-mayan-date)
+  (define-key calendar-mode-map "po"  'calendar-print-other-dates)
   (define-key calendar-mode-map "id"  'insert-diary-entry)
   (define-key calendar-mode-map "iw"  'insert-weekly-diary-entry)
   (define-key calendar-mode-map "im"  'insert-monthly-diary-entry)
@@ -1948,6 +1968,7 @@ the inserted text.  Value is always t."
   (define-key calendar-mode-map "tw2" 'cal-tex-cursor-week2)
   (define-key calendar-mode-map "tw3" 'cal-tex-cursor-week-iso)
   (define-key calendar-mode-map "tw4" 'cal-tex-cursor-week-monday)
+  (define-key calendar-mode-map "tfd" 'cal-tex-cursor-filofax-daily)
   (define-key calendar-mode-map "tfw" 'cal-tex-cursor-filofax-2week)
   (define-key calendar-mode-map "tfW" 'cal-tex-cursor-filofax-week)
   (define-key calendar-mode-map "tfy" 'cal-tex-cursor-filofax-year)
@@ -2008,6 +2029,10 @@ For a complete description, type \
   (setq buffer-read-only t)
   (setq indent-tabs-mode nil)
   (update-calendar-mode-line)
+  (if window-system
+      (progn
+        (make-local-hook 'activate-menubar-hook)
+        (add-hook 'activate-menubar-hook 'cal-menu-update nil t)))
   (make-local-variable 'calendar-mark-ring)
   (make-local-variable 'displayed-month);;  Month in middle of window.
   (make-local-variable 'displayed-year));;  Year in middle of window.
@@ -2061,7 +2086,8 @@ the STRINGS are just concatenated and the result truncated."
   "List of all calendar-related buffers."
   (let* ((diary-buffer (get-file-buffer diary-file))
          (buffers (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
-                        fancy-diary-buffer diary-buffer calendar-buffer))
+                        fancy-diary-buffer diary-buffer calendar-buffer
+                        other-calendars-buffer))
          (buffer-list nil)
          b)
     (while buffers
@@ -2077,11 +2103,10 @@ the STRINGS are just concatenated and the result truncated."
   "Get out of the calendar window and hide it and related buffers."
   (interactive)
   (let* ((diary-buffer (get-file-buffer diary-file)))
-    (if (and diary-buffer (buffer-modified-p diary-buffer)
-            (not
-             (yes-or-no-p
-              "Diary modified; do you really want to exit the calendar? ")))
-       (error)
+    (if (or (not diary-buffer)
+            (not (buffer-modified-p diary-buffer))
+            (yes-or-no-p
+             "Diary modified; do you really want to exit the calendar? "))
       ;; Need to do this multiple times because one time can replace some
       ;; calendar-related buffers with other calendar-related buffers
       (mapcar (lambda (x)
@@ -2301,26 +2326,22 @@ If optional NODAY is t, does not ask for day, but just returns
 (defun calendar-day-name (date &optional width absolute)
   "Returns a string with the name of the day of the week of DATE.
 If WIDTH is non-nil, return just the first WIDTH characters of the name.
-If ABSOLUTE is non-nil, then DATE is actual the day-of-the-week
+If ABSOLUTE is non-nil, then DATE is actually the day-of-the-week
 rather than a date."
   (let ((string (aref calendar-day-name-array
                      (if absolute date (calendar-day-of-week date)))))
-    (if width
-       (let ((i 0) (result "") (pos 0))
-         (while (< i width)
-           (let ((chartext (char-to-string (sref string pos))))
-             (setq pos (+ pos (length chartext)))
-             (setq result (concat result chartext)))
-           (setq i (1+ i)))
-         result)
-      string)))
+    (cond ((null width) string)
+         (enable-multibyte-characters (truncate-string-to-width string width))
+         (t (substring string 0 width)))))
 
 (defvar calendar-day-name-array
-  ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"])
+  ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"]
+  "Array of capitalized strings giving, in order, the day names.")
 
 (defvar calendar-month-name-array
   ["January" "February" "March"     "April"   "May"      "June"
-   "July"    "August"   "September" "October" "November" "December"])
+   "July"    "August"   "September" "October" "November" "December"]
+  "Array of capitalized strings giving, in order, the month names.")
 
 (defun calendar-make-alist (sequence &optional start-index filter)
   "Make an assoc list corresponding to SEQUENCE.
@@ -2502,6 +2523,53 @@ Defaults to today's date if DATE is not given."
     (format "Day %d of %d; %d day%s remaining in the year"
             day year days-remaining (if (= days-remaining 1) "" "s"))))
 
+(defun calendar-print-other-dates ()
+  "Show dates on other calendars for date under the cursor."
+  (interactive)
+  (let* ((date (calendar-cursor-to-date t)))
+    (save-excursion
+      (set-buffer (get-buffer-create other-calendars-buffer))
+      (setq buffer-read-only nil)
+      (calendar-set-mode-line
+       (concat (calendar-date-string date) " (Gregorian)"))
+      (erase-buffer)
+      (insert
+       (mapconcat 'identity
+                  (list (calendar-day-of-year-string date)
+                        (format "ISO date: %s" (calendar-iso-date-string date))
+                        (format "Julian date: %s"
+                                (calendar-julian-date-string date))
+                        (format
+                         "Astronomical (Julian) day number (at noon UTC): %s.0"
+                         (calendar-astro-date-string date))
+                        (format "Fixed (RD) date: %s"
+                                (calendar-absolute-from-gregorian date))
+                        (format "Hebrew date (before sunset): %s"
+                                (calendar-hebrew-date-string date))
+                        (format "Persian date: %s"
+                                (calendar-persian-date-string date))
+                        (let ((i (calendar-islamic-date-string date)))
+                          (if (not (string-equal i ""))
+                              (format "Islamic date (before sunset): %s" i)))
+                        (format "Chinese date: %s"
+                                (calendar-chinese-date-string date))
+                        (let ((c (calendar-coptic-date-string date)))
+                          (if (not (string-equal c ""))
+                              (format "Coptic date: %s" c)))
+                        (let ((e (calendar-ethiopic-date-string date)))
+                          (if (not (string-equal e ""))
+                              (format "Ethiopic date: %s" e)))
+                        (let ((f (calendar-french-date-string date)))
+                          (if (not (string-equal f ""))
+                              (format "French Revolutionary date: %s" f)))
+                        (format "Mayan date: %s"
+                                (calendar-mayan-date-string date)))
+                  "\n"))
+      (goto-char (point-min))
+      (set-buffer-modified-p nil)
+      (setq buffer-read-only t)
+      (display-buffer other-calendars-buffer))))
+
 (defun calendar-print-day-of-year ()
   "Show day number in year/days remaining in year for date under the cursor."
   (interactive)