(pages-copy-header-and-position): Call end-of-line, not forward-line.
[bpt/emacs.git] / lisp / diary-lib.el
index 0c2808c..c7b79f4 100644 (file)
@@ -1,9 +1,9 @@
 ;;; diary.el --- diary functions.
 
-;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
-;; Last-Modified: 30 Jun 1992
+;; Copyright (C) 1989, 1990, 1992 Free Software Foundation, Inc.
 
-;; Copyright (C) 1989, 1990 Free Software Foundation, Inc.
+;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
+;; Keywords: calendar
 
 ;; This file is part of GNU Emacs.
 
@@ -42,7 +42,7 @@
   "Generate the diary window for ARG days starting with the current date.
 If no argument is provided, the number of days of diary entries is governed
 by the variable `number-of-diary-entries'.  This function is suitable for
-execution in a .emacs file."
+execution in a `.emacs' file."
   (interactive "P")
   (let ((d-file (substitute-in-file-name diary-file))
         (date (calendar-current-date)))
@@ -60,9 +60,9 @@ execution in a .emacs file."
 
 (defun view-diary-entries (arg)
   "Prepare and display a buffer with diary entries.
-Searches the file diary-file for entries that match ARG days starting with
-the date indicated by the cursor position in the displayed three-month
-calendar."
+Searches the file named in `diary-file' for entries that
+match ARG days starting with the date indicated by the cursor position
+in the displayed three-month calendar."
   (interactive "p")
   (let ((d-file (substitute-in-file-name diary-file)))
     (if (and d-file (file-exists-p d-file))
@@ -76,14 +76,35 @@ calendar."
 (autoload 'check-calendar-holidays "holidays"
   "Check the list of holidays for any that occur on DATE.
 The value returned is a list of strings of relevant holiday descriptions.
-The holidays are those in the list calendar-holidays.")
+The holidays are those in the list `calendar-holidays'."
+  t)
+
 
 (autoload 'calendar-holiday-list "holidays"
   "Form the list of holidays that occur on dates in the calendar window.
-The holidays are those in the list calendar-holidays.")
+The holidays are those in the list `calendar-holidays'."
+  t)
+
+(autoload 'diary-french-date "cal-french"
+  "French calendar equivalent of date diary entry."
+  t)
+
+(autoload 'diary-mayan-date "cal-mayan"
+  "Mayan calendar equivalent of date diary entry."
+  t)
+
+(autoload 'diary-phases-of-moon "lunar" "Moon phases diary entry." t)
 
-(defvar diary-syntax-table
-  (standard-syntax-table)
+(autoload 'diary-sunrise-sunset "solar"
+  "Local time of sunrise and sunset as a diary entry."
+  t)
+
+(autoload 'diary-sabbath-candles "solar"
+  "Local time of candle lighting diary entry--applies if date is a Friday.
+No diary entry if there is no sunset on that date."
+  t)
+
+(defvar diary-syntax-table (copy-syntax-table (standard-syntax-table))
   "The syntax table used when parsing dates in the diary file.
 It is the standard syntax table used in Fundamental mode, but with the
 syntax of `*' changed to be a word constituent.")
@@ -92,19 +113,18 @@ syntax of `*' changed to be a word constituent.")
 
 (defun list-diary-entries (date number)
   "Create and display a buffer containing the relevant lines in diary-file.
-All lines that apply to DATE and the next NUMBER-1 days are included.
-
-Makes all diary entries in the diary file invisible (using selective display),
-*except* those that are relevant.
+The arguments are DATE and NUMBER; the entries selected are those
+for NUMBER days starting with date DATE.  The other entries are hidden
+using selective display.
 
 Returns a list of all relevant diary entries found, if any, in order by date.
 The list entries have the form ((month day year) string).  If the variable
-`diary-list-include-blanks' is t, this list will include a dummy diary entry
-\(consisting of the empty string\) for a date with no diary entries.
+`diary-list-include-blanks' is t, this list includes a dummy diary entry
+\(consisting of the empty string) for a date with no diary entries.
 
 After the list is prepared, the hooks `nongregorian-diary-listing-hook',
-`list-diary-entries-hook', and `diary-display-hook' are run.  These hooks
-have the following distinct roles:
+`list-diary-entries-hook', `diary-display-hook', and `diary-hook' are run.
+These hooks have the following distinct roles:
 
     `nongregorian-diary-listing-hook' can cull dates from the diary
         and each included file.  Usually used for Hebrew or Islamic
@@ -112,10 +132,16 @@ have the following distinct roles:
 
     `list-diary-entries-hook' adds or manipulates diary entries from
         external sources.  Used, for example, to include diary entries
-        from other files or to sort the diary entries.  Invoked *once* only.
+        from other files or to sort the diary entries.  Invoked *once* only,
+        before the display hook is run.
 
-    `diary-display-hook' does the actual display of information.  Could be
-        used also for an appointment notification function."
+    `diary-display-hook' does the actual display of information.  If this is
+        nil, simple-diary-display will be used.  Use add-hook to set this to
+        fancy-diary-display, if desired.  If you want no diary display, use
+        add-hook to set this to ignore.
+
+    `diary-hook' is run last.  This can be used for an appointment
+        notification function."
 
   (if (< 0 number)
       (let* ((original-date date);; save for possible use in the hooks
@@ -218,19 +244,21 @@ have the following distinct roles:
           (set-syntax-table old-diary-syntax-table))
         (goto-char (point-min))
         (run-hooks 'nongregorian-diary-listing-hook
-                   'list-diary-entries-hook
-                   'diary-display-hook)
+                   'list-diary-entries-hook)
+        (if diary-display-hook
+            (run-hooks 'diary-display-hook)
+          (simple-diary-display))
+        (run-hooks 'diary-hook)
         diary-entries-list))))
 
 (defun include-other-diary-files ()
   "Include the diary entries from other diary files with those of diary-file.
-This function is suitable for use just before fancy-diary-display as the
-list-diary-entries-hook; it enables you to use shared diary files together
-with your own.  The files included are specified in the diary-file by lines of
-the form
+This function is suitable for use in `list-diary-entries-hook';
+it enables you to use shared diary files together with your own.
+The files included are specified in the diaryfile by lines of this form:
         #include \"filename\"
 This is recursive; that is, #include directives in diary files thus included
-are obeyed.  You can change the \"#include\" to some other string by
+are obeyed.  You can change the `#include' to some other string by
 changing the variable `diary-include-string'."
   (goto-char (point-min))
   (while (re-search-forward
@@ -243,7 +271,8 @@ changing the variable `diary-include-string'."
                        (buffer-substring (match-beginning 2) (match-end 2))))
           (diary-list-include-blanks nil)
           (list-diary-entries-hook 'include-other-diary-files)
-          (diary-display-hook nil))
+          (diary-display-hook 'ignore)
+          (diary-hook nil))
       (if (file-exists-p diary-file)
           (if (file-readable-p diary-file)
               (unwind-protect
@@ -273,8 +302,7 @@ changing the variable `diary-include-string'."
             (message msg)
           (set-buffer (get-buffer-create holiday-buffer))
           (setq buffer-read-only nil)
-          (setq mode-line-format
-                (format "--------------------------%s%%-" date-string))
+          (calendar-set-mode-line date-string)
           (erase-buffer)
           (insert (mapconcat 'identity holiday-list "\n"))
           (goto-char (point-min))
@@ -282,19 +310,16 @@ changing the variable `diary-include-string'."
           (setq buffer-read-only t)
           (display-buffer holiday-buffer)
           (message  "No diary entries for %s" date-string))
-      (setq mode-line-format
-            (format "%%*--%sDiary %s %s%s%s%%-"
-                    (if holiday-list "" "---------------")
-                    (if holiday-list "for" "entries for")
-                    date-string
-                    (if holiday-list ": " "")
-                    (mapconcat 'identity holiday-list "; ")))
+      (calendar-set-mode-line
+       (concat "Diary for " date-string
+               (if holiday-list ": " "")
+               (mapconcat 'identity holiday-list "; ")))
       (display-buffer (get-file-buffer d-file))
       (message "Preparing diary...done"))))
 
 (defun fancy-diary-display ()
   "Prepare a diary buffer with relevant entries in a fancy, noneditable form.
-This function is provided for optional use as the `list-diary-entries-hook'."
+This function is provided for optional use as the `diary-display-hook'."
   (if (or (not diary-entries-list)
           (and (not (cdr diary-entries-list))
                (string-equal (car (cdr (car diary-entries-list))) "")))
@@ -307,8 +332,7 @@ This function is provided for optional use as the `list-diary-entries-hook'."
             (message msg)
           (set-buffer (get-buffer-create holiday-buffer))
           (setq buffer-read-only nil)
-          (setq mode-line-format
-                (format "--------------------------%s%%-" date-string))
+          (calendar-set-mode-line date-string)
           (erase-buffer)
           (insert (mapconcat 'identity holiday-list "\n"))
           (goto-char (point-min))
@@ -327,7 +351,7 @@ This function is provided for optional use as the `list-diary-entries-hook'."
       (set-buffer (get-buffer-create fancy-diary-buffer))
       (setq buffer-read-only nil)
       (make-local-variable 'mode-line-format)
-      (setq mode-line-format "---------------------------Diary Entries%-")
+      (calendar-set-mode-line "Diary Entries")
       (erase-buffer)
       (let ((entry-list diary-entries-list)
             (holiday-list)
@@ -386,42 +410,48 @@ This function is provided for optional use as the `list-diary-entries-hook'."
       (message "Preparing diary...done"))))
 
 (defun print-diary-entries ()
-  "Print a hard copy of the entries visible in the diary window.
-The hooks given by the variable `print-diary-entries-hook' are called after
-the temporary buffer of visible diary entries is prepared; it is the hooks
-that do the actual printing and kill the buffer."
+  "Print a hard copy of the diary display.
+
+If the simple diary display is being used, prepare a temp buffer with the
+visible lines of the diary buffer, add a heading line composed from the mode
+line, print the temp buffer, and destroy it.
+
+If the fancy diary display is being used, just print the buffer.
+
+The hooks given by the variable `print-diary-entries-hook' are called to do
+the actual printing."
   (interactive)
-  (let ((diary-buffer (get-file-buffer (substitute-in-file-name diary-file))))
-    (if diary-buffer
-        (let ((temp-buffer (get-buffer-create "*Printable Diary Entries*")))
-          (save-excursion
-            (set-buffer diary-buffer)
-            (copy-to-buffer temp-buffer (point-min) (point-max))
-            (set-buffer temp-buffer)
-            (while (re-search-forward "\^M.*$" nil t)
-              (replace-match ""))
-            (run-hooks 'print-diary-entries-hook)))
-      (error "You don't have a diary buffer!"))))
-
-(defun add-diary-heading ()
-  "Add a heading to the diary entries for printing.
-The heading is formed from the mode line of the diary buffer.  This function
-is used in the default value of the variable `print-diary-entry-hooks'."
-  (save-excursion
-    (let ((heading))
-      (set-buffer diary-buffer)
-      (setq heading mode-line-format)
-      (string-match "%\\*-*\\([^-].*\\)%-$" heading)
-      (setq heading
-            (substring heading (match-beginning 1) (match-end 1)))
-      (set-buffer temp-buffer)
-      (goto-char (point-min))
-      (insert heading "\n"
-              (make-string (length heading) ?=) "\n"))))
+  (if (bufferp (get-buffer fancy-diary-buffer))
+      (save-excursion
+        (set-buffer (get-buffer fancy-diary-buffer))
+        (run-hooks 'print-diary-entries-hook))
+    (let ((diary-buffer
+           (get-file-buffer (substitute-in-file-name diary-file))))
+      (if diary-buffer
+          (let ((temp-buffer (get-buffer-create "*Printable Diary Entries*"))
+                (heading))
+            (save-excursion
+              (set-buffer diary-buffer)
+              (setq heading
+                    (if (not (stringp mode-line-format))
+                        "All Diary Entries"
+                      (string-match "^-*\\([^-].*[^-]\\)-*$" mode-line-format)
+                      (substring mode-line-format
+                                 (match-beginning 1) (match-end 1))))
+              (copy-to-buffer temp-buffer (point-min) (point-max))
+              (set-buffer temp-buffer)
+              (while (re-search-forward "\^M.*$" nil t)
+                (replace-match ""))
+              (goto-char (point-min))
+              (insert heading "\n"
+                      (make-string (length heading) ?=) "\n")
+              (run-hooks 'print-diary-entries-hook)
+              (kill-buffer temp-buffer)))
+        (error "You don't have a diary buffer!")))))
 
 (defun show-all-diary-entries ()
-  "Show all of the diary entries in the diary-file.
-This function gets rid of the selective display of the diary-file so that
+  "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
 is created."
   (interactive)
@@ -438,8 +468,7 @@ is created."
                   (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)
                   (setq selective-display nil)
                   (make-local-variable 'mode-line-format)
-                  (setq mode-line-format
-                        "%*---------------------------All Diary Entries%-")
+                  (setq mode-line-format default-mode-line-format)
                   (display-buffer (current-buffer))
                   (set-buffer-modified-p diary-modified))))
           (error "Your diary file is not readable!"))
@@ -467,8 +496,8 @@ name."
 
 (defun mark-diary-entries ()
   "Mark days in the calendar window that have diary entries.
-Each entry in diary-file visible in the calendar window is marked.  After the
-entries are marked, the hooks `nongregorian-diary-marking-hook' and
+Each entry in the diary file visible in the calendar window is marked.
+After the entries are marked, the hooks `nongregorian-diary-marking-hook' and
 `mark-diary-entries-hook' are run."
   (interactive)
   (setq mark-diary-entries-in-calendar t)
@@ -587,7 +616,7 @@ entries are marked, the hooks `nongregorian-diary-marking-hook' and
 
 (defun mark-sexp-diary-entries ()
   "Mark days in the calendar window that have sexp diary entries.
-Each entry in diary-file (or included files) visible in the calendar window
+Each entry in the diary file (or included files) visible in the calendar window
 is marked.  See the documentation for the function `list-sexp-diary-entries'."
   (let* ((sexp-mark (regexp-quote sexp-diary-entry-symbol))
          (s-entry (concat "\\(\\`\\|\^M\\|\n\\)" sexp-mark "("))
@@ -641,13 +670,13 @@ is marked.  See the documentation for the function `list-sexp-diary-entries'."
                (calendar-gregorian-from-absolute date))))))))
 
 (defun mark-included-diary-files ()
-  "Mark the diary entries from other diary files with those of diary-file.
-This function is suitable for use as the mark-diary-entries-hook; it enables
+  "Mark the diary entries from other diary files with those of the diary file.
+This function is suitable for use as the `mark-diary-entries-hook'; it enables
 you to use shared diary files together with your own.  The files included are
-specified in the diary-file by lines of the form
+specified in the diary-file by lines of this form:
         #include \"filename\"
 This is recursive; that is, #include directives in diary files thus included
-are obeyed.  You can change the \"#include\" to some other string by
+are obeyed.  You can change the `#include' to some other string by
 changing the variable `diary-include-string'."
   (goto-char (point-min))
   (while (re-search-forward
@@ -695,7 +724,7 @@ changing the variable `diary-include-string'."
 
 (defun mark-calendar-date-pattern (month day year)
   "Mark all dates in the calendar window that conform to MONTH/DAY/YEAR.
-A value of 0 in any position is a wild-card."
+A value of 0 in any position is a wildcard."
   (save-excursion
     (set-buffer calendar-buffer)
     (let ((m displayed-month)
@@ -707,7 +736,7 @@ A value of 0 in any position is a wild-card."
 
 (defun mark-calendar-month (month year p-month p-day p-year)
   "Mark dates in the MONTH/YEAR that conform to pattern P-MONTH/P_DAY/P-YEAR.
-A value of 0 in any position of the pattern is a wild-card."
+A value of 0 in any position of the pattern is a wildcard."
   (if (or (and (= month p-month)
                (or (= p-year 0) (= year p-year)))
           (and (= p-month 0)
@@ -718,6 +747,10 @@ A value of 0 in any position of the pattern is a wild-card."
             (mark-visible-calendar-date (list month i year)))
         (mark-visible-calendar-date (list month p-day year)))))
 
+(defun sort-diary-entries ()
+  "Sort the list of diary entries by time of day."
+  (setq diary-entries-list (sort diary-entries-list 'diary-entry-compare)))
+
 (defun diary-entry-compare (e1 e2)
   "Returns t if E1 is earlier than E2."
   (or (calendar-date-compare e1 e2)
@@ -755,16 +788,16 @@ and XX:XXam or XX:XXpm."
         (t -9999)));; Unrecognizable
 
 (defun list-hebrew-diary-entries ()
-  "Add any Hebrew date entries from the diary-file to diary-entries-list.
-Hebrew date diary entries must be prefaced by a hebrew-diary-entry-symbol
-\(normally an `H'\).  The same diary-date-forms govern the style of the Hebrew
+  "Add any Hebrew date entries from the diary file to `diary-entries-list'.
+Hebrew date diary entries must be prefaced by `hebrew-diary-entry-symbol'
+(normally an `H').  The same diary date forms govern the style of the Hebrew
 calendar entries, except that the Hebrew month names must be spelled in full.
 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
 common Hebrew year.  If a Hebrew date diary entry begins with a
-diary-nonmarking-symbol the entry will appear in the diary listing, but will
+`diary-nonmarking-symbol', the entry will appear in the diary listing, but will
 not be marked in the calendar.  This function is provided for use with the
-nongregorian-diary-listing-hook."
+`nongregorian-diary-listing-hook'."
   (if (< 0 number)
       (let ((buffer-read-only nil)
             (diary-modified (buffer-modified-p))
@@ -841,7 +874,7 @@ nongregorian-diary-listing-hook."
   "Mark days in the calendar window that have Hebrew date diary entries.
 Each entry in diary-file (or included files) visible in the calendar window
 is marked.  Hebrew date entries are prefaced by a hebrew-diary-entry-symbol
-\(normally an `H'\).  The same diary-date-forms govern the style of the Hebrew
+(normally an `H').  The same diary-date-forms govern the style of the Hebrew
 calendar entries, except that the Hebrew month names must be spelled in full.
 The Hebrew months are numbered from 1 to 13 with Nisan being 1, 12 being
 Adar I and 13 being Adar II; you must use `Adar I' if you want Adar of a
@@ -947,8 +980,8 @@ is provided for use as part of the nongregorian-diary-marking-hook."
       (setq d (cdr d)))))
 
 (defun mark-hebrew-calendar-date-pattern (month day year)
-  "Mark all dates in the calendar window that conform to the Hebrew date
-MONTH/DAY/YEAR.  A value of 0 in any position is a wild-card."
+  "Mark dates in calendar window that conform to Hebrew date MONTH/DAY/YEAR.
+A value of 0 in any position is a wildcard."
   (save-excursion
     (set-buffer calendar-buffer)
     (if (and (/= 0 month) (/= 0 day))
@@ -1021,10 +1054,11 @@ MONTH/DAY/YEAR.  A value of 0 in any position is a wild-card."
                   (calendar-gregorian-from-absolute date)))))))))
 
 (defun list-sexp-diary-entries (date)
-  "Add any sexp entries for DATE from the diary-file to diary-entries-list
-and make them visible in the diary file.  Returns t if any entries were found.
+  "Add sexp entries for DATE from the diary file to `diary-entries-list'.
+Also, Make them visible in the diary file.  Returns t if any entries were
+found.
 
-Sexp diary entries must be prefaced by a sexp-diary-entry-symbol (normally
+Sexp diary entries must be prefaced by a `sexp-diary-entry-symbol' (normally
 `%%').  The form of a sexp diary entry is
 
                   %%(SEXP) ENTRY
@@ -1104,6 +1138,28 @@ A number of built-in functions are available for this type of diary entry:
                   made every day.  Note that since there is no text, it
                   makes sense only if the fancy diary display is used.
 
+      %%(diary-astro-day-number) Diary entries giving the corresponding
+                  astronomical (Julian) day number will be made every day.
+                  Note that since there is no text, it makes sense only if the
+                  fancy diary display is used.
+
+      %%(diary-julian-date) Diary entries giving the corresponding
+                 Julian date will be made every day.  Note that since
+                 there is no text, it makes sense only if the fancy diary
+                 display is used.
+
+      %%(diary-sunrise-sunset)
+                  Diary entries giving the local times of sunrise and sunset
+                  will be made every day.  Note that since there is no text,
+                  it makes sense only if the fancy diary display is used.
+                  Floating point required.
+
+      %%(diary-phases-of-moon)
+                  Diary entries giving the times of the phases of the moon
+                  will be when appropriate.  Note that since there is no text,
+                  it makes sense only if the fancy diary display is used.
+                  Floating point required.
+
       %%(diary-yahrzeit MONTH DAY YEAR) text
                   Text is assumed to be the name of the person; the date is
                   the date of death on the *civil* calendar.  The diary entry
@@ -1169,21 +1225,24 @@ best if they are nonmarking."
 
 (defun diary-sexp-entry (sexp entry date)
   "Process a SEXP diary ENTRY for DATE."
-  (let ((result (condition-case nil
-                    (eval (car (read-from-string sexp)))
-                  (error
-                   (beep)
-                   (message "Bad sexp at line %d in %s: %s"
-                            (save-excursion
-                              (save-restriction
-                                (narrow-to-region 1 (point))
-                                (goto-char (point-min))
-                                (let ((lines 1))
-                                  (while (re-search-forward "\n\\|\^M" nil t)
-                                    (setq lines (1+ lines)))
-                                  lines)))
-                            diary-file sexp)
-                   (sleep-for 2)))))
+  (let ((result (if calendar-debug-sexp
+                  (let ((stack-trace-on-error t))
+                    (eval (car (read-from-string sexp))))
+                  (condition-case nil
+                      (eval (car (read-from-string sexp)))
+                    (error
+                     (beep)
+                     (message "Bad sexp at line %d in %s: %s"
+                              (save-excursion
+                                (save-restriction
+                                  (narrow-to-region 1 (point))
+                                  (goto-char (point-min))
+                                  (let ((lines 1))
+                                    (while (re-search-forward "\n\\|\^M" nil t)
+                                      (setq lines (1+ lines)))
+                                    lines)))
+                              diary-file sexp)
+                     (sleep-for 2))))))
     (if (stringp result)
         result
       (if result
@@ -1191,8 +1250,9 @@ best if they are nonmarking."
         nil))))
 
 (defun diary-block (m1 d1 y1 m2 d2 y2)
-  "Block diary entry--entry applies if date is between two dates.  Order of
-the parameters is M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
+  "Block diary entry.
+Entry applies if date is between two dates.  Order of the parameters is
+M1, D1, Y1, M2, D2, Y2 `european-calendar-style' is nil, and
 D1, M1, Y1, D2, M2, Y2 if `european-calendar-style' is t."
   (let ((date1 (calendar-absolute-from-gregorian
                 (if european-calendar-style
@@ -1221,9 +1281,10 @@ backward from the end of the month."
         entry)))
 
 (defun diary-anniversary (month day year)
-  "Anniversary diary entry--entry applies if date is the anniversary of
-MONTH, DAY, YEAR if `european-calendar-style' is nil, and DAY, MONTH, YEAR
-if `european-calendar-style' is t.  Diary entry can contain `%d' or `%d%s'; the
+  "Anniversary diary entry.
+Entry applies if date is the anniversary of MONTH, DAY, YEAR if
+`european-calendar-style' is nil, and DAY, MONTH, YEAR if
+`european-calendar-style' is t.  Diary entry can contain `%d' or `%d%s'; the
 %d will be replaced by the number of years since the MONTH DAY, YEAR and the
 %s will be replaced by the ordinal ending of that number (that is, `st', `nd',
 `rd' or `th', as appropriate.  The anniversary of February 29 is considered
@@ -1288,52 +1349,39 @@ ending of that number (that is, `st', `nd', `rd' or `th', as appropriate."
 
 (defun diary-islamic-date ()
   "Islamic calendar equivalent of date diary entry."
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname " " year)
-            '(monthname " " day ", " year)))
-         (i-date (calendar-islamic-from-absolute
+  (let* ((i-date (calendar-islamic-from-absolute
                   (calendar-absolute-from-gregorian date)))
          (calendar-month-name-array calendar-islamic-month-name-array))
     (if (>= (extract-calendar-year i-date) 1)
-        (format "Islamic date: %s" (calendar-date-string i-date)))))
+        (format "Islamic date: %s" (calendar-date-string i-date nil t)))))
 
 (defun diary-hebrew-date ()
   "Hebrew calendar equivalent of date diary entry."
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname " " year)
-            '(monthname " " day ", " year)))
-         (h-date (calendar-hebrew-from-absolute
+  (let* ((h-date (calendar-hebrew-from-absolute
                   (calendar-absolute-from-gregorian date)))
          (calendar-month-name-array
           (if (hebrew-calendar-leap-year-p
                (extract-calendar-year h-date))
               calendar-hebrew-month-name-array-leap-year
             calendar-hebrew-month-name-array-common-year)))
-    (format "Hebrew date: %s" (calendar-date-string h-date))))
+    (format "Hebrew date: %s" (calendar-date-string h-date nil t))))
 
-(defun diary-french-date ()
-  "French calendar equivalent of date diary entry."
-  (let* ((french-date (calendar-french-from-absolute
-                       (calendar-absolute-from-gregorian date)))
-         (y (extract-calendar-year french-date))
-         (m (extract-calendar-month french-date))
-         (d (extract-calendar-day french-date)))
-    (if (> y 0)
-      (if (= m 13)
-          (format "Jour %s de l'Annee %d de la Revolution"
-                   (aref french-calendar-special-days-array (1- d))
-                   y)
-        (format "Decade %s, %s de %s de l'Annee %d de la Revolution"
-                 (make-string (1+ (/ (1- d) 10)) ?I)
-                 (aref french-calendar-day-name-array (% (1- d) 10))
-                 (aref french-calendar-month-name-array (1- m))
-                 y)))))
+(defun diary-julian-date ()
+  "Julian calendar equivalent of date diary entry."
+  (format "Julian date: %s"
+          (calendar-date-string
+           (calendar-julian-from-absolute
+            (calendar-absolute-from-gregorian date)))
+          nil t))
+
+(defun diary-astro-day-number ()
+  "Astronomical (Julian) day number diary entry."
+  (format "Astronomical (Julian) day number %d"
+          (+ 1721425 (calendar-absolute-from-gregorian date))))
 
 (defun diary-omer ()
-  "Omer count diary entry--entry applies if date is within 50 days after
-Passover."
+  "Omer count diary entry.
+Entry applies if date is within 50 days after Passover."
   (let* ((passover
           (calendar-absolute-from-hebrew
            (list 1 15 (+ (extract-calendar-year date) 3760))))
@@ -1358,7 +1406,7 @@ Passover."
 Parameters are DEATH-MONTH, DEATH-DAY, DEATH-YEAR; the diary entry is assumed
 to be the name of the person.  Date of death is on the *civil* calendar;
 although the date of death is specified by the civil calendar, the proper
-Hebrew calendar yahrzeit is determined.  If european-calendar-style is t, the
+Hebrew calendar yahrzeit is determined.  If `european-calendar-style' is t, the
 order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR."
   (let* ((h-date (calendar-hebrew-from-absolute
                   (calendar-absolute-from-gregorian
@@ -1383,8 +1431,8 @@ order of the parameters is changed to DEATH-DAY, DEATH-MONTH, DEATH-YEAR."
                       (t "th"))))))
 
 (defun diary-rosh-hodesh ()
-  "Rosh Hodesh diary entry--entry applies if date is Rosh Hodesh, the day
-before, or the Saturday before."
+  "Rosh Hodesh diary entry.
+Entry applies if date is Rosh Hodesh, the day before, or the Saturday before."
   (let* ((d (calendar-absolute-from-gregorian date))
          (h-date (calendar-hebrew-from-absolute d))
          (h-month (extract-calendar-month h-date))
@@ -1412,7 +1460,7 @@ before, or the Saturday before."
            (if (= h-yesterday 30)
                (format "%s (second day)" this-month)
              this-month)))
-      (if (= (mod d 7) 6);; Saturday--check for Shabbat Mevarhim
+      (if (= (% d 7) 6);; Saturday--check for Shabbat Mevarhim
           (cond ((and (> h-day 22) (/= h-month 6) (= 29 last-day))
                  (format "Mevarhim Rosh Hodesh %s (%s)"
                          (aref h-month-names
@@ -1428,7 +1476,7 @@ before, or the Saturday before."
                              "tomorrow"
                            (aref calendar-day-name-array (- 29 h-day)))
                          (aref calendar-day-name-array
-                               (mod (- 30 h-day) 7)))))
+                               (% (- 30 h-day) 7)))))
         (if (and (= h-day 29) (/= h-month 6))
             (format "Erev Rosh Hodesh %s"
                     (aref h-month-names
@@ -1479,13 +1527,13 @@ before, or the Saturday before."
                  (hebrew-calendar-parasha-name parasha))))))))
 
 (defun add-to-diary-list (date string)
-  "Add the entry (DATE STRING) to the diary-entries-list.
+  "Add the entry (DATE STRING) to `diary-entries-list'.
 Do nothing if DATE or STRING is nil."
   (and date string
        (setq diary-entries-list 
              (append diary-entries-list (list (list date string))))))
 
-(defconst hebrew-calendar-parashiot-names
+(defvar hebrew-calendar-parashiot-names
 ["Bereshith"   "Noah"      "Lech L'cha" "Vayera"    "Hayei Sarah" "Toledoth"
  "Vayetze"     "Vayishlah" "Vayeshev"   "Mikketz"   "Vayiggash"   "Vayhi"
  "Shemoth"     "Vaera"     "Bo"         "Beshallah" "Yithro"      "Mishpatim"
@@ -1503,58 +1551,58 @@ Do nothing if DATE or STRING is nil."
   [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
     23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
     43 44 45 46 47 48 49 50]
-  "The structure of the parashiot in a Hebrew year that starts on Saturday,
-is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
-start on Sunday.")
+  "The structure of the parashiot.
+Hebrew year starts on Saturday, is `incomplete' (Heshvan and Kislev each have
+29 days), and has Passover start on Sunday.")
 
 (defconst hebrew-calendar-year-Saturday-complete-Tuesday
   [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
     23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
     43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Saturday,
-is `complete' (Heshvan and Kislev each have 30 days), and has Passover
-start on Tuesday.")
+  "The structure of the parashiot.
+Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
+have 30 days), and has Passover start on Tuesday.")
 
 (defconst hebrew-calendar-year-Monday-incomplete-Tuesday
   [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
     23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
     43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Monday,
-is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
-start on Tuesday.")
+  "The structure of the parashiot.
+Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
+have 29 days), and has Passover start on Tuesday.")
 
 (defconst hebrew-calendar-year-Monday-complete-Thursday
   [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
-   23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34.35) (35.36)
-   (36.37) (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Monday,
-is `complete' (Heshvan and Kislev each have 30 days), and has Passover
-start on Thursday.")
+   23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34 . 35) (35 . 36)
+   (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
+  "The structure of the parashiot.
+Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
+30 days), and has Passover start on Thursday.")
 
 (defconst hebrew-calendar-year-Tuesday-regular-Thursday
   [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
-   23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34.35) (35.36)
-   (36.37) (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Tuesday,
-is `regular' (Heshvan has 29 days and Kislev has 30 days), and has Passover
-start on Thursday.")
+   23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 (nil . 34) (34 . 35) (35 . 36)
+   (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
+  "The structure of the parashiot.
+Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
+Kislev has 30 days), and has Passover start on Thursday.")
 
 (defconst hebrew-calendar-year-Thursday-regular-Saturday
-  [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22]
-   23 24 nil (nil . 25) (25.[26 27]) ([26 27].[28 29]) ([28 29].30) (30.31)
-   ([31 32].32) 33 34 35 36 37 38 39 40 [41 42]
-    43 44 45 46 47 48 49 50]
-  "The structure of the parashiot in a Hebrew year that starts on Thursday,
-is `regular' (Heshvan has 29 days and Kislev has 30 days), and has Passover
-start on Saturday.")
+  [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [21 22] 23
+   24 nil (nil . 25) (25 . [26 27]) ([26 27] . [28 29]) ([28 29] . 30)
+   (30 . 31) ([31 32] . 32) 33 34 35 36 37 38 39 40 [41 42] 43 44 45 46 47 48
+   49 50]
+  "The structure of the parashiot.
+Hebrew year that starts on Thursday, is `regular' (Heshvan has 29 days and
+Kislev has 30 days), and has Passover start on Saturday.")
 
 (defconst hebrew-calendar-year-Thursday-complete-Sunday
   [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
     23 24 nil 25 [26 27] [28 29] 30 [31 32] 33 34 35 36 37 38 39 40 [41 42]
     43 44 45 46 47 48 49 50]
-  "The structure of the parashiot in a Hebrew year that starts on Thursday,
-is `complete' (Heshvan and Kislev each have 30 days), and has Passover
-start on Sunday.")
+  "The structure of the parashiot.
+Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev each
+have 30 days), and has Passover start on Sunday.")
 
 ;; The seven leap year types (keviot)
 
@@ -1562,59 +1610,59 @@ start on Sunday.")
   [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
     23 24 25 26 27 nil 28 29 30 31 32 33 34 35 36 37 38 39 40 [41 42]
     43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Saturday,
-is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
-start on Tuesday.")
+  "The structure of the parashiot.
+Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev each
+have 29 days), and has Passover start on Tuesday.")
 
 (defconst hebrew-calendar-year-Saturday-complete-Thursday
   [nil 52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
-   23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34.35) (35.36) (36.37)
-   (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Saturday,
-is `complete' (Heshvan and Kislev each have 30 days), and has Passover
-start on Thursday.")
+   23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34 . 35) (35 . 36)
+   (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
+  "The structure of the parashiot.
+Hebrew year that starts on Saturday, is `complete' (Heshvan and Kislev each
+have 30 days), and has Passover start on Thursday.")
 
 (defconst hebrew-calendar-year-Monday-incomplete-Thursday
   [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
-   23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34.35) (35.36) (36.37)
-  (37.38) ([38 39].39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Monday,
-is `incomplete' (Heshvan and Kislev each have 29 days), and has Passover
-start on Thursday.")
+   23 24 25 26 27 nil 28 29 30 31 32 33 (nil . 34) (34 . 35) (35 . 36)
+   (36 . 37) (37 . 38) ([38 39] . 39) 40 [41 42] 43 44 45 46 47 48 49 [50 51]]
+  "The structure of the parashiot.
+Hebrew year that starts on Monday, is `incomplete' (Heshvan and Kislev each
+have 29 days), and has Passover start on Thursday.")
 
 (defconst hebrew-calendar-year-Monday-complete-Saturday
   [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
-   23 24 25 26 27 nil (nil . 28) (28.29) (29.30) (30.31) (31.32) (32.33)
-   (33.34) (34.35) (35.36) (36.37) (37.38) (38.39) (39.40) (40.41) ([41 42].42)
-   43 44 45 46 47 48 49 50]
-  "The structure of the parashiot in a Hebrew year that starts on Monday,
-is `complete' (Heshvan and Kislev each have 30 days), and has Passover
-start on Saturday.")
+   23 24 25 26 27 nil (nil . 28) (28 . 29) (29 . 30) (30 . 31) (31 . 32)
+   (32 . 33) (33 . 34) (34 . 35) (35 . 36) (36 . 37) (37 . 38) (38 . 39)
+   (39 . 40) (40 . 41) ([41 42] . 42) 43 44 45 46 47 48 49 50]
+  "The structure of the parashiot.
+Hebrew year that starts on Monday, is `complete' (Heshvan and Kislev each have
+30 days), and has Passover start on Saturday.")
 
 (defconst hebrew-calendar-year-Tuesday-regular-Saturday
   [51 52 nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
-   23 24 25 26 27 nil (nil . 28) (28.29) (29.30) (30.31) (31.32) (32.33)
-   (33.34) (34.35) (35.36) (36.37) (37.38) (38.39) (39.40) (40.41) ([41 42].42)
-   43 44 45 46 47 48 49 50]
-  "The structure of the parashiot in a Hebrew year that starts on Tuesday,
-is `regular' (Heshvan has 29 days and Kislev has 30 days), and has Passover
-start on Saturday.")
+   23 24 25 26 27 nil (nil . 28) (28 . 29) (29 . 30) (30 . 31) (31 . 32)
+   (32 . 33) (33 . 34) (34 . 35) (35 . 36) (36 . 37) (37 . 38) (38 . 39)
+   (39 . 40) (40 . 41) ([41 42] . 42) 43 44 45 46 47 48 49 50]
+  "The structure of the parashiot.
+Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29 days and
+Kislev has 30 days), and has Passover start on Saturday.")
 
 (defconst hebrew-calendar-year-Thursday-incomplete-Sunday
   [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
     23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
     43 44 45 46 47 48 49 50]
-  "The structure of the parashiot in a Hebrew year that starts on Thursday,
-is `incomplete' (Heshvan and Kislev both have 29 days), and has Passover
-start on Sunday.")
+  "The structure of the parashiot.
+Hebrew year that starts on Thursday, is `incomplete' (Heshvan and Kislev both
+have 29 days), and has Passover start on Sunday.")
 
 (defconst hebrew-calendar-year-Thursday-complete-Tuesday
   [52 nil nil 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
     23 24 25 26 27 28 nil 29 30 31 32 33 34 35 36 37 38 39 40 41 42
     43 44 45 46 47 48 49 [50 51]]
-  "The structure of the parashiot in a Hebrew year that starts on Thursday,
-is `complete' (Heshvan and Kislev both have 30 days), and has Passover
-start on Tuesday.")
+  "The structure of the parashiot.
+Hebrew year that starts on Thursday, is `complete' (Heshvan and Kislev both
+have 30 days), and has Passover start on Tuesday.")
 
 (defun hebrew-calendar-parasha-name (p)
   "Name(s) corresponding to parasha P."
@@ -1625,15 +1673,15 @@ start on Tuesday.")
     (aref hebrew-calendar-parashiot-names p)))
 
 (defun list-islamic-diary-entries ()
-  "Add any Islamic date entries from the diary-file to diary-entries-list.
-Islamic date diary entries must be prefaced by an islamic-diary-entry-symbol
-\(normally an `I'\).  The same diary-date-forms govern the style of the Islamic
+  "Add any Islamic date entries from the diary file to `diary-entries-list'.
+Islamic date diary entries must be prefaced by an `islamic-diary-entry-symbol'
+(normally an `I').  The same diary date forms govern the style of the Islamic
 calendar entries, except that the Islamic month names must be spelled in full.
 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
 Dhu al-Hijjah.  If an Islamic date diary entry begins with a
-diary-nonmarking-symbol the entry will appear in the diary listing, but will
+`diary-nonmarking-symbol', the entry will appear in the diary listing, but will
 not be marked in the calendar.  This function is provided for use with the
-nongregorian-diary-listing-hook."
+`nongregorian-diary-listing-hook'."
   (if (< 0 number)
       (let ((buffer-read-only nil)
             (diary-modified (buffer-modified-p))
@@ -1710,7 +1758,7 @@ nongregorian-diary-listing-hook."
   "Mark days in the calendar window that have Islamic date diary entries.
 Each entry in diary-file (or included files) visible in the calendar window
 is marked.  Islamic date entries are prefaced by a islamic-diary-entry-symbol
-\(normally an `I'\).  The same diary-date-forms govern the style of the Islamic
+(normally an `I').  The same diary-date-forms govern the style of the Islamic
 calendar entries, except that the Islamic month names must be spelled in full.
 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
 Dhu al-Hijjah.  Islamic date diary entries that begin with a
@@ -1813,8 +1861,8 @@ provided for use as part of the nongregorian-diary-marking-hook."
       (setq d (cdr d)))))
 
 (defun mark-islamic-calendar-date-pattern (month day year)
-  "Mark all dates in the calendar window that conform to the Islamic date
-MONTH/DAY/YEAR.  A value of 0 in any position is a wild-card."
+  "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR.
+A value of 0 in any position is a wildcard."
   (save-excursion
     (set-buffer calendar-buffer)
     (if (and (/= 0 month) (/= 0 day))
@@ -1870,246 +1918,6 @@ MONTH/DAY/YEAR.  A value of 0 in any position is a wild-card."
                  (mark-visible-calendar-date
                   (calendar-gregorian-from-absolute date)))))))))
 
-(defun make-diary-entry (string &optional nonmarking file)
-  "Insert a diary entry STRING which may be NONMARKING in FILE.
-If omitted, NONMARKING defaults to nil and FILE defaults to diary-file."
-  (find-file-other-window
-   (substitute-in-file-name (if file file diary-file)))
-  (goto-char (point-max))
-  (insert
-   (if (bolp) "" "\n")
-   (if nonmarking diary-nonmarking-symbol "")
-   string " "))
-
-(defun insert-diary-entry (arg)
-  "Insert a diary entry for the date indicated by point.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname " " year)
-            '(monthname " " day ", " year))))
-    (make-diary-entry
-     (calendar-date-string
-      (or (calendar-cursor-to-date)
-          (error "Cursor is not on a date!"))
-      t)
-     arg)))
-
-(defun insert-weekly-diary-entry (arg)
-  "Insert a weekly diary entry for the day of the week indicated by point.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (make-diary-entry
-   (calendar-day-name
-    (or (calendar-cursor-to-date)
-        (error "Cursor is not on a date!")))
-   arg))
-
-(defun insert-monthly-diary-entry (arg)
-  "Insert a monthly diary entry for the day of the month indicated by point.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " * ")
-            '("* " day))))
-    (make-diary-entry
-     (calendar-date-string
-      (or (calendar-cursor-to-date)
-          (error "Cursor is not on a date!"))
-      t)
-     arg)))
-
-(defun insert-yearly-diary-entry (arg)
-  "Insert an annual diary entry for the day of the year indicated by point.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname)
-            '(monthname " " day))))
-    (make-diary-entry
-     (calendar-date-string
-      (or (calendar-cursor-to-date)
-          (error "Cursor is not on a date!"))
-      t)
-     arg)))
-
-(defun insert-anniversary-diary-entry (arg)
-  "Insert an anniversary diary entry for the date given by point.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " month " " year)
-            '(month " " day " " year))))
-    (make-diary-entry
-     (format "%s(diary-anniversary %s)"
-             sexp-diary-entry-symbol
-             (calendar-date-string
-              (or (calendar-cursor-to-date)
-                  (error "Cursor is not on a date!"))))
-     arg)))
-
-(defun insert-block-diary-entry (arg)
-  "Insert a block diary entry for the days between the point and marked date.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " month " " year)
-            '(month " " day " " year)))
-         (cursor (or (calendar-cursor-to-date)
-                     (error "Cursor is not on a date!")))
-         (mark (or (car calendar-mark-ring)
-                   (error "No mark set in this buffer")))
-         (start)
-         (end))
-    (if (< (calendar-absolute-from-gregorian mark)
-           (calendar-absolute-from-gregorian cursor))
-        (setq start mark
-              end cursor)
-      (setq start cursor
-              end mark))
-    (make-diary-entry
-     (format "%s(diary-block %s %s)"
-      sexp-diary-entry-symbol
-      (calendar-date-string start)
-      (calendar-date-string end))
-     arg)))
-
-(defun insert-cyclic-diary-entry (arg)
-  "Insert a cyclic diary entry starting at the date given by point.
-Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " month " " year)
-            '(month " " day " " year))))
-    (make-diary-entry
-     (format "%s(diary-cyclic %d %s)"
-             sexp-diary-entry-symbol
-             (calendar-read "Repeat every how many days: "
-                            '(lambda (x) (> x 0)))
-             (calendar-date-string
-              (or (calendar-cursor-to-date)
-                  (error "Cursor is not on a date!"))))
-     arg)))
-
-(defun insert-hebrew-diary-entry (arg)
-  "Insert a diary entry for the Hebrew date corresponding to the date
-indicated by point.  Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname " " year)
-            '(monthname " " day ", " year)))
-         (calendar-month-name-array
-          calendar-hebrew-month-name-array-leap-year))
-    (make-diary-entry
-     (concat
-      hebrew-diary-entry-symbol
-      (calendar-date-string 
-       (calendar-hebrew-from-absolute
-        (calendar-absolute-from-gregorian
-         (or (calendar-cursor-to-date)
-             (error "Cursor is not on a date!"))))))
-     arg)))
-
-(defun insert-monthly-hebrew-diary-entry (arg)
-  "Insert a monthly diary entry for the day of the Hebrew month corresponding
-to the date indicated by point.  Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style '(day " * ") '("* " day )))
-         (calendar-month-name-array
-          calendar-hebrew-month-name-array-leap-year))
-    (make-diary-entry
-     (concat
-      hebrew-diary-entry-symbol
-      (calendar-date-string 
-       (calendar-hebrew-from-absolute
-        (calendar-absolute-from-gregorian
-         (or (calendar-cursor-to-date)
-             (error "Cursor is not on a date!"))))))
-     arg)))
-
-(defun insert-yearly-hebrew-diary-entry (arg)
-  "Insert an annual diary entry for the day of the Hebrew year corresponding
-to the date indicated by point.  Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname)
-            '(monthname " " day)))
-         (calendar-month-name-array
-          calendar-hebrew-month-name-array-leap-year))
-    (make-diary-entry
-     (concat
-      hebrew-diary-entry-symbol
-      (calendar-date-string 
-       (calendar-hebrew-from-absolute
-        (calendar-absolute-from-gregorian
-         (or (calendar-cursor-to-date)
-             (error "Cursor is not on a date!"))))))
-     arg)))
-
-(defun insert-islamic-diary-entry (arg)
-  "Insert a diary entry for the Islamic date corresponding to the date
-indicated by point.  Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname " " year)
-            '(monthname " " day ", " year)))
-         (calendar-month-name-array calendar-islamic-month-name-array))
-    (make-diary-entry
-     (concat
-      islamic-diary-entry-symbol
-      (calendar-date-string 
-       (calendar-islamic-from-absolute
-        (calendar-absolute-from-gregorian
-         (or (calendar-cursor-to-date)
-             (error "Cursor is not on a date!"))))))
-     arg)))
-
-(defun insert-monthly-islamic-diary-entry (arg)
-  "Insert a monthly diary entry for the day of the Islamic month corresponding
-to the date indicated by point.  Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style '(day " * ") '("* " day )))
-         (calendar-month-name-array calendar-islamic-month-name-array))
-    (make-diary-entry
-     (concat
-      islamic-diary-entry-symbol
-      (calendar-date-string 
-       (calendar-islamic-from-absolute
-        (calendar-absolute-from-gregorian
-         (or (calendar-cursor-to-date)
-             (error "Cursor is not on a date!"))))))
-     arg)))
-
-(defun insert-yearly-islamic-diary-entry (arg)
-  "Insert an annual diary entry for the day of the Islamic year corresponding
-to the date indicated by point.  Prefix arg will make the entry nonmarking."
-  (interactive "P")
-  (let* ((calendar-date-display-form
-          (if european-calendar-style
-              '(day " " monthname)
-            '(monthname " " day)))
-         (calendar-month-name-array calendar-islamic-month-name-array))
-    (make-diary-entry
-     (concat
-      islamic-diary-entry-symbol
-      (calendar-date-string 
-       (calendar-islamic-from-absolute
-        (calendar-absolute-from-gregorian
-         (or (calendar-cursor-to-date)
-             (error "Cursor is not on a date!"))))))
-     arg)))
-
 (provide 'diary)
 
 ;;; diary.el ends here