Anonymous avatar Anonymous committed 285ce99

Synch against FSF Emacs 20.2

Comments (0)

Files changed (13)

+1998-06-19  Jeff Miller  <jmiller@smart.net>
+
+	* Makefile: updated .elc targets.
+   
+	* cal-china.el: new, synched with Emacs 20.2
+	* cal-coptic.el: new, synched with Emacs 20.2
+	* cal-persia.el: new, synched with Emacs 20.2
+	* cal-tex.el: new, synched with Emacs 20.2
+   
+	* cal-hebrew.el: new file, old functions, synched with Emacs 20.2
+	* cal-islam.el: new file, old functions, synched with Emacs 20.2
+	* cal-iso.el: new file, old functions, synched with Emacs 20.2
+	* cal-julian.el: new file, old functions, synched with Emacs 20.2
+	* cal-move.el: new file, old functions, synched with Emacs 20.2
+   
+	* appt.el: some synching with Emacs 20.2, minor bug fixes.
+   
+	* cal-x.el: synched with Emacs 20.2 (mostly)
+	* cal-xemacs.el: synched with cal-menu.el in Emacs 20.2
+	* calendar.el: synched with Emacs 20.2 (mostly)
+   
+	* cal-dst.el: synched with Emacs 20.2
+	* cal-mayan.el: synched with Emacs 20.2
+	* diary-lib.el: synched with Emacs 20.2
+	* holidays.el: synched with Emacs 20.2
+	* lunar.el: synched with Emacs 20.2
+	* solar.el: synched with Emacs 20.2
+   
+	* cal-french.el: no change
+   
+	* diary-ins.el: removed, obsolete. Functions moved to various 
+                        cal-xxx files.
 1998-01-25  SL Baur  <steve@altair.xemacs.org>
 
 	* Makefile (VERSION): Update to package standard 1.0.
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.03
+VERSION = 1.04
 AUTHOR_VERSION =
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = calendar
 CATEGORY = oa
 
 ELCS = appt.elc cal-dst.elc cal-french.elc cal-mayan.elc cal-x.elc \
-	cal-xemacs.elc calendar.elc diary-ins.elc diary-lib.elc holidays.elc \
-	lunar.elc solar.elc
+	cal-xemacs.elc calendar.elc diary-lib.elc holidays.elc cal-tex.elc \
+	cal-hebrew.elc cal-islam.elc cal-iso.elc cal-move.elc cal-persia.elc\
+	cal-china.elc cal-coptic.elc cal-julian.elc lunar.elc solar.elc
 
 include ../../XEmacs.rules
 
 
 ;;; -*- Mode:Emacs-Lisp -*-
 ;; Appointment notification functions.
-;; Copyright (C) 1989, 1990, 1992, 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1990, 1994 Free Software Foundation, Inc.
 
+;; Author: Neil Mager <neilm@juliet.ll.mit.edu>
+;; Maintainer: FSF
+;; Keywords: calendar
+ 
 ;; This file is part of XEmacs.
 
 ;; XEmacs is free software; you can redistribute it and/or modify it
 ;;; 21-mar-97   better support for fancy diary display by Tomasz J. Cholewo 
 ;;;             <t.cholewo@ieee.org>
 ;;;
+;;; Commentary:
+
+;;
 ;; appt.el - visible and/or audible notification of
 ;;           appointments from ~/diary file generated from
 ;;           Edward M. Reingold's calendar.el.
 ;;; ******* 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 have a message
-;;; displayed in a new buffer.
+;;; 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 
+;;; have a message displayed in a new buffer.
 ;;;
 ;;; Variables of note:
 ;;;
 ;;;	   9:30am Coffee break
 ;;;	  12:00pm Lunch
 ;;; 
-;;; Based upon the above lines in your .emacs and diary files, the calendar
-;;; and/or diary will be displayed when you enter 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.
+;;; 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.  
+;;; You will then be reminded at 9:20am about your coffee break 
+;;; and at 11:50am to go to lunch.
 ;;;
 ;;; In order to interactively add or delete items from today's list, use 
 ;;; Meta-x appt-add and Meta-x appt-delete.  (This does not modify your 
 ;;;  o  There should be some way to mark certain appointments as "important,"
 ;;;     so that you will be harassed about them even after they have expired.
 
+;;; Code:
 
+;; Make sure calendar is loaded when we compile this.
 (require 'calendar)
-(require 'diary-lib)
 
+(provide 'appt)
+
+;;;###autoload
 (defcustom appt-issue-message t
-  "*If T, the diary buffer is checked for appointments.  For an
- appointment warning to be made, the time must be the first thing on
- the line."
+  "*Non-nil means check for appointments in the diary buffer.
+To be detected, the diary entry must have the time
+as the first thing on a line."
   :type 'boolean
   :group 'appt)
 
   :group 'appt)
 
 (defcustom appt-check-time-syntax nil
-  "*Whether all diary entries are intended to beging with time specifications.
+  "*Whether all diary entries are intended to begin with time specifications.
 Appt will beep and issue a warning message when encountering unparsable 
 lines."
   :type 'boolean
   :group 'appt)
 
+;;;###autoload
 (defcustom appt-audible t
   "*Controls whether appointment announcements should beep.
 Appt uses two sound-types for beeps: `appt' and `appt-final'.
   :type 'boolean
   :group 'appt)
 
+;;;###autoload
 (defcustom appt-display-mode-line t
-  "*Controls if minutes-to-appointment should be displayed on the mode line."
+  "*Non-nil means display minutes to appointment and time on the mode line."
   :type 'boolean
   :group 'appt)
 
+(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."
+  :type 'integer
+  :group 'appt)
+
 (defcustom appt-announce-method 'appt-window-announce
   "*The name of the function used to notify the user of an impending 
 appointment.  This is called with two arguments, the number of minutes
   :type 'function
   :group 'appt)
 
-
 (defvar appt-time-msg-list nil
-  "The list of appointments for today.  Use appt-add and appt-delete
- to add and delete appointments from list.  The original list is generated
- from the today's diary-entries-list. The number before each time/message
- is the time in minutes after midnight.")
+  "The list of appointments for today.  
+Use `appt-add' and `appt-delete' to add and delete appointments from list.
+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
   "11:59pm in minutes - number of minutes in a day minus 1.")
 		       (if (eq 1 min-to-app) "" "s")
 		       (car (cdr appt))))))
 
-
 (defun appt-persistent-message-announce (min-to-app appt)
   "Set appt-announce-method to the name of this function to cause appointment
 notifications to be given via messages in the minibuffer, but have those 
     ))
 
 
-(defcustom appt-display-duration 5
-  "*The number of seconds an appointment message is displayed in its own 
- window if appt-announce-method is 'appt-window-announce."
-  :type 'integer
-  :group 'appt)
-
 (defun appt-window-announce (min-to-app appt)
   "Set appt-announce-method to the name of this function to cause appointment 
 notifications to be given via messages in a pop-up window.  The variable
 	       (concat "-------------------- Appointment "
 		 (if (eq min-to-app 0)
 		     "NOW"
-		   (concat "in " min-to-app
+		   (concat "in " (format "%s" min-to-app)
 		     (if (eq min-to-app 1) " minute" " minutes")))
 		 ". ("
 		 (let ((h (string-to-int
 			    (substring (current-time-string) 11 13))))
-		   (concat (if (> h 12) (- h 12) h) ":"
+		   (concat (if (> h 12) (format "%s" (- h 12))
+			     (format "%s" h)) ":"
 			   (substring (current-time-string) 14 16)
-			   (if (< h 12) "am" "pm")))
+	 		   (if (< h 12) "am" "pm")))
 		 ") %-"))
 	     (pop-to-buffer appt-disp-buf)
 	     (insert (car (cdr appt)))
 	    (concat "-------------------- Appointment "
 		    (if (eq min-to-app 0)
 			"NOW"
-		      (concat "in " min-to-app
+		      (concat "in " (format "%s" min-to-app)
 			      (if (eq min-to-app 1) " minute" " minutes")))
 		    ". ("
 		    (let ((h (string-to-int
 			      (substring (current-time-string) 11 13))))
-		      (concat (if (> h 12) (- h 12) h) ":"
+		      (concat (if (> h 12) (format "%s" (- h 12))
+				(format "%s" h)) ":"
 			      (substring (current-time-string) 14 16)
 			      (if (< h 12) "am" "pm")))
 		    ") %-"))
 	(if (and appt-display-mode-line min-to-app)
 	    (if (eq 0 min-to-app)
 		"App't NOW "
-		(concat "App't in " min-to-app
+		(concat "App't in " (format "%s" min-to-app)
 			(if (eq 1 min-to-app) " minute  " " minutes ")))
 	    ""))
   ;; make sure our variable is visible in global-mode-string.
 
 ;;; Internal stuff
 
-(defun appt-convert-time (time2conv)
-  "Convert hour:min[am/pm] format to minutes from midnight."
-  (cond ((string-match "^[ \t]*midni\\(ght\\|te\\)[ \t]*\\'" time2conv)
-	 0)
-	((string-match "^[ \t]*noon[ \t]*\\'" time2conv)
-	 (* 12 60))
-	(t
-	 (let ((hr 0)
-	       (min 0))
-	   (or (string-match
-		 "\\`[ \t]*\\([0-9][0-9]?\\)[ \t]*\\(:[ \t]*\\([0-9][0-9]\\)\\)?[ \t]*\\(am\\|pm\\)?"
-		 time2conv)
-	       (error "unparsable time \"%s\"" time2conv))
-	   (setq hr (string-to-int
-		      (substring time2conv
-				 (match-beginning 1) (match-end 1))))
-	   (if (match-beginning 3)
-	       (setq min (string-to-int 
-			   (substring time2conv 
-				      (match-beginning 3) (match-end 3)))))
-	   ;; convert the time appointment time into 24 hour time
-	   (if (match-beginning 4)
-	       (progn
-		 (if (or (= hr 0) (> hr 12))
-		     (error "mixing 12hr and 24 hr time!  %s" time2conv))
-		 (if (string-match "am"
-				   (substring time2conv (match-beginning 4)))
-		     (if (= hr 12) (setq hr 0))
-		   (if (< hr 12) (setq hr (+ 12 hr))))))
-	   (if (> min 59) (error "minutes outa bounds - %s" time2conv))
-	   (+ (* hr 60) min)))))
-
 
 (defun appt-current-time-in-minutes ()
   "Returns the current time in minutes since midnight."
     (+ (* hour 60) min)))
 
 
-(defun appt-sort-list (appt-list)
-  (sort (copy-sequence appt-list)
-	(function (lambda (x y)
-	  (< (car (car x)) (car (car y)))))))
-
 (defun appt-diary-entries ()
   "Return an updated list of appointments for today."
   (let ((list-diary-entries-hook '(appt-make-list))
 	  ((= n 1) (message "1 appointment today."))
 	  (t (message "%d appointments today." n)))))
 
-(defun appt-make-list ()
-  "Don't call this directly; call appt-initialize or appt-diary-entries."
-  (setq appt-time-msg-list nil)
-  (if diary-entries-list
-      ;; Cycle through the entry-list (diary-entries-list) looking for
-      ;; entries beginning with a time. If the entry begins with a time,
-      ;; add it to the appt-time-msg-list. Then sort the list.
-      ;;
-      (let ((entry-list diary-entries-list)
-	    (new-appts '()))
-	(while (and entry-list
-		    (calendar-date-equal
-		      (calendar-current-date) (car (car entry-list))))
-	  (let ((time-string (car (cdr (car entry-list)))))
-	    (while (string-match
-		    "\\`[ \t\n]*\\([0-9]?[0-9]\\(:[0-9][0-9]\\)?[ \t]*\\(am\\|pm\\)?\\|noon\\|midnight\\|midnite\\).*$"
-		     time-string)
-	      (let* ((eol (match-end 0))
-		     (appt-time-string
-		      (substring time-string (match-beginning 1)
-				 (match-end 1)))
-		     (appt-msg-string
-		      (substring time-string (match-end 1) eol))
-		     (appt-time (list (appt-convert-time appt-time-string))))
-		(setq time-string (substring time-string eol)
-		      new-appts (cons (cons appt-time
-					    (list (concat appt-time-string ":"
-							  appt-msg-string)))
-				      new-appts))))
-	    (if appt-check-time-syntax
-		(while (string-match "\n*\\([^\n]+\\)$" time-string)
-		  (beep)
-		  (message "Unparsable time: %s"
-			   (substring time-string (match-beginning 1)
-				      (match-end 1)))
-		  (sit-for 3)
-		  (setq time-string (substring time-string (match-end 0)))))
-					       
-	    )
-	  (setq entry-list (cdr entry-list)))
-	(setq appt-time-msg-list ; seems we can't nconc this list...
-	      (append (nreverse new-appts) appt-time-msg-list))))
-  (setq appt-time-msg-list (appt-sort-list appt-time-msg-list))
-  ;;
-  ;; Get the current time and convert it to minutes from midnight, i.e.,
-  ;; 12:01am = 1, midnight = 0, so that the elements in the list that
-  ;; are earlier than the present time can be removed.
-  ;;
-  (let ((cur-comp-time (appt-current-time-in-minutes))
-	(appt-comp-time (car (car (car appt-time-msg-list)))))
-    (while (and appt-time-msg-list (< appt-comp-time cur-comp-time))
-      (setq appt-time-msg-list (cdr appt-time-msg-list)) 
-      (if appt-time-msg-list
-          (setq appt-comp-time (car (car (car appt-time-msg-list)))))))
-  appt-time-msg-list)
-
+(defvar appt-buffer-name " *appt-buf*"
+  "Name of the appointments buffer.")
 
 (defun appt-beep (&optional final-p)
   (cond ((null appt-audible) nil)
 
 (defun appt-check ()
   "Check for an appointment and update the mode line and minibuffer if
- desired. Note: the time must be the first thing in the line in the diary
+ desired.
+Note: the time must be the first thing in the line in the diary 
  for a warning to be issued.
-  The format of the time can be either 24 hour or am/pm.  Example: 
- 
+
+The format of the time can be either 24 hour or am/pm.
+Example: 
+  
                02/23/89
                  18:00 Dinner
+
               Thursday
                 11:45am Lunch meeting.
   
  The following variables control the action of the notification:
  
- appt-issue-message		If this variable is nil, then the code in this
-				file does nothing.
+appt-issue-message
+       If T, the diary buffer is checked for appointments.
+
  appt-msg-countdown-list	Specifies how much warning you want before 
 				appointments.
- appt-audible			Whether to beep when it's notification-time.
+appt-audible
+       Variable used to determine if appointment is audible.
+       Default is t.
+
  appt-display-mode-line		Whether to display a countdown to the next 
 				appointment in the mode-line.
  appt-announce-method   	The function used to do the notifications.
 				window, 'appt-message-announce or 
 				'appt-persistent-message-announce to do it 
 				in the echo-area.
+appt-display-duration
+       The number of seconds an appointment message
+       is displayed in another window.
+
  appt-display-duration  	If appt-announce-method is set to the function
 				'appt-window-announce, this specifies how many
 				seconds the pop-up window should stick around.
  
  This function is run from the `loadst' or `wakeup' process for display-time.
- Therefore, you need to have (display-time) in your .emacs file."
+ Therefore, you need to have `(display-time)' in your .emacs file."
   (if appt-issue-message
    (let ((min-to-app -1))
      ;; Get the current time and convert it to minutes
-     ;; from midnight, i.e., 12:01am = 1, midnight = 0.
+     ;; from midnight. i.e., 12:01am = 1, midnight = 0.
      (let* ((cur-comp-time (appt-current-time-in-minutes))
 	    ;; If the current time is the same as the tick, just return.
 	    ;; This means that this function has been called more than once
        (if 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))
-	     (while (and appt-time-msg-list (< appt-comp-time cur-comp-time))
+	
+	     (while (and appt-time-msg-list 
+			 (< appt-comp-time cur-comp-time))
 	       (setq appt-time-msg-list (cdr appt-time-msg-list)) 
 	       (if appt-time-msg-list
 		   (setq appt-comp-time (car (car (car appt-time-msg-list))))))
 ;;; Interactively adding and deleting appointments
 
 (defun appt-add (new-appt-time new-appt-msg)
-  "Adds an appointment to the list of appointments for the day at TIME
- and issue MESSAGE. The time should be in either 24 hour format or
- am/pm format. "
+  "Add an appointment for the day at TIME and issue MESSAGE.
+The time should be in either 24 hour format or am/pm format."
  
   (interactive "sTime (hh:mm[am/pm]): \nsMessage: ")
   (if (string-match "[0-9]?[0-9]:[0-9][0-9]\\(am\\|pm\\)?" new-appt-time)
     (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)))) 
 
 (defun appt-delete ()
-  "Deletes an appointment from the list of appointments."
+  "Delete an appointment from the list of appointments."
   (interactive)
   (let* ((tmp-msg-list appt-time-msg-list))
     (while tmp-msg-list
     (message "")))
 
 
-;;; Patching in to existing time code to install our hook.
+;; Create the appointments list from todays diary buffer.
+;; The time must be at the beginning of a line for it to be
+;; put in the appointments list.
+;;                02/23/89
+;;                  12:00pm lunch
+;;                 Wednesday
+;;                   10:00am group meeting
+;; We assume that the variables DATE and NUMBER
+;; hold the arguments that list-diary-entries received.
+;; They specify the range of dates that the diary is being processed for.
+
+;;;###autoload
+ (defun appt-make-list ()
+  "Don't call this directly; call appt-initialize or appt-diary-entries."
+  (setq appt-time-msg-list nil)
+  (if diary-entries-list
+
+           ;; Cycle through the entry-list (diary-entries-list)
+           ;; looking for entries beginning with a time. If 
+           ;; the entry begins with a time, add it to the
+           ;; appt-time-msg-list. Then sort the list.
+
+      (let ((entry-list diary-entries-list)
+	    (new-appts '()))
+	(while (and entry-list
+		    (calendar-date-equal
+		      (calendar-current-date) (car (car entry-list))))
+	  (let ((time-string (car (cdr (car entry-list)))))
+	    (while (string-match
+		    "\\`[ \t\n]*\\([0-9]?[0-9]\\(:[0-9][0-9]\\)?[ \t]*\\(am\\|pm\\)?\\|noon\\|midnight\\|midnite\\).*$"
+		     time-string)
+	      (let* ((eol (match-end 0))
+		     (appt-time-string
+		      (substring time-string (match-beginning 1)
+				 (match-end 1)))
+		     (appt-msg-string
+		      (substring time-string (match-end 1) eol))
+		     (appt-time (list (appt-convert-time appt-time-string))))
+		(setq time-string (substring time-string eol)
+		      new-appts (cons (cons appt-time
+					    (list (concat appt-time-string ":"
+							  appt-msg-string)))
+				      new-appts))))
+	    (if appt-check-time-syntax
+		(while (string-match "\n*\\([^\n]+\\)$" time-string)
+		  (beep)
+		  (message "Unparsable time: %s"
+			   (substring time-string (match-beginning 1)
+				      (match-end 1)))
+		  (sit-for 3)
+		  (setq time-string (substring time-string (match-end 0)))))
+					       
+	    )
+	  (setq entry-list (cdr entry-list)))
+	(setq appt-time-msg-list ; seems we can't nconc this list...
+	      (append (nreverse new-appts) appt-time-msg-list))))
+  (setq appt-time-msg-list (appt-sort-list appt-time-msg-list))
+        ;; Get the current time and convert it to minutes 
+        ;; from midnight, i.e., 12:01am = 1, midnight = 0, 
+        ;; so that the elements in the list 
+        ;; that are earlier than the present time can 
+        ;; be removed.
+
+  (let ((cur-comp-time (appt-current-time-in-minutes))
+	(appt-comp-time (car (car (car appt-time-msg-list)))))
+    (while (and appt-time-msg-list (< appt-comp-time cur-comp-time))
+      (setq appt-time-msg-list (cdr appt-time-msg-list)) 
+      (if appt-time-msg-list
+          (setq appt-comp-time (car (car (car appt-time-msg-list)))))))
+  appt-time-msg-list)
+
+(defun appt-sort-list (appt-list)
+  (sort (copy-sequence appt-list)
+	(function (lambda (x y)
+	  (< (car (car x)) (car (car y)))))))
+
+(defun appt-convert-time (time2conv)
+  "Convert hour:min[am/pm] format to minutes from midnight."
+  (cond ((string-match "^[ \t]*midni\\(ght\\|te\\)[ \t]*\\'" time2conv)
+	 0)
+	((string-match "^[ \t]*noon[ \t]*\\'" time2conv)
+	 (* 12 60))
+	(t
+	 (let ((hr 0)
+	       (min 0))
+	   (or (string-match
+		 "\\`[ \t]*\\([0-9][0-9]?\\)[ \t]*\\(:[ \t]*\\([0-9][0-9]\\)\\)?[ \t]*\\(am\\|pm\\)?"
+		 time2conv)
+	       (error "unparsable time \"%s\"" time2conv))
+	   (setq hr (string-to-int
+		      (substring time2conv
+				 (match-beginning 1) (match-end 1))))
+	   (if (match-beginning 3)
+	       (setq min (string-to-int 
+			   (substring time2conv 
+				      (match-beginning 3) (match-end 3)))))
+	   ;; convert the time appointment time into 24 hour time
+	   (if (match-beginning 4)
+	       (progn
+		 (if (or (= hr 0) (> hr 12))
+		     (error "mixing 12hr and 24 hr time!  %s" time2conv))
+		 (if (string-match "am"
+				   (substring time2conv (match-beginning 4)))
+		     (if (= hr 12) (setq hr 0))
+		   (if (< hr 12) (setq hr (+ 12 hr))))))
+	   (if (> min 59) (error "minutes outa bounds - %s" time2conv))
+	   (+ (* hr 60) min)))))
 
 
 (defvar display-time-hook-installed nil)
      (setq display-time-hook (cons appt-check display-time-hook)))
    ))
 
-(provide 'appt)
+;;; appt.el ends here
+
 ;;; cal-dst.el --- calendar functions for daylight savings rules.
 
-;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
 
 ;; Author: Paul Eggert <eggert@twinsun.com>
 ;;	Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Synched up with: FSF 20.2
+
 ;;; Commentary:
 
 ;; This collection of functions implements the features of calendar.el and
 ;;; Code:
 
 (require 'calendar)
+(require 'cal-persia)
 
 (defvar calendar-current-time-zone-cache nil
   "Cache for result of calendar-current-time-zone.")
 
 (defun calendar-time-zone-daylight-rules (abs-date utc-diff)
   "Return daylight transition rule for ABS-DATE, UTC-DIFF sec offset from UTC.
-ABS-DIFF must specify a day that contains a daylight savings transition.
+ABS-DATE must specify a day that contains a daylight savings transition.
 The result has the proper form for calendar-daylight-savings-starts'."
   (let* ((date (calendar-gregorian-from-absolute abs-date))
 	 (weekday (% abs-date 7))
 		      (cons
 		       (list 'calendar-nth-named-day 1 weekday m 'year j)
 		       l)))
-	     l)))
+            l)
+          ;; 01-01 and 07-01 for this year's Persian calendar.
+          (if (and (= m 3) (<= 20 d) (<= d 21))
+              '((calendar-gregorian-from-absolute
+                 (calendar-absolute-from-persian
+                  (list 1 1 (- year 621))))))
+          (if (and (= m 9) (<= 22 d) (<= d 23))
+              '((calendar-gregorian-from-absolute
+                 (calendar-absolute-from-persian
+                  (list 7 1 (- year 621))))))))
 	 (prevday-sec (- -1 utc-diff)) ;; last sec of previous local day
 	 (year (1+ y)))
     ;; Scan through the next few years until only one rule remains.
 		    (list t1-name t0-name t2-rules t1-rules t2-time t1-time)
 		    )))))))))))
 
-;;; The following six defvars relating to daylight savings time should NOT be
+;;; The following eight defvars relating to daylight savings time should NOT be
 ;;; marked to go into loaddefs.el where they would be evaluated when Emacs is
 ;;; dumped.  These variables' appropriate values depend on the conditions under
 ;;; which the code is INVOKED; so it's inappropriate to initialize them when
       calendar-daylight-savings-starts-time)
   "*Number of minutes after midnight that daylight savings time ends.")
 
+(defun dst-in-effect (date)
+  "True if on absolute DATE daylight savings time is in effect.
+Fractional part of DATE is local standard time of day."
+  (let* ((year (extract-calendar-year
+                (calendar-gregorian-from-absolute (floor date))))
+         (dst-starts-gregorian (eval calendar-daylight-savings-starts))
+         (dst-ends-gregorian (eval calendar-daylight-savings-ends))
+         (dst-starts (and dst-starts-gregorian
+                          (+ (calendar-absolute-from-gregorian
+                              dst-starts-gregorian)
+                             (/ calendar-daylight-savings-starts-time
+                                60.0 24.0))))
+         (dst-ends (and dst-ends-gregorian
+                        (+ (calendar-absolute-from-gregorian
+                            dst-ends-gregorian)
+                           (/ (- calendar-daylight-savings-ends-time
+                                 calendar-daylight-time-offset)
+                              60.0 24.0)))))
+    (and dst-starts dst-ends
+         (if (< dst-starts dst-ends)
+             (and (<= dst-starts date) (< date dst-ends))
+           (or (<= dst-starts date) (< date dst-ends))))))
+
+(defun dst-adjust-time (date time &optional style)
+  "Adjust, to account for dst on DATE, decimal fraction standard TIME.
+Returns a list (date adj-time zone) where `date' and `adj-time' are the values
+adjusted for `zone'; here `date' is a list (month day year), `adj-time' is a
+decimal fraction time, and `zone' is a string.
+
+Optional parameter STYLE forces the result time to be standard time when its
+value is 'standard and daylight savings time (if available) when its value is
+'daylight.
+
+Conversion to daylight savings time is done according to
+`calendar-daylight-savings-starts', `calendar-daylight-savings-ends',
+`calendar-daylight-savings-starts-time',
+`calendar-daylight-savings-ends-time', and
+`calendar-daylight-savings-offset'."
+
+  (let* ((rounded-abs-date (+ (calendar-absolute-from-gregorian date)
+                             (/ (round (* 60 time)) 60.0 24.0)))
+         (dst (dst-in-effect rounded-abs-date))
+        (time-zone (if dst
+                       calendar-daylight-time-zone-name
+                       calendar-standard-time-zone-name))
+        (time (+ rounded-abs-date
+                  (if dst (/ calendar-daylight-time-offset 24.0 60.0) 0))))
+    (list (calendar-gregorian-from-absolute (truncate time))
+          (* 24.0 (- time (truncate time)))
+          time-zone)))
+ 
 (provide 'cal-dst)
 
 ;;; cal-dst.el ends here
 ;;; cal-mayan.el --- calendar functions for the Mayan calendars.
 
-;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc.
 
 ;; Author: Stewart M. Clamen <clamen@cs.cmu.edu>
 ;;	Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Synched up with: FSF 20.2
+
 ;;; Commentary:
 
 ;; This collection of functions implements the features of calendar.el and
 
 (require 'calendar)
 
-(defun mayan-adjusted-mod (m n)
-  "Non-negative remainder of M/N with N instead of 0."
-  (1+ (mod (1- m) n)))
-
 (defconst calendar-mayan-days-before-absolute-zero 1137140
   "Number of days of the Mayan calendar epoch before absolute day 0.
 According to the Goodman-Martinez-Thompson correlation.  This correlation is
 (defun calendar-mayan-tzolkin-from-absolute (date)
   "Convert absolute DATE into a Mayan tzolkin date (a pair)."
   (let* ((long-count (+ date calendar-mayan-days-before-absolute-zero))
-         (day (mayan-adjusted-mod
+         (day (calendar-mod
                (+ long-count (car calendar-mayan-tzolkin-at-epoch))
                13))
-         (name (mayan-adjusted-mod
+         (name (calendar-mod
                 (+ long-count (cdr calendar-mayan-tzolkin-at-epoch))
                 20)))
     (cons day name)))
 
 (defun calendar-next-calendar-round-date
   (tzolkin-date haab-date &optional noecho)
-  "Move cursor to next instance of Mayan HAAB-DATE TZOKLIN-DATE combination.
+  "Move cursor to next instance of Mayan HAAB-DATE TZOLKIN-DATE combination.
 Echo Mayan date if NOECHO is t."
   (interactive (list (calendar-read-mayan-tzolkin-date)
                      (calendar-read-mayan-haab-date)))
 
 (defun calendar-previous-calendar-round-date
   (tzolkin-date haab-date &optional noecho)
-  "Move to previous instance of Mayan TZOKLIN-DATE HAAB-DATE combination.
+  "Move to previous instance of Mayan TZOLKIN-DATE HAAB-DATE combination.
 Echo Mayan date if NOECHO is t."
   (interactive (list (calendar-read-mayan-tzolkin-date)
                      (calendar-read-mayan-haab-date)))
 ;;; cal-x.el --- calendar windows in dedicated frames in x-windows
 
-;; Copyright (C) 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
 ;;      Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Synched up with (Mostly): FSF 20.2
+
 ;;; Commentary:
 
 ;; This collection of functions implements dedicated frames in x-windows for
 ;;; Code:
 
 (require 'calendar)
-(if (not (fboundp 'calendar-basic-setup))
-    (fset 'calendar-basic-setup (symbol-function 'calendar)))
- 
-;;;###autoload
-(defvar calendar-setup 'one-frame
-  "The frame set up of the calendar.
-The choices are `one-frame' (calendar and diary together in one separate,
-dediciated frame) or `two-frames' (calendar and diary in separate, dedicated
-frames); with any other value the current frame is used.")
-
-(defun calendar (&optional arg)
-  "Choose between the one frame, two frame, or basic calendar displays.
-The original function `calendar' has been renamed `calendar-basic-setup'."
-  (interactive "P")
-  (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
-        ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
-        (t (calendar-basic-setup arg))))
 
 (defvar calendar-frame nil "Frame in which to display the calendar.")
 
 (defvar diary-frame nil "Frame in which to display the diary.")
   
+;; This should not specify the font.  That's up to the user.
+;; 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)
-    (font . "6x13") (auto-lower . t) (auto-raise . t) (minibuffer . nil))
+    (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)
-    (auto-raise . t) (auto-lower . t) (font . "6x13") (unsplittable . t)
-    (vertical-scroll-bars . nil))
+    (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)
-    (font . "6x13") (auto-raise . t) (auto-lower . t))
+  '((name . "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 make-fancy-diary-buffer ()
-  (save-excursion
-    (set-buffer (get-buffer-create fancy-diary-buffer))
-    (setq buffer-read-only nil)
-    (make-local-variable 'mode-line-format)
-    (calendar-set-mode-line "Diary Entries")
-    (erase-buffer)
-    (set-buffer-modified-p nil)
-    (setq buffer-read-only t)))
-
 (if (not (string-match "XEmacs" emacs-version))
     (setq special-display-buffer-names
 	  (append special-display-buffer-names
 ;;; cal-xemacs.el --- calendar functions for menu bar and popup menu support
 ;;; Original file is cal-menu.el.
 
-;; Copyright (C) 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
 ;;	Lara Rios <lrios@coewl.cen.uiuc.edu>
 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Synched up with: cal-menu.el in Emacs 20.2
+
 ;;; Commentary:
 
 ;; This collection of functions implements menu bar and popup menu support for
 	       ["Mark date" calendar-mouse-set-mark t]
 	       ["Sunrise/sunset" calendar-mouse-sunrise/sunset t]
 	       ["Other calendars" calendar-mouse-print-dates (calendar-event-to-date e)]
+	       ["Prepare LaTeX Buffer" calendar-mouse-cal-tex-menu (calendar-event-to-date e)]
 	       ["Diary entries" calendar-mouse-view-diary-entries t]
 	       ["Insert diary entry" calendar-mouse-insert-diary-entry t]
 	       ["Other Diary file entries"
 		(calendar-cursor-to-date)]
 	       )))
     (popup-menu menu)))
+
 (define-key calendar-mode-map 'button2 'calendar-popup-menu-2)
 
+(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)
+		     "-----"
+		     ["Daily (1 page)"    cal-tex-mouse-day  ]
+		     ["Weekly (1 page)"   cal-tex-mouse-week ]
+		     ["Weekly (2 pages)"  cal-tex-mouse-week2]
+		     ["Weekly (other style; 1 page)" cal-tex-mouse-week-iso]
+		     ["Weekly (yet another style; 1 page)"
+		      cal-tex-mouse-week-monday]
+		     ["Monthly" cal-tex-mouse-month]
+		     ["Monthly (landscape)"  cal-tex-mouse-month-landscape]
+		     ["Yearly"  cal-tex-mouse-year]
+		     ["Yearly (landscape)"  cal-tex-mouse-year-landscape]
+		     ["Filofax styles" cal-tex-mouse-filofax]
+		     )))
+    (popup-menu 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)
+		     "-----"
+		     ["Filofax Weekly (2-weeks-at-a-glance)"   
+		      cal-tex-mouse-filofax-2week]
+		     ["Filofax Weekly (week-at-a-glance)" 
+		      cal-tex-mouse-filofax-week]
+		     ["Filofax Yearly"  cal-tex-mouse-filofax-year]
+		     )))
+    (popup-menu menu)
+    ))
+
 (defconst calendar-scroll-menu
   '("Scroll"
     ["Forward 1 Month" scroll-calendar-left t]
 
 (defconst calendar-goto-menu
   '("Goto"
-    ["Today" calendar-current-month t]
+    ["Today" calendar-goto-today t]
     ["Beginning of week" calendar-beginning-of-week (calendar-cursor-to-date)]
     ["End of week" calendar-end-of-week (calendar-cursor-to-date)]
     ["Beginning of month" calendar-beginning-of-month (calendar-cursor-to-date)]
     ["ISO date" calendar-goto-iso-date t]
     ["Astronomical date" calendar-goto-astro-day-number t]
     ["Hebrew date" calendar-goto-hebrew-date t]
+    ["Persian date" calendar-goto-persian-date t]
     ["Islamic date" calendar-goto-islamic-date t]
     ["Julian date" calendar-goto-julian-date t]
+    ["Chinese date" calendar-goto-chinese-date t]
+    ["Coptoc date" calendar-goto-coptic-date t]
+    ["Ethiopic date" calendar-goto-ethiopic-date t]
     ("Mayan date"
      ["Next Tzolkin" calendar-next-tzolkin-date t]
      ["Previous Tzolkin" calendar-previous-tzolkin-date t]
   '("Holidays"
     ["One day" calendar-cursor-holidays (calendar-cursor-to-date)]
     ["3 months" list-calendar-holidays t]
+    ["Year" cal-menu-list-holidays-year t]
+    ["Following year"  cal-menu-list-holidays-following-year]
+    ["Previous year"  cal-menu-list-holidays-previous-year]
     ["Mark" mark-calendar-holidays t]
     ["Unmark" calendar-unmark t]))
 
     (if (not (assoc "Moon" current-menubar))
 	(add-menu-button '("Calendar") ["Moon" calendar-phases-of-moon t]))))
 
+(defun cal-menu-list-holidays-year ()
+  "Display a list of the holidays of the selected date's year."
+  (interactive)
+  (let ((year (extract-calendar-year (calendar-cursor-to-date))))
+    (list-holidays year year)))
+
+(defun cal-menu-list-holidays-following-year ()
+  "Display a list of the holidays of the following year."
+  (interactive)
+  (let ((year (1+ (extract-calendar-year (calendar-cursor-to-date)))))
+    (list-holidays year year)))
+
+(defun cal-menu-list-holidays-previous-year ()
+  "Display a list of the holidays of the previous year."
+  (interactive)
+  (let ((year (1- (extract-calendar-year (calendar-cursor-to-date)))))
+    (list-holidays year year)))
+
 (defun calendar-event-to-date (event &optional error)
   "Date of last event.
 If event is not on a specific date, signals an error if optional parameter
     (setq calendar-foobar nil)
     (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)
+    (cal-tex-cursor-day nil)))
+
+(defun cal-tex-mouse-week ()
+  "One page calendar for week indicated by cursor.
+Holidays are included if `cal-tex-holidays' is t."
+  (interactive)
+  (save-excursion
+    (calendar-goto-date calendar-foobar)
+    (setq calendar-foobar nil)
+    (cal-tex-cursor-week nil)))
+
+(defun cal-tex-mouse-week2 ()
+  "Make a buffer with LaTeX commands for the week cursor is on.
+The printed output will be on two pages."
+  (interactive)
+  (save-excursion
+    (calendar-goto-date calendar-foobar)
+    (setq calendar-foobar nil)
+    (cal-tex-cursor-week2 nil)))
+
+(defun cal-tex-mouse-week-iso ()
+  "One page calendar for week indicated by cursor.
+Holidays are included if `cal-tex-holidays' is t."
+  (interactive)
+  (save-excursion
+    (calendar-goto-date calendar-foobar)
+    (setq calendar-foobar nil)
+    (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)
+    (cal-tex-cursor-week-monday 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)
+    (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)
+    (cal-tex-cursor-filofax-week nil)))
+
+(defun cal-tex-mouse-month ()
+  "Make a buffer with LaTeX commands for the month cursor is on.
+Calendar is condensed onto one page."
+  (interactive)
+  (save-excursion
+    (calendar-goto-date calendar-foobar)
+    (setq calendar-foobar nil)
+    (cal-tex-cursor-month nil)))
+
+(defun cal-tex-mouse-month-landscape ()
+  "Make a buffer with LaTeX commands for the month cursor is on.
+The output is in landscape format, one month to a page."
+  (interactive)
+  (save-excursion
+    (calendar-goto-date calendar-foobar)
+    (setq calendar-foobar nil)
+    (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)
+    (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)
+    (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)
+    (cal-tex-cursor-year-landscape nil)))
+
 (defun calendar-mouse-print-dates ()
   "Pop up menu of equivalent dates to mouse selected date."
   (interactive)
 			     (calendar-astro-date-string calendar-foobar))
 		     (format "Hebrew date (before sunset): %s"
 			     (calendar-hebrew-date-string calendar-foobar))
+		     (format "Persian date: %s"
+			     (calendar-persian-date-string calendar-foobar))
 		     (let ((i (calendar-islamic-date-string calendar-foobar)))
 		       (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)))
+		       (if (not (string-equal c ""))
+			   (format "Coptic date: %s" c)))
+		     (let ((e (calendar-ethiopic-date-string calendar-foobar)))
+		       (if (not (string-equal e ""))
+			   (format "Ethiopic date: %s" e)))
 		     (let ((f (calendar-french-date-string calendar-foobar)))
 		       (if (not (string-equal f ""))
 			   (format "French Revolutionary date: %s" f)))
-		     (format "Mayan date: %s" (calendar-mayan-date-string calendar-foobar)))))
-    (popup-menu menu))
+		     (format "Mayan date: %s" 
+			     (calendar-mayan-date-string calendar-foobar))
+		     )))
+    (popup-menu menu)
+    (message "%s" menu)
+    )
   (setq calendar-foobar nil))
 
 (run-hooks 'cal-xemacs-load-hook)
 ;;; calendar.el --- Calendar functions.  -*-byte-compile-dynamic: t;-*-
 
-;;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Free Software
-;;; Foundation, Inc.
+;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997 
+;;       Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; Keywords: calendar
 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Synched up with (Mostly): FSF 20.2
+
 ;;; Commentary:
 
-;; This collection of functions implements a calendar window.  It
-;; generates a calendar for the current month, together with the previous
-;; and coming months, or for any other three-month period.  The calendar
-;; can be scrolled forward and backward in the window to show months in
-;; the past or future; the cursor can move forward and backward by days,
-;; weeks, or months, making it possible, for instance, to jump to the
-;; date a specified number of days, weeks, or months from the date under
-;; the cursor.  The user can display a list of holidays and other notable
-;; days for the period shown; the notable days can be marked on the
-;; calendar, if desired.  The user can also specify that dates having
-;; corresponding diary entries (in a file that the user specifies) be
-;; marked; the diary entries for any date can be viewed in a separate
-;; window.  The diary and the notable days can be viewed independently of
-;; the calendar.  Dates can be translated from the (usual) Gregorian
-;; calendar to the day of the year/days remaining in year, to the ISO
-;; commercial calendar, to the Julian (old style) calendar, to the Hebrew
-;; calendar, to the Islamic calendar, to the French Revolutionary calendar,
-;; to the Mayan calendar, and to the astronomical (Julian) day number.
-;; When floating point is available, times of sunrise/sunset can be displayed,
-;; as can the phases of the moon.  Appointment notification for diary entries
-;; is available.
+;; This collection of functions implements a calendar window.  It generates a
+;; calendar for the current month, together with the previous and coming
+;; months, or for any other three-month period.  The calendar can be scrolled
+;; forward and backward in the window to show months in the past or future; 
+;; the cursor can move forward and backward by days, weeks, or months, making 
+;; it possible, for instance, to jump to the date a specified number of days,
+;; weeks, or months from the date under the cursor.  The user can display a
+;; list of holidays and other notable days for the period shown; the notable
+;; days can be marked on the calendar, if desired.  The user can also specify
+;; that dates having corresponding diary entries (in a file that the user
+;; specifies) be marked; the diary entries for any date can be viewed in a
+;; separate window.  The diary and the notable days can be viewed 
+;; independently of the calendar.  Dates can be translated from the (usual) 
+;; Gregorian calendar to the day of the year/days remaining in year, to the 
+;; ISO commercial calendar, to the Julian (old style) calendar, to the Hebrew 
+;; calendar, to the Islamic calendar, to the French Revolutionary calendar, to
+;; the Mayan calendar, to the Chinese calendar, to the Coptic calendar, to the
+;; Ethiopic calendar,and to the astronomical (Julian) day number.  When
+;; floating point is available, times of sunrise/sunset can be displayed, as
+;; can the phases of the moon.  Appointment notification for diary entries is
+;; available. Calendar printing via LaTeX is available.
 
 ;; The following files are part of the calendar/diary code:
 
+;;       appt.el                       Appointment notification
+;;       cal-china.el                  Chinese calendar
+;;       cal-coptic.el                 Coptic/Ethiopic calendars
+;;       cal-dst.el                    Daylight savings time rules
+;;       cal-hebrew.el                 Hebrew calendar
+;;       cal-islam.el                  Islamic calendar
+;;       cal-iso.el                    ISO calendar
+;;       cal-julian.el                 Julian/astronomical calendars
+;;       cal-mayan.el                  Mayan calendars
 ;;       cal-menu.el                   Menu support
+;;       cal-move.el                   Movement in the calendar
+;;       cal-persia.el                 Persian calendar
+;;       cal-tex.el                    Calendars in LaTeX
 ;;       cal-x.el                      X-windows dedicated frame functions
-;;       diary-lib.el, diary-ins.el    Diary functions
+;;       diary-lib.el                  Diary functions
 ;;       holidays.el                   Holiday functions
 ;;       cal-french.el                 French Revolutionary calendar
-;;       cal-mayan.el                  Mayan calendars
-;;       cal-dst.el                    Daylight savings time rules
+;;       lunar.el                      Phases of the moon
 ;;       solar.el                      Sunrise/sunset, equinoxes/solstices
-;;       lunar.el                      Phases of the moon
-;;       appt.el                       Appointment notification
 
 ;; Comments, corrections, and improvements should be sent to
 ;;  Edward M. Reingold               Department of Computer Science
 
 ;;; Code:
 
+(defun calendar-version ()
+  (interactive)
+  (message "Version 6, October 12, 1995"))
+
+(defgroup calendar nil
+  "Calendar and time management support."
+  :group 'applications)
+
 (defgroup diary nil
-  "Diary customization"
+  "Emacs diary."
+  :group 'calendar)
+
+(defgroup appt nil
+  "Appointment notification."
+  :tag "Appointments"
   :group 'calendar)
 
 (defgroup holidays nil
-  "Holidays in calendar"
+  "Holidays support in calendar."
+  :group 'calendar
+  :prefix "calendar-"
+  :group 'local)
+
+(defgroup chinese-calendar nil
+  "Chinese calendar support."
   :group 'calendar)
 
-(defun calendar-version ()
-  (interactive)
-  (message "Version 5.3, January 25, 1994"))
+(defgroup calendar-tex nil
+  "Options for printing calendar with LaTeX."
+  :prefix "cal-tex-"
+  :group 'calendar)
 
-(defgroup appt nil
-  "Appointment notification"
-  :tag "Appointments"
+(defgroup calendar-hooks nil
+  "Calendar hooks."
+  :prefix "calendar-"
   :group 'calendar)
 
 
 This variable does not affect the diary display with the `d' command
 from the calendar; in that case, the prefix argument controls the
 number of days of diary entries displayed."
-  :type 'integer
-  :group 'diary)
+  :type '(choice (integer :tag "Entries")
+                (vector :value [0 0 0 0 0 0 0]
+                        (integer :tag "Sunday")
+                        (integer :tag "Monday")
+                        (integer :tag "Tuesday")
+                        (integer :tag "Wednesday")
+                        (integer :tag "Thursday")
+                        (integer :tag "Friday")
+                        (integer :tag "Saturday")))
+    :group 'diary)
 
 ;;;###autoload
 (defcustom mark-diary-entries-in-calendar nil
 			 (set-face-font 'diary-face bfont 'global
 					gray-tag)))))))
     'diary-face)
-  "*Used to mark dates that have diary entries.
-Can be either a single-character string or a face."
+  "*How to mark dates that have diary entries.
+The value can be either a single-character string or a face."
   :type '(choice string face)
   :group 'diary)
 
     (if (not (face-differs-from-default-p 'calendar-today-face))
 	(set-face-underline-p 'calendar-today-face t))
     'calendar-today-face)
-  "*Used to mark today's date.
-Can be either a single-character string or a face."
+  "*How to mark today's date in the calendar.
+The value can be either a single-character string or a face.
+Marking today's date is done only if you set up `today-visible-calendar-hook'
+to request that."
   :type '(choice string face)
   :group 'calendar)
 
 	       (set-face-background 'holiday-face "pink" 'global color-tag)
 	       (set-face-reverse-p 'holiday-face t 'global 'tty))))
     'holiday-face)
-  "*Used to mark notable dates in the calendar.
-Can be either a single-character string or a face."
+  "*How to mark notable dates in the calendar.
+The value can be either a single-character string or a face."
   :type '(choice string face)
-  :group 'holidays)
+  :group 'calendar)
 
 ;;;###autoload
 (defcustom view-calendar-holidays-initially nil
   "*List of functions to be called after the calendar is first loaded.
 This is the place to add key bindings to `calendar-mode-map'."
   :type 'hook
-  :group 'calendar)
+  :group 'calendar-hooks)
 
 ;;;###autoload
 (defcustom initial-calendar-window-hook nil
 once opened is never called again.  Leaving the calendar with the `q' command
 and reentering it will cause these functions to be called again."
   :type 'hook
-  :group 'calendar)
+  :group 'calendar-hooks)
 
 ;;;###autoload
 (defcustom today-visible-calendar-hook nil
 characters in the calendar buffer by the hooks may cause the failure of the
 functions that move by days and weeks."
   :type 'hook
-  :group 'calendar)
+  :group 'calendar-hooks)
 
 ;;;###autoload
 (defcustom today-invisible-calendar-hook nil
 characters in the calendar buffer by the hooks may cause the failure of the
 functions that move by days and weeks."
   :type 'hook
-  :group 'calendar)
+  :group 'calendar-hooks)
 
 ;;;###autoload
 (defcustom diary-file "~/diary"
 10, 1990.  Other functions available are `diary-float', `diary-anniversary',
 `diary-cyclic', `diary-day-of-year', `diary-iso-date', `diary-french-date',
 `diary-hebrew-date', `diary-islamic-date', `diary-mayan-date',
-`diary-yahrzeit', `diary-sunrise-sunset', `diary-phases-of-moon',
-`diary-parasha', `diary-omer', `diary-rosh-hodesh', and
-`diary-sabbath-candles'.  See the documentation for the function
+`diary-chinese-date', `diary-coptic-date', `diary-ethiopic-date',
+`diary-persian-date', `diary-yahrzeit', `diary-sunrise-sunset',
+`diary-phases-of-moon', `diary-parasha', `diary-omer', `diary-rosh-hodesh',
+and `diary-sabbath-candles'.  See the documentation for the function
 `list-sexp-diary-entries' for more details.
 
 Diary entries based on the Hebrew and/or the Islamic calendar are also
 fancy diary buffer next to the date.  This slows down the diary functions
 somewhat; setting it to nil makes the diary display faster."
   :type 'boolean
-  :group 'diary)
+  :group 'holidays)
 
 (defvar calendar-mark-ring nil)
 
 ;;;###autoload
+(put 'general-holidays 'risky-local-variable t)
+;;;###autoload
 (defcustom general-holidays
   '((holiday-fixed 1 1 "New Year's Day")
     (holiday-float 1 1 3 "Martin Luther King Day")
     (holiday-fixed 2 14 "Valentine's Day")
     (holiday-float 2 1 3 "President's Day")
     (holiday-fixed 3 17 "St. Patrick's Day")
-    (holiday-fixed 4 1 "April Fool's Day")
+    (holiday-fixed 4 1 "April Fools' Day")
     (holiday-float 5 0 2 "Mother's Day")
     (holiday-float 5 1 -1 "Memorial Day")
     (holiday-fixed 6 14 "Flag Day")
   :group 'holidays)
 
 ;;;###autoload
-(put 'general-holidays 'risky-local-variable t)
+(put 'oriental-holidays 'risky-local-variable t)
+;;;###autoload
+(defcustom oriental-holidays
+  '((if (fboundp 'atan)
+       (holiday-chinese-new-year)))
+  "*Oriental holidays.
+See the documentation for `calendar-holidays' for details."
+  :type 'sexp
+  :group 'holidays)
 
 ;;;###autoload
+(put 'local-holidays 'risky-local-variable t)
+;;;###autoload
 (defcustom local-holidays nil
   "*Local holidays.
 See the documentation for `calendar-holidays' for details."
   :type 'sexp
-  :group 'holidays
-  :group 'local)
+  :group 'local
+  :group 'holidays)
 
 ;;;###autoload
-(put 'local-holidays 'risky-local-variable t)
+(put 'other-holidays 'risky-local-variable t)
 ;;;###autoload
 (defcustom other-holidays nil
   "*User defined holidays.
   :group 'holidays)
 
 ;;;###autoload
-(put 'other-holidays 'risky-local-variable t)
-
+(put 'hebrew-holidays-1 'risky-local-variable t)
 ;;;###autoload
 (defvar hebrew-holidays-1
   '((holiday-rosh-hashanah-etc)
                21))) "\"Tal Umatar\" (evening)"))))
 
 ;;;###autoload
-(put 'hebrew-holidays-1 'risky-local-variable t)
-
+(put 'hebrew-holidays-2 'risky-local-variable t)
 ;;;###autoload
 (defvar hebrew-holidays-2
   '((if all-hebrew-calendar-holidays
         (holiday-hebrew 11 15 "Tu B'Shevat"))))
 
 ;;;###autoload
-(put 'hebrew-holidays-2 'risky-local-variable t)
-
+(put 'hebrew-holidays-3 'risky-local-variable t)
 ;;;###autoload
 (defvar hebrew-holidays-3
   '((if all-hebrew-calendar-holidays
                   (day (extract-calendar-day s-s)))
              day))
          "Shabbat Shirah"))))
+
 ;;;###autoload
-(put 'hebrew-holidays-3 'risky-local-variable t)
-
+(put 'hebrew-holidays-4 'risky-local-variable t)
 ;;;###autoload
 (defvar hebrew-holidays-4
   '((holiday-passover-etc)
         (holiday-julian 3 26 "Kiddush HaHamah"))
     (if all-hebrew-calendar-holidays
         (holiday-tisha-b-av-etc))))
-;;;###autoload
-(put 'hebrew-holidays-4 'risky-local-variable t)
-
-;;;###autoload
-(defvar hebrew-holidays (append hebrew-holidays-1 hebrew-holidays-2
-				hebrew-holidays-3 hebrew-holidays-4)
-  "*Jewish holidays.
-See the documentation for `calendar-holidays' for details.")
 
 ;;;###autoload
 (put 'hebrew-holidays 'risky-local-variable t)
+;;;###autoload
+(defcustom hebrew-holidays (append hebrew-holidays-1 hebrew-holidays-2
+				hebrew-holidays-3 hebrew-holidays-4)
+  "*Jewish holidays.
+See the documentation for `calendar-holidays' for details."
+  :type 'sexp
+  :group 'holidays)
 
 ;;;###autoload
-(defvar christian-holidays
+(put 'christian-holidays 'risky-local-variable t)
+;;;###autoload
+(defcustom christian-holidays
   '((if all-christian-calendar-holidays
         (holiday-fixed 1 6 "Epiphany"))
     (holiday-easter-etc)
     (if all-christian-calendar-holidays
         (holiday-julian 12 25 "Eastern Orthodox Christmas")))
   "*Christian holidays.
-See the documentation for `calendar-holidays' for details.")
+See the documentation for `calendar-holidays' for details."
+  :type 'sexp
+  :group 'holidays)
 
 ;;;###autoload
-(put 'christian-holidays 'risky-local-variable t)
-
+(put 'islamic-holidays 'risky-local-variable t)
 ;;;###autoload
-(defvar islamic-holidays
+(defcustom islamic-holidays
   '((holiday-islamic
      1 1
      (format "Islamic New Year %d"
     (if all-islamic-calendar-holidays
         (holiday-islamic 12 10 "Id-al-Adha")))
   "*Islamic holidays.
-See the documentation for `calendar-holidays' for details.")
+See the documentation for `calendar-holidays' for details."
+  :type 'sexp
+  :group 'holidays)
 
 ;;;###autoload
-(put 'islamic-holidays 'risky-local-variable t)
-
+(put 'solar-holidays 'risky-local-variable t)
 ;;;###autoload
-(defvar solar-holidays
+(defcustom solar-holidays
   '((if (fboundp 'atan)
 	(solar-equinoxes-solstices))
     (if (progn
                    calendar-daylight-time-zone-name)
                 ""))))
   "*Sun-related holidays.
-See the documentation for `calendar-holidays' for details.")
+See the documentation for `calendar-holidays' for details."
+  :type 'sexp
+  :group 'holidays)
 
 ;;;###autoload
-(put 'solar-holidays 'risky-local-variable t)
-
-;;;###autoload
-(defvar calendar-holidays
+(put 'calendar-holidays 'risky-local-variable t)
+(defcustom calendar-holidays
   (append general-holidays local-holidays other-holidays
           christian-holidays hebrew-holidays islamic-holidays
-          solar-holidays)
+          oriental-holidays solar-holidays)
   "*List of notable days for the command M-x holidays.
 
 Additional holidays are easy to add to the list, just put them in the list
 `other-holidays' in your .emacs file.  Similarly, by setting any of
 `general-holidays', `local-holidays' `christian-holidays', `hebrew-holidays',
-`islamic-holidays', or `solar-holidays' to nil in your .emacs file, you can
-eliminate unwanted categories of holidays.  The intention is that (in the US)
-`local-holidays' be set in site-init.el and `other-holidays' be set by the
-user.
+`islamic-holidays', `oriental-holidays', or `solar-holidays' to nil in your
+.emacs file, you can eliminate unwanted categories of holidays.  The intention
+is that (in the US) `local-holidays' be set in site-init.el and
+`other-holidays' be set by the user.
 
 Entries on the list are expressions that return (possibly empty) lists of
 items of the form ((month day year) string) of a holiday in the in the
 you've written to return a (possibly empty) list of the relevant VISIBLE dates
 with descriptive strings such as
 
-     (((2 6 1989) \"New Moon\") ((2 12 1989) \"First Quarter Moon\") ... ).")
-
-;;;###autoload
-(put 'calendar-holidays 'risky-local-variable t)
-
+     (((2 6 1989) \"New Moon\") ((2 12 1989) \"First Quarter Moon\") ... )."
+  :type 'sexp
+  :group 'holidays)
+ 
 (defconst calendar-buffer "*Calendar*"
   "Name of the buffer used for the calendar.")
 
        (- (/ prior-years 100));;    - century years
        (/ prior-years 400))));;     + Gregorian leap years
 
+(autoload 'calendar-goto-today "cal-move"
+  "Reposition the calendar window so the current date is visible."
+  t)
+
+(autoload 'calendar-forward-month "cal-move"
+  "Move the cursor forward ARG months."
+  t)
+
+(autoload 'calendar-forward-year "cal-move"
+  "Move the cursor forward by ARG years."
+  t)
+
+(autoload 'calendar-backward-month "cal-move"
+  "Move the cursor backward by ARG months."
+  t)
+
+(autoload 'calendar-backward-year "cal-move"
+  "Move the cursor backward ARG years."
+  t)
+
+(autoload 'scroll-calendar-left "cal-move"
+  "Scroll the displayed calendar left by ARG months."
+  t)
+
+(autoload 'scroll-calendar-right "cal-move"
+  "Scroll the displayed calendar window right by ARG months."
+  t)
+
+(autoload 'scroll-calendar-left-three-months "cal-move"
+  "Scroll the displayed calendar window left by 3*ARG months."
+  t)
+
+(autoload 'scroll-calendar-right-three-months "cal-move"
+  "Scroll the displayed calendar window right by 3*ARG months."
+  t)
+
+(autoload 'calendar-cursor-to-nearest-date "cal-move"
+  "Move the cursor to the closest date."
+  t)
+
+(autoload 'calendar-forward-day "cal-move"
+  "Move the cursor forward ARG days."
+  t)
+
+(autoload 'calendar-backward-day "cal-move"
+  "Move the cursor back ARG days."
+  t)
+
+(autoload 'calendar-forward-week "cal-move"
+  "Move the cursor forward ARG weeks."
+  t)
+
+(autoload 'calendar-backward-week "cal-move"
+  "Move the cursor back ARG weeks."
+  t)
+
+(autoload 'calendar-beginning-of-week "cal-move"
+  "Move the cursor back ARG calendar-week-start-day's."
+  t)
+
+(autoload 'calendar-end-of-week "cal-move"
+  "Move the cursor forward ARG calendar-week-start-day+6's."
+  t)
+
+(autoload 'calendar-beginning-of-month "cal-move"
+  "Move the cursor backward ARG month beginnings."
+  t)
+
+(autoload 'calendar-end-of-month "cal-move"
+  "Move the cursor forward ARG month ends."
+  t)
+
+(autoload 'calendar-beginning-of-year "cal-move"
+  "Move the cursor backward ARG year beginnings."
+  t)
+
+(autoload 'calendar-end-of-year "cal-move"
+  "Move the cursor forward ARG year beginnings."
+  t)
+
+(autoload 'calendar-cursor-to-visible-date "cal-move"
+  "Move the cursor to DATE that is on the screen."
+  t)
+
+(autoload 'calendar-goto-date "cal-move"
+  "Move cursor to DATE."
+  t)
+
+(autoload 'calendar-one-frame-setup "cal-x"
+  "Start calendar and display it in a dedicated frame together with the diary.")
+
+(autoload 'calendar-two-frame-setup "cal-x"
+  "Start calendar and diary in separate, dedicated frames.")
+  
+;;;###autoload
+(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.")
+
 ;;;###autoload
 (defun calendar (&optional arg)
+  "Choose between the one frame, two frame, or basic calendar displays.
+The original function `calendar' has been renamed `calendar-basic-setup'."
+  (interactive "P")
+  (cond ((equal calendar-setup 'one-frame) (calendar-one-frame-setup arg))
+        ((equal calendar-setup 'two-frames) (calendar-two-frame-setup arg))
+        (t (calendar-basic-setup arg))))
+
+(defun calendar-basic-setup (&optional arg)
   "Display a three-month calendar in another window.
 The three months appear side by side, with the current month in the middle
 surrounded by the previous and next months.  The cursor is put on today's date.
   t)
 
 (autoload 'calendar-french-date-string "cal-french"
-  "String of French Revolutionary date of Gregorian DATE."
+  "String of French Revolutionary date of Gregorian date."
   t)
 
 (autoload 'calendar-mayan-date-string "cal-mayan"
-  "String of Mayan date of Gregorian DATE."
+  "String of Mayan date of Gregorian date."
   t)
 
 (autoload 'calendar-print-mayan-date "cal-mayan"
   t)
 
 (autoload 'calendar-next-calendar-round-date "cal-mayan"
-  "Move cursor to next instance of Mayan Haab/Tzoklin combination."
+  "Move cursor to next instance of Mayan Haab/Tzolkin combination."
   t)
 
 (autoload 'calendar-previous-calendar-round-date "cal-mayan"
-  "Move cursor to previous instance of Mayan Haab/Tzoklin combination."
+  "Move cursor to previous instance of Mayan Haab/Tzolkin combination."
+  t)
+
+(autoload 'calendar-goto-chinese-date "cal-china"
+   "Move cursor to Chinese date."
+   t)
+
+(autoload 'calendar-print-chinese-date "cal-china"
+ "Show the Chinese date equivalents of date."
+ t)
+
+(autoload 'calendar-chinese-date-string "cal-china"
+  "String of Chinese date of Gregorian date."
+   t)
+
+(autoload 'calendar-absolute-from-astro
+  "Absolute date of astronomical (Julian) day number D."
+  "cal-julian")
+
+(autoload 'calendar-astro-from-absolute "cal-julian"
+  "Astronomical (Julian) day number of absolute date D.")
+
+(autoload 'calendar-astro-date-string "cal-julian"
+  "String of astronomical (Julian) day number of Gregorian date."
+  t)
+
+(autoload 'calendar-goto-astro-date "cal-julian"
+   "Move cursor to astronomical (Julian) day number."
+   t)
+
+(autoload 'calendar-julian-from-absolute "cal-julian"
+  "Compute the Julian (month day year) corresponding to the absolute DATE.
+The absolute date is the number of days elapsed since the (imaginary)
+Gregorian date Sunday, December 31, 1 BC.")
+
+(autoload 'calendar-goto-julian-date "cal-julian"
+  "Move cursor to Julian DATE; echo Julian date unless NOECHO is t."
+  t)
+
+(autoload 'calendar-print-julian-date "cal-julian"
+  "Show the Julian calendar equivalent of the date under the cursor."
+  t)
+
+(autoload 'calendar-julian-date-string "cal-julian"
+  "String of Julian date of Gregorian DATE.
+Defaults to today's date if DATE is not given.
+Driven by the variable `calendar-date-display-form'.")
+
+(autoload 'calendar-goto-iso-date "cal-iso"
+  "Move cursor to ISO date."
+  t)
+
+(autoload 'calendar-print-iso-date "cal-iso"
+  "Show the ISO date equivalents of date."
+  t)
+
+(autoload 'calendar-iso-date-string "cal-iso"
+  "String of ISO date of Gregorian date."
+  t)
+
+(autoload 'calendar-print-islamic-date "cal-islam"
+  "Show the Islamic date equivalents of date."
+  t)
+
+(autoload 'calendar-islamic-date-string "cal-islam"
+  "String of Islamic date of Gregorian date."
+  t)
+
+(autoload 'calendar-goto-hebrew-date "cal-hebrew"
+  "Move cursor to Hebrew date date."
+  t)
+
+(autoload 'calendar-print-hebrew-date "cal-hebrew"
+  "Show the Hebrew date equivalents of date."
+  t)
+
+(autoload 'calendar-hebrew-date-string "cal-hebrew"
+  "String of Hebrew date of Gregorian date."
+  t)
+
+(autoload 'calendar-goto-coptic-date "cal-coptic"
+   "Move cursor to Coptic date date."
+   t)
+
+(autoload 'calendar-print-coptic-date "cal-coptic"
+ "Show the Coptic date equivalents of date."
+ t)
+
+(autoload 'calendar-coptic-date-string "cal-coptic"
+  "String of Coptic date of Gregorian date."
+  t)
+
+(autoload 'calendar-goto-ethiopic-date "cal-coptic"
+  "Move cursor to Ethiopic date date."
+  t)
+
+(autoload 'calendar-print-ethiopic-date "cal-coptic"
+  "Show the Ethiopic date equivalents of date."
+  t)
+
+(autoload 'calendar-ethiopic-date-string "cal-coptic"
+  "String of Ethiopic date of Gregorian date."
+  t)
+
+(autoload 'calendar-goto-persian-date "cal-persia"
+   "Move cursor to Persian date date."
+   t)
+
+(autoload 'calendar-print-persian-date "cal-persia"
+ "Show the Persian date equivalents of date."
+ t)
+
+(autoload 'calendar-persian-date-string "cal-persia"
+  "String of Persian date of Gregorian date."
   t)
 
 (autoload 'show-all-diary-entries "diary-lib"
 Each entry in diary file visible in the calendar window is marked."
   t)
 
-(autoload 'insert-diary-entry "diary-ins"
+(autoload 'make-diary-entry "diary-lib"
+  "Insert a diary entry STRING which may be NONMARKING in FILE."
+  t)
+
+(autoload 'insert-diary-entry "diary-lib"
   "Insert a diary entry for the date indicated by point."
   t)
 
-(autoload 'insert-weekly-diary-entry "diary-ins"
+(autoload 'insert-weekly-diary-entry "diary-lib"
   "Insert a weekly diary entry for the day of the week indicated by point."
   t)
 
 
-(autoload 'insert-monthly-diary-entry "diary-ins"
+(autoload 'insert-monthly-diary-entry "diary-lib"
   "Insert a monthly diary entry for the day of the month indicated by point."
   t)
 
-(autoload 'insert-yearly-diary-entry "diary-ins"
+(autoload 'insert-yearly-diary-entry "diary-lib"
   "Insert an annual diary entry for the day of the year indicated by point."
   t)
 
-(autoload 'insert-anniversary-diary-entry "diary-ins"
+(autoload 'insert-anniversary-diary-entry "diary-lib"
   "Insert an anniversary diary entry for the date indicated by point."
   t)
 
-(autoload 'insert-block-diary-entry "diary-ins"
+(autoload 'insert-block-diary-entry "diary-lib"
   "Insert a block diary entry for the dates indicated by point and mark."
   t)
 
-(autoload 'insert-cyclic-diary-entry "diary-ins"
+(autoload 'insert-cyclic-diary-entry "diary-lib"
   "Insert a cyclic diary entry starting at the date indicated by point."
   t)
 
-(autoload 'insert-hebrew-diary-entry "diary-ins"
+(autoload 'insert-hebrew-diary-entry "cal-hebrew"
   "Insert a diary entry for the Hebrew date corresponding to the date
 indicated by point."
   t)
 
-(autoload 'insert-monthly-hebrew-diary-entry "diary-ins"
+(autoload 'insert-monthly-hebrew-diary-entry "cal-hebrew"
   "Insert a monthly diary entry for the day of the Hebrew month corresponding
 to the date indicated by point."
   t)
 
-(autoload 'insert-yearly-hebrew-diary-entry "diary-ins"
+(autoload 'insert-yearly-hebrew-diary-entry "cal-hebrew"
   "Insert an annual diary entry for the day of the Hebrew year corresponding
 to the date indicated by point."
   t)
 
-(autoload 'insert-islamic-diary-entry "diary-ins"
+(autoload 'insert-islamic-diary-entry "cal-islam"
   "Insert a diary entry for the Islamic date corresponding to the date
 indicated by point."
   t)
 
-(autoload 'insert-monthly-islamic-diary-entry "diary-ins"
+(autoload 'insert-monthly-islamic-diary-entry "cal-islam"
   "Insert a monthly diary entry for the day of the Islamic month corresponding
 to the date indicated by point."
   t)
 
-(autoload 'insert-yearly-islamic-diary-entry "diary-ins"
+(autoload 'insert-yearly-islamic-diary-entry "cal-islam"
   "Insert an annual diary entry for the day of the Islamic year corresponding
 to the date indicated by point."
   t)
 holidays are found, nil if not."
   t)
 
+(autoload 'cal-tex-cursor-month "cal-tex"
+  "Make a buffer with LaTeX commands for the month cursor is on.
+Optional prefix argument specifies number of months to be produced.
+Calendar is condensed onto one page.")
+
+(autoload 'cal-tex-cursor-month-landscape "cal-tex"
+  "Make a buffer with LaTeX commands for the month cursor is on.
+Optional prefix argument specifies number of months to be produced.")
+
+(autoload 'cal-tex-cursor-day "cal-tex"
+  "Make a buffer with LaTeX commands for the day cursor is on.")
+
+(autoload 'cal-tex-cursor-week "cal-tex"
+  "Make a buffer with LaTeX commands for a two-page one-week calendar.
+It applies to the week that point is in.
+Optional prefix argument specifies number of weeks.
+Holidays are included if `cal-tex-holidays' is t.")
+
+(autoload 'cal-tex-cursor-week2 "cal-tex" 
+  "Make a buffer with LaTeX commands for a two-page one-week calendar.
+It applies to the week that point is in.
+Optional prefix argument specifies number of weeks.
+Holidays are included if `cal-tex-holidays' is t.")
+
+(autoload 'cal-tex-cursor-week-iso "cal-tex"
+  "Make a buffer with LaTeX commands for a one page ISO-style weekly calendar.
+Optional prefix argument specifies number of weeks.
+Diary entries are included if `cal-tex-diary' is t.
+Holidays are included if `cal-tex-holidays' is t.")
+
+(autoload 'cal-tex-cursor-week-monday "cal-tex"
+  "Make a buffer with LaTeX commands for a two-page one-week calendar.
+It applies to the week that point is in, and starts on Monday.
+Optional prefix argument specifies number of weeks.
+Holidays are included if `cal-tex-holidays' is t.")
+
+(autoload 'cal-tex-cursor-filofax-2week "cal-tex"
+  "Two-weeks-at-a-glance Filofax style calendar for week indicated by cursor.
+Optional prefix argument specifies number of weeks.
+Diary entries are included if cal-tex-diary is t.
+Holidays are included if `cal-tex-holidays' is t.")
+
+(autoload 'cal-tex-cursor-filofax-week "cal-tex"
+  "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
+Optional prefix argument specifies number of weeks.
+Weeks start on Monday. 
+Diary entries are included if cal-tex-diary is t.
+Holidays are included if `cal-tex-holidays' is t.")
+
+(autoload 'cal-tex-cursor-year "cal-tex"
+  "Make a buffer with LaTeX commands for a year's calendar.
+Optional prefix argument specifies number of years.")
+
+(autoload 'cal-tex-cursor-year-landscape "cal-tex"
+  "Make a buffer with LaTeX commands for a year's calendar (landscape).
+Optional prefix argument specifies number of years.")
+
+(autoload 'cal-tex-cursor-filofax-year "cal-tex"
+  "Make a buffer with LaTeX commands for a year's calendar (Filofax).
+Optional prefix argument specifies number of years.")
+
 (autoload 'mark-calendar-holidays "holidays"
   "Mark notable days in the calendar window."
   t)
    (goto-char (point-min))
    (calendar-insert-indented
     (calendar-string-spread
-     (list "" (format "%s %d" (calendar-month-name month) year) "") ?  20)
+     (list (format "%s %d" (calendar-month-name month) year)) ?  20)
     indent t)
    (calendar-insert-indented "" indent);; Go to proper spot
    (calendar-for-loop i from 0 to 6 do
-      (insert (substring (aref calendar-day-name-array 
-                               (mod (+ calendar-week-start-day i) 7))
-                         0 2))
+      (insert (calendar-day-name (mod (+ calendar-week-start-day i) 7)
+                                2 t))
       (insert " "))
    (calendar-insert-indented "" 0 t);; Force onto following line
    (calendar-insert-indented "" indent);; Go to proper spot
     (generate-calendar-window displayed-month displayed-year)
     (calendar-cursor-to-visible-date cursor-date)))
 
-(defvar calendar-debug-sexp nil
-  "*Turn debugging on when evaluating a sexp in the diary or holiday list.")
+(defcustom calendar-debug-sexp nil
+  "*Turn debugging on when evaluating a sexp in the diary or holiday list."
+  :type 'boolean
+  :group 'calendar)
 
 (defvar calendar-mode-map nil)
 (if calendar-mode-map
   (define-key calendar-mode-map "ga"  'calendar-goto-astro-day-number)
   (define-key calendar-mode-map "gh"  'calendar-goto-hebrew-date)
   (define-key calendar-mode-map "gi"  'calendar-goto-islamic-date)
+  (define-key calendar-mode-map "gC"  'calendar-goto-chinese-date)
+  (define-key calendar-mode-map "gk"  'calendar-goto-coptic-date)
+  (define-key calendar-mode-map "ge"  'calendar-goto-ethiopic-date)
+  (define-key calendar-mode-map "gp"  'calendar-goto-persian-date)
   (define-key calendar-mode-map "gc"  'calendar-goto-iso-date)
   (define-key calendar-mode-map "gf"  'calendar-goto-french-date)
   (define-key calendar-mode-map "gml"  'calendar-goto-mayan-long-count-date)
   (define-key calendar-mode-map "D"   'view-other-diary-entries)
   (define-key calendar-mode-map "s"   'show-all-diary-entries)
   (define-key calendar-mode-map "pd"  'calendar-print-day-of-year)
+  (define-key calendar-mode-map "pC"  'calendar-print-chinese-date)
+  (define-key calendar-mode-map "pk"  'calendar-print-coptic-date)
+  (define-key calendar-mode-map "pe"  'calendar-print-ethiopic-date)
+  (define-key calendar-mode-map "pp"  'calendar-print-persian-date)
   (define-key calendar-mode-map "pc"  'calendar-print-iso-date)
   (define-key calendar-mode-map "pj"  'calendar-print-julian-date)
   (define-key calendar-mode-map "pa"  'calendar-print-astro-day-number)
   (define-key calendar-mode-map "iid" 'insert-islamic-diary-entry)
   (define-key calendar-mode-map "iim" 'insert-monthly-islamic-diary-entry)
   (define-key calendar-mode-map "iiy" 'insert-yearly-islamic-diary-entry)
-  (define-key calendar-mode-map "?"   'calendar-goto-info-node))
+  (define-key calendar-mode-map "?"   'calendar-goto-info-node)
+  (define-key calendar-mode-map "tm" 'cal-tex-cursor-month)
+  (define-key calendar-mode-map "tM" 'cal-tex-cursor-month-landscape)
+  (define-key calendar-mode-map "td" 'cal-tex-cursor-day)
+  (define-key calendar-mode-map "tw1" 'cal-tex-cursor-week)
+  (define-key calendar-mode-map "tw2" 'cal-tex-cursor-week2)
+  (define-key calendar-mode-map "tw3" 'cal-tex-cursor-week-iso)
+  (define-key calendar-mode-map "tw4" 'cal-tex-cursor-week-monday)
+  (define-key calendar-mode-map "tfw" 'cal-tex-cursor-filofax-2week)
+  (define-key calendar-mode-map "tfW" 'cal-tex-cursor-filofax-week)
+  (define-key calendar-mode-map "tfy" 'cal-tex-cursor-filofax-year)
+  (define-key calendar-mode-map "ty" 'cal-tex-cursor-year)
+  (define-key calendar-mode-map "tY" 'cal-tex-cursor-year-landscape))
 
 (defun describe-calendar-mode ()
   "Create a help buffer with a brief description of the calendar-mode."
   "Go to the info node for the calendar."
   (interactive)
   (require 'info)
-  (let ((where (Info-find-emacs-command-nodes 'calendar)))
+  (let ((where (save-window-excursion
+                (Info-find-emacs-command-nodes 'calendar))))
     (if (not where)
         (error "Couldn't find documentation for the calendar.")
-      (save-window-excursion (info))
-      (pop-to-buffer "*info*")
-      (Info-find-node (car (car where)) (car (cdr (car where)))))))
+      (let (same-window-buffer-names)
+       (info))
+       (Info-find-node (car (car where)) (car (cdr (car where)))))))
 
 (defun calendar-mode ()
   "A major mode for the calendar window.
   (make-local-variable 'displayed-year));;  Year in middle of window.
 
 (defun calendar-string-spread (strings char length)
-  "Concatenate list of STRINGS separated with copies of CHAR to fill LENGTH
-There must be at least 2 strings.  The effect is like mapconcat but the
-separating pieces are as balanced as possible.  Each item of STRINGS is
-evaluated before concatenation so it can actually be an expression that
-evaluates to a string.  If LENGTH is too short, the STRINGS are just
-concatenated and the result truncated."
+  "Concatenate list of STRINGS separated with copies of CHAR to fill LENGTH.
+The effect is like mapconcat but the separating pieces are as balanced as
+possible.  Each item of STRINGS is evaluated before concatenation so it can
+actually be an expression that evaluates to a string.  If LENGTH is too short,
+the STRINGS are just concatenated and the result truncated."
 ;; The algorithm is based on equation (3.25) on page 85 of Concrete
 ;; Mathematics by Ronald L. Graham, Donald E. Knuth, and Oren Patashnik,
 ;; Addison-Wesley, Reading, MA, 1989
-  (let* ((strings (mapcar 'eval strings))
+  (let* ((strings (mapcar 'eval
+                          (if (< (length strings) 2)
+                              (append (list "") strings (list ""))
+                            strings)))
          (n (- length (length (apply 'concat strings))))
          (m (1- (length strings)))
          (s (car strings))
          (t (set-buffer buffer)
             (bury-buffer))))))
 
-(defun calendar-goto-today ()
-  "Reposition the calendar window so the current date is visible."
-  (interactive)
-  (let ((today (calendar-current-date)));; The date might have changed.
-    (if (not (calendar-date-is-visible-p today))
-        (generate-calendar-window)
-      (update-calendar-mode-line)
-      (calendar-cursor-to-visible-date today))))
-
-(defun calendar-forward-month (arg)
-  "Move the cursor forward ARG months.
-Movement is backward if ARG is negative."
-  (interactive "p")
-  (calendar-cursor-to-nearest-date)
-  (let* ((cursor-date (calendar-cursor-to-date t))
-         (month (extract-calendar-month cursor-date))
-         (day (extract-calendar-day cursor-date))
-         (year (extract-calendar-year cursor-date)))
-    (increment-calendar-month month year arg)
-    (let ((last (calendar-last-day-of-month month year)))
-      (if (< last day)
-        (setq day last)))
-    ;; Put the new month on the screen, if needed, and go to the new date.
-    (let ((new-cursor-date (list month day year)))
-      (if (not (calendar-date-is-visible-p new-cursor-date))
-          (calendar-other-month month year))
-      (calendar-cursor-to-visible-date new-cursor-date))))
-
-(defun calendar-forward-year (arg)
-  "Move the cursor forward by ARG years.
-Movement is backward if ARG is negative."
-  (interactive "p")
-  (calendar-forward-month (* 12 arg)))
-
-(defun calendar-backward-month (arg)
-  "Move the cursor backward by ARG months.
-Movement is forward if ARG is negative."
-  (interactive "p")
-  (calendar-forward-month (- arg)))
-
-(defun calendar-backward-year (arg)
-  "Move the cursor backward ARG years.
-Movement is forward is ARG is negative."
-  (interactive "p")
-  (calendar-forward-month (* -12 arg)))
-
-(defun scroll-calendar-left (arg)
-  "Scroll the displayed calendar left by ARG months.
-If ARG is negative the calendar is scrolled right.  Maintains the relative
-position of the cursor with respect to the calendar as well as possible."
-  (interactive "p")
-  (calendar-cursor-to-nearest-date)
-  (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)
-          (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))))))))
-
-(defun scroll-calendar-right (arg)
-  "Scroll the displayed calendar window right by ARG months.
-If ARG is negative the calendar is scrolled left.  Maintains the relative
-position of the cursor with respect to the calendar as well as possible."
-  (interactive "p")
-  (scroll-calendar-left (- arg)))
-
-(defun scroll-calendar-left-three-months (arg)
-  "Scroll the displayed calendar window left by 3*ARG months.
-If ARG is negative the calendar is scrolled right.  Maintains the relative
-position of the cursor with respect to the calendar as well as possible."
-  (interactive "p")
-  (scroll-calendar-left (* 3 arg)))
-
-(defun scroll-calendar-right-three-months (arg)
-  "Scroll the displayed calendar window right by 3*ARG months.
-If ARG is negative the calendar is scrolled left.  Maintains the relative
-position of the cursor with respect to the calendar as well as possible."
-  (interactive "p")
-  (scroll-calendar-left (* -3 arg)))
-
 (defun calendar-current-date ()
   "Returns the current date in a list (month day year)."
-  (let ((s (current-time-string)))
-    (list (length (member (substring s 4 7)
-                          '("Dec" "Nov" "Oct" "Sep" "Aug" "Jul"
-                            "Jun" "May" "Apr" "Mar" "Feb" "Jan")))
-          (string-to-number (substring s 8 10))
-          (string-to-number (substring s 20 24)))))
+  (let ((now (decode-time)))
+    (list (nth 4 now) (nth 3 now) (nth 5 now))))
 
 (defun calendar-cursor-to-date (&optional error)
   "Returns a list (month day year) of current cursor position.
 	     ((and (=  12 month) (= segment 0)) (1- displayed-year))
 	     ((and (=   1 month) (= segment 2)) (1+ displayed-year))
 	     (t displayed-year))))
-      (if (and (looking-at "[0-9]")
+    (if (and (looking-at "[ 0-9]?[0-9][^0-9]")
 	       (< 2 (count-lines (point-min) (point))))
 	  (save-excursion
-	    (re-search-backward "[^0-9]")
+          (if (not (looking-at " "))
+                   (re-search-backward "[^0-9]"))
 	    (list month
 		  (string-to-int (buffer-substring (1+ (point)) (+ 4 (point))))
 		  year))
 		(if error (error "Not on a date!"))))
 	  (if error (error "Not on a date!")))))))
 
-(defun calendar-cursor-to-nearest-date ()
-  "Move the cursor to the closest date.
-The position of the cursor is unchanged if it is already on a date.
-Returns the list (month day year) giving the cursor position."
-  (let ((date (calendar-cursor-to-date))
-        (column (current-column)))
-    (if date
-        date
-      (if (> 3 (count-lines (point-min) (point)))
-          (progn
-            (goto-line 3)
-            (move-to-column column)))
-      (if (not (looking-at "[0-9]"))
-          (if (and (not (looking-at " *$"))
-                   (or (< column 25)
-                       (and (> column 27)
-                            (< column 50))
-                       (and (> column 52)
-                            (< column 75))))
-              (progn
-                (re-search-forward "[0-9]" nil t)
-                (backward-char 1))
-            (re-search-backward "[0-9]" nil t)))
-      (calendar-cursor-to-date))))
-
-(defun calendar-forward-day (arg)
-  "Move the cursor forward ARG days.
-Moves backward if ARG is negative."
-  (interactive "p")
-  (if (/= 0 arg)
-      (let*
-          ((cursor-date (calendar-cursor-to-date))
-           (cursor-date (if cursor-date
-                            cursor-date
-                          (if (> arg 0) (setq arg (1- arg)))
-                          (calendar-cursor-to-nearest-date)))
-           (new-cursor-date
-            (calendar-gregorian-from-absolute
-             (+ (calendar-absolute-from-gregorian cursor-date) arg)))
-           (new-display-month (extract-calendar-month new-cursor-date))
-           (new-display-year (extract-calendar-year new-cursor-date)))
-        ;; Put the new month on the screen, if needed, and go to the new date.
-        (if (not (calendar-date-is-visible-p new-cursor-date))
-            (calendar-other-month new-display-month new-display-year))
-        (calendar-cursor-to-visible-date new-cursor-date))))
-
-(defun calendar-backward-day (arg)
-  "Move the cursor back ARG days.
-Moves forward if ARG is negative."
-  (interactive "p")
-  (calendar-forward-day (- arg)))
-
-(defun calendar-forward-week (arg)
-  "Move the cursor forward ARG weeks.
-Moves backward if ARG is negative."
-  (interactive "p")
-  (calendar-forward-day (* arg 7)))
-
-(defun calendar-backward-week (arg)
-  "Move the cursor back ARG weeks.
-Moves forward if ARG is negative."
-  (interactive "p")
-  (calendar-forward-day (* arg -7)))
-
-(defun calendar-beginning-of-week (arg)
-  "Move the cursor back ARG calendar-week-start-day's."
-  (interactive "p")
-  (calendar-cursor-to-nearest-date)
-  (let ((day (calendar-day-of-week (calendar-cursor-to-date))))
-    (calendar-backward-day
-     (if (= day calendar-week-start-day)
-         (* 7 arg)
-       (+ (mod (- day calendar-week-start-day) 7)
-          (* 7 (1- arg)))))))
-
-(defun calendar-end-of-week (arg)
-  "Move the cursor forward ARG calendar-week-start-day+6's."
-  (interactive "p")
-  (calendar-cursor-to-nearest-date)
-  (let ((day (calendar-day-of-week (calendar-cursor-to-date))))
-    (calendar-forward-day
-     (if (= day (mod (1- calendar-week-start-day) 7))
-         (* 7 arg)
-       (+ (- 6 (mod (- day calendar-week-start-day) 7))
-          (* 7 (1- arg)))))))
-
-(defun calendar-beginning-of-month (arg)
-  "Move the cursor backward ARG month beginnings."
-  (interactive "p")
-  (calendar-cursor-to-nearest-date)
-  (let* ((date (calendar-cursor-to-date))
-         (month (extract-calendar-month date))
-         (day (extract-calendar-day date))
</