Commits

Anonymous committed 061291d

Synch with Emacs 20.5. Patch from Jeff Miller
with reference <14421.56401.875222.386264@max3p117.smart.net>.

  • Participants
  • Parent commits f892650

Comments (0)

Files changed (21)

+1999-12-13  Jeff Miller  <jmiller@smart.net>
+
+	This info is pulled from the Emacs 20.4/5 lisp/ChangeLog
+
+	* cal-dst.el: update Synched with to 20.4/5, no other change
+	  cal-iso.el: ditto
+	  holidays.el: ditto
+	  lunar.el:   ditto
+	  solar.el:   ditto
+
+	* calendar.el (redraw-calendar): Move to nearest date before
+	redrawing.
+
+	* diary-lib.el (list-diary-entries): Make sure two-digit years
+	have leading zeros.
+
+	* diary-lib.el (simple-diary-display): Reset modeline even if
+	there are no diary entries since the diary buffer may be displayed.
+
+	* calendar/cal-x.el (special-display-buffer-names):
+	Don't put (get-file-buffer diary-file) on this list.
+
+        * cal-x.el (calendar-only-one-frame-setup): New function.
+        * calendar.el (calendar): Call it if requested.
+
+	* calendar/calendar.el (calendar-mode-map): Fix bindings for
+        appt-add and appt-delete.
+
+ 	* cal-x.el (diary-frame-parameters, calendar-frame-parameters,
+        calendar-and-diary-frame-parameters):  Add title parameter.
+
+        * calendar/calendar.el (calendar-day-name-array): Add doc string.
+        (calendar-month-name-array): Add doc string.
+
+        * cal-china.el (chinese-year-cache): Change range of years from
+        1989-2000 to 1990-2010.
+
+        * calendar/cal-tex.el (cal-tex-cursor-filofax-daily): Don't use oddp.
+
+        * appt.el (appt-max-time): Renamed from max-time.
+
+	* calendar/diary-lib.el (mark-diary-entries): Use
+        assoc-ignore-case and do not capitalize when matching month and
+        day names.
+        * calendar/calendar.el (calendar-read-date): Ditto.
+        * calendar/cal-hebrew.el (calendar-goto-hebrew-date)
+        (mark-hebrew-diary-entries, list-yahrzeit-dates): Ditto.
+        * calendar/cal-coptic.el (coptic-prompt-for-date): Ditto.
+        * calendar/cal-french.el (calendar-goto-french-date): Ditto.
+        * calendar/cal-islam.el (calendar-goto-islamic-date)
+        (mark-islamic-diary-entries): Ditto.
+        * calendar/cal-julian.el (calendar-goto-julian-date): Ditto.
+        * calendar/cal-mayan.el (calendar-read-mayan-haab-date)
+        (calendar-read-mayan-tzolkin-date): Ditto.
+        * calendar/cal-persia.el (persian-prompt-for-date): Ditto.
+
+	* calendar/cal-move.el (scroll-calendar-left): Don't set
+        displayed-month and displayed-year here, let generate-calendar do
+        it, after range checking.
+
+        * calendar/diary-lib.el (mark-sexp-diary-entries): Avoid infinite
+        loop when sexp entry ends at end of file with no newline.
+        * diary-lib.el (diary-float): Fix end-of-year error and typos in
+        comments.
+        * diary-lib.el (diary-remind): Rewritten to behave sensibly for
+        diary-block diary entries for which the reminders and the diary
+        entries can overlap.
+
 1999-11-11  Andreas Jaeger  <aj@suse.de>
 
 	* calendar.el (calendar-string-spread): Check that string-width is
 ;;; appt.el --- appointment notification functions.
 ;; Keywords: calendar
 
-;; Copyright (C) 1989, 1990, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1990, 1994, 1998 Free Software Foundation, Inc.
 
 ;; Author: Neil Mager <neilm@juliet.ll.mit.edu>
 ;; Maintainer: FSF
 
 ;;
 ;; appt.el - visible and/or audible notification of
-;;           appointments from ~/diary file generated from
-;;           Edward M. Reingold's calendar.el.
+;;           appointments from ~/diary file.
 ;;
 ;; Version 2.1
 ;;
 ;;; ******* It is necessary to invoke 'display-time' and ********
 ;;; ******* 'appt-initialize' for this to work properly. ********
 ;;; 
-;;; A message will be displayed in the mode line of the emacs buffer 
-;;; and (if the user desires) the terminal will beep and display a message 
-;;; from the diary in the mini-buffer, or the user may select to 
+;;; A message will be displayed in the mode line of the Emacs buffer 
+;;; and (if you request) the terminal will beep and display a message 
+;;; from the diary in the mini-buffer, or you can choose to 
 ;;; have a message displayed in a new buffer.
 ;;;
 ;;; Variables of note:
 ;;; 
 ;;; Based upon the above lines in your .emacs and diary files, 
 ;;; the calendar and diary will be displayed when you enter
-;;; emacs and your appointments list will automatically be created.  
+;;; Emacs and your appointments list will automatically be created.  
 ;;; You will then be reminded at 9:20am about your coffee break 
 ;;; and at 11:50am to go to lunch.
 ;;;
 ;;; Meta-x appt-add and Meta-x appt-delete.  (This does not modify your 
 ;;; diary file, so these will be forgotten when you exit emacs.)
 ;;;
-;;; Additionally, the appointments list is recreated automatically at 12:01am 
-;;; for those who do not logout every day or are programming late.
+;;;  Additionally, the appointments list is recreated automatically 
+;;;  at 12:01am for those who do not logout every day or are programming 
+;;;  late.
 ;;;
 ;;; You can have special appointments which execute arbitrary code rather than
 ;;; simply notifying you -- sort of like the unix "cron" facility.  The syntax
   :type 'boolean
   :group 'appt)
 
+;;;###autoload
 (defcustom appt-display-duration 10
   "*The number of seconds an appointment message is displayed in its own 
  window if appt-announce-method is 'appt-window-announce."
 The original list is generated from the today's `diary-entries-list'. 
 The number before each time/message is the time in minutes from midnight.")
 
-(defconst max-time 1439
+(defconst appt-max-time 1439
   "11:59pm in minutes - number of minutes in a day minus 1.")
 
 (defconst appt-check-tick -1)
       (message "%s" str))
     ))
 
-
+(defvar appt-buffer-name " *appt-buf*"
+  "Name of the appointments buffer.")
 
 (defvar appt-frame-defaults nil)
 (defvaralias 'appt-screen-defaults 'appt-frame-defaults)
 	  ((= n 1) (message "1 appointment today."))
 	  (t (message "%d appointments today." n)))))
 
-(defvar appt-buffer-name " *appt-buf*"
-  "Name of the appointments buffer.")
 
 (defun appt-beep (&optional final-p)
   (cond ((null appt-audible) nil)
               Thursday
                 11:45am Lunch meeting.
   
- The following variables control the action of the notification:
+The following variables control appointment notification:
  
 `appt-issue-message'
        If t, the diary buffer is checked for appointments.
 		 (cur-min (nth 1 now))
 		 (cur-comp-time (+ (* cur-hour 60) cur-min))
 
+	       ;; At the first check in any given day, update our 
+	       ;; appointments to today's list.
+
 	    ;; If the current time is the same as the tick, just return.
 	    ;; This means that this function has been called more than once
 	    ;; in the current minute, which is not useful.
        ;; today's list.  Show the diary entries (tjc).
        (if turnover-p (diary 1))
        ;;
-       ;; Get the first time off of the list and calculate the number
-       ;; of minutes until the appointment.
+	  ;; If there are entries in the list, and the
+	  ;; user wants a message issued,
+	  ;; get the first time off of the list 
+	  ;; and calculate the number of minutes until the appointment.
+
        (if (and appt-issue-message appt-time-msg-list)
 	   (let ((appt-comp-time (car (car (car appt-time-msg-list)))))
 	     (setq min-to-app (- appt-comp-time cur-comp-time))
 		   (setq appt-comp-time 
 			 (car (car (car appt-time-msg-list))))))
 	     ;;
-	     ;; If we have an appointment between midnight and warning-time
-	     ;; minutes after midnight, we must begin to issue a message
-	     ;; before midnight.  Midnight is considered 0 minutes and 11:59pm
-	     ;; is 1439 minutes. Therefore we must recalculate the minutes to
-	     ;; appointment variable. It is equal to the number of minutes
-	     ;; before midnight plus the number of minutes after midnight our
-	     ;; appointment is.
-	     ;;
-	     ;; ## I don't think this does anything -- it would if it were
-	     ;; (for example) a 12:01am appt on the list at 11:55pm, but that
-	     ;; can't ever happen, because the applicable 12:01am appt is for
-	     ;; tomorrow, not today, and we only have today's diary list.
-	     ;; It's not simply a matter of concatenating two days together,
-	     ;; either, because then tuesday's appts would be signalled on
-	     ;; monday.  We have to do a real one-day lookahead -- keep a list
-	     ;; of tomorrow's appts, and check it when near midnight.
-	     ;;
-	     (if (and (< appt-comp-time (apply 'max appt-msg-countdown-list))
-		      (> (+ cur-comp-time (apply 'max appt-msg-countdown-list))
-			 max-time))
-		 (setq min-to-app (+ (- (1+ max-time) cur-comp-time))
+		;; If we have an appointment between midnight and
+		;; warning-time minutes after midnight, we must begin
+		;; to issue a message before midnight.  Midnight is
+		;; considered 0 minutes and 11:59pm is 1439
+		;; minutes. Therefore we must recalculate the minutes
+		;; to appointment variable. It is equal to the number
+		;; of minutes before midnight plus the number of
+		;; minutes after midnight our appointment is.
+		;;
+		;; ## I don't think this does anything -- it would if
+		;; it were (for example) a 12:01am appt on the list at
+		;; 11:55pm, but that can't ever happen, because the
+		;; applicable 12:01am appt is for tomorrow, not today,
+		;; and we only have today's diary list.  It's not
+		;; simply a matter of concatenating two days together,
+		;; either, because then tuesday's appts would be
+		;; signalled on monday.  We have to do a real one-day
+		;; lookahead -- keep a list of tomorrow's appts, and
+		;; check it when near midnight.
+		;;
+		(if (and (< appt-comp-time 
+			    (apply 'max appt-msg-countdown-list))
+			 (> (+ cur-comp-time 
+			       (apply 'max appt-msg-countdown-list))
+			    appt-max-time))
+		    (setq min-to-app (+ (- (1+ appt-max-time) cur-comp-time))
 		       appt-comp-time))
 	     ;;
 	     ;; issue warning if the appointment time is within warning-time
 			 (car appt-time-msg-list))
 		;; update mode line and expire if necessary
 		(appt-display-mode-line min-to-app)
-		;; if it's expired, remove it.
+		  ;; When an appointment is reached,
+		  ;; delete it from the list.
+		  ;; Reset the count to 0 in case we display another
+		  ;; appointment on the next cycle.
 		(if (= min-to-app 0)
 		    (setq appt-time-msg-list 
-			  (cdr appt-time-msg-list))))
+			    (cdr appt-time-msg-list)
+			    )))
 	       (t
 		;; else we're not near any appointment, or there are no
 		;; apointments; make sure mode line is clear.
 		 ") %-"))
 	     (pop-to-buffer appt-disp-buf)
 	     (insert (car (cdr appt)))
-	     (shrink-window-if-larger-than-buffer
-	       (get-buffer-window appt-disp-buf))
+	      (shrink-window-if-larger-than-buffer (get-buffer-window appt-disp-buf))
 	     (set-buffer-modified-p nil)
 	     (sit-for appt-display-duration))
 	(and appt-disp-buf (kill-buffer appt-disp-buf)))))))
 ;;;###autoload
 (defun appt-make-list ()
   "Don't call this directly; call appt-initialize or appt-diary-entries."
+  ;; Clear the appointments list, then fill it in from the diary.
   (setq appt-time-msg-list nil)
   (if diary-entries-list
 
            ;; appt-time-msg-list. Then sort the list.
 
       (let ((entry-list diary-entries-list)
-	    (new-appts '()))
+	    (new-appts '())
+	    (new-time-string ""))
+	;; Skip diary entries for dates before today.
+	(while (and entry-list
+		    (calendar-date-compare
+		     (car entry-list) (list (calendar-current-date))))
+	  (setq entry-list (cdr entry-list)))
+	;; Parse the entries for today.
 	(while (and entry-list
 		    (calendar-date-equal
 		      (calendar-current-date) (car (car entry-list))))
 ;;Append the smallest element left into the new list, and remove
 ;;it from the original list.
 (defun appt-sort-list (appt-list)
-  (sort (copy-sequence appt-list)
-	(function (lambda (x y)
-	  (< (car (car x)) (car (car y)))))))
+  (let ((order-list nil))
+    (while appt-list
+      (let* ((element (car appt-list))
+             (element-time (car (car element)))
+             (tmp-list (cdr appt-list)))
+        (while tmp-list
+          (if (< element-time (car (car (car tmp-list))))
+              nil
+            (setq element (car tmp-list))
+            (setq element-time (car (car element))))
+          (setq tmp-list (cdr tmp-list)))
+        (setq order-list (append order-list (list element)))
+        (setq appt-list (delq element appt-list))))
+    order-list))
+
 
 (defun appt-convert-time (time2conv)
   "Convert hour:min[am/pm] format to minutes from midnight."
 	((string-match "^[ \t]*noon[ \t]*\\'" time2conv)
 	 (* 12 60))
 	(t
-         (let ((hr 0)
+         (let ((conv-time 0)
+	       (hr 0)
                (min 0))
            (or (string-match
                  "\\`[ \t]*\\([0-9][0-9]?\\)[ \t]*\\(:[ \t]*\\([0-9][0-9]\\)\\)?[ 
      (setq display-time-hook (cons appt-check display-time-hook)))
    ))
 
+;defvar appt-timer nil
+;  "Timer used for diary appointment notifications (`appt-check').")
+
+;(unless appt-timer
+;  (progn
+;    (setq appt-timer (make-itimer))
+;    (set-itimer-fun
+ 
+
 ;;; appt.el ends here
 

File cal-china.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
        (calendar-astro-from-absolute d))))))
 
 (defvar chinese-year-cache
-  '((1989 (12 726110) (1 726139) (2 726169) (3 726198) (4 726227) (5 726257)
-          (6 726286) (7 726316) (8 726345) (9 726375) (10 726404) (11 726434))
-    (1990 (12 726464) (1 726494) (2 726523) (3 726553) (4 726582) (5 726611)
+  '((1990 (12 726464) (1 726494) (2 726523) (3 726553) (4 726582) (5 726611)
           (5.5 726641) (6 726670) (7 726699) (8 726729) (9 726758) (10 726788)
           (11 726818))
     (1991 (12 726848) (1 726878) (2 726907) (3 726937) (4 726966) (5 726995)
     (1999 (12 729771) (1 729801) (2 729831) (3 729860) (4 729889) (5 729919)
           (6 729948) (7 729977) (8 730007) (9 730036) (10 730066) (11 730096))
     (2000 (12 730126) (1 730155) (2 730185) (3 730215) (4 730244) (5 730273)
-          (6 730303) (7 730332) (8 730361) (9 730391) (10 730420) (11 730450)))
+          (6 730303) (7 730332) (8 730361) (9 730391) (10 730420) (11 730450))
+    (2001 (12 730480) (1 730509) (2 730539) (3 730569) (4 730598) (4.5 730628)
+          (5 730657) (6 730687) (7 730716) (8 730745) (9 730775) (10 730804)
+          (11 730834))
+    (2002 (12 730863) (1 730893) (2 730923) (3 730953) (4 730982) (5 731012)
+          (6 731041) (7 731071) (8 731100) (9 731129) (10 731159) (11 731188))
+    (2003 (12 731218) (1 731247) (2 731277) (3 731307) (4 731336) (5 731366)
+          (6 731396) (7 731425) (8 731455) (9 731484) (10 731513) (11 731543))
+    (2004 (12 731572) (1 731602) (2 731631) (2.5 731661) (3 731690) (4 731720)
+          (5 731750) (6 731779) (7 731809) (8 731838) (9 731868) (10 731897)
+          (11 731927))
+    (2005 (12 731956) (1 731986) (2 732015) (3 732045) (4 732074) (5 732104)
+          (6 732133) (7 732163) (8 732193) (9 732222) (10 732252) (11 732281))
+    (2006 (12 732311) (1 732340) (2 732370) (3 732399) (4 732429) (5 732458)
+          (6 732488) (7 732517) (7.5 732547) (8 732576) (9 732606) (10 732636)
+          (11 732665))
+    (2007 (12 732695) (1 732725) (2 732754) (3 732783) (4 732813) (5 732842)
+          (6 732871) (7 732901) (8 732930) (9 732960) (10 732990) (11 733020))
+    (2008 (12 733049) (1 733079) (2 733109) (3 733138) (4 733167) (5 733197)
+          (6 733226) (7 733255) (8 733285) (9 733314) (10 733344) (11 733374))
+    (2009 (12 733403) (1 733433) (2 733463) (3 733493) (4 733522) (5 733551)
+          (5.5 733581) (6 733610) (7 733639) (8 733669) (9 733698) (10 733728)
+          (11 733757))
+    (2010 (12 733787) (1 733817) (2 733847) (3 733876) (4 733906) (5 733935)
+          (6 733965) (7 733994) (8 734023) (9 734053) (10 734082) (11 734112)))
   "An assoc list of Chinese year structures as determined by `chinese-year'.
 
 Values are computed as needed, but to save time, the initial value consists
-of the precomputed years 1989-2000.  The code works just as well with this
-set to nil initially (which is how the value for 1989-2000 was computed).")
+of the precomputed years 1990-2010.  The code works just as well with this
+set to nil initially (which is how the value for 1990-2010 was computed).")
 
 (defun chinese-year (y)
   "The structure of the Chinese year for Gregorian year Y.

File cal-coptic.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
                   (calendar-coptic-from-absolute
                    (calendar-absolute-from-gregorian today))))))
          (completion-ignore-case t)
-         (month (cdr (assoc
-                      (capitalize
+         (month (cdr (assoc-ignore-case
                        (completing-read
                         (format "%s calendar month name: " coptic-name)
                         (mapcar 'list
                                 (append coptic-calendar-month-name-array nil))
-                        nil t))
+                        nil t)
                       (calendar-make-alist coptic-calendar-month-name-array
-                                           1 'capitalize))))
+                                           1))))
          (last (coptic-calendar-last-day-of-month month year))
          (day (calendar-read
                (format "%s calendar day (1-%d): " coptic-name last)
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 

File cal-french.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 ;;; Commentary:
 
 ;; This collection of functions implements the features of calendar.el and
 				    (concat "Jour " x))
                                  special-days))))))))
           (completion-ignore-case t)
-          (month (cdr (assoc
-                       (capitalize
+          (month (cdr (assoc-ignore-case
                         (completing-read
                          "Mois ou Sansculottide: "
                          month-list
-                         nil t))
-                       (calendar-make-alist
-                        month-list
-                        1
-                        '(lambda (x) (capitalize (car x)))))))
+                         nil t)
+			(calendar-make-alist month-list 1 'car))))
           (decade (if (> month 12)
                       1
                     (calendar-read

File cal-hebrew.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
                            calendar-hebrew-month-name-array-leap-year
                          calendar-hebrew-month-name-array-common-year))
           (completion-ignore-case t)
-          (month (cdr (assoc
-                       (capitalize
+          (month (cdr (assoc-ignore-case
                         (completing-read
                          "Hebrew calendar month name: "
                          (mapcar 'list (append month-array nil))
                          (if (= year 3761)
                              '(lambda (x)
                                 (let ((m (cdr
-                                          (assoc
+                                          (assoc-ignore-case
                                            (car x)
                                            (calendar-make-alist
                                             month-array)))))
                                             (hebrew-calendar-last-day-of-month
                                              m year)
                                             year))))))
-                                 
-                         t))
-                       (calendar-make-alist month-array 1 'capitalize))))
+                         t)
+                       (calendar-make-alist month-array 1))))
           (last (hebrew-calendar-last-day-of-month month year))
           (first (if (and (= year 3761) (= month 10))
                      18 1))
                          (string-to-int y-str)))))
             (if dd-name
                 (mark-calendar-days-named
-                 (cdr (assoc (capitalize (substring dd-name 0 3))
+                 (cdr (assoc-ignore-case 
+		       (substring dd-name 0 3)
                              (calendar-make-alist
                                calendar-day-name-array
                                0
                     (setq
                       mm
                       (cdr 
-                        (assoc
-                          (capitalize mm-name)
+                        (assoc-ignore-case
+			 mm-name
                             (calendar-make-alist
                                calendar-hebrew-month-name-array-leap-year))))))
               (mark-hebrew-calendar-date-pattern mm dd yy)))))
                            (int-to-string (extract-calendar-year today))))
                     (month-array calendar-month-name-array)
                     (completion-ignore-case t)
-                    (month (cdr (assoc
-                                 (capitalize
+                    (month (cdr (assoc-ignore-case
                                   (completing-read
                                    "Month of death (name): "
                                    (mapcar 'list (append month-array nil))
-                                   nil t))
-                                 (calendar-make-alist
-                                  month-array 1 'capitalize))))
+                                   nil t)
+                                 (calendar-make-alist month-array 1))))
                     (last (calendar-last-day-of-month month year))
                     (day (calendar-read
                           (format "Day of death (1-%d): " last)

File cal-islam.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
                     (calendar-absolute-from-gregorian today))))))
           (month-array calendar-islamic-month-name-array)
           (completion-ignore-case t)
-          (month (cdr (assoc
-                       (capitalize
+          (month (cdr (assoc-ignore-case
                         (completing-read
                          "Islamic calendar month name: "
                          (mapcar 'list (append month-array nil))
-                         nil t))
-                       (calendar-make-alist month-array 1 'capitalize))))
+                         nil t)
+                       (calendar-make-alist month-array 1))))
           (last (islamic-calendar-last-day-of-month month year))
           (day (calendar-read
                 (format "Islamic calendar day (1-%d): " last)
                          (string-to-int y-str)))))
             (if dd-name
                 (mark-calendar-days-named
-                 (cdr (assoc (capitalize (substring dd-name 0 3))
+                 (cdr (assoc-ignore-case (substring dd-name 0 3)
                              (calendar-make-alist
                                calendar-day-name-array
                                0
                   (if (string-equal mm-name "*")
                       (setq mm 0)
                     (setq mm
-                          (cdr (assoc
-                                (capitalize mm-name)
+                          (cdr (assoc-ignore-case
+                                mm-name
                                 (calendar-make-alist
                                   calendar-islamic-month-name-array))))))
               (mark-islamic-calendar-date-pattern mm dd yy)))))
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 

File cal-julian.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
                      today))))))
           (month-array calendar-month-name-array)
           (completion-ignore-case t)
-          (month (cdr (assoc
-                       (capitalize
+          (month (cdr (assoc-ignore-case
                         (completing-read
                          "Julian calendar month name: "
                          (mapcar 'list (append month-array nil))
-                         nil t))
-                       (calendar-make-alist month-array 1 'capitalize))))
+                         nil t)
+                       (calendar-make-alist month-array 1))))
           (last 
            (if (and (zerop (% year 4)) (= month 2))
                29

File cal-mayan.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
          (haab-month-list (append calendar-mayan-haab-month-name-array 
                                   (and (< haab-day 5) '("Uayeb"))))
          (haab-month (cdr
-                      (assoc
-                       (capitalize
+                      (assoc-ignore-case
                         (completing-read "Haab uinal: "
                                          (mapcar 'list haab-month-list)
-                                         nil t))
-                       (calendar-make-alist
-                        haab-month-list 1 'capitalize)))))
+                                         nil t)
+                       (calendar-make-alist haab-month-list 1)))))
     (cons haab-day haab-month)))
 
 (defun calendar-read-mayan-tzolkin-date ()
                          '(lambda (x) (and (> x 0) (< x 14)))))
          (tzolkin-name-list (append calendar-mayan-tzolkin-names-array nil))
          (tzolkin-name (cdr
-                        (assoc
-                         (capitalize
+                        (assoc-ignore-case
                           (completing-read "Tzolkin uinal: " 
                                            (mapcar 'list tzolkin-name-list)
-                                           nil t))
-                         (calendar-make-alist
-                          tzolkin-name-list 1 'capitalize)))))
+                                           nil t)
+                         (calendar-make-alist tzolkin-name-list 1)))))
     (cons tzolkin-count tzolkin-name)))
 
 (defun calendar-next-calendar-round-date
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
   (let ((old-date (calendar-cursor-to-date))
         (today (calendar-current-date)))
     (if (/= arg 0)
-        (progn
-          (increment-calendar-month displayed-month displayed-year arg)
-          (generate-calendar-window displayed-month displayed-year)
+        (let ((month displayed-month)
+	      (year displayed-year))
+          (increment-calendar-month month year arg)
+	  (generate-calendar-window month year)
           (calendar-cursor-to-visible-date
            (cond
             ((calendar-date-is-visible-p old-date) old-date)
             ((calendar-date-is-visible-p today) today)
-            (t (list displayed-month 1 displayed-year))))))))
+            (t (list month 1 year))))))))
 
 (defun scroll-calendar-right (arg)
   "Scroll the displayed calendar window right by ARG months.

File cal-persia.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
                    (calendar-absolute-from-gregorian today))))))
          (completion-ignore-case t)
          (month (cdr (assoc
-                      (capitalize
                        (completing-read
                         "Persian calendar month name: "
                         (mapcar 'list
                                 (append persian-calendar-month-name-array nil))
-                        nil t))
+                        nil t)
                       (calendar-make-alist persian-calendar-month-name-array
-                                           1 'capitalize))))
+                                           1))))
          (last (persian-calendar-last-day-of-month month year))
          (day (calendar-read
                (format "Persian calendar day (1-%d): " last)
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
     (cal-tex-cmd "\\pagestyle{empty}")
     (calendar-for-loop i from 1 to n do
        (calendar-for-loop j from 1 to 5 do 
-       (insert (if (oddp j) "\\righthead" "\\lefthead"))
+	(let ((odd (/= 0 (% j 2))))
+           (insert (if odd "\\righthead" "\\lefthead"))
        (cal-tex-arg (calendar-date-string date))
        (insert "%\n")
-          (insert (if (oddp j) "\\rightday"  "\\leftday"))
+       (insert (if odd "\\rightday"  "\\leftday")))
           (cal-tex-arg (cal-tex-latexify-list diary-list date))
           (cal-tex-arg (cal-tex-latexify-list holidays date))
           (cal-tex-arg (eval cal-tex-daily-string))
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with (Mostly): FSF 20.3
+;;; Synched up with (Mostly): FSF 20.5
 
 ;;; Commentary:
 
 ;; Certainly it should not specify auto-lower and auto-raise
 ;; since most users won't like that.
 (defvar diary-frame-parameters
-  '((name . "Diary") (height . 10) (width . 80) (unsplittable . t)
-    (minibuffer . nil))
+  '((name . "Diary") (title . "Diary") (height . 10) (width . 80) 
+    (unsplittable . t) (minibuffer . nil))
   "Parameters of the diary frame, if the diary is in its own frame.
 Location and color should be set in .Xdefaults.")
                                  
 (defvar calendar-frame-parameters
-  '((name . "Calendar") (minibuffer . nil) (height . 10) (width . 80)
-    (unsplittable . t) (vertical-scroll-bars . nil))
+  '((name . "Calendar") (title . "Calendar") (minibuffer . nil) 
+    (height . 10) (width . 80) (unsplittable . t) (vertical-scroll-bars . nil))
   "Parameters of the calendar frame, if the calendar is in a separate frame.
 Location and color should be set in .Xdefaults.")
 
 (defvar calendar-and-diary-frame-parameters
-  '((name . "Calendar") (height . 28) (width . 80) (minibuffer . nil))
+  '((name . "Calendar") (title . "Calendar") (height . 28) (width . 80) 
+    (minibuffer . nil))
   "Parameters of the frame that displays both the calendar and the diary.
 Location and color should be set in .Xdefaults.")
   
               fancy-diary-buffer))
            'diary))))))
 
+(defun calendar-only-one-frame-setup (&optional arg)
+  "Start calendar and display it in a dedicated frame."
+  (if (calendar-not-using-window-system-p)
+      (calendar-basic-setup arg)
+    (if (frame-live-p calendar-frame) (delete-frame calendar-frame))
+    (let ((special-display-buffer-names nil)
+          (view-diary-entries-initially nil))
+      (save-window-excursion
+        (save-excursion
+          (setq calendar-frame
+               (make-frame calendar-frame-parameters))
+          (run-hooks 'calendar-after-frame-setup-hooks)
+          (select-frame calendar-frame)
+	  (calendar-deiconify-frame calendar-frame)
+          (calendar-basic-setup arg)
+          (set-window-dedicated-p (selected-window) 'calendar))))))
+
 (defun calendar-two-frame-setup (&optional arg)
   "Start calendar and diary in separate, dedicated frames."
   (if (calendar-not-using-window-system-p)
             fancy-diary-buffer))
          'diary)))))
 
-(if (not (string-match "XEmacs" emacs-version))
+;(if (not (string-match "XEmacs" emacs-version))
+;; Formerly (get-file-buffer diary-file) was added to the list here,
+;; but that isn't clean, and the value could even be nil.
     (setq special-display-buffer-names
 	  (append special-display-buffer-names
 		  (list "*Yahrzeits*" lunar-phases-buffer holiday-buffer
-			fancy-diary-buffer (get-file-buffer diary-file)
-			other-calendars-buffer calendar-buffer))))
+			fancy-diary-buffer 
+			other-calendars-buffer calendar-buffer)))
+;)
 
 (run-hooks 'cal-x-load-hook)
 

File cal-xemacs.el

   (popup-menu calendar-popup-menu-3))
 (define-key calendar-mode-map 'button3 'calendar-popup-menu-3)
 
-(defvar calendar-foobar nil)
-
-(defun calendar-popup-menu-2 (e)
-  (interactive "@e")
-  (setq calendar-foobar (calendar-event-to-date  t))
-  (let ((menu (list (format "Menu - %s" (calendar-date-string calendar-foobar) t t)
-	       "-----"
-	       ["Holidays" calendar-mouse-holidays t]
-	       ["Mark date" calendar-mouse-set-mark t]
-	       ["Sunrise/sunset" calendar-mouse-sunrise/sunset t]
-	       ["Other calendars" calendar-mouse-print-dates (calendar-event-to-date )]
-	       ["Prepare LaTeX Buffer" calendar-mouse-cal-tex-menu (calendar-event-to-date )]
-	       ["Diary entries" calendar-mouse-view-diary-entries t]
-	       ["Insert diary entry" calendar-mouse-insert-diary-entry t]
-	       ["Other Diary file entries"
-		calendar-mouse-view-other-diary-entries
-		(calendar-cursor-to-date)]
-	       )))
-    (popup-menu menu)))
-
-(define-key calendar-mode-map 'button2 'calendar-popup-menu-2)
+(define-key calendar-mode-map 'button2 'calendar-mouse-2-date-menu)
 
 
 (defun cal-tex-mouse-filofax (e) 
   "Pop up sub-submenu for Mouse-2 for Filofax cal-tex commands for selected date."
   (interactive "e")
-   (let* ((menu (list (calendar-date-string calendar-foobar t nil)
+  (let* ((date (calendar-event-to-date t))
+	 (menu (list (calendar-date-string date t nil)
 		     "-----"
 		     ["Filofax Daily (One-day-per-page)"   
 		      cal-tex-mouse-filofax-daily]
 			   'cal-menu-today-holidays t) l))
 	    (setq l (cons "---" l))
 	    (calendar-for-loop;; Show 11 years--5 before, 5 after year of
-	     ;; middle month
+	     ;; middle month    (calendar-mouse-goto-date (calendar-event-to-date))
+
              i from (- displayed-year 5) to (+ displayed-year 5) do
              (setq l (cons (vector (format "For Year %s" i)
                                    (list (list 'lambda 'nil '(interactive)
 If event is not on a specific date, signals an error if optional parameter
 ERROR is t, otherwise just returns nil."
   (save-excursion
+    ;; we keep a copy of the last button press event.  This makes it easier
+    ;; to mimic the Emacs version.  Otherwise, on the next call, we get
+    ;; a misc-user-event when a menu item is selected.  Then we lose the 
+    ;; buffer and point information
+    (if (button-event-p last-input-event)
+	(progn
+	  (setq last-calendar-button-event (allocate-event))
+	  (copy-event last-input-event last-calendar-button-event))
+      )
     ;;  Emacs has this.  
     ;;(set-buffer (window-buffer (posn-window (event-start last-input-event))))
     ;;(goto-char (posn-point (event-start last-input-event)))
-    ;; I think this does the same thing
-    (set-buffer (event-buffer last-input-event))
-    (goto-char (event-point last-input-event))
+    ;; I think this does the same thing - jmiller 
+    (set-buffer (event-buffer last-calendar-button-event))
+    (goto-char (event-point last-calendar-button-event))
     (calendar-cursor-to-date error)))
 
 (defun calendar-mouse-insert-hebrew-diary-entry (event)
   "Show sunrise/sunset times for mouse-selected date."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (calendar-sunrise-sunset)))
 
 (defun cal-menu-today-holidays ()
   "Show holidays for today's date."
   (interactive)
   (save-excursion
-    ;(calendar-cursor-to-date (calendar-current-date))
-    (calendar-goto-today)
+    (calendar-cursor-to-date (calendar-current-date))
     (calendar-cursor-holidays)))
 
 (defun calendar-mouse-holidays ()
   "Pop up menu of holidays for mouse selected date."
   (interactive)
   (save-excursion
-    (let* ((date calendar-foobar)
+    (let* ((date (calendar-event-to-date))
 	   (l (check-calendar-holidays date))
 	   (menu 
 	    (cons
 	     (format "Holidays for %s" (calendar-date-string date))
 	     (if l l '("None")))))
-      (setq calendar-foobar nil)
       (popup-menu menu))))
   
 (defun calendar-mouse-view-diary-entries ()
   "Pop up menu of diary entries for mouse selected date."
   (interactive)
   (save-excursion
-    (let* ((date calendar-foobar)
+    (let* ((date (calendar-event-to-date))
 	   (l (mapcar '(lambda (x) (concat (car (cdr x)) ""))
 		      (let ((diary-list-include-blanks nil)
 			    (diary-display-hook 'ignore))
 	    (cons
 	     (format "Diary Entries for %s" (calendar-date-string date))
 	     (if l l '("None")))))
-      (setq calendar-foobar nil)
       (popup-menu menu))))
 
 (defun calendar-mouse-view-other-diary-entries ()
   "Pop up menu of diary entries from alternative file on mouse-selected date."
   (interactive)
   (save-excursion
-    (let* ((date calendar-foobar)
+    (let* ((date  (calendar-event-to-date))
 	   (l (mapcar '(lambda (x) (concat (car (cdr x)) ""))
 		      (let ((diary-list-include-blanks nil)
 			    (diary-display-hook 'ignore)
 		     diary-file
 		     (calendar-date-string date))
 	     (if l l '("None")))))
-      (setq calendar-foobar nil)
       (popup-menu menu))))
 
 (defun calendar-mouse-insert-diary-entry ()
   "Insert diary entry for mouse-selected date."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (insert-diary-entry nil)))
 
 (defun calendar-mouse-set-mark ()
   "Mark the date under the cursor."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (calendar-set-mark nil)))
 
 (defun cal-tex-mouse-day ()
   "Make a buffer with LaTeX commands for the day mouse is on."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-day nil)))
 
 (defun cal-tex-mouse-week ()
 Holidays are included if `cal-tex-holidays' is t."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-week nil)))
 
 (defun cal-tex-mouse-week2 ()
 The printed output will be on two pages."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-week2 nil)))
 
 (defun cal-tex-mouse-week-iso ()
 Holidays are included if `cal-tex-holidays' is t."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-week-iso nil)))
 
 (defun cal-tex-mouse-week-monday ()
   "One page calendar for week indicated by cursor."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-week-monday nil)))
 
 (defun cal-tex-mouse-filofax-daily ()
   "Day-per-page Filofax calendar for week indicated by cursor."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-filofax-daily nil)))
 
 (defun cal-tex-mouse-filofax-2week ()
   "One page Filofax calendar for week indicated by cursor."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-filofax-2week nil)))
 
 (defun cal-tex-mouse-filofax-week ()
   "Two page Filofax calendar for week indicated by cursor."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-filofax-week nil)))
 
 (defun cal-tex-mouse-month ()
 Calendar is condensed onto one page."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-month nil)))
 
 (defun cal-tex-mouse-month-landscape ()
 The output is in landscape format, one month to a page."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-month-landscape nil)))
 
 (defun cal-tex-mouse-year ()
   "Make a buffer with LaTeX commands for the year cursor is on."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-year nil)))
 
 (defun cal-tex-mouse-filofax-year ()
   "Make a buffer with LaTeX commands for Filofax calendar of year cursor is on."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-filofax-year nil)))
 
 (defun cal-tex-mouse-year-landscape ()
   "Make a buffer with LaTeX commands for the year cursor is on."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (cal-tex-cursor-year-landscape nil)))
 
 (defun calendar-mouse-print-dates ()
   "Pop up menu of equivalent dates to mouse selected date."
   (interactive)
-  (let* ((menu (list (format "Date Menu - %s (Gregorian)"
-			     (calendar-date-string calendar-foobar))
+  (let* ((date (calendar-event-to-date))
+	 (menu (list (format "Date Menu - %s (Gregorian)"
+			     (calendar-date-string date))
 		     "-----"
-		     (calendar-day-of-year-string calendar-foobar)
-		     (format "ISO date: %s" (calendar-iso-date-string calendar-foobar))
+		     (calendar-day-of-year-string date)
+		     (format "ISO date: %s" (calendar-iso-date-string date))
 		     (format "Julian date: %s"
-			     (calendar-julian-date-string calendar-foobar))
+			     (calendar-julian-date-string date))
 		     (format "Astronomical (Julian) date (before noon): %s"
-			     (calendar-astro-date-string calendar-foobar))
+			     (calendar-astro-date-string date))
 		     (format "Hebrew date (before sunset): %s"
-			     (calendar-hebrew-date-string calendar-foobar))
+			     (calendar-hebrew-date-string date))
 		     (format "Persian date: %s"
-			     (calendar-persian-date-string calendar-foobar))
-		     (let ((i (calendar-islamic-date-string calendar-foobar)))
+			     (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 calendar-foobar))
-		     (let ((c (calendar-coptic-date-string calendar-foobar)))
+			     (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 calendar-foobar)))
+		     (let ((e (calendar-ethiopic-date-string date)))
 		       (if (not (string-equal e ""))
 			   (format "Ethiopic date: %s" e)))
-		     (let ((f (calendar-french-date-string calendar-foobar)))
+		     (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 calendar-foobar))
+			     (calendar-mayan-date-string date))
 		     )))
     (popup-menu menu)
-    )
-  (setq calendar-foobar nil))
+    ))
 
 (defun calendar-mouse-cal-tex-menu (e) 
   "Pop up submenu for Mouse-2 for cal-tex commands for selected date in the calendar window."
   (interactive "e")
-   (let* ((menu (list (calendar-date-string calendar-foobar t nil)
+  (let* ((date (calendar-event-to-date t))
+	 (menu (list (calendar-date-string date t nil)
 		     "-----"
 		     ["Daily (1 page)"    cal-tex-mouse-day  ]
 		     ["Weekly (1 page)"   cal-tex-mouse-week ]
   "Show Chinese equivalent for mouse-selected date."
   (interactive)
   (save-excursion
-    (calendar-goto-date calendar-foobar)
-    (setq calendar-foobar nil)
+    (calendar-mouse-goto-date (calendar-event-to-date))
     (calendar-print-chinese-date)))
 
 (defun calendar-mouse-goto-date (date)
-  (set-buffer (event-buffer  last-input-event))
+  (set-buffer (event-buffer  last-calendar-button-event))
   (calendar-goto-date date))
 
+(defun calendar-mouse-2-date-menu (event)
+  (interactive "@e")
+  (let* ((date (calendar-event-to-date))
+	(menu (list (format "Menu - %s" (calendar-date-string date) t t)
+	       "-----"
+	       ["Holidays" calendar-mouse-holidays t]
+	       ["Mark date" calendar-mouse-set-mark t]
+	       ["Sunrise/sunset" calendar-mouse-sunrise/sunset t]
+	       ["Other calendars" calendar-mouse-print-dates t]
+	       ["Prepare LaTeX Buffer" calendar-mouse-cal-tex-menu t]
+	       ["Diary entries" calendar-mouse-view-diary-entries t]
+	       ["Insert diary entry" calendar-mouse-insert-diary-entry t]
+	       ["Other Diary file entries"
+		calendar-mouse-view-other-diary-entries
+		(calendar-cursor-to-date)]
+	       )))
+    (popup-menu menu)))
 
 (run-hooks 'cal-xemacs-load-hook)
 
-;;; calendar.el --- Calendar functions.  -*-byte-compile-dynamic: t;-*-
+;;; calendar.el --- Calendar functions.
 
 ;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997 
 ;;       Free Software Foundation, Inc.
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with (Mostly): FSF 20.3
+;;; Synched up with (Mostly): FSF 20.5
 
 ;;; Commentary:
 
 (defvar calendar-setup nil
   "The frame set up of the calendar.
 The choices are `one-frame' (calendar and diary together in one separate,
-dedicated frame) or `two-frames' (calendar and diary in separate, dedicated
-frames); with any other value the current frame is used.")
+dedicated frame), `two-frames' (calendar and diary in separate, dedicated
+frames), `calendar-only' (calendar in a separate, dedicated frame); with 
+any other value the current frame is used.")
 
 ;;;###autoload
 (defun calendar (&optional arg)
   (interactive "P")
   (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
         ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
+        ((equal calendar-setup 'calendar-only)
+         (calendar-only-one-frame-setup arg))
         (t (calendar-basic-setup arg))))
 
 (defun calendar-basic-setup (&optional arg)
   "String of Chinese date of Gregorian date."
    t)
 
-(autoload 'calendar-absolute-from-astro
+(autoload 'calendar-absolute-from-astro "cal-julian"
   "Absolute date of astronomical (Julian) day number D."
-  "cal-julian")
+  t)
 
 (autoload 'calendar-astro-from-absolute "cal-julian"
   "Astronomical (Julian) day number of absolute date D.")
 (defun redraw-calendar ()
   "Redraw the calendar display."
   (interactive)
-  (let ((cursor-date (calendar-cursor-to-date)))
+  (let ((cursor-date (calendar-cursor-to-nearest-date)))
     (generate-calendar-window displayed-month displayed-year)
     (calendar-cursor-to-visible-date cursor-date)))
 
   (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 "Aa"   'appt-add)
+  (define-key calendar-mode-map "Ad"   '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)
                                 (calendar-current-date)))))
          (month-array calendar-month-name-array)
          (completion-ignore-case t)
-         (month (cdr (assoc
-                      (capitalize
+         (month (cdr (assoc-ignore-case
                        (completing-read
                         "Month name: "
                         (mapcar 'list (append month-array nil))
-                        nil t))
-                      (calendar-make-alist month-array 1 'capitalize))))
+                        nil t)
+                      (calendar-make-alist month-array 1))))
          (last (calendar-last-day-of-month month year)))
     (if noday
         (if (eq noday t)
 
 (defvar calendar-english-day-name-array
   ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"])
-(defvar calendar-day-name-array calendar-english-day-name-array)
+(defvar calendar-day-name-array calendar-english-day-name-array
+  "Array of capitalized strings giving, in order, the day names.")
 
 (defvar calendar-english-month-name-array
   ["January" "February" "March"     "April"   "May"      "June"
    "July"    "August"   "September" "October" "November" "December"])
-(defvar calendar-month-name-array calendar-english-month-name-array)
+(defvar calendar-month-name-array calendar-english-month-name-array
+  "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.
 
 (provide 'calendar)
 
+;;; Local variables:
+;;; byte-compile-dynamic: t
+;;; End:
 
 ;;; calendar.el ends here

File diary-lib.el

 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; (Mostly) Synched up with: FSF 20.3
+;;; (Mostly) Synched up with: FSF 20.5
 ;;; XEmacs has extra function `diary-countdown'
 
 ;;; Commentary:
                            (concat
                             "\\*\\|0*" (int-to-string year)
                             (if abbreviated-calendar-year
-                                (concat "\\|" (int-to-string (% year 100)))
+				(concat "\\|" (format "%02d" (% year 100)))
                               "")))
                           (regexp
                            (concat
          (msg (format "No diary entries for %s %s"
                       (concat 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 "; ")))
     (if (or (not diary-entries-list)
             (and (not (cdr diary-entries-list))
                  (string-equal (car (cdr (car diary-entries-list))) "")))
           (setq buffer-read-only t)
           (display-buffer holiday-buffer)
           (message  "No diary entries for %s" date-string))
-      (calendar-set-mode-line
-       (concat "Diary for " date-string
-               (if holiday-list ": " "")
-               (mapconcat 'identity holiday-list "; ")))
       (display-buffer (find-buffer-visiting d-file))
       (message "Preparing diary...done"))))
 
        (setq ndays diary-mail-days))
     (calendar)
     (view-diary-entries ndays)
-    (set-buffer "*Fancy Diary Entries*")
+    (set-buffer fancy-diary-buffer)
     (setq text (buffer-substring (point-min) (point-max)))
 
     ;; Now send text as a mail message.
                                      (string-to-int y-str)))))
                         (if dd-name
                             (mark-calendar-days-named
-                             (cdr (assoc (capitalize (substring dd-name 0 3))
+                             (cdr (assoc-ignore-case
+				   (substring dd-name 0 3)
                                          (calendar-make-alist
                                           calendar-day-name-array
                                           0
                               (if (string-equal mm-name "*")
                                   (setq mm 0)
                                 (setq mm
-                                      (cdr (assoc
-                                            (capitalize
-                                             (substring mm-name 0 3))
+                                      (cdr (assoc-ignore-case
+                                             (substring mm-name 0 3)
                                             (calendar-make-alist
                                              calendar-month-name-array
                                              1
               (backward-char 1)
               (setq entry ""))
           (setq entry-start (point))
+          ;; Find end of entry
           (re-search-forward "\^M\\|\n" nil t)
           (while (looking-at " \\|\^I")
-            (re-search-forward "\^M\\|\n" nil t))
-          (backward-char 1)
+	    (or (re-search-forward "\^M\\|\n" nil t)
+		(re-search-forward "$" nil t)))
+          (if (or (char-equal (preceding-char) ?\^M)
+		  (char-equal (preceding-char) ?\n))
+	      (backward-char 1))
           (setq entry (buffer-substring-no-properties entry-start (point)))
           (while (string-match "[\^M]" entry)
             (aset entry (match-beginning 0) ?\n )))
                                         (calendar-last-day-of-month m1 y1)))))
                        (and (<= d1 d) (<= d d2))))
                 ;; only possible base dates straddle two months
-                (and (< m1 m2)
+                (and (or (< y1 y2)
+                         (and (= y1 y2) (< m1 m2)))
                      (or
-                      ;; m1, d1 works is a base date
+                      ;; m1, d1 works as a base date
                       (and
                        (or (and (listp month) (memq m1 month))
                            (eq month t)
                        (<= d1 (or day (if (> n 0)
                                           1
                                         (calendar-last-day-of-month m1 y1)))))
-                      ;; m2, d2 works is a base date
+                      ;; m2, d2 works as a base date
                       (and (or (and (listp month) (memq m2 month))
                                (eq month t)
                                (= m2 month))
 SEXP, then a suitable message (as specified by `diary-remind-message' is
 returned.
 
-In addition to the reminders beforehand, the diary entry also appears on
-the date itself.
+In addition to the reminders beforehand, the diary entry also appears on the
+ date itself.
  
-If optional parameter MARKING is non-nil then the reminders are marked on the
-calendar.  Marking of reminders is independent of whether the entry itself is
-a marking or nonmarking one."
-  (let ((diary-entry))
-    (if (or (not marking-diary-entries) marking)
+A `diary-nonmarking-symbol' at the beginning of the line of the diary-remind
+entry specifies that the diary entry (not the reminder) is non-marking.
+Marking of reminders is independent of whether the entry itself is a marking
+or nonmarking; if optional parameter MARKING is non-nil then the reminders are
+marked on the calendar."
+  (let ((diary-entry (eval sexp)))
         (cond
-         ((integerp days)
+     ;; Diary entry applies on date
+     ((and diary-entry
+           (or (not marking-diary-entries) marking-diary-entry))
+      diary-entry)
+     ;; Diary entry may apply to `days' before date
+     ((and (integerp days)
+           (not diary-entry); Diary entry does not apply to date
+           (or (not marking-diary-entries) marking))
           (let ((date (calendar-gregorian-from-absolute
                        (+ (calendar-absolute-from-gregorian date) days))))
             (if (setq diary-entry (eval sexp))
-                (setq diary-entry (mapconcat 'eval diary-remind-message "")))))
+            (mapconcat 'eval diary-remind-message ""))))
+     ;; Diary entry may apply to one of a list of days before date
          ((and (listp days) days)
-          (setq diary-entry (diary-remind sexp (car days) marking))
-          (if (not diary-entry)
-              (setq diary-entry (diary-remind sexp (cdr days) marking))))))
-    (or diary-entry
-        (and (or (not marking-diary-entries) marking-diary-entry)
-             (eval sexp)))))
+      (or (diary-remind sexp (car days) marking)
+          (diary-remind sexp (cdr days) marking))))))
 
 (defun add-to-diary-list (date string specifier)
   "Add the entry (DATE STRING SPECIFIER) to `diary-entries-list'.
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
  
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary:
 
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Synched up with: FSF 20.3
+;;; Synched up with: FSF 20.5
 
 ;;; Commentary: