]> code.delx.au - gnu-emacs/blobdiff - lisp/calendar/cal-tex.el
Update for rename islamic-diary-entry-symbol to diary-islamic-entry-symbol.
[gnu-emacs] / lisp / calendar / cal-tex.el
index fa971a9b644bb9ecc63df6310d7b3b2fb62b5ad0..e613bdda497cd194126055d351a8312307bef5ed 100644 (file)
@@ -4,7 +4,7 @@
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Steve Fisk <fisk@bowdoin.edu>
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Steve Fisk <fisk@bowdoin.edu>
-;;      Edward M. Reingold <reingold@cs.uiuc.edu>
+;;         Edward M. Reingold <reingold@cs.uiuc.edu>
 ;; Maintainer: Glenn Morris <rgm@gnu.org>
 ;; Keywords: calendar
 ;; Human-Keywords: Calendar, LaTeX
 ;; Maintainer: Glenn Morris <rgm@gnu.org>
 ;; Keywords: calendar
 ;; Human-Keywords: Calendar, LaTeX
 
 (require 'calendar)
 
 
 (require 'calendar)
 
-(autoload 'diary-list-entries "diary-lib" nil t)
-(autoload 'calendar-holiday-list "holidays" nil t)
-(autoload 'calendar-iso-from-absolute "cal-iso" nil t)
-
 ;;;
 ;;; Customizable variables
 ;;;
 ;;;
 ;;; Customizable variables
 ;;;
@@ -154,7 +150,7 @@ For example, to include extra packages:
 
 (defcustom cal-tex-hook nil
   "List of functions called after any LaTeX calendar buffer is generated.
 
 (defcustom cal-tex-hook nil
   "List of functions called after any LaTeX calendar buffer is generated.
-You can use this to do postprocessing on the buffer.  For example, to change
+You can use this to do post-processing on the buffer.  For example, to change
 characters with diacritical marks to their LaTeX equivalents, use
     (add-hook 'cal-tex-hook
               (lambda () (iso-iso2tex (point-min) (point-max))))"
 characters with diacritical marks to their LaTeX equivalents, use
     (add-hook 'cal-tex-hook
               (lambda () (iso-iso2tex (point-min) (point-max))))"
@@ -241,6 +237,8 @@ The names are taken from `calendar-day-name-array'.")
   "LaTeX code to insert one box with date info in calendar.
 This definition is the heart of the calendar!")
 
   "LaTeX code to insert one box with date info in calendar.
 This definition is the heart of the calendar!")
 
+(autoload 'calendar-holiday-list "holidays")
+
 (defun cal-tex-list-holidays (d1 d2)
   "Generate a list of all holidays from absolute date D1 to D2."
   (let* ((start (calendar-gregorian-from-absolute d1))
 (defun cal-tex-list-holidays (d1 d2)
   "Generate a list of all holidays from absolute date D1 to D2."
   (let* ((start (calendar-gregorian-from-absolute d1))
@@ -265,6 +263,8 @@ This definition is the heart of the calendar!")
            (setq in-range (append (list hol) in-range))))
     in-range))
 
            (setq in-range (append (list hol) in-range))))
     in-range))
 
+(autoload 'diary-list-entries "diary-lib")
+
 (defun cal-tex-list-diary-entries (d1 d2)
   "Generate a list of all diary-entries from absolute date D1 to D2."
   (let ((diary-list-include-blanks nil)
 (defun cal-tex-list-diary-entries (d1 d2)
   "Generate a list of all diary-entries from absolute date D1 to D2."
   (let ((diary-list-include-blanks nil)
@@ -312,7 +312,7 @@ Optional string ARGS are included as options for the article document class."
 ;;;  Yearly calendars
 ;;;
 
 ;;;  Yearly calendars
 ;;;
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-year (&optional arg)
   "Make a buffer with LaTeX commands for the year cursor is on.
 Optional prefix argument ARG specifies number of years."
 (defun cal-tex-cursor-year (&optional arg)
   "Make a buffer with LaTeX commands for the year cursor is on.
 Optional prefix argument ARG specifies number of years."
@@ -320,7 +320,7 @@ Optional prefix argument ARG specifies number of years."
   (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t))
                 (or arg 1)))
 
   (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t))
                 (or arg 1)))
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-year-landscape (&optional arg)
   "Make a buffer with LaTeX commands for the year cursor is on.
 Optional prefix argument ARG specifies number of years."
 (defun cal-tex-cursor-year-landscape (&optional arg)
   "Make a buffer with LaTeX commands for the year cursor is on.
 Optional prefix argument ARG specifies number of years."
@@ -364,7 +364,7 @@ landscape mode with three rows of four months each."
     (run-hooks 'cal-tex-year-hook))
   (run-hooks 'cal-tex-hook))
 
     (run-hooks 'cal-tex-year-hook))
   (run-hooks 'cal-tex-hook))
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-filofax-year (&optional arg)
   "Make a Filofax one page yearly calendar of year indicated by cursor.
 Optional prefix argument ARG specifies number of years."
 (defun cal-tex-cursor-filofax-year (&optional arg)
   "Make a Filofax one page yearly calendar of year indicated by cursor.
 Optional prefix argument ARG specifies number of years."
@@ -417,7 +417,7 @@ Optional prefix argument ARG specifies number of years."
 ;;;  Monthly calendars
 ;;;
 
 ;;;  Monthly calendars
 ;;;
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-month-landscape (&optional arg)
   "Make a LaTeX calendar buffer for the month the cursor is on.
 Optional prefix argument ARG specifies number of months to be
 (defun cal-tex-cursor-month-landscape (&optional arg)
   "Make a LaTeX calendar buffer for the month the cursor is on.
 Optional prefix argument ARG specifies number of months to be
@@ -436,57 +436,56 @@ month to a page.  It shows holiday and diary entries if
          (d2 (calendar-absolute-from-gregorian
               (list end-month
                     (calendar-last-day-of-month end-month end-year)
          (d2 (calendar-absolute-from-gregorian
               (list end-month
                     (calendar-last-day-of-month end-month end-year)
-                    end-year))))
-    (increment-calendar-month end-month end-year (1- n))
-    (let ((diary-list (if cal-tex-diary
-                          (cal-tex-list-diary-entries d1 d2)))
-          (holidays (if cal-tex-holidays
-                        (cal-tex-list-holidays d1 d2)))
-          other-month other-year small-months-at-start)
-      (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt")
-      (cal-tex-cmd cal-tex-cal-one-month)
-      (dotimes (i n)
-        (setq other-month month
-              other-year year)
-        (increment-calendar-month other-month other-year -1)
-        (insert (cal-tex-mini-calendar other-month other-year "lastmonth"
-                                       "\\cellwidth" "\\cellheight"))
-        (increment-calendar-month other-month other-year 2)
-        (insert (cal-tex-mini-calendar other-month other-year "nextmonth"
-                                       "\\cellwidth" "\\cellheight"))
-        (cal-tex-insert-month-header 1 month year month year)
-        (cal-tex-insert-day-names)
-        (cal-tex-nl ".2cm")
-        (if (setq small-months-at-start
-                  (< 1 (mod (- (calendar-day-of-week (list month 1 year))
+                    end-year)))
+         (diary-list (progn
+                       (increment-calendar-month end-month end-year (1- n))
+                       (if cal-tex-diary (cal-tex-list-diary-entries d1 d2))))
+         (holidays (if cal-tex-holidays (cal-tex-list-holidays d1 d2)))
+         other-month other-year small-months-at-start)
+    (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt")
+    (cal-tex-cmd cal-tex-cal-one-month)
+    (dotimes (i n)
+      (setq other-month month
+            other-year year)
+      (increment-calendar-month other-month other-year -1)
+      (insert (cal-tex-mini-calendar other-month other-year "lastmonth"
+                                     "\\cellwidth" "\\cellheight"))
+      (increment-calendar-month other-month other-year 2)
+      (insert (cal-tex-mini-calendar other-month other-year "nextmonth"
+                                     "\\cellwidth" "\\cellheight"))
+      (cal-tex-insert-month-header 1 month year month year)
+      (cal-tex-insert-day-names)
+      (cal-tex-nl ".2cm")
+      (if (setq small-months-at-start
+                (< 1 (mod (- (calendar-day-of-week (list month 1 year))
                                calendar-week-start-day)
                                calendar-week-start-day)
-                            7)))
-            (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}"))
-        (cal-tex-insert-blank-days month year cal-tex-day-prefix)
-        (cal-tex-insert-days month year diary-list holidays
-                             cal-tex-day-prefix)
-        (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix)
-        (if (and (not small-months-at-start)
-                 (< 1 (mod (- (1- calendar-week-start-day)
-                              (calendar-day-of-week
-                               (list month
-                                     (calendar-last-day-of-month month year)
-                                     year)))
-                           7)))
-            (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}"
-                    "\\lastmonth\\nextmonth%
+                          7)))
+          (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}"))
+      (cal-tex-insert-blank-days month year cal-tex-day-prefix)
+      (cal-tex-insert-days month year diary-list holidays
+                           cal-tex-day-prefix)
+      (cal-tex-insert-blank-days-at-end month year cal-tex-day-prefix)
+      (if (and (not small-months-at-start)
+               (< 1 (mod (- (1- calendar-week-start-day)
+                            (calendar-day-of-week
+                             (list month
+                                   (calendar-last-day-of-month month year)
+                                   year)))
+                         7)))
+          (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}"
+                  "\\lastmonth\\nextmonth%
 "))
 "))
-        (unless (= i (1- n))
-          (run-hooks 'cal-tex-month-hook)
-          (cal-tex-newpage)
-          (increment-calendar-month month year 1)
-          (cal-tex-vspace "-2cm")
-          (cal-tex-insert-preamble
-           (cal-tex-number-weeks month year 1) t "12pt" t)))
-      (cal-tex-end-document)
-      (run-hooks 'cal-tex-hook))))
-
-;;;###autoload
+      (unless (= i (1- n))
+        (run-hooks 'cal-tex-month-hook)
+        (cal-tex-newpage)
+        (increment-calendar-month month year 1)
+        (cal-tex-vspace "-2cm")
+        (cal-tex-insert-preamble
+         (cal-tex-number-weeks month year 1) t "12pt" t))))
+  (cal-tex-end-document)
+  (run-hooks 'cal-tex-hook))
+
+;;;###cal-autoload
 (defun cal-tex-cursor-month (arg)
   "Make a LaTeX calendar buffer for the month the cursor is on.
 Optional prefix argument ARG specifies number of months to be
 (defun cal-tex-cursor-month (arg)
   "Make a LaTeX calendar buffer for the month the cursor is on.
 Optional prefix argument ARG specifies number of months to be
@@ -494,46 +493,44 @@ produced (default 1).  The calendar is condensed onto one page.
 It shows holiday and diary entries if `cal-tex-holidays' and
 `cal-tex-diary', respectively, are non-nil."
   (interactive "p")
 It shows holiday and diary entries if `cal-tex-holidays' and
 `cal-tex-diary', respectively, are non-nil."
   (interactive "p")
-  (let* ((date (calendar-cursor-to-date t))
+  (let* ((n (or arg 1))
+         (date (calendar-cursor-to-date t))
          (month (extract-calendar-month date))
          (year (extract-calendar-year date))
          (end-month month)
          (end-year year)
          (month (extract-calendar-month date))
          (year (extract-calendar-year date))
          (end-month month)
          (end-year year)
-         (n (or arg 1))
          (d1 (calendar-absolute-from-gregorian (list month 1 year)))
          (d2 (calendar-absolute-from-gregorian
               (list end-month
                     (calendar-last-day-of-month end-month end-year)
          (d1 (calendar-absolute-from-gregorian (list month 1 year)))
          (d2 (calendar-absolute-from-gregorian
               (list end-month
                     (calendar-last-day-of-month end-month end-year)
-                    end-year))))
-    (increment-calendar-month end-month end-year (1- n))
-    (let ((diary-list (if cal-tex-diary
-                          (cal-tex-list-diary-entries d1 d2)))
-          (holidays (if cal-tex-holidays
-                        (cal-tex-list-holidays d1 d2)))
-          other-month other-year)
-      (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil"12pt")
-      (if (> n 1)
-          (cal-tex-cmd cal-tex-cal-multi-month)
-        (cal-tex-cmd cal-tex-cal-one-month))
-      (cal-tex-insert-month-header n month year end-month end-year)
-      (cal-tex-insert-day-names)
-      (cal-tex-nl ".2cm")
-      (cal-tex-insert-blank-days month year cal-tex-day-prefix)
-      (dotimes (idummy n)
-        (setq other-month month
-              other-year year)
-        (cal-tex-insert-days month year diary-list holidays cal-tex-day-prefix)
-        (when (= (mod (calendar-absolute-from-gregorian
+                    end-year)))
+         (diary-list (progn
+                       (increment-calendar-month end-month end-year (1- n))
+                       (if cal-tex-diary (cal-tex-list-diary-entries d1 d2))))
+         (holidays (if cal-tex-holidays (cal-tex-list-holidays d1 d2)))
+         other-month other-year)
+    (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil "12pt")
+    (if (> n 1)
+        (cal-tex-cmd cal-tex-cal-multi-month)
+      (cal-tex-cmd cal-tex-cal-one-month))
+    (cal-tex-insert-month-header n month year end-month end-year)
+    (cal-tex-insert-day-names)
+    (cal-tex-nl ".2cm")
+    (cal-tex-insert-blank-days month year cal-tex-day-prefix)
+    (dotimes (idummy n)
+      (setq other-month month
+            other-year year)
+      (cal-tex-insert-days month year diary-list holidays cal-tex-day-prefix)
+      (when (= 6 (mod (calendar-absolute-from-gregorian
                        (list month
                              (calendar-last-day-of-month month year)
                              year))
                        (list month
                              (calendar-last-day-of-month month year)
                              year))
-                      7)
-                 6)                   ; last day of month was Saturday
-          (cal-tex-hfill)
-          (cal-tex-nl))
-        (increment-calendar-month month year 1))
-      (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix)
-      (cal-tex-end-document)))
+                      7))           ; last day of month was Saturday
+        (cal-tex-hfill)
+        (cal-tex-nl))
+      (increment-calendar-month month year 1))
+    (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix))
+  (cal-tex-end-document)
   (run-hooks 'cal-tex-hook))
 
 (defun cal-tex-insert-days (month year diary-list holidays day-format)
   (run-hooks 'cal-tex-hook))
 
 (defun cal-tex-insert-days (month year diary-list holidays day-format)
@@ -611,10 +608,11 @@ The entry is formatted using DAY-FORMAT."
               (mod
                (- (calendar-day-of-week (list month last-day year))
                   calendar-week-start-day)
               (mod
                (- (calendar-day-of-week (list month last-day year))
                   calendar-week-start-day)
-               7)))
-        (calendar-for-loop i from (1+ blank-days) to 6 do
-           (if (memq i cal-tex-which-days)
-               (insert (format day-format "" "") "{}{}{}{}%\n"))))))
+               7))
+             (i blank-days))
+        (while (<= (setq i (1+ i)) 6)
+          (if (memq i cal-tex-which-days)
+              (insert (format day-format "" "") "{}{}{}{}%\n"))))))
 
 (defun cal-tex-first-blank-p (month year)
   "Determine if any days of the first week will be printed.
 
 (defun cal-tex-first-blank-p (month year)
   "Determine if any days of the first week will be printed.
@@ -634,15 +632,16 @@ in the calendar starting in MONTH YEAR."
   "Determine if any days of the last week will be printed.
 Return t if there will there be any days of the last week printed
 in the calendar starting in MONTH YEAR."
   "Determine if any days of the last week will be printed.
 Return t if there will there be any days of the last week printed
 in the calendar starting in MONTH YEAR."
-  (let ((last-day (calendar-last-day-of-month month year))
-        any-days the-sunday)          ; the day of week of last Sunday
-    (calendar-for-loop i from (- last-day 6) to last-day do
-       (if (= 0 (calendar-day-of-week (list month i year)))
-           (setq the-sunday i)))
-    (calendar-for-loop i from the-sunday to last-day do
-       (if (memq (calendar-day-of-week (list month i year))
-                 cal-tex-which-days)
-           (setq any-days t)))
+  (let* ((last-day (calendar-last-day-of-month month year))
+         (i (- last-day 7))
+         any-days the-sunday)          ; the day of week of last Sunday
+    (while (<= (setq i (1+ i)) last-day)
+      (if (zerop (calendar-day-of-week (list month i year)))
+          (setq the-sunday i)))
+    (setq i (1- the-sunday))
+    (while (<= (setq i (1+ i)) last-day)
+      (if (memq (calendar-day-of-week (list month i year)) cal-tex-which-days)
+          (setq any-days t)))
     any-days))
 
 (defun cal-tex-number-weeks (month year n)
     any-days))
 
 (defun cal-tex-number-weeks (month year n)
@@ -672,7 +671,7 @@ this is only an upper bound."
 
 ;; TODO cal-tex-diary-support.
 ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours).
 
 ;; TODO cal-tex-diary-support.
 ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours).
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-week (&optional arg)
   "Make a LaTeX calendar buffer for a two-page one-week calendar.
 It applies to the week that point is in.  The optional prefix
 (defun cal-tex-cursor-week (&optional arg)
   "Make a LaTeX calendar buffer for a two-page one-week calendar.
 It applies to the week that point is in.  The optional prefix
@@ -725,7 +724,7 @@ entries are not shown).  The calendar shows the hours 8-12am, 1-5pm."
 
 ;; TODO cal-tex-diary support.
 ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours).
 
 ;; TODO cal-tex-diary support.
 ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours).
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-week2 (&optional arg)
   "Make a LaTeX calendar buffer for a two-page one-week calendar.
 It applies to the week that point is in.  Optional prefix
 (defun cal-tex-cursor-week2 (&optional arg)
   "Make a LaTeX calendar buffer for a two-page one-week calendar.
 It applies to the week that point is in.  Optional prefix
@@ -805,7 +804,9 @@ entries are not shown).  The calendar shows the hours 8-12am, 1-5pm"
     (cal-tex-end-document)
     (run-hooks 'cal-tex-hook)))
 
     (cal-tex-end-document)
     (run-hooks 'cal-tex-hook)))
 
-;;;###autoload
+(autoload 'calendar-iso-from-absolute "cal-iso")
+
+;;;###cal-autoload
 (defun cal-tex-cursor-week-iso (&optional arg)
   "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar.
 Optional prefix argument ARG specifies number of weeks (default 1).
 (defun cal-tex-cursor-week-iso (&optional arg)
   "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar.
 Optional prefix argument ARG specifies number of weeks (default 1).
@@ -937,7 +938,7 @@ shown are hard-coded to 8-12, 13-17."
 
 ;; TODO cal-tex-diary support.
 ;; TODO respect cal-tex-daily-start,end (see cal-tex-weekly4-box).
 
 ;; TODO cal-tex-diary support.
 ;; TODO respect cal-tex-daily-start,end (see cal-tex-weekly4-box).
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-week-monday (&optional arg)
   "Make a LaTeX calendar buffer for a two-page one-week calendar.
 It applies to the week that point is in, and starts on Monday.
 (defun cal-tex-cursor-week-monday (&optional arg)
   "Make a LaTeX calendar buffer for a two-page one-week calendar.
 It applies to the week that point is in, and starts on Monday.
@@ -1018,7 +1019,7 @@ shown are hard-coded to 8-12, 13-17."
      (cal-tex-e-framebox)
      (cal-tex-hspace "1cm")))
 
      (cal-tex-e-framebox)
      (cal-tex-hspace "1cm")))
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-filofax-2week (&optional arg)
   "Two-weeks-at-a-glance Filofax style calendar for week cursor is in.
 Optional prefix argument ARG specifies number of weeks (default 1).
 (defun cal-tex-cursor-filofax-2week (&optional arg)
   "Two-weeks-at-a-glance Filofax style calendar for week cursor is in.
 Optional prefix argument ARG specifies number of weeks (default 1).
@@ -1113,7 +1114,7 @@ The calendar shows holiday and diary entries if
     (cal-tex-end-document)
     (run-hooks 'cal-tex-hook)))
 
     (cal-tex-end-document)
     (run-hooks 'cal-tex-hook)))
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-filofax-week (&optional arg)
   "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
 Optional prefix argument ARG specifies number of weeks (default 1),
 (defun cal-tex-cursor-filofax-week (&optional arg)
   "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
 Optional prefix argument ARG specifies number of weeks (default 1),
@@ -1253,7 +1254,7 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
     (cal-tex-end-document)
     (run-hooks 'cal-tex-hook)))
 
     (cal-tex-end-document)
     (run-hooks 'cal-tex-hook)))
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-filofax-daily (&optional arg)
   "Day-per-page Filofax style calendar for week indicated by cursor.
 Optional prefix argument ARG specifies number of weeks (default 1),
 (defun cal-tex-cursor-filofax-daily (&optional arg)
   "Day-per-page Filofax style calendar for week indicated by cursor.
 Optional prefix argument ARG specifies number of weeks (default 1),
@@ -1278,7 +1279,7 @@ are non-nil.  Pages are ruled if `cal-tex-rules' is non-nil."
                          (cal-tex-list-diary-entries
                           ;; FIXME d1?
                           (calendar-absolute-from-gregorian (list month 1 year))
                          (cal-tex-list-diary-entries
                           ;; FIXME d1?
                           (calendar-absolute-from-gregorian (list month 1 year))
-                         d2))))
+                          d2))))
     (cal-tex-preamble "twoside")
     (cal-tex-cmd "\\textwidth 3.25in")
     (cal-tex-cmd "\\textheight 6.5in")
     (cal-tex-preamble "twoside")
     (cal-tex-cmd "\\textwidth 3.25in")
     (cal-tex-cmd "\\textheight 6.5in")
@@ -1367,7 +1368,7 @@ are non-nil.  Pages are ruled if `cal-tex-rules' is non-nil."
 ;;;  Daily calendars
 ;;;
 
 ;;;  Daily calendars
 ;;;
 
-;;;###autoload
+;;;###cal-autoload
 (defun cal-tex-cursor-day (&optional arg)
   "Make a buffer with LaTeX commands for the day cursor is on.
 Optional prefix argument ARG specifies number of days.  The calendar shows
 (defun cal-tex-cursor-day (&optional arg)
   "Make a buffer with LaTeX commands for the day cursor is on.
 Optional prefix argument ARG specifies number of days.  The calendar shows
@@ -1397,6 +1398,7 @@ Uses the 24-hour clock if `cal-tex-24' is non-nil.  Produces
 hourly sections for the period specified by `cal-tex-daily-start'
 and `cal-tex-daily-end'."
   (let ((month-name (cal-tex-month-name (extract-calendar-month date)))
 hourly sections for the period specified by `cal-tex-daily-start'
 and `cal-tex-daily-end'."
   (let ((month-name (cal-tex-month-name (extract-calendar-month date)))
+        (i (1- cal-tex-daily-start))
         hour)
     (cal-tex-banner "cal-tex-daily-page")
     (cal-tex-b-makebox "4cm" "l")
         hour)
     (cal-tex-banner "cal-tex-daily-page")
     (cal-tex-b-makebox "4cm" "l")
@@ -1418,22 +1420,22 @@ and `cal-tex-daily-end'."
     (cal-tex-hspace ".4cm")
     (cal-tex-rule "0mm" "16.1cm" "1mm")
     (cal-tex-nl ".1cm")
     (cal-tex-hspace ".4cm")
     (cal-tex-rule "0mm" "16.1cm" "1mm")
     (cal-tex-nl ".1cm")
-    (calendar-for-loop i from cal-tex-daily-start to cal-tex-daily-end do
-       (cal-tex-cmd "\\noindent")
-       (setq hour (if cal-tex-24
-                      i
-                    (mod i 12)))
-       (if (zerop hour) (setq hour 12))
-       (cal-tex-b-makebox "1cm" "c")
-       (cal-tex-arg (number-to-string hour))
-       (cal-tex-e-makebox)
-       (cal-tex-rule "0mm" "15.5cm" ".2mm")
-       (cal-tex-nl ".2cm")
-       (cal-tex-b-makebox "1cm" "c")
-       (cal-tex-arg "$\\diamond$" )
-       (cal-tex-e-makebox)
-       (cal-tex-rule "0mm" "15.5cm" ".2mm")
-       (cal-tex-nl ".2cm"))
+    (while (<= (setq i (1+ i)) cal-tex-daily-end)
+      (cal-tex-cmd "\\noindent")
+      (setq hour (if cal-tex-24
+                     i
+                   (mod i 12)))
+      (if (zerop hour) (setq hour 12))
+      (cal-tex-b-makebox "1cm" "c")
+      (cal-tex-arg (number-to-string hour))
+      (cal-tex-e-makebox)
+      (cal-tex-rule "0mm" "15.5cm" ".2mm")
+      (cal-tex-nl ".2cm")
+      (cal-tex-b-makebox "1cm" "c")
+      (cal-tex-arg "$\\diamond$" )
+      (cal-tex-e-makebox)
+      (cal-tex-rule "0mm" "15.5cm" ".2mm")
+      (cal-tex-nl ".2cm"))
     (cal-tex-hfill)
     (insert (cal-tex-mini-calendar
              (extract-calendar-month (cal-tex-previous-month date))
     (cal-tex-hfill)
     (insert (cal-tex-mini-calendar
              (extract-calendar-month (cal-tex-previous-month date))
@@ -1577,7 +1579,7 @@ informative header, and run HOOK."
   "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'.
 Select the output buffer, and insert the preamble for a calendar
 of WEEKS weeks.  Insert code for landscape mode if LANDSCAPE is
   "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'.
 Select the output buffer, and insert the preamble for a calendar
 of WEEKS weeks.  Insert code for landscape mode if LANDSCAPE is
-non-nil.  Use pointsize SIZE.  Optional argument APPEND, if
+non-nil.  Use point-size SIZE.  Optional argument APPEND, if
 non-nil, means add to end of buffer without erasing current contents."
   (let ((width "18cm")
         (height "24cm"))
 non-nil, means add to end of buffer without erasing current contents."
   (let ((width "18cm")
         (height "24cm"))
@@ -1632,18 +1634,19 @@ non-nil, means add to end of buffer without erasing current contents."
       ""
     (let ((head "")
           (tail string)
       ""
     (let ((head "")
           (tail string)
-          (list cal-tex-LaTeX-subst-list))
+          (list cal-tex-LaTeX-subst-list)
+          ch pair)
       (while (not (string-equal tail ""))
       (while (not (string-equal tail ""))
-        (let* ((ch (substring-no-properties tail 0 1))
-               (pair (assoc ch list)))
-          (if (and pair (string-equal ch "\""))
-              (setq list (reverse list))) ; quote changes meaning each time
-          (setq tail (substring-no-properties tail 1)
-                head (concat head (if pair (cdr pair) ch)))))
+        (setq ch (substring-no-properties tail 0 1)
+              pair (assoc ch list))
+        (if (and pair (string-equal ch "\""))
+            (setq list (reverse list))) ; quote changes meaning each time
+        (setq tail (substring-no-properties tail 1)
+              head (concat head (if pair (cdr pair) ch))))
       head)))
 
 (defun cal-tex-month-name (month)
       head)))
 
 (defun cal-tex-month-name (month)
-  "The name of MONTH, LaTeXified."
+  "The name of MONTH, LaTeX-ified."
   (cal-tex-LaTeXify-string (calendar-month-name month)))
 
 (defun cal-tex-hfill ()
   (cal-tex-LaTeXify-string (calendar-month-name month)))
 
 (defun cal-tex-hfill ()
@@ -1806,9 +1809,5 @@ Add trailing COMMENT if present."
 
 (provide 'cal-tex)
 
 
 (provide 'cal-tex)
 
-;; Local Variables:
-;; generated-autoload-file: "cal-loaddefs.el"
-;; End:
-
 ;; arch-tag: ca8168a4-5a00-4508-a565-17e3bccce6d0
 ;;; cal-tex.el ends here
 ;; arch-tag: ca8168a4-5a00-4508-a565-17e3bccce6d0
 ;;; cal-tex.el ends here