aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-07-24 06:01:40 +0000
committerGlenn Morris2007-07-24 06:01:40 +0000
commit55abc44f16196f6110749e662f0df01f177614d4 (patch)
treeccb5db46ebd65b39f6e6a46cdfcb4dc755f36fb8
parent4892f741bb00cf05b4fbc8823750337b23e7a764 (diff)
downloademacs-55abc44f16196f6110749e662f0df01f177614d4.tar.gz
emacs-55abc44f16196f6110749e662f0df01f177614d4.zip
Remove leading `*' from defcustom docs.
(cal-tex-daily-string, cal-tex-daily-start, cal-tex-daily-end) (cal-tex-day-name-format, cal-tex-cal-one-month) (cal-tex-cal-multi-month, cal-tex-myday, cal-tex-preamble) (cal-tex-comment, cal-tex-nl, cal-tex-cmd, cal-tex-e-parbox) (cal-tex-mini-calendar, cal-tex-em): Doc fix. (cal-tex-list-holidays, cal-tex-cursor-year) (cal-tex-cursor-year-landscape, cal-tex-year) (cal-tex-cursor-filofax-year, cal-tex-cursor-month-landscape) (cal-tex-cursor-month, cal-tex-insert-days) (cal-tex-insert-day-names, cal-tex-insert-blank-days) (cal-tex-first-blank-p, cal-tex-cursor-week) (cal-tex-cursor-week2, cal-tex-cursor-week-iso) (cal-tex-week-hours, cal-tex-cursor-week-monday) (cal-tex-weekly4-box, cal-tex-cursor-filofax-2week) (cal-tex-cursor-filofax-week, cal-tex-cursor-filofax-daily) (cal-tex-cursor-day, cal-tex-daily-page, cal-tex-mini-calendar) (cal-tex-latexify-list, cal-tex-previous-month) (cal-tex-next-month, cal-tex-insert-preamble): General tidy-up and modernization, mainly using dotimes rather than calendar-for-loop. (cal-tex-LaTeX-subst-list): Remove `@'. (cal-tex-em, cal-tex-bf, cal-tex-Huge-bf, cal-tex-large-bf): Use \textit and \textbf rather than \em and \it.
-rw-r--r--lisp/ChangeLog25
-rw-r--r--lisp/calendar/cal-tex.el969
2 files changed, 483 insertions, 511 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d3963fd51db..32599427112 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -11,6 +11,31 @@
11 (cal-tex-cursor-filofax-2week, cal-tex-cursor-filofax-week) 11 (cal-tex-cursor-filofax-2week, cal-tex-cursor-filofax-week)
12 (cal-tex-cursor-filofax-daily, cal-tex-daily-page): Doc fix. 12 (cal-tex-cursor-filofax-daily, cal-tex-daily-page): Doc fix.
13 13
14 * calendar/cal-tex.el: Remove leading `*' from defcustom docs.
15 (cal-tex-daily-string, cal-tex-daily-start, cal-tex-daily-end)
16 (cal-tex-day-name-format, cal-tex-cal-one-month)
17 (cal-tex-cal-multi-month, cal-tex-myday, cal-tex-preamble)
18 (cal-tex-comment, cal-tex-nl, cal-tex-cmd, cal-tex-e-parbox)
19 (cal-tex-mini-calendar, cal-tex-em): Doc fix.
20 (cal-tex-list-holidays, cal-tex-cursor-year)
21 (cal-tex-cursor-year-landscape, cal-tex-year)
22 (cal-tex-cursor-filofax-year, cal-tex-cursor-month-landscape)
23 (cal-tex-cursor-month, cal-tex-insert-days)
24 (cal-tex-insert-day-names, cal-tex-insert-blank-days)
25 (cal-tex-first-blank-p, cal-tex-cursor-week)
26 (cal-tex-cursor-week2, cal-tex-cursor-week-iso)
27 (cal-tex-week-hours, cal-tex-cursor-week-monday)
28 (cal-tex-weekly4-box, cal-tex-cursor-filofax-2week)
29 (cal-tex-cursor-filofax-week, cal-tex-cursor-filofax-daily)
30 (cal-tex-cursor-day, cal-tex-daily-page, cal-tex-mini-calendar)
31 (cal-tex-latexify-list, cal-tex-previous-month)
32 (cal-tex-next-month, cal-tex-insert-preamble): General tidy-up and
33 modernization, including using dotimes rather than
34 calendar-for-loop.
35 (cal-tex-LaTeX-subst-list): Remove `@'.
36 (cal-tex-em, cal-tex-bf, cal-tex-Huge-bf, cal-tex-large-bf): Use
37 \textit and \textbf rather than \em and \it.
38
142007-07-23 Stefan Monnier <monnier@iro.umontreal.ca> 392007-07-23 Stefan Monnier <monnier@iro.umontreal.ca>
15 40
16 * ses.el (ses-cleanup): Prevent Emacs from spuriously checking if the 41 * ses.el (ses-cleanup): Prevent Emacs from spuriously checking if the
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 6c3ce9a5e84..4eaa22ecad0 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -54,7 +54,7 @@
54;;; 54;;;
55 55
56(defcustom cal-tex-which-days '(0 1 2 3 4 5 6) 56(defcustom cal-tex-which-days '(0 1 2 3 4 5 6)
57 "*The days of the week that are displayed on the portrait monthly calendar. 57 "The days of the week that are displayed on the portrait monthly calendar.
58Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to 58Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to
59Saturday. For example, use 59Saturday. For example, use
60 60
@@ -85,16 +85,16 @@ At present, this only affects the daily filofax calendar."
85 85
86(defcustom cal-tex-daily-string 86(defcustom cal-tex-daily-string
87 '(let* ((year (extract-calendar-year date)) 87 '(let* ((year (extract-calendar-year date))
88 (day (calendar-day-number date)) 88 (day (calendar-day-number date))
89 (days-remaining (- (calendar-day-number (list 12 31 year)) day))) 89 (days-remaining (- (calendar-day-number (list 12 31 year)) day)))
90 (format "%d/%d" day days-remaining)) 90 (format "%d/%d" day days-remaining))
91 "*An expression in the variable `date' whose value is placed on date. 91 "An expression in the variable `date' whose value is placed on date.
92The string resulting from evaluating this expression is placed at the bottom 92The string resulting from evaluating this expression is placed at the bottom
93center of `date' on the monthly calendar, next to the date in the weekly 93center of `date' on the monthly calendar, next to the date in the weekly
94calendars, and in the top center of daily calendars. 94calendars, and in the top center of daily calendars.
95 95
96Default is ordinal day number of the year and the number of days remaining. 96Default is ordinal day number of the year and the number of days remaining.
97As an example of what you do, setting this to 97As an example, setting this to
98 98
99 '(progn 99 '(progn
100 (require 'cal-hebrew) 100 (require 'cal-hebrew)
@@ -115,12 +115,12 @@ will put the Hebrew date at the bottom of each day."
115 :group 'calendar-tex) 115 :group 'calendar-tex)
116 116
117(defcustom cal-tex-daily-start 8 117(defcustom cal-tex-daily-start 8
118 "*The first hour of the daily calendar page." 118 "The first hour of the daily LaTeX calendar page."
119 :type 'integer 119 :type 'integer
120 :group 'calendar-tex) 120 :group 'calendar-tex)
121 121
122(defcustom cal-tex-daily-end 20 122(defcustom cal-tex-daily-end 20
123 "*The last hour of the daily calendar page." 123 "The last hour of the daily LaTeX calendar page."
124 :type 'integer 124 :type 'integer
125 :group 'calendar-tex) 125 :group 'calendar-tex)
126 126
@@ -133,7 +133,7 @@ For example, to include extra packages:
133 :version "22.1") 133 :version "22.1")
134 134
135(defcustom cal-tex-hook nil 135(defcustom cal-tex-hook nil
136 "*List of functions called after any LaTeX calendar buffer is generated. 136 "List of functions called after any LaTeX calendar buffer is generated.
137You can use this to do postprocessing on the buffer. For example, to change 137You can use this to do postprocessing on the buffer. For example, to change
138characters with diacritical marks to their LaTeX equivalents, use 138characters with diacritical marks to their LaTeX equivalents, use
139 (add-hook 'cal-tex-hook 139 (add-hook 'cal-tex-hook
@@ -142,22 +142,22 @@ characters with diacritical marks to their LaTeX equivalents, use
142 :group 'calendar-tex) 142 :group 'calendar-tex)
143 143
144(defcustom cal-tex-year-hook nil 144(defcustom cal-tex-year-hook nil
145 "*List of functions called after a LaTeX year calendar buffer is generated." 145 "List of functions called after a LaTeX year calendar buffer is generated."
146 :type 'hook 146 :type 'hook
147 :group 'calendar-tex) 147 :group 'calendar-tex)
148 148
149(defcustom cal-tex-month-hook nil 149(defcustom cal-tex-month-hook nil
150 "*List of functions called after a LaTeX month calendar buffer is generated." 150 "List of functions called after a LaTeX month calendar buffer is generated."
151 :type 'hook 151 :type 'hook
152 :group 'calendar-tex) 152 :group 'calendar-tex)
153 153
154(defcustom cal-tex-week-hook nil 154(defcustom cal-tex-week-hook nil
155 "*List of functions called after a LaTeX week calendar buffer is generated." 155 "List of functions called after a LaTeX week calendar buffer is generated."
156 :type 'hook 156 :type 'hook
157 :group 'calendar-tex) 157 :group 'calendar-tex)
158 158
159(defcustom cal-tex-daily-hook nil 159(defcustom cal-tex-daily-hook nil
160 "*List of functions called after a LaTeX daily calendar buffer is generated." 160 "List of functions called after a LaTeX daily calendar buffer is generated."
161 :type 'hook 161 :type 'hook
162 :group 'calendar-tex) 162 :group 'calendar-tex)
163 163
@@ -170,35 +170,35 @@ characters with diacritical marks to their LaTeX equivalents, use
170The holidays, diary entries, bottom string, and the text follow.") 170The holidays, diary entries, bottom string, and the text follow.")
171 171
172(defvar cal-tex-day-name-format "\\myday{%s}%%" 172(defvar cal-tex-day-name-format "\\myday{%s}%%"
173 "The format for LaTeX code for a day name. The names are taken from 173 "The format for LaTeX code for a day name.
174`calendar-day-name-array'.") 174The names are taken from `calendar-day-name-array'.")
175 175
176(defvar cal-tex-cal-one-month 176(defvar cal-tex-cal-one-month
177"\\def\\calmonth#1#2% 177 "\\def\\calmonth#1#2%
178{\\begin{center}% 178{\\begin{center}%
179\\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]% 179\\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]%
180\\end{center}}% 180\\end{center}}%
181\\vspace*{-1.5cm}% 181\\vspace*{-1.5cm}%
182% 182%
183" 183"
184 "LaTeX code for the month header") 184 "LaTeX code for the month header.")
185 185
186(defvar cal-tex-cal-multi-month 186(defvar cal-tex-cal-multi-month
187"\\def\\calmonth#1#2#3#4% 187 "\\def\\calmonth#1#2#3#4%
188{\\begin{center}% 188{\\begin{center}%
189\\Huge\\bf #1 #2---#3 #4\\\\[1cm]% 189\\Huge\\bf #1 #2---#3 #4\\\\[1cm]%
190\\end{center}}% 190\\end{center}}%
191\\vspace*{-1.5cm}% 191\\vspace*{-1.5cm}%
192% 192%
193" 193"
194 "LaTeX code for the month header") 194 "LaTeX code for the month header.")
195 195
196(defvar cal-tex-myday 196(defvar cal-tex-myday
197"\\renewcommand{\\myday}[1]% 197 "\\renewcommand{\\myday}[1]%
198{\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}} 198{\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}}
199% 199%
200" 200"
201 "LaTeX code for a day heading") 201 "LaTeX code for a day heading.")
202 202
203(defvar cal-tex-caldate 203(defvar cal-tex-caldate
204"\\fboxsep=0pt 204"\\fboxsep=0pt
@@ -233,18 +233,16 @@ This definition is the heart of the calendar!")
233 (1+ (/ (calendar-interval displayed-month displayed-year 233 (1+ (/ (calendar-interval displayed-month displayed-year
234 end-month end-year) 234 end-month end-year)
235 3))) 235 3)))
236 (holidays nil) 236 holidays in-range a)
237 (in-range))
238 (increment-calendar-month displayed-month displayed-year 1) 237 (increment-calendar-month displayed-month displayed-year 1)
239 (calendar-for-loop i from 1 to number-of-intervals do 238 (dotimes (idummy number-of-intervals)
240 (setq holidays (append holidays (calendar-holiday-list))) 239 (setq holidays (append holidays (calendar-holiday-list)))
241 (increment-calendar-month displayed-month displayed-year 3)) 240 (increment-calendar-month displayed-month displayed-year 3))
242 (while holidays 241 (dolist (hol holidays)
243 (and (car (car holidays)) 242 (and (car hol)
244 (let ((a (calendar-absolute-from-gregorian (car (car holidays))))) 243 (setq a (calendar-absolute-from-gregorian (car hol)))
245 (and (<= d1 a) (<= a d2))) 244 (and (<= d1 a) (<= a d2))
246 (setq in-range (append (list (car holidays)) in-range))) 245 (setq in-range (append (list hol) in-range))))
247 (setq holidays (cdr holidays)))
248 in-range)) 246 in-range))
249 247
250(defun cal-tex-list-diary-entries (d1 d2) 248(defun cal-tex-list-diary-entries (d1 d2)
@@ -256,9 +254,9 @@ This definition is the heart of the calendar!")
256 (1+ (- d2 d1))))) 254 (1+ (- d2 d1)))))
257 255
258(defun cal-tex-preamble (&optional args) 256(defun cal-tex-preamble (&optional args)
259 "Insert the LaTeX preamble. 257 "Insert the LaTeX calendar preamble.
260Preamble Includes initial definitions for various LaTeX commands. 258Preamble includes initial definitions for various LaTeX commands.
261Optional ARGS are included." 259Optional ARGS are included as article document class options."
262 (set-buffer (get-buffer-create cal-tex-buffer)) 260 (set-buffer (get-buffer-create cal-tex-buffer))
263 (erase-buffer) 261 (erase-buffer)
264 (insert "\\documentclass") 262 (insert "\\documentclass")
@@ -296,29 +294,28 @@ Optional ARGS are included."
296 294
297(defun cal-tex-cursor-year (&optional arg) 295(defun cal-tex-cursor-year (&optional arg)
298 "Make a buffer with LaTeX commands for the year cursor is on. 296 "Make a buffer with LaTeX commands for the year cursor is on.
299Optional prefix argument specifies number of years." 297Optional prefix argument ARG specifies number of years."
300 (interactive "p") 298 (interactive "p")
301 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t)) 299 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t))
302 (if arg arg 1))) 300 (or arg 1)))
303 301
304(defun cal-tex-cursor-year-landscape (&optional arg) 302(defun cal-tex-cursor-year-landscape (&optional arg)
305 "Make a buffer with LaTeX commands for the year cursor is on. 303 "Make a buffer with LaTeX commands for the year cursor is on.
306Optional prefix argument specifies number of years." 304Optional prefix argument ARG specifies number of years."
307 (interactive "p") 305 (interactive "p")
308 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t)) 306 (cal-tex-year (extract-calendar-year (calendar-cursor-to-date t))
309 (if arg arg 1) 307 (or arg 1) t))
310 t))
311 308
312(defun cal-tex-year (year n &optional landscape) 309(defun cal-tex-year (year n &optional landscape)
313 "Make a one page yearly calendar of YEAR; do this for N years. 310 "Make a one page yearly calendar of YEAR; do this for N years.
314There are four rows of three months each, unless optional LANDSCAPE is t, 311There are four rows of three months each, unless optional LANDSCAPE is t,
315in which case the calendar isprinted in landscape mode with three rows of 312in which case the calendar is printed in landscape mode with three rows of
316four months each." 313four months each."
317 (cal-tex-insert-preamble 1 landscape "12pt") 314 (cal-tex-insert-preamble 1 landscape "12pt")
318 (if landscape 315 (if landscape
319 (cal-tex-vspace "-.6cm") 316 (cal-tex-vspace "-.6cm")
320 (cal-tex-vspace "-3.1cm")) 317 (cal-tex-vspace "-3.1cm"))
321 (calendar-for-loop j from 1 to n do 318 (dotimes (j n)
322 (insert "\\vfill%\n") 319 (insert "\\vfill%\n")
323 (cal-tex-b-center) 320 (cal-tex-b-center)
324 (cal-tex-Huge (number-to-string year)) 321 (cal-tex-Huge (number-to-string year))
@@ -329,28 +326,28 @@ four months each."
329 (insert "\n") 326 (insert "\n")
330 (cal-tex-noindent) 327 (cal-tex-noindent)
331 (cal-tex-nl) 328 (cal-tex-nl)
332 (calendar-for-loop i from 1 to 12 do 329 (dotimes (i 12)
333 (insert (cal-tex-mini-calendar i year "month" "1.1in" "1in")) 330 (insert (cal-tex-mini-calendar (1+ i) year "month" "1.1in" "1in"))
334 (insert "\\month") 331 (insert "\\month")
335 (cal-tex-hspace "0.5in") 332 (cal-tex-hspace "0.5in")
336 (if (zerop (mod i (if landscape 4 3))) 333 (if (zerop (mod (1+ i) (if landscape 4 3)))
337 (cal-tex-nl "0.5in"))) 334 (cal-tex-nl "0.5in")))
338 (cal-tex-e-parbox) 335 (cal-tex-e-parbox)
339 (cal-tex-e-center) 336 (cal-tex-e-center)
340 (insert "\\vfill%\n") 337 (insert "\\vfill%\n")
341 (setq year (1+ year)) 338 (setq year (1+ year))
342 (if (/= j n) 339 (if (= j (1- n))
343 (cal-tex-newpage) 340 (cal-tex-end-document)
344 (cal-tex-end-document)) 341 (cal-tex-newpage))
345 (run-hooks 'cal-tex-year-hook)) 342 (run-hooks 'cal-tex-year-hook))
346 (run-hooks 'cal-tex-hook)) 343 (run-hooks 'cal-tex-hook))
347 344
348(defun cal-tex-cursor-filofax-year (&optional arg) 345(defun cal-tex-cursor-filofax-year (&optional arg)
349 "Make a Filofax one page yearly calendar of year indicated by cursor. 346 "Make a Filofax one page yearly calendar of year indicated by cursor.
350Optional parameter specifies number of years." 347Optional prefix argument ARG specifies number of years."
351 (interactive "p") 348 (interactive "p")
352 (let* ((n (if arg arg 1)) 349 (let ((n (or arg 1))
353 (year (extract-calendar-year (calendar-cursor-to-date t)))) 350 (year (extract-calendar-year (calendar-cursor-to-date t))))
354 (cal-tex-preamble "twoside") 351 (cal-tex-preamble "twoside")
355 (cal-tex-cmd "\\textwidth 3.25in") 352 (cal-tex-cmd "\\textwidth 3.25in")
356 (cal-tex-cmd "\\textheight 6.5in") 353 (cal-tex-cmd "\\textheight 6.5in")
@@ -362,7 +359,7 @@ Optional parameter specifies number of years."
362 (cal-tex-cmd "\\pagestyle{empty}") 359 (cal-tex-cmd "\\pagestyle{empty}")
363 (cal-tex-b-document) 360 (cal-tex-b-document)
364 (cal-tex-cmd "\\vspace*{0.25in}") 361 (cal-tex-cmd "\\vspace*{0.25in}")
365 (calendar-for-loop j from 1 to n do 362 (dotimes (j n)
366 (insert (format "\\hfil {\\Large \\bf %s} \\hfil\\\\\n" year)) 363 (insert (format "\\hfil {\\Large \\bf %s} \\hfil\\\\\n" year))
367 (cal-tex-b-center) 364 (cal-tex-b-center)
368 (cal-tex-b-parbox "l" "\\textwidth") 365 (cal-tex-b-parbox "l" "\\textwidth")
@@ -374,9 +371,8 @@ Optional parameter specifies number of years."
374 ;; the names of the months they insert. 371 ;; the names of the months they insert.
375 ["January" "February" "March" "April" "May" "June" 372 ["January" "February" "March" "April" "May" "June"
376 "July" "August" "September" "October" "November" "December"])) 373 "July" "August" "September" "October" "November" "December"]))
377 (calendar-for-loop i from 1 to 12 do 374 (dotimes (i 12)
378 (insert (cal-tex-mini-calendar i year 375 (insert (cal-tex-mini-calendar (1+ i) year (aref month-names i)
379 (aref month-names (1- i))
380 "1in" ".9in" "tiny" "0.6mm")))) 376 "1in" ".9in" "tiny" "0.6mm"))))
381 (insert 377 (insert
382 "\\noindent\\fbox{\\January}\\fbox{\\February}\\fbox{\\March}\\\\ 378 "\\noindent\\fbox{\\January}\\fbox{\\February}\\fbox{\\March}\\\\
@@ -387,7 +383,7 @@ Optional parameter specifies number of years."
387 (cal-tex-e-parbox) 383 (cal-tex-e-parbox)
388 (cal-tex-e-center) 384 (cal-tex-e-center)
389 (setq year (1+ year)) 385 (setq year (1+ year))
390 (if (= j n) 386 (if (= j (1- n))
391 (cal-tex-end-document) 387 (cal-tex-end-document)
392 (cal-tex-newpage) 388 (cal-tex-newpage)
393 (cal-tex-cmd "\\vspace*{0.25in}")) 389 (cal-tex-cmd "\\vspace*{0.25in}"))
@@ -400,45 +396,34 @@ Optional parameter specifies number of years."
400 396
401(defun cal-tex-cursor-month-landscape (&optional arg) 397(defun cal-tex-cursor-month-landscape (&optional arg)
402 "Make a LaTeX calendar buffer for the month the cursor is on. 398 "Make a LaTeX calendar buffer for the month the cursor is on.
403Optional prefix argument specifies number of months to be 399Optional prefix argument ARG specifies number of months to be
404produced (default 1). The output is in landscape format, one 400produced (default 1). The output is in landscape format, one
405month to a page. It shows holiday and diary entries if 401month to a page. It shows holiday and diary entries if
406`cal-tex-holidays' and `cal-tex-diary', respectively, are 402`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
407non-nil."
408 (interactive "p") 403 (interactive "p")
409 (let* ((n (if arg arg 1)) 404 (let* ((n (or arg 1))
410 (date (calendar-cursor-to-date t)) 405 (date (calendar-cursor-to-date t))
411 (month (extract-calendar-month date)) 406 (month (extract-calendar-month date))
412 (year (extract-calendar-year date)) 407 (year (extract-calendar-year date))
413 (end-month month) 408 (end-month month)
414 (end-year year) 409 (end-year year)
415 (cal-tex-which-days '(0 1 2 3 4 5 6))) 410 (cal-tex-which-days '(0 1 2 3 4 5 6))
411 (d1 (calendar-absolute-from-gregorian (list month 1 year)))
412 (d2 (calendar-absolute-from-gregorian
413 (list end-month
414 (calendar-last-day-of-month end-month end-year)
415 end-year))))
416 (increment-calendar-month end-month end-year (1- n)) 416 (increment-calendar-month end-month end-year (1- n))
417 (let ((diary-list (if cal-tex-diary 417 (let ((diary-list (if cal-tex-diary
418 (cal-tex-list-diary-entries 418 (cal-tex-list-diary-entries d1 d2)))
419 (calendar-absolute-from-gregorian
420 (list month 1 year))
421 (calendar-absolute-from-gregorian
422 (list end-month
423 (calendar-last-day-of-month
424 end-month end-year)
425 end-year)))))
426 (holidays (if cal-tex-holidays 419 (holidays (if cal-tex-holidays
427 (cal-tex-list-holidays 420 (cal-tex-list-holidays d1 d2)))
428 (calendar-absolute-from-gregorian 421 other-month other-year small-months-at-start)
429 (list month 1 year))
430 (calendar-absolute-from-gregorian
431 (list end-month
432 (calendar-last-day-of-month end-month end-year)
433 end-year)))))
434 (other-month)
435 (other-year)
436 (small-months-at-start))
437 (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt") 422 (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt")
438 (cal-tex-cmd cal-tex-cal-one-month) 423 (cal-tex-cmd cal-tex-cal-one-month)
439 (calendar-for-loop i from 1 to n do 424 (dotimes (i n)
440 (setq other-month month) 425 (setq other-month month
441 (setq other-year year) 426 other-year year)
442 (increment-calendar-month other-month other-year -1) 427 (increment-calendar-month other-month other-year -1)
443 (insert (cal-tex-mini-calendar other-month other-year "lastmonth" 428 (insert (cal-tex-mini-calendar other-month other-year "lastmonth"
444 "\\cellwidth" "\\cellheight")) 429 "\\cellwidth" "\\cellheight"))
@@ -448,11 +433,10 @@ non-nil."
448 (cal-tex-insert-month-header 1 month year month year) 433 (cal-tex-insert-month-header 1 month year month year)
449 (cal-tex-insert-day-names) 434 (cal-tex-insert-day-names)
450 (cal-tex-nl ".2cm") 435 (cal-tex-nl ".2cm")
451 (setq small-months-at-start 436 (if (setq small-months-at-start
452 (< 1 (mod (- (calendar-day-of-week (list month 1 year)) 437 (< 1 (mod (- (calendar-day-of-week (list month 1 year))
453 calendar-week-start-day) 438 calendar-week-start-day)
454 7))) 439 7)))
455 (if small-months-at-start
456 (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}")) 440 (insert "\\lastmonth\\nextmonth\\hspace*{-2\\cellwidth}"))
457 (cal-tex-insert-blank-days month year cal-tex-day-prefix) 441 (cal-tex-insert-blank-days month year cal-tex-day-prefix)
458 (cal-tex-insert-days month year diary-list holidays 442 (cal-tex-insert-days month year diary-list holidays
@@ -468,20 +452,19 @@ non-nil."
468 (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}" 452 (insert "\\vspace*{-\\cellwidth}\\hspace*{-2\\cellwidth}"
469 "\\lastmonth\\nextmonth% 453 "\\lastmonth\\nextmonth%
470")) 454"))
471 (if (/= i n) 455 (unless (= i (1- n))
472 (progn 456 (run-hooks 'cal-tex-month-hook)
473 (run-hooks 'cal-tex-month-hook) 457 (cal-tex-newpage)
474 (cal-tex-newpage) 458 (increment-calendar-month month year 1)
475 (increment-calendar-month month year 1) 459 (cal-tex-vspace "-2cm")
476 (cal-tex-vspace "-2cm") 460 (cal-tex-insert-preamble
477 (cal-tex-insert-preamble 461 (cal-tex-number-weeks month year 1) t "12pt" t)))
478 (cal-tex-number-weeks month year 1) t "12pt" t))))
479 (cal-tex-end-document) 462 (cal-tex-end-document)
480 (run-hooks 'cal-tex-hook)))) 463 (run-hooks 'cal-tex-hook))))
481 464
482(defun cal-tex-cursor-month (arg) 465(defun cal-tex-cursor-month (arg)
483 "Make a LaTeX calendar buffer for the month the cursor is on. 466 "Make a LaTeX calendar buffer for the month the cursor is on.
484Optional prefix argument specifies number of months to be 467Optional prefix argument ARG specifies number of months to be
485produced (default 1). The calendar is condensed onto one page. 468produced (default 1). The calendar is condensed onto one page.
486It shows holiday and diary entries if `cal-tex-holidays' and 469It shows holiday and diary entries if `cal-tex-holidays' and
487`cal-tex-diary', respectively, are non-nil." 470`cal-tex-diary', respectively, are non-nil."
@@ -491,27 +474,18 @@ It shows holiday and diary entries if `cal-tex-holidays' and
491 (year (extract-calendar-year date)) 474 (year (extract-calendar-year date))
492 (end-month month) 475 (end-month month)
493 (end-year year) 476 (end-year year)
494 (n (if arg arg 1))) 477 (n (or arg 1))
478 (d1 (calendar-absolute-from-gregorian (list month 1 year)))
479 (d2 (calendar-absolute-from-gregorian
480 (list end-month
481 (calendar-last-day-of-month end-month end-year)
482 end-year))))
495 (increment-calendar-month end-month end-year (1- n)) 483 (increment-calendar-month end-month end-year (1- n))
496 (let ((diary-list (if cal-tex-diary 484 (let ((diary-list (if cal-tex-diary
497 (cal-tex-list-diary-entries 485 (cal-tex-list-diary-entries d1 d2)))
498 (calendar-absolute-from-gregorian
499 (list month 1 year))
500 (calendar-absolute-from-gregorian
501 (list end-month
502 (calendar-last-day-of-month
503 end-month end-year)
504 end-year)))))
505 (holidays (if cal-tex-holidays 486 (holidays (if cal-tex-holidays
506 (cal-tex-list-holidays 487 (cal-tex-list-holidays d1 d2)))
507 (calendar-absolute-from-gregorian 488 other-month other-year)
508 (list month 1 year))
509 (calendar-absolute-from-gregorian
510 (list end-month
511 (calendar-last-day-of-month end-month end-year)
512 end-year)))))
513 (other-month)
514 (other-year))
515 (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil"12pt") 489 (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil"12pt")
516 (if (> n 1) 490 (if (> n 1)
517 (cal-tex-cmd cal-tex-cal-multi-month) 491 (cal-tex-cmd cal-tex-cal-multi-month)
@@ -520,20 +494,18 @@ It shows holiday and diary entries if `cal-tex-holidays' and
520 (cal-tex-insert-day-names) 494 (cal-tex-insert-day-names)
521 (cal-tex-nl ".2cm") 495 (cal-tex-nl ".2cm")
522 (cal-tex-insert-blank-days month year cal-tex-day-prefix) 496 (cal-tex-insert-blank-days month year cal-tex-day-prefix)
523 (calendar-for-loop i from 1 to n do 497 (dotimes (idummy n)
524 (setq other-month month) 498 (setq other-month month
525 (setq other-year year) 499 other-year year)
526 (cal-tex-insert-days month year diary-list holidays 500 (cal-tex-insert-days month year diary-list holidays cal-tex-day-prefix)
527 cal-tex-day-prefix) 501 (when (= (mod (calendar-absolute-from-gregorian
528 (if (= (mod (calendar-absolute-from-gregorian
529 (list month 502 (list month
530 (calendar-last-day-of-month month year) 503 (calendar-last-day-of-month month year)
531 year)) 504 year))
532 7) 505 7)
533 6); last day of month was Saturday 506 6) ; last day of month was Saturday
534 (progn 507 (cal-tex-hfill)
535 (cal-tex-hfill) 508 (cal-tex-nl))
536 (cal-tex-nl)))
537 (increment-calendar-month month year 1)) 509 (increment-calendar-month month year 1))
538 (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix) 510 (cal-tex-insert-blank-days-at-end end-month end-year cal-tex-day-prefix)
539 (cal-tex-end-document))) 511 (cal-tex-end-document)))
@@ -544,32 +516,31 @@ It shows holiday and diary entries if `cal-tex-holidays' and
544LaTeX commands are inserted for the days of the MONTH in YEAR. 516LaTeX commands are inserted for the days of the MONTH in YEAR.
545Diary entries on DIARY-LIST are included. Holidays on HOLIDAYS 517Diary entries on DIARY-LIST are included. Holidays on HOLIDAYS
546are included. Each day is formatted using format DAY-FORMAT." 518are included. Each day is formatted using format DAY-FORMAT."
547 (let* ((blank-days;; at start of month 519 (let ((blank-days ; at start of month
548 (mod 520 (mod
549 (- (calendar-day-of-week (list month 1 year)) 521 (- (calendar-day-of-week (list month 1 year))
550 calendar-week-start-day) 522 calendar-week-start-day)
551 7)) 523 7))
552 (date) 524 (last (calendar-last-day-of-month month year))
553 (last (calendar-last-day-of-month month year))) 525 date j)
554 (calendar-for-loop i from 1 to last do 526 (dotimes (i last)
555 (setq date (list month i year)) 527 (setq j (1+ i) ; 1-last, incl
556 (if (memq (calendar-day-of-week date) cal-tex-which-days) 528 date (list month j year))
557 (progn 529 (when (memq (calendar-day-of-week date) cal-tex-which-days)
558 (insert (format day-format (cal-tex-month-name month) i)) 530 (insert (format day-format (cal-tex-month-name month) j))
559 (cal-tex-arg (cal-tex-latexify-list diary-list date)) 531 (cal-tex-arg (cal-tex-latexify-list diary-list date))
560 (cal-tex-arg (cal-tex-latexify-list holidays date)) 532 (cal-tex-arg (cal-tex-latexify-list holidays date))
561 (cal-tex-arg (eval cal-tex-daily-string)) 533 (cal-tex-arg (eval cal-tex-daily-string))
562 (cal-tex-arg) 534 (cal-tex-arg)
563 (cal-tex-comment))) 535 (cal-tex-comment))
564 (if (and (zerop (mod (+ i blank-days) 7)) 536 (when (and (zerop (mod (+ j blank-days) 7))
565 (/= i last)) 537 (/= j last))
566 (progn 538 (cal-tex-hfill)
567 (cal-tex-hfill) 539 (cal-tex-nl)))))
568 (cal-tex-nl))))))
569 540
570(defun cal-tex-insert-day-names () 541(defun cal-tex-insert-day-names ()
571 "Insert the names of the days at top of a monthly calendar." 542 "Insert the names of the days at top of a monthly calendar."
572 (calendar-for-loop i from 0 to 6 do 543 (dotimes (i 7)
573 (if (memq i cal-tex-which-days) 544 (if (memq i cal-tex-which-days)
574 (insert (format cal-tex-day-name-format 545 (insert (format cal-tex-day-name-format
575 (cal-tex-LaTeXify-string 546 (cal-tex-LaTeXify-string
@@ -581,13 +552,13 @@ are included. Each day is formatted using format DAY-FORMAT."
581 "Create a title for a calendar. 552 "Create a title for a calendar.
582A title is inserted for a calendar with N months starting with 553A title is inserted for a calendar with N months starting with
583MONTH YEAR and ending with END-MONTH END-YEAR." 554MONTH YEAR and ending with END-MONTH END-YEAR."
584 (let ((month-name (cal-tex-month-name month)) 555 (let ((month-name (cal-tex-month-name month))
585 (end-month-name (cal-tex-month-name end-month))) 556 (end-month-name (cal-tex-month-name end-month)))
586 (if (= 1 n) 557 (if (= 1 n)
587 (insert (format "\\calmonth{%s}{%s}\n\\vspace*{-0.5cm}" 558 (insert (format "\\calmonth{%s}{%s}\n\\vspace*{-0.5cm}"
588 month-name year) ) 559 month-name year) )
589 (insert (format "\\calmonth{%s}{%s}{%s}{%s}\n\\vspace*{-0.5cm}" 560 (insert (format "\\calmonth{%s}{%s}{%s}{%s}\n\\vspace*{-0.5cm}"
590 month-name year end-month-name end-year)))) 561 month-name year end-month-name end-year))))
591 (cal-tex-comment)) 562 (cal-tex-comment))
592 563
593(defun cal-tex-insert-blank-days (month year day-format) 564(defun cal-tex-insert-blank-days (month year day-format)
@@ -596,12 +567,12 @@ Insert LaTeX code for the blank days at the beginning of the MONTH in
596YEAR. The entry is formatted using DAY-FORMAT. If the entire week is 567YEAR. The entry is formatted using DAY-FORMAT. If the entire week is
597blank, no days are inserted." 568blank, no days are inserted."
598 (if (cal-tex-first-blank-p month year) 569 (if (cal-tex-first-blank-p month year)
599 (let* ((blank-days;; at start of month 570 (let ((blank-days ; at start of month
600 (mod 571 (mod
601 (- (calendar-day-of-week (list month 1 year)) 572 (- (calendar-day-of-week (list month 1 year))
602 calendar-week-start-day) 573 calendar-week-start-day)
603 7))) 574 7)))
604 (calendar-for-loop i from 0 to (1- blank-days) do 575 (dotimes (i blank-days)
605 (if (memq i cal-tex-which-days) 576 (if (memq i cal-tex-which-days)
606 (insert (format day-format " " " ") "{}{}{}{}%\n")))))) 577 (insert (format day-format " " " ") "{}{}{}{}%\n"))))))
607 578
@@ -611,7 +582,7 @@ Insert LaTeX code for the blank days at the end of the MONTH in YEAR.
611The entry is formatted using DAY-FORMAT." 582The entry is formatted using DAY-FORMAT."
612 (if (cal-tex-last-blank-p month year) 583 (if (cal-tex-last-blank-p month year)
613 (let* ((last-day (calendar-last-day-of-month month year)) 584 (let* ((last-day (calendar-last-day-of-month month year))
614 (blank-days;; at end of month 585 (blank-days ; at end of month
615 (mod 586 (mod
616 (- (calendar-day-of-week (list month last-day year)) 587 (- (calendar-day-of-week (list month last-day year))
617 calendar-week-start-day) 588 calendar-week-start-day)
@@ -624,24 +595,22 @@ The entry is formatted using DAY-FORMAT."
624 "Determine if any days of the first week will be printed. 595 "Determine if any days of the first week will be printed.
625Return t if there will there be any days of the first week printed 596Return t if there will there be any days of the first week printed
626in the calendar starting in MONTH YEAR." 597in the calendar starting in MONTH YEAR."
627 (let ((any-days nil) 598 (let (any-days the-saturday) ; the day of week of 1st Saturday
628 (the-saturday)) ;the day of week of 1st Saturday 599 (dotimes (i 7)
629 (calendar-for-loop i from 1 to 7 do 600 (if (= 6 (calendar-day-of-week (list month (1+ i) year)))
630 (if (= 6 (calendar-day-of-week (list month i year))) 601 (setq the-saturday (1+ i))))
631 (setq the-saturday i))) 602 (dotimes (i the-saturday)
632 (calendar-for-loop i from 1 to the-saturday do 603 (if (memq (calendar-day-of-week (list month (1+ i) year))
633 (if (memq (calendar-day-of-week (list month i year)) 604 cal-tex-which-days)
634 cal-tex-which-days) 605 (setq any-days t)))
635 (setq any-days t)))
636 any-days)) 606 any-days))
637 607
638(defun cal-tex-last-blank-p (month year) 608(defun cal-tex-last-blank-p (month year)
639 "Determine if any days of the last week will be printed. 609 "Determine if any days of the last week will be printed.
640Return t if there will there be any days of the last week printed 610Return t if there will there be any days of the last week printed
641in the calendar starting in MONTH YEAR." 611in the calendar starting in MONTH YEAR."
642 (let ((any-days nil) 612 (let ((last-day (calendar-last-day-of-month month year))
643 (last-day (calendar-last-day-of-month month year)) 613 any-days the-sunday) ; the day of week of last Sunday
644 (the-sunday)) ;the day of week of last Sunday
645 (calendar-for-loop i from (- last-day 6) to last-day do 614 (calendar-for-loop i from (- last-day 6) to last-day do
646 (if (= 0 (calendar-day-of-week (list month i year))) 615 (if (= 0 (calendar-day-of-week (list month i year)))
647 (setq the-sunday i))) 616 (setq the-sunday i)))
@@ -654,7 +623,7 @@ in the calendar starting in MONTH YEAR."
654(defun cal-tex-number-weeks (month year n) 623(defun cal-tex-number-weeks (month year n)
655 "Determine the number of weeks in a range of dates. 624 "Determine the number of weeks in a range of dates.
656Compute the number of weeks in the calendar starting with MONTH and YEAR, 625Compute the number of weeks in the calendar starting with MONTH and YEAR,
657and lasting N months, including only the days in WHICH-DAYS. As it stands, 626and lasting N months, including only the days in WHICH-DAYS. As it stands,
658this is only an upper bound." 627this is only an upper bound."
659 (let ((d (list month 1 year))) 628 (let ((d (list month 1 year)))
660 (increment-calendar-month month year (1- n)) 629 (increment-calendar-month month year (1- n))
@@ -680,11 +649,11 @@ this is only an upper bound."
680(defun cal-tex-cursor-week (&optional arg) 649(defun cal-tex-cursor-week (&optional arg)
681 "Make a LaTeX calendar buffer for a two-page one-week calendar. 650 "Make a LaTeX calendar buffer for a two-page one-week calendar.
682It applies to the week that point is in. The optional prefix 651It applies to the week that point is in. The optional prefix
683argument specifies the number of weeks (default 1). The calendar 652argument ARG specifies the number of weeks (default 1). The calendar
684shows holidays if `cal-tex-holidays' is t (note that diary 653shows holidays if `cal-tex-holidays' is t (note that diary
685entries are not shown)." 654entries are not shown)."
686 (interactive "p") 655 (interactive "p")
687 (let* ((n (if arg arg 1)) 656 (let* ((n (or arg 1))
688 (date (calendar-gregorian-from-absolute 657 (date (calendar-gregorian-from-absolute
689 (calendar-dayname-on-or-before 658 (calendar-dayname-on-or-before
690 calendar-week-start-day 659 calendar-week-start-day
@@ -692,11 +661,10 @@ entries are not shown)."
692 (calendar-cursor-to-date t))))) 661 (calendar-cursor-to-date t)))))
693 (month (extract-calendar-month date)) 662 (month (extract-calendar-month date))
694 (year (extract-calendar-year date)) 663 (year (extract-calendar-year date))
664 (d1 (calendar-absolute-from-gregorian date))
665 (d2 (+ (* 7 n) d1))
695 (holidays (if cal-tex-holidays 666 (holidays (if cal-tex-holidays
696 (cal-tex-list-holidays 667 (cal-tex-list-holidays d1 d2))))
697 (calendar-absolute-from-gregorian date)
698 (+ (* 7 n)
699 (calendar-absolute-from-gregorian date))))))
700 (cal-tex-preamble "11pt") 668 (cal-tex-preamble "11pt")
701 (cal-tex-cmd "\\textwidth 6.5in") 669 (cal-tex-cmd "\\textwidth 6.5in")
702 (cal-tex-cmd "\\textheight 10.5in") 670 (cal-tex-cmd "\\textheight 10.5in")
@@ -705,7 +673,7 @@ entries are not shown)."
705 (insert cal-tex-LaTeX-hourbox) 673 (insert cal-tex-LaTeX-hourbox)
706 (cal-tex-b-document) 674 (cal-tex-b-document)
707 (cal-tex-cmd "\\pagestyle{empty}") 675 (cal-tex-cmd "\\pagestyle{empty}")
708 (calendar-for-loop i from 1 to n do 676 (dotimes (i n)
709 (cal-tex-vspace "-1.5in") 677 (cal-tex-vspace "-1.5in")
710 (cal-tex-b-center) 678 (cal-tex-b-center)
711 (cal-tex-Huge-bf (format "\\uppercase{%s}" 679 (cal-tex-Huge-bf (format "\\uppercase{%s}"
@@ -716,16 +684,15 @@ entries are not shown)."
716 (cal-tex-e-center) 684 (cal-tex-e-center)
717 (cal-tex-hspace "-.2in") 685 (cal-tex-hspace "-.2in")
718 (cal-tex-b-parbox "l" "7in") 686 (cal-tex-b-parbox "l" "7in")
719 (calendar-for-loop j from 1 to 7 do 687 (dotimes (jdummy 7)
720 (cal-tex-week-hours date holidays "3.1") 688 (cal-tex-week-hours date holidays "3.1")
721 (setq date (cal-tex-incr-date date))) 689 (setq date (cal-tex-incr-date date)))
722 (cal-tex-e-parbox) 690 (cal-tex-e-parbox)
723 (setq month (extract-calendar-month date)) 691 (setq month (extract-calendar-month date)
724 (setq year (extract-calendar-year date)) 692 year (extract-calendar-year date))
725 (if (/= i n) 693 (unless (= i (1- n))
726 (progn 694 (run-hooks 'cal-tex-week-hook)
727 (run-hooks 'cal-tex-week-hook) 695 (cal-tex-newpage)))
728 (cal-tex-newpage))))
729 (cal-tex-end-document) 696 (cal-tex-end-document)
730 (run-hooks 'cal-tex-hook))) 697 (run-hooks 'cal-tex-hook)))
731 698
@@ -733,11 +700,11 @@ entries are not shown)."
733(defun cal-tex-cursor-week2 (&optional arg) 700(defun cal-tex-cursor-week2 (&optional arg)
734 "Make a LaTeX calendar buffer for a two-page one-week calendar. 701 "Make a LaTeX calendar buffer for a two-page one-week calendar.
735It applies to the week that point is in. Optional prefix 702It applies to the week that point is in. Optional prefix
736argument specifies number of weeks (default 1). The calendar 703argument ARG specifies number of weeks (default 1). The calendar
737shows holidays if `cal-tex-holidays' is non-nil (note that diary 704shows holidays if `cal-tex-holidays' is non-nil (note that diary
738entries are not shown)." 705entries are not shown)."
739 (interactive "p") 706 (interactive "p")
740 (let* ((n (if arg arg 1)) 707 (let* ((n (or arg 1))
741 (date (calendar-gregorian-from-absolute 708 (date (calendar-gregorian-from-absolute
742 (calendar-dayname-on-or-before 709 (calendar-dayname-on-or-before
743 calendar-week-start-day 710 calendar-week-start-day
@@ -746,11 +713,10 @@ entries are not shown)."
746 (month (extract-calendar-month date)) 713 (month (extract-calendar-month date))
747 (year (extract-calendar-year date)) 714 (year (extract-calendar-year date))
748 (d date) 715 (d date)
716 (d1 (calendar-absolute-from-gregorian date))
717 (d2 (+ (* 7 n) d1))
749 (holidays (if cal-tex-holidays 718 (holidays (if cal-tex-holidays
750 (cal-tex-list-holidays 719 (cal-tex-list-holidays d1 d2))))
751 (calendar-absolute-from-gregorian date)
752 (+ (* 7 n)
753 (calendar-absolute-from-gregorian date))))))
754 (cal-tex-preamble "12pt") 720 (cal-tex-preamble "12pt")
755 (cal-tex-cmd "\\textwidth 6.5in") 721 (cal-tex-cmd "\\textwidth 6.5in")
756 (cal-tex-cmd "\\textheight 10.5in") 722 (cal-tex-cmd "\\textheight 10.5in")
@@ -759,7 +725,7 @@ entries are not shown)."
759 (insert cal-tex-LaTeX-hourbox) 725 (insert cal-tex-LaTeX-hourbox)
760 (cal-tex-b-document) 726 (cal-tex-b-document)
761 (cal-tex-cmd "\\pagestyle{empty}") 727 (cal-tex-cmd "\\pagestyle{empty}")
762 (calendar-for-loop i from 1 to n do 728 (dotimes (i n)
763 (cal-tex-vspace "-1.5in") 729 (cal-tex-vspace "-1.5in")
764 (cal-tex-b-center) 730 (cal-tex-b-center)
765 (cal-tex-Huge-bf (format "\\uppercase{%s}" 731 (cal-tex-Huge-bf (format "\\uppercase{%s}"
@@ -770,7 +736,7 @@ entries are not shown)."
770 (cal-tex-e-center) 736 (cal-tex-e-center)
771 (cal-tex-hspace "-.2in") 737 (cal-tex-hspace "-.2in")
772 (cal-tex-b-parbox "l" "\\textwidth") 738 (cal-tex-b-parbox "l" "\\textwidth")
773 (calendar-for-loop j from 1 to 3 do 739 (dotimes (jdummy 3)
774 (cal-tex-week-hours date holidays "5") 740 (cal-tex-week-hours date holidays "5")
775 (setq date (cal-tex-incr-date date))) 741 (setq date (cal-tex-incr-date date)))
776 (cal-tex-e-parbox) 742 (cal-tex-e-parbox)
@@ -798,26 +764,25 @@ entries are not shown)."
798 (insert "}") 764 (insert "}")
799 (cal-tex-nl) 765 (cal-tex-nl)
800 (cal-tex-b-parbox "l" "\\textwidth") 766 (cal-tex-b-parbox "l" "\\textwidth")
801 (calendar-for-loop j from 4 to 7 do 767 (dotimes (jdummy 4)
802 (cal-tex-week-hours date holidays "5") 768 (cal-tex-week-hours date holidays "5")
803 (setq date (cal-tex-incr-date date))) 769 (setq date (cal-tex-incr-date date)))
804 (cal-tex-e-parbox) 770 (cal-tex-e-parbox)
805 (setq month (extract-calendar-month date)) 771 (setq month (extract-calendar-month date)
806 (setq year (extract-calendar-year date)) 772 year (extract-calendar-year date))
807 (if (/= i n) 773 (unless (= i (1- n))
808 (progn 774 (run-hooks 'cal-tex-week-hook)
809 (run-hooks 'cal-tex-week-hook) 775 (cal-tex-newpage)))
810 (cal-tex-newpage))))
811 (cal-tex-end-document) 776 (cal-tex-end-document)
812 (run-hooks 'cal-tex-hook))) 777 (run-hooks 'cal-tex-hook)))
813 778
814(defun cal-tex-cursor-week-iso (&optional arg) 779(defun cal-tex-cursor-week-iso (&optional arg)
815 "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar. 780 "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar.
816Optional prefix argument specifies number of weeks (default 1). 781Optional prefix argument ARG specifies number of weeks (default 1).
817The calendar shows holiday and diary entries if 782The calendar shows holiday and diary entries if
818`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." 783`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
819 (interactive "p") 784 (interactive "p")
820 (let* ((n (if arg arg 1)) 785 (let* ((n (or arg 1))
821 (date (calendar-gregorian-from-absolute 786 (date (calendar-gregorian-from-absolute
822 (calendar-dayname-on-or-before 787 (calendar-dayname-on-or-before
823 1 788 1
@@ -826,17 +791,16 @@ The calendar shows holiday and diary entries if
826 (month (extract-calendar-month date)) 791 (month (extract-calendar-month date))
827 (year (extract-calendar-year date)) 792 (year (extract-calendar-year date))
828 (day (extract-calendar-day date)) 793 (day (extract-calendar-day date))
794 (d1 (calendar-absolute-from-gregorian date))
795 (d2 (+ (* 7 n) d1))
829 (holidays (if cal-tex-holidays 796 (holidays (if cal-tex-holidays
830 (cal-tex-list-holidays 797 (cal-tex-list-holidays d1 d2)))
831 (calendar-absolute-from-gregorian date)
832 (+ (* 7 n)
833 (calendar-absolute-from-gregorian date)))))
834 (diary-list (if cal-tex-diary 798 (diary-list (if cal-tex-diary
835 (cal-tex-list-diary-entries 799 (cal-tex-list-diary-entries
836 (calendar-absolute-from-gregorian 800 ;; FIXME d1?
837 (list month 1 year)) 801 (calendar-absolute-from-gregorian (list month 1 year))
838 (+ (* 7 n) 802 d2)))
839 (calendar-absolute-from-gregorian date)))))) 803 s)
840 (cal-tex-preamble "11pt") 804 (cal-tex-preamble "11pt")
841 (cal-tex-cmd "\\textwidth 6.5in") 805 (cal-tex-cmd "\\textwidth 6.5in")
842 (cal-tex-cmd "\\textheight 10.5in") 806 (cal-tex-cmd "\\textheight 10.5in")
@@ -844,19 +808,19 @@ The calendar shows holiday and diary entries if
844 (cal-tex-cmd "\\evensidemargin 0in") 808 (cal-tex-cmd "\\evensidemargin 0in")
845 (cal-tex-b-document) 809 (cal-tex-b-document)
846 (cal-tex-cmd "\\pagestyle{empty}") 810 (cal-tex-cmd "\\pagestyle{empty}")
847 (calendar-for-loop i from 1 to n do 811 (dotimes (i n)
848 (cal-tex-vspace "-1.5in") 812 (cal-tex-vspace "-1.5in")
849 (cal-tex-b-center) 813 (cal-tex-b-center)
850 (cal-tex-Huge-bf 814 (cal-tex-Huge-bf
851 (let* ((d (calendar-iso-from-absolute 815 (let ((d (calendar-iso-from-absolute
852 (calendar-absolute-from-gregorian date)))) 816 (calendar-absolute-from-gregorian date))))
853 (format "Week %d of %d" 817 (format "Week %d of %d"
854 (extract-calendar-month d) 818 (extract-calendar-month d)
855 (extract-calendar-year d)))) 819 (extract-calendar-year d))))
856 (cal-tex-nl ".5cm") 820 (cal-tex-nl ".5cm")
857 (cal-tex-e-center) 821 (cal-tex-e-center)
858 (cal-tex-b-parbox "l" "\\textwidth") 822 (cal-tex-b-parbox "l" "\\textwidth")
859 (calendar-for-loop j from 1 to 7 do 823 (dotimes (j 7)
860 (cal-tex-b-parbox "t" "\\textwidth") 824 (cal-tex-b-parbox "t" "\\textwidth")
861 (cal-tex-b-parbox "t" "\\textwidth") 825 (cal-tex-b-parbox "t" "\\textwidth")
862 (cal-tex-rule "0pt" "\\textwidth" ".2mm") 826 (cal-tex-rule "0pt" "\\textwidth" ".2mm")
@@ -867,37 +831,35 @@ The calendar shows holiday and diary entries if
867 (cal-tex-large-bf (cal-tex-month-name month)) 831 (cal-tex-large-bf (cal-tex-month-name month))
868 (insert " ") 832 (insert " ")
869 (cal-tex-large-bf (number-to-string day)) 833 (cal-tex-large-bf (number-to-string day))
870 (if (not (string= "" (cal-tex-latexify-list holidays date))) 834 (unless (string-equal "" (setq s (cal-tex-latexify-list
871 (progn 835 holidays date "; ")))
872 (insert ": ") 836 (insert ": ")
873 (cal-tex-large-bf (cal-tex-latexify-list holidays date "; ")))) 837 (cal-tex-large-bf s))
874 (cal-tex-hfill) 838 (cal-tex-hfill)
875 (insert " " (eval cal-tex-daily-string)) 839 (insert " " (eval cal-tex-daily-string))
876 (cal-tex-e-parbox) 840 (cal-tex-e-parbox)
877 (cal-tex-nl) 841 (cal-tex-nl)
878 (cal-tex-noindent) 842 (cal-tex-noindent)
879 (cal-tex-b-parbox "t" "\\textwidth") 843 (cal-tex-b-parbox "t" "\\textwidth")
880 (if (not (string= "" (cal-tex-latexify-list diary-list date))) 844 (unless (string-equal "" (setq s (cal-tex-latexify-list
881 (progn 845 diary-list date)))
882 (insert "\\vbox to 0pt{") 846 (insert "\\vbox to 0pt{")
883 (cal-tex-large-bf 847 (cal-tex-large-bf s)
884 (cal-tex-latexify-list diary-list date)) 848 (insert "}"))
885 (insert "}")))
886 (cal-tex-e-parbox) 849 (cal-tex-e-parbox)
887 (cal-tex-nl) 850 (cal-tex-nl)
888 (setq date (cal-tex-incr-date date)) 851 (setq date (cal-tex-incr-date date)
889 (setq month (extract-calendar-month date)) 852 month (extract-calendar-month date)
890 (setq day (extract-calendar-day date)) 853 day (extract-calendar-day date))
891 (cal-tex-e-parbox) 854 (cal-tex-e-parbox)
892 (cal-tex-e-parbox "2cm") 855 (cal-tex-e-parbox "2cm")
893 (cal-tex-nl) 856 (cal-tex-nl)
894 (setq month (extract-calendar-month date)) 857 (setq month (extract-calendar-month date)
895 (setq year (extract-calendar-year date))) 858 year (extract-calendar-year date)))
896 (cal-tex-e-parbox) 859 (cal-tex-e-parbox)
897 (if (/= i n) 860 (unless (= i (1- n))
898 (progn 861 (run-hooks 'cal-tex-week-hook)
899 (run-hooks 'cal-tex-week-hook) 862 (cal-tex-newpage)))
900 (cal-tex-newpage))))
901 (cal-tex-end-document) 863 (cal-tex-end-document)
902 (run-hooks 'cal-tex-hook))) 864 (run-hooks 'cal-tex-hook)))
903 865
@@ -905,9 +867,9 @@ The calendar shows holiday and diary entries if
905 "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT. 867 "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT.
906Uses the 24-hour clock if `cal-tex-24' is non-nil." 868Uses the 24-hour clock if `cal-tex-24' is non-nil."
907 (let ((month (extract-calendar-month date)) 869 (let ((month (extract-calendar-month date))
908 (day (extract-calendar-day date)) 870 (day (extract-calendar-day date))
909 (year (extract-calendar-year date)) 871 (year (extract-calendar-year date))
910 (afternoon)) 872 morning afternoon s)
911 (cal-tex-comment "begin cal-tex-week-hours") 873 (cal-tex-comment "begin cal-tex-week-hours")
912 (cal-tex-cmd "\\ \\\\[-.2cm]") 874 (cal-tex-cmd "\\ \\\\[-.2cm]")
913 (cal-tex-cmd "\\noindent") 875 (cal-tex-cmd "\\noindent")
@@ -917,48 +879,49 @@ Uses the 24-hour clock if `cal-tex-24' is non-nil."
917 (cal-tex-large-bf (cal-tex-month-name month)) 879 (cal-tex-large-bf (cal-tex-month-name month))
918 (insert " ") 880 (insert " ")
919 (cal-tex-large-bf (number-to-string day)) 881 (cal-tex-large-bf (number-to-string day))
920 (if (not (string= "" (cal-tex-latexify-list holidays date))) 882 (unless (string-equal "" (setq s (cal-tex-latexify-list
921 (progn 883 holidays date "; ")))
922 (insert ": ") 884 (insert ": ")
923 (cal-tex-large-bf (cal-tex-latexify-list holidays date "; ")))) 885 (cal-tex-large-bf s))
924 (cal-tex-hfill) 886 (cal-tex-hfill)
925 (insert " " (eval cal-tex-daily-string)) 887 (insert " " (eval cal-tex-daily-string))
926 (cal-tex-e-parbox) 888 (cal-tex-e-parbox)
927 (cal-tex-nl "-.3cm") 889 (cal-tex-nl "-.3cm")
928 (cal-tex-rule "0pt" "6.8in" ".2mm") 890 (cal-tex-rule "0pt" "6.8in" ".2mm")
929 (cal-tex-nl "-.1cm") 891 (cal-tex-nl "-.1cm")
930 (calendar-for-loop i from 8 to 12 do 892 (dotimes (i 5)
931 (if cal-tex-24 893 (setq morning (+ i 8) ; 8-12 incl
932 (setq afternoon (+ i 5)) 894 afternoon (if cal-tex-24
933 (setq afternoon (- i 7))) 895 (+ i 13) ; 13-17 incl
934 (cal-tex-cmd "\\hourbox" (number-to-string i)) 896 (1+ i))) ; 1-5 incl
935 (cal-tex-arg height) 897 (cal-tex-cmd "\\hourbox" (number-to-string morning))
936 (cal-tex-hspace ".4cm") 898 (cal-tex-arg height)
937 (cal-tex-cmd "\\hourbox" (number-to-string afternoon)) 899 (cal-tex-hspace ".4cm")
938 (cal-tex-arg height) 900 (cal-tex-cmd "\\hourbox" (number-to-string afternoon))
939 (cal-tex-nl)))) 901 (cal-tex-arg height)
902 (cal-tex-nl))))
940 903
941;; TODO cal-tex-diary support. 904;; TODO cal-tex-diary support.
942(defun cal-tex-cursor-week-monday (&optional arg) 905(defun cal-tex-cursor-week-monday (&optional arg)
943 "Make a LaTeX calendar buffer for a two-page one-week calendar. 906 "Make a LaTeX calendar buffer for a two-page one-week calendar.
944It applies to the week that point is in, and starts on Monday. 907It applies to the week that point is in, and starts on Monday.
945Optional prefix argument specifies number of weeks (default 1). 908Optional prefix argument ARG specifies number of weeks (default 1).
946The calendar shows holidays if `cal-tex-holidays' is 909The calendar shows holidays if `cal-tex-holidays' is
947non-nil (note that diary entries are not shown)." 910non-nil (note that diary entries are not shown)."
948 (interactive "p") 911 (interactive "p")
949 (let* ((n (if arg arg 1)) 912 (let ((n (or arg 1))
950 (date (calendar-gregorian-from-absolute 913 (date (calendar-gregorian-from-absolute
951 (calendar-dayname-on-or-before 914 (calendar-dayname-on-or-before
952 0 915 0
953 (calendar-absolute-from-gregorian 916 (calendar-absolute-from-gregorian
954 (calendar-cursor-to-date t)))))) 917 (calendar-cursor-to-date t))))))
955 (cal-tex-preamble "11pt") 918 (cal-tex-preamble "11pt")
956 (cal-tex-cmd "\\textwidth 6.5in") 919 (cal-tex-cmd "\\textwidth 6.5in")
957 (cal-tex-cmd "\\textheight 10.5in") 920 (cal-tex-cmd "\\textheight 10.5in")
958 (cal-tex-cmd "\\oddsidemargin 0in") 921 (cal-tex-cmd "\\oddsidemargin 0in")
959 (cal-tex-cmd "\\evensidemargin 0in") 922 (cal-tex-cmd "\\evensidemargin 0in")
960 (cal-tex-b-document) 923 (cal-tex-b-document)
961 (calendar-for-loop i from 1 to n do 924 (dotimes (i n)
962 (cal-tex-vspace "-1cm") 925 (cal-tex-vspace "-1cm")
963 (insert "\\noindent ") 926 (insert "\\noindent ")
964 (cal-tex-weekly4-box (cal-tex-incr-date date) nil) 927 (cal-tex-weekly4-box (cal-tex-incr-date date) nil)
@@ -969,61 +932,58 @@ non-nil (note that diary entries are not shown)."
969 (cal-tex-nl ".2cm") 932 (cal-tex-nl ".2cm")
970 (cal-tex-weekly4-box (cal-tex-incr-date date 3) nil) 933 (cal-tex-weekly4-box (cal-tex-incr-date date 3) nil)
971 (cal-tex-weekly4-box (cal-tex-incr-date date 6) t) 934 (cal-tex-weekly4-box (cal-tex-incr-date date 6) t)
972 (if (/= i n) 935 (unless (= i (1- n))
973 (progn 936 (run-hooks 'cal-tex-week-hook)
974 (run-hooks 'cal-tex-week-hook) 937 (setq date (cal-tex-incr-date date 7))
975 (setq date (cal-tex-incr-date date 7)) 938 (cal-tex-newpage)))
976 (cal-tex-newpage))))
977 (cal-tex-end-document) 939 (cal-tex-end-document)
978 (run-hooks 'cal-tex-hook))) 940 (run-hooks 'cal-tex-hook)))
979 941
980(defun cal-tex-weekly4-box (date weekend) 942(defun cal-tex-weekly4-box (date weekend)
981 "Make one box for DATE, different if WEEKEND. 943 "Make one box for DATE, different if WEEKEND.
982Uses the 24-hour clock if `cal-tex-24' is non-nil." 944Uses the 24-hour clock if `cal-tex-24' is non-nil."
983 (let* ( 945 (let* ((day (extract-calendar-day date))
984 (day (extract-calendar-day date)) 946 (month (extract-calendar-month date))
985 (month (extract-calendar-month date)) 947 (year (extract-calendar-year date))
986 (year (extract-calendar-year date)) 948 (dayname (cal-tex-LaTeXify-string (calendar-day-name date)))
987 (dayname (cal-tex-LaTeXify-string (calendar-day-name date))) 949 (date1 (cal-tex-incr-date date))
988 (date1 (cal-tex-incr-date date)) 950 (day1 (extract-calendar-day date1))
989 (day1 (extract-calendar-day date1)) 951 (month1 (extract-calendar-month date1))
990 (month1 (extract-calendar-month date1)) 952 (year1 (extract-calendar-year date1))
991 (year1 (extract-calendar-year date1)) 953 (dayname1 (cal-tex-LaTeXify-string (calendar-day-name date1))))
992 (dayname1 (cal-tex-LaTeXify-string (calendar-day-name date1)))
993 )
994 (cal-tex-b-framebox "8cm" "l") 954 (cal-tex-b-framebox "8cm" "l")
995 (cal-tex-b-parbox "b" "7.5cm") 955 (cal-tex-b-parbox "b" "7.5cm")
996 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year)) 956 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year))
997 (cal-tex-rule "0pt" "7.5cm" ".5mm") 957 (cal-tex-rule "0pt" "7.5cm" ".5mm")
998 (cal-tex-nl) 958 (cal-tex-nl)
999 (if (not weekend) 959 (unless weekend
1000 (progn 960 (dotimes (i 5)
1001 (calendar-for-loop i from 8 to 12 do 961 (insert (format "{\\large\\sf %d}\\\\\n" (+ i 8))))
1002 (insert (format "{\\large\\sf %d}\\\\\n" i))) 962 (dotimes (i 5)
1003 (calendar-for-loop i from 1 to 5 do 963 (insert (format "{\\large\\sf %d}\\\\\n"
1004 (insert (format "{\\large\\sf %d}\\\\\n" 964 (if cal-tex-24
1005 (if cal-tex-24 (+ i 12) i)))))) 965 (+ i 13) ; 13-17 incl
966 (1+ i)))))) ; 1-5 incl
1006 (cal-tex-nl ".5cm") 967 (cal-tex-nl ".5cm")
1007 (if weekend 968 (when weekend
1008 (progn 969 (cal-tex-vspace "1cm")
1009 (cal-tex-vspace "1cm") 970 (insert "\\ \\vfill")
1010 (insert "\\ \\vfill") 971 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n"
1011 (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" 972 dayname1 month1 day1 year1))
1012 dayname1 month1 day1 year1)) 973 (cal-tex-rule "0pt" "7.5cm" ".5mm")
1013 (cal-tex-rule "0pt" "7.5cm" ".5mm") 974 (cal-tex-nl "1.5cm")
1014 (cal-tex-nl "1.5cm") 975 (cal-tex-vspace "1cm"))
1015 (cal-tex-vspace "1cm")))
1016 (cal-tex-e-parbox) 976 (cal-tex-e-parbox)
1017 (cal-tex-e-framebox) 977 (cal-tex-e-framebox)
1018 (cal-tex-hspace "1cm"))) 978 (cal-tex-hspace "1cm")))
1019 979
1020(defun cal-tex-cursor-filofax-2week (&optional arg) 980(defun cal-tex-cursor-filofax-2week (&optional arg)
1021 "Two-weeks-at-a-glance Filofax style calendar for week cursor is in. 981 "Two-weeks-at-a-glance Filofax style calendar for week cursor is in.
1022Optional prefix argument specifies number of weeks (default 1). 982Optional prefix argument ARG specifies number of weeks (default 1).
1023The calendar shows holiday and diary entries if 983The calendar shows holiday and diary entries if
1024`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." 984`cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1025 (interactive "p") 985 (interactive "p")
1026 (let* ((n (if arg arg 1)) 986 (let* ((n (or arg 1))
1027 (date (calendar-gregorian-from-absolute 987 (date (calendar-gregorian-from-absolute
1028 (calendar-dayname-on-or-before 988 (calendar-dayname-on-or-before
1029 calendar-week-start-day 989 calendar-week-start-day
@@ -1032,17 +992,15 @@ The calendar shows holiday and diary entries if
1032 (month (extract-calendar-month date)) 992 (month (extract-calendar-month date))
1033 (year (extract-calendar-year date)) 993 (year (extract-calendar-year date))
1034 (day (extract-calendar-day date)) 994 (day (extract-calendar-day date))
995 (d1 (calendar-absolute-from-gregorian date))
996 (d2 (+ (* 7 n) d1))
1035 (holidays (if cal-tex-holidays 997 (holidays (if cal-tex-holidays
1036 (cal-tex-list-holidays 998 (cal-tex-list-holidays d1 d2)))
1037 (calendar-absolute-from-gregorian date)
1038 (+ (* 7 n)
1039 (calendar-absolute-from-gregorian date)))))
1040 (diary-list (if cal-tex-diary 999 (diary-list (if cal-tex-diary
1041 (cal-tex-list-diary-entries 1000 (cal-tex-list-diary-entries
1042 (calendar-absolute-from-gregorian 1001 ;; FIXME d1?
1043 (list month 1 year)) 1002 (calendar-absolute-from-gregorian (list month 1 year))
1044 (+ (* 7 n) 1003 d2))))
1045 (calendar-absolute-from-gregorian date))))))
1046 (cal-tex-preamble "twoside") 1004 (cal-tex-preamble "twoside")
1047 (cal-tex-cmd "\\textwidth 3.25in") 1005 (cal-tex-cmd "\\textwidth 3.25in")
1048 (cal-tex-cmd "\\textheight 6.5in") 1006 (cal-tex-cmd "\\textheight 6.5in")
@@ -1073,58 +1031,53 @@ The calendar shows holiday and diary entries if
1073") 1031")
1074 (cal-tex-b-document) 1032 (cal-tex-b-document)
1075 (cal-tex-cmd "\\pagestyle{empty}") 1033 (cal-tex-cmd "\\pagestyle{empty}")
1076 (calendar-for-loop i from 1 to n do 1034 (dotimes (i n)
1077 (if (= (mod i 2) 1) 1035 (if (zerop (mod i 2))
1078 (insert "\\righthead") 1036 (insert "\\righthead")
1079 (insert "\\lefthead")) 1037 (insert "\\lefthead"))
1080 (cal-tex-arg 1038 (cal-tex-arg
1081 (let ((d (cal-tex-incr-date date 6))) 1039 (let ((d (cal-tex-incr-date date 6)))
1082 (if (= (extract-calendar-month date) 1040 (if (= (extract-calendar-month date)
1083 (extract-calendar-month d)) 1041 (extract-calendar-month d))
1084 (format "%s %s" 1042 (format "%s %s"
1085 (cal-tex-month-name 1043 (cal-tex-month-name (extract-calendar-month date))
1086 (extract-calendar-month date)) 1044 (extract-calendar-year date))
1087 (extract-calendar-year date)) 1045 (if (= (extract-calendar-year date)
1088 (if (= (extract-calendar-year date) 1046 (extract-calendar-year d))
1089 (extract-calendar-year d)) 1047 (format "%s---%s %s"
1090 (format "%s---%s %s" 1048 (cal-tex-month-name (extract-calendar-month date))
1091 (cal-tex-month-name 1049 (cal-tex-month-name (extract-calendar-month d))
1092 (extract-calendar-month date)) 1050 (extract-calendar-year date))
1093 (cal-tex-month-name
1094 (extract-calendar-month d))
1095 (extract-calendar-year date))
1096 (format "%s %s---%s %s" 1051 (format "%s %s---%s %s"
1097 (cal-tex-month-name 1052 (cal-tex-month-name (extract-calendar-month date))
1098 (extract-calendar-month date))
1099 (extract-calendar-year date) 1053 (extract-calendar-year date)
1100 (cal-tex-month-name (extract-calendar-month d)) 1054 (cal-tex-month-name (extract-calendar-month d))
1101 (extract-calendar-year d)))))) 1055 (extract-calendar-year d))))))
1102 (insert "%\n") 1056 (insert "%\n")
1103 (calendar-for-loop j from 1 to 7 do 1057 (dotimes (jdummy 7)
1104 (if (= (mod i 2) 1) 1058 (if (zerop (mod i 2))
1105 (insert "\\rightday") 1059 (insert "\\rightday")
1106 (insert "\\leftday")) 1060 (insert "\\leftday"))
1107 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) 1061 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date)))
1108 (cal-tex-arg (int-to-string (extract-calendar-day date))) 1062 (cal-tex-arg (int-to-string (extract-calendar-day date)))
1109 (cal-tex-arg (cal-tex-latexify-list diary-list date)) 1063 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1110 (cal-tex-arg (cal-tex-latexify-list holidays date)) 1064 (cal-tex-arg (cal-tex-latexify-list holidays date))
1111 (cal-tex-arg (eval cal-tex-daily-string)) 1065 (cal-tex-arg (eval cal-tex-daily-string))
1112 (insert "%\n") 1066 (insert "%\n")
1113 (setq date (cal-tex-incr-date date))) 1067 (setq date (cal-tex-incr-date date)))
1114 (if (/= i n) 1068 (unless (= i (1- n))
1115 (progn 1069 (run-hooks 'cal-tex-week-hook)
1116 (run-hooks 'cal-tex-week-hook) 1070 (cal-tex-newpage)))
1117 (cal-tex-newpage))))
1118 (cal-tex-end-document) 1071 (cal-tex-end-document)
1119 (run-hooks 'cal-tex-hook))) 1072 (run-hooks 'cal-tex-hook)))
1120 1073
1121(defun cal-tex-cursor-filofax-week (&optional arg) 1074(defun cal-tex-cursor-filofax-week (&optional arg)
1122 "One-week-at-a-glance Filofax style calendar for week indicated by cursor. 1075 "One-week-at-a-glance Filofax style calendar for week indicated by cursor.
1123Optional prefix argument specifies number of weeks (default 1), 1076Optional prefix argument ARG specifies number of weeks (default 1),
1124starting on Mondays. The calendar shows holiday and diary entries 1077starting on Mondays. The calendar shows holiday and diary entries
1125if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." 1078if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1126 (interactive "p") 1079 (interactive "p")
1127 (let* ((n (if arg arg 1)) 1080 (let* ((n (or arg 1))
1128 (date (calendar-gregorian-from-absolute 1081 (date (calendar-gregorian-from-absolute
1129 (calendar-dayname-on-or-before 1082 (calendar-dayname-on-or-before
1130 1 1083 1
@@ -1133,17 +1086,15 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1133 (month (extract-calendar-month date)) 1086 (month (extract-calendar-month date))
1134 (year (extract-calendar-year date)) 1087 (year (extract-calendar-year date))
1135 (day (extract-calendar-day date)) 1088 (day (extract-calendar-day date))
1089 (d1 (calendar-absolute-from-gregorian date))
1090 (d2 (+ (* 7 n) d1))
1136 (holidays (if cal-tex-holidays 1091 (holidays (if cal-tex-holidays
1137 (cal-tex-list-holidays 1092 (cal-tex-list-holidays d1 d2)))
1138 (calendar-absolute-from-gregorian date)
1139 (+ (* 7 n)
1140 (calendar-absolute-from-gregorian date)))))
1141 (diary-list (if cal-tex-diary 1093 (diary-list (if cal-tex-diary
1142 (cal-tex-list-diary-entries 1094 (cal-tex-list-diary-entries
1143 (calendar-absolute-from-gregorian 1095 ;; FIXME d1?
1144 (list month 1 year)) 1096 (calendar-absolute-from-gregorian (list month 1 year))
1145 (+ (* 7 n) 1097 d2))))
1146 (calendar-absolute-from-gregorian date))))))
1147 (cal-tex-preamble "twoside") 1098 (cal-tex-preamble "twoside")
1148 (cal-tex-cmd "\\textwidth 3.25in") 1099 (cal-tex-cmd "\\textwidth 3.25in")
1149 (cal-tex-cmd "\\textheight 6.5in") 1100 (cal-tex-cmd "\\textheight 6.5in")
@@ -1183,32 +1134,28 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1183 (cal-tex-b-document) 1134 (cal-tex-b-document)
1184 (cal-tex-cmd "\\pagestyle{empty}\\ ") 1135 (cal-tex-cmd "\\pagestyle{empty}\\ ")
1185 (cal-tex-newpage) 1136 (cal-tex-newpage)
1186 (calendar-for-loop i from 1 to n do 1137 (dotimes (i n)
1187 (insert "\\lefthead") 1138 (insert "\\lefthead")
1188 (cal-tex-arg 1139 (cal-tex-arg
1189 (let ((d (cal-tex-incr-date date 2))) 1140 (let ((d (cal-tex-incr-date date 2)))
1190 (if (= (extract-calendar-month date) 1141 (if (= (extract-calendar-month date)
1191 (extract-calendar-month d)) 1142 (extract-calendar-month d))
1192 (format "%s %s" 1143 (format "%s %s"
1193 (cal-tex-month-name 1144 (cal-tex-month-name (extract-calendar-month date))
1194 (extract-calendar-month date))
1195 (extract-calendar-year date)) 1145 (extract-calendar-year date))
1196 (if (= (extract-calendar-year date) 1146 (if (= (extract-calendar-year date)
1197 (extract-calendar-year d)) 1147 (extract-calendar-year d))
1198 (format "%s---%s %s" 1148 (format "%s---%s %s"
1199 (cal-tex-month-name 1149 (cal-tex-month-name (extract-calendar-month date))
1200 (extract-calendar-month date)) 1150 (cal-tex-month-name (extract-calendar-month d))
1201 (cal-tex-month-name
1202 (extract-calendar-month d))
1203 (extract-calendar-year date)) 1151 (extract-calendar-year date))
1204 (format "%s %s---%s %s" 1152 (format "%s %s---%s %s"
1205 (cal-tex-month-name 1153 (cal-tex-month-name (extract-calendar-month date))
1206 (extract-calendar-month date))
1207 (extract-calendar-year date) 1154 (extract-calendar-year date)
1208 (cal-tex-month-name (extract-calendar-month d)) 1155 (cal-tex-month-name (extract-calendar-month d))
1209 (extract-calendar-year d)))))) 1156 (extract-calendar-year d))))))
1210 (insert "%\n") 1157 (insert "%\n")
1211 (calendar-for-loop j from 1 to 3 do 1158 (dotimes (jdummy 3)
1212 (insert "\\leftday") 1159 (insert "\\leftday")
1213 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) 1160 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date)))
1214 (cal-tex-arg (int-to-string (extract-calendar-day date))) 1161 (cal-tex-arg (int-to-string (extract-calendar-day date)))
@@ -1225,25 +1172,21 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1225 (if (= (extract-calendar-month date) 1172 (if (= (extract-calendar-month date)
1226 (extract-calendar-month d)) 1173 (extract-calendar-month d))
1227 (format "%s %s" 1174 (format "%s %s"
1228 (cal-tex-month-name 1175 (cal-tex-month-name (extract-calendar-month date))
1229 (extract-calendar-month date))
1230 (extract-calendar-year date)) 1176 (extract-calendar-year date))
1231 (if (= (extract-calendar-year date) 1177 (if (= (extract-calendar-year date)
1232 (extract-calendar-year d)) 1178 (extract-calendar-year d))
1233 (format "%s---%s %s" 1179 (format "%s---%s %s"
1234 (cal-tex-month-name 1180 (cal-tex-month-name (extract-calendar-month date))
1235 (extract-calendar-month date)) 1181 (cal-tex-month-name (extract-calendar-month d))
1236 (cal-tex-month-name
1237 (extract-calendar-month d))
1238 (extract-calendar-year date)) 1182 (extract-calendar-year date))
1239 (format "%s %s---%s %s" 1183 (format "%s %s---%s %s"
1240 (cal-tex-month-name 1184 (cal-tex-month-name (extract-calendar-month date))
1241 (extract-calendar-month date))
1242 (extract-calendar-year date) 1185 (extract-calendar-year date)
1243 (cal-tex-month-name (extract-calendar-month d)) 1186 (cal-tex-month-name (extract-calendar-month d))
1244 (extract-calendar-year d)))))) 1187 (extract-calendar-year d))))))
1245 (insert "%\n") 1188 (insert "%\n")
1246 (calendar-for-loop j from 1 to 2 do 1189 (dotimes (jdummy 2)
1247 (insert "\\rightday") 1190 (insert "\\rightday")
1248 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) 1191 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date)))
1249 (cal-tex-arg (int-to-string (extract-calendar-day date))) 1192 (cal-tex-arg (int-to-string (extract-calendar-day date)))
@@ -1252,7 +1195,7 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1252 (cal-tex-arg (eval cal-tex-daily-string)) 1195 (cal-tex-arg (eval cal-tex-daily-string))
1253 (insert "%\n") 1196 (insert "%\n")
1254 (setq date (cal-tex-incr-date date))) 1197 (setq date (cal-tex-incr-date date)))
1255 (calendar-for-loop j from 1 to 2 do 1198 (dotimes (jdummy 2)
1256 (insert "\\weekend") 1199 (insert "\\weekend")
1257 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date))) 1200 (cal-tex-arg (cal-tex-LaTeXify-string (calendar-day-name date)))
1258 (cal-tex-arg (int-to-string (extract-calendar-day date))) 1201 (cal-tex-arg (int-to-string (extract-calendar-day date)))
@@ -1261,21 +1204,20 @@ if `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil."
1261 (cal-tex-arg (eval cal-tex-daily-string)) 1204 (cal-tex-arg (eval cal-tex-daily-string))
1262 (insert "%\n") 1205 (insert "%\n")
1263 (setq date (cal-tex-incr-date date))) 1206 (setq date (cal-tex-incr-date date)))
1264 (if (/= i n) 1207 (unless (= i (1- n))
1265 (progn 1208 (run-hooks 'cal-tex-week-hook)
1266 (run-hooks 'cal-tex-week-hook) 1209 (cal-tex-newpage)))
1267 (cal-tex-newpage))))
1268 (cal-tex-end-document) 1210 (cal-tex-end-document)
1269 (run-hooks 'cal-tex-hook))) 1211 (run-hooks 'cal-tex-hook)))
1270 1212
1271(defun cal-tex-cursor-filofax-daily (&optional arg) 1213(defun cal-tex-cursor-filofax-daily (&optional arg)
1272 "Day-per-page Filofax style calendar for week indicated by cursor. 1214 "Day-per-page Filofax style calendar for week indicated by cursor.
1273Optional prefix argument specifies number of weeks (default 1), 1215Optional prefix argument ARG specifies number of weeks (default 1),
1274starting on Mondays. The calendar shows holiday and diary 1216starting on Mondays. The calendar shows holiday and diary
1275entries if `cal-tex-holidays' and `cal-tex-diary', respectively, 1217entries if `cal-tex-holidays' and `cal-tex-diary', respectively,
1276are non-nil. Pages are ruled if `cal-tex-rules' is non-nil." 1218are non-nil. Pages are ruled if `cal-tex-rules' is non-nil."
1277 (interactive "p") 1219 (interactive "p")
1278 (let* ((n (if arg arg 1)) 1220 (let* ((n (or arg 1))
1279 (date (calendar-gregorian-from-absolute 1221 (date (calendar-gregorian-from-absolute
1280 (calendar-dayname-on-or-before 1222 (calendar-dayname-on-or-before
1281 1 1223 1
@@ -1284,17 +1226,15 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil."
1284 (month (extract-calendar-month date)) 1226 (month (extract-calendar-month date))
1285 (year (extract-calendar-year date)) 1227 (year (extract-calendar-year date))
1286 (day (extract-calendar-day date)) 1228 (day (extract-calendar-day date))
1229 (d1 (calendar-absolute-from-gregorian date))
1230 (d2 (+ (* 7 n) d1))
1287 (holidays (if cal-tex-holidays 1231 (holidays (if cal-tex-holidays
1288 (cal-tex-list-holidays 1232 (cal-tex-list-holidays d1 d2)))
1289 (calendar-absolute-from-gregorian date)
1290 (+ (* 7 n)
1291 (calendar-absolute-from-gregorian date)))))
1292 (diary-list (if cal-tex-diary 1233 (diary-list (if cal-tex-diary
1293 (cal-tex-list-diary-entries 1234 (cal-tex-list-diary-entries
1294 (calendar-absolute-from-gregorian 1235 ;; FIXME d1?
1295 (list month 1 year)) 1236 (calendar-absolute-from-gregorian (list month 1 year))
1296 (+ (* 7 n) 1237 d2))))
1297 (calendar-absolute-from-gregorian date))))))
1298 (cal-tex-preamble "twoside") 1238 (cal-tex-preamble "twoside")
1299 (cal-tex-cmd "\\textwidth 3.25in") 1239 (cal-tex-cmd "\\textwidth 3.25in")
1300 (cal-tex-cmd "\\textheight 6.5in") 1240 (cal-tex-cmd "\\textheight 6.5in")
@@ -1337,24 +1277,28 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil."
1337") 1277")
1338 (cal-tex-b-document) 1278 (cal-tex-b-document)
1339 (cal-tex-cmd "\\pagestyle{empty}") 1279 (cal-tex-cmd "\\pagestyle{empty}")
1340 (calendar-for-loop i from 1 to n do 1280 (dotimes (i n)
1341 (calendar-for-loop j from 1 to 5 do 1281 (dotimes (j 4)
1342 (let ((odd (/= 0 (% j 2)))) 1282 (let ((even (zerop (% j 2))))
1343 (insert (if odd "\\righthead" "\\lefthead")) 1283 (insert (if even
1344 (cal-tex-arg (calendar-date-string date)) 1284 "\\righthead"
1345 (insert "%\n") 1285 "\\lefthead"))
1346 (insert (if odd "\\rightday" "\\leftday"))) 1286 (cal-tex-arg (calendar-date-string date))
1347 (cal-tex-arg (cal-tex-latexify-list diary-list date)) 1287 (insert "%\n")
1348 (cal-tex-arg (cal-tex-latexify-list holidays date "\\\\" t)) 1288 (insert (if even
1349 (cal-tex-arg (eval cal-tex-daily-string)) 1289 "\\rightday"
1350 (insert "%\n") 1290 "\\leftday")))
1351 (if cal-tex-rules 1291 (cal-tex-arg (cal-tex-latexify-list diary-list date))
1352 (insert "\\linesfill\n") 1292 (cal-tex-arg (cal-tex-latexify-list holidays date "\\\\" t))
1353 (insert "\\vfill\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")) 1293 (cal-tex-arg (eval cal-tex-daily-string))
1354 (cal-tex-newpage) 1294 (insert "%\n")
1355 (setq date (cal-tex-incr-date date))) 1295 (if cal-tex-rules
1296 (insert "\\linesfill\n")
1297 (insert "\\vfill\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n"))
1298 (cal-tex-newpage)
1299 (setq date (cal-tex-incr-date date)))
1356 (insert "%\n") 1300 (insert "%\n")
1357 (calendar-for-loop j from 1 to 2 do 1301 (dotimes (jdummy 2)
1358 (insert "\\lefthead") 1302 (insert "\\lefthead")
1359 (cal-tex-arg (calendar-date-string date)) 1303 (cal-tex-arg (calendar-date-string date))
1360 (insert "\\weekend") 1304 (insert "\\weekend")
@@ -1366,12 +1310,11 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil."
1366 (insert "\\linesfill\n") 1310 (insert "\\linesfill\n")
1367 (insert "\\vfill")) 1311 (insert "\\vfill"))
1368 (setq date (cal-tex-incr-date date))) 1312 (setq date (cal-tex-incr-date date)))
1369 (if (not cal-tex-rules) 1313 (or cal-tex-rules
1370 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n")) 1314 (insert "\\noindent\\rule{\\textwidth}{0.3pt}\\\\%\n"))
1371 (if (/= i n) 1315 (unless (= i (1- n))
1372 (progn 1316 (run-hooks 'cal-tex-week-hook)
1373 (run-hooks 'cal-tex-week-hook) 1317 (cal-tex-newpage)))
1374 (cal-tex-newpage))))
1375 (cal-tex-end-document) 1318 (cal-tex-end-document)
1376 (run-hooks 'cal-tex-hook))) 1319 (run-hooks 'cal-tex-hook)))
1377 1320
@@ -1382,23 +1325,22 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil."
1382 1325
1383(defun cal-tex-cursor-day (&optional arg) 1326(defun cal-tex-cursor-day (&optional arg)
1384 "Make a buffer with LaTeX commands for the day cursor is on. 1327 "Make a buffer with LaTeX commands for the day cursor is on.
1385Optional prefix argument specifies number of days." 1328Optional prefix argument ARG specifies number of days."
1386 (interactive "p") 1329 (interactive "p")
1387 (let ((n (if arg arg 1)) 1330 (let ((n (or arg 1))
1388 (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t)))) 1331 (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t))))
1389 (cal-tex-preamble "12pt") 1332 (cal-tex-preamble "12pt")
1390 (cal-tex-cmd "\\textwidth 6.5in") 1333 (cal-tex-cmd "\\textwidth 6.5in")
1391 (cal-tex-cmd "\\textheight 10.5in") 1334 (cal-tex-cmd "\\textheight 10.5in")
1392 (cal-tex-b-document) 1335 (cal-tex-b-document)
1393 (cal-tex-cmd "\\pagestyle{empty}") 1336 (cal-tex-cmd "\\pagestyle{empty}")
1394 (calendar-for-loop i from 1 to n do 1337 (dotimes (i n)
1395 (cal-tex-vspace "-1.7in") 1338 (cal-tex-vspace "-1.7in")
1396 (cal-tex-daily-page (calendar-gregorian-from-absolute date)) 1339 (cal-tex-daily-page (calendar-gregorian-from-absolute date))
1397 (setq date (1+ date)) 1340 (setq date (1+ date))
1398 (if (/= i n) 1341 (unless (= i (1- n))
1399 (progn 1342 (cal-tex-newpage)
1400 (cal-tex-newpage) 1343 (run-hooks 'cal-tex-daily-hook)))
1401 (run-hooks 'cal-tex-daily-hook))))
1402 (cal-tex-end-document) 1344 (cal-tex-end-document)
1403 (run-hooks 'cal-tex-hook))) 1345 (run-hooks 'cal-tex-hook)))
1404 1346
@@ -1407,8 +1349,8 @@ Optional prefix argument specifies number of days."
1407Uses the 24-hour clock if `cal-tex-24' is non-nil. Produces 1349Uses the 24-hour clock if `cal-tex-24' is non-nil. Produces
1408hourly sections for the period specified by `cal-tex-daily-start' 1350hourly sections for the period specified by `cal-tex-daily-start'
1409and `cal-tex-daily-end'." 1351and `cal-tex-daily-end'."
1410 (let* ((hour) 1352 (let ((month-name (cal-tex-month-name (extract-calendar-month date)))
1411 (month-name (cal-tex-month-name (extract-calendar-month date)))) 1353 hour)
1412 (cal-tex-banner "cal-tex-daily-page") 1354 (cal-tex-banner "cal-tex-daily-page")
1413 (cal-tex-b-makebox "4cm" "l") 1355 (cal-tex-b-makebox "4cm" "l")
1414 (cal-tex-b-parbox "b" "3.8cm") 1356 (cal-tex-b-parbox "b" "3.8cm")
@@ -1434,7 +1376,7 @@ and `cal-tex-daily-end'."
1434 (setq hour (if cal-tex-24 1376 (setq hour (if cal-tex-24
1435 i 1377 i
1436 (mod i 12))) 1378 (mod i 12)))
1437 (if (= 0 hour) (setq hour 12)) 1379 (if (zerop hour) (setq hour 12))
1438 (cal-tex-b-makebox "1cm" "c") 1380 (cal-tex-b-makebox "1cm" "c")
1439 (cal-tex-arg (number-to-string hour)) 1381 (cal-tex-arg (number-to-string hour))
1440 (cal-tex-e-makebox) 1382 (cal-tex-e-makebox)
@@ -1475,47 +1417,49 @@ and `cal-tex-daily-end'."
1475 1417
1476(defun cal-tex-mini-calendar (month year name width height &optional ptsize colsep) 1418(defun cal-tex-mini-calendar (month year name width height &optional ptsize colsep)
1477 "Produce mini-calendar for MONTH, YEAR in macro NAME with WIDTH and HEIGHT. 1419 "Produce mini-calendar for MONTH, YEAR in macro NAME with WIDTH and HEIGHT.
1478Optional PTSIZE gives the point ptsize; scriptsize is the default. Optional 1420Optional string PTSIZE gives the point size (default \"scriptsize\").
1479COLSEP gives the column separation; 1mm is the default." 1421Optional string COLSEP gives the column separation (default \"1mm\")."
1480 (let* ((blank-days;; at start of month 1422 (or colsep (setq colsep "1mm"))
1481 (mod 1423 (or ptsize (setq ptsize "scriptsize"))
1482 (- (calendar-day-of-week (list month 1 year)) 1424 (let ((blank-days ; at start of month
1483 calendar-week-start-day) 1425 (mod
1484 7)) 1426 (- (calendar-day-of-week (list month 1 year))
1485 (last (calendar-last-day-of-month month year)) 1427 calendar-week-start-day)
1486 (colsep (if colsep colsep "1mm")) 1428 7))
1487 (str (concat "\\def\\" name "{\\hbox to" width "{%\n" 1429 (last (calendar-last-day-of-month month year))
1488 "\\vbox to" height "{%\n" 1430 (str (concat "\\def\\" name "{\\hbox to" width "{%\n"
1489 "\\vfil \\hbox to" width "{%\n" 1431 "\\vbox to" height "{%\n"
1490 "\\hfil\\" 1432 "\\vfil \\hbox to" width "{%\n"
1491 (if ptsize ptsize "scriptsize") 1433 "\\hfil\\" ptsize
1492 "\\begin{tabular}" 1434 "\\begin{tabular}"
1493 "{@{\\hspace{0mm}}r@{\\hspace{" colsep 1435 "{@{\\hspace{0mm}}r@{\\hspace{" colsep
1494 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep 1436 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep
1495 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep 1437 "}}r@{\\hspace{" colsep "}}r@{\\hspace{" colsep
1496 "}}r@{\\hspace{" colsep "}}r@{\\hspace{0mm}}}%\n" 1438 "}}r@{\\hspace{" colsep "}}r@{\\hspace{0mm}}}%\n"
1497 "\\multicolumn{7}{c}{" 1439 "\\multicolumn{7}{c}{"
1498 (cal-tex-month-name month) 1440 (cal-tex-month-name month)
1499 " " 1441 " "
1500 (int-to-string year) 1442 (int-to-string year)
1501 "}\\\\[1mm]\n"))) 1443 "}\\\\[1mm]\n")))
1502 (calendar-for-loop i from 0 to 6 do 1444 (dotimes (i 6)
1503 (setq str 1445 (setq str
1504 (concat str 1446 (concat str
1505 (cal-tex-LaTeXify-string 1447 (cal-tex-LaTeXify-string
1506 (substring (aref calendar-day-name-array 1448 (substring (aref calendar-day-name-array
1507 (mod (+ calendar-week-start-day i) 7)) 1449 (mod (+ calendar-week-start-day i) 7))
1450
1508 0 2)) 1451 0 2))
1509 (if (/= i 6) 1452 (if (= i 6)
1510 " & " 1453 "\\\\[0.7mm]\n"
1511 "\\\\[0.7mm]\n")))) 1454 " & "))))
1512 (calendar-for-loop i from 1 to blank-days do 1455 (dotimes (idummy blank-days)
1513 (setq str (concat str " & "))) 1456 (setq str (concat str " & ")))
1514 (calendar-for-loop i from 1 to last do 1457 (dotimes (i last)
1515 (setq str (concat str (int-to-string i))) 1458 (setq str (concat str (int-to-string (1+ i)))
1516 (setq str (concat str (if (zerop (mod (+ i blank-days) 7)) 1459 str (concat str (if (zerop (mod (+ i 1 blank-days) 7))
1517 (if (/= i last) "\\\\[0.5mm]\n" "") 1460 (unless (= i (1- last))
1518 " & ")))) 1461 "\\\\[0.5mm]\n" "")
1462 " & "))))
1519 (setq str (concat str "\n\\end{tabular}\\hfil}\\vfil}}}%\n")) 1463 (setq str (concat str "\n\\end{tabular}\\hfil}\\vfil}}}%\n"))
1520 str)) 1464 str))
1521 1465
@@ -1527,40 +1471,38 @@ COLSEP gives the column separation; 1mm is the default."
1527 "The date of the day following DATE. 1471 "The date of the day following DATE.
1528If optional N is given, the date of N days after DATE." 1472If optional N is given, the date of N days after DATE."
1529 (calendar-gregorian-from-absolute 1473 (calendar-gregorian-from-absolute
1530 (+ (if n n 1) (calendar-absolute-from-gregorian date)))) 1474 (+ (or n 1) (calendar-absolute-from-gregorian date))))
1531 1475
1532(defun cal-tex-latexify-list (date-list date &optional separator final-separator) 1476(defun cal-tex-latexify-list (date-list date &optional separator final-separator)
1533 "Return string with concatenated, LaTeXified entries in DATE-LIST for DATE. 1477 "Return string with concatenated, LaTeX-ified entries in DATE-LIST for DATE.
1534Use double backslash as a separator unless optional SEPARATOR is given. 1478Use double backslash as a separator unless optional SEPARATOR is given.
1535If resulting string is not empty, put separator at end if optional 1479If resulting string is not empty, put separator at end if optional
1536FINAL-SEPARATOR is t." 1480FINAL-SEPARATOR is t."
1537 (let* ((sep (if separator separator "\\\\")) 1481 (or separator (setq separator "\\\\"))
1538 (result 1482 (let ((result
1539 (mapconcat '(lambda (x) (cal-tex-LaTeXify-string x)) 1483 (mapconcat (lambda (x) (cal-tex-LaTeXify-string x))
1540 (let ((result) 1484 (let (result)
1541 (p date-list)) 1485 (dolist (d date-list (reverse result))
1542 (while p 1486 (and (car d)
1543 (and (car (car p)) 1487 (calendar-date-equal date (car d))
1544 (calendar-date-equal date (car (car p))) 1488 (setq result (cons (cadr d) result)))))
1545 (setq result (cons (car (cdr (car p))) result))) 1489 separator)))
1546 (setq p (cdr p))) 1490 (if (and final-separator
1547 (reverse result)) 1491 (not (string-equal result "")))
1548 sep))) 1492 (concat result separator)
1549 (if (and final-separator (not (string-equal result ""))) 1493 result)))
1550 (concat result sep)
1551 result)))
1552 1494
1553(defun cal-tex-previous-month (date) 1495(defun cal-tex-previous-month (date)
1554 "Return the date of the first day in the month previous to DATE." 1496 "Return the date of the first day in the month previous to DATE."
1555 (let* ((month (extract-calendar-month date)) 1497 (let ((month (extract-calendar-month date))
1556 (year (extract-calendar-year date))) 1498 (year (extract-calendar-year date)))
1557 (increment-calendar-month month year -1) 1499 (increment-calendar-month month year -1)
1558 (list month 1 year))) 1500 (list month 1 year)))
1559 1501
1560(defun cal-tex-next-month (date) 1502(defun cal-tex-next-month (date)
1561 "Return the date of the first day in the month following DATE." 1503 "Return the date of the first day in the month following DATE."
1562 (let* ((month (extract-calendar-month date)) 1504 (let ((month (extract-calendar-month date))
1563 (year (extract-calendar-year date))) 1505 (year (extract-calendar-year date)))
1564 (increment-calendar-month month year 1) 1506 (increment-calendar-month month year 1)
1565 (list month 1 year))) 1507 (list month 1 year)))
1566 1508
@@ -1590,26 +1532,24 @@ Use pointsize SIZE. Optional argument APPEND, if t, means add to end of
1590without erasing current contents." 1532without erasing current contents."
1591 (let ((width "18cm") 1533 (let ((width "18cm")
1592 (height "24cm")) 1534 (height "24cm"))
1593 (if landscape 1535 (when landscape
1594 (progn 1536 (setq width "24cm"
1595 (setq width "24cm") 1537 height "18cm"))
1596 (setq height "18cm"))) 1538 (unless append
1597 (if (not append) 1539 (cal-tex-preamble size)
1598 (progn 1540 (if (not landscape)
1599 (cal-tex-preamble size) 1541 (progn
1600 (if (not landscape) 1542 (cal-tex-cmd "\\oddsidemargin -1.75cm")
1601 (progn 1543 (cal-tex-cmd "\\def\\holidaymult{.06}"))
1602 (cal-tex-cmd "\\oddsidemargin -1.75cm") 1544 (cal-tex-cmd "\\special{landscape}")
1603 (cal-tex-cmd "\\def\\holidaymult{.06}")) 1545 (cal-tex-cmd "\\textwidth 9.5in")
1604 (cal-tex-cmd "\\special{landscape}") 1546 (cal-tex-cmd "\\textheight 7in")
1605 (cal-tex-cmd "\\textwidth 9.5in") 1547 (cal-tex-comment)
1606 (cal-tex-cmd "\\textheight 7in") 1548 (cal-tex-cmd "\\def\\holidaymult{.08}"))
1607 (cal-tex-comment) 1549 (cal-tex-cmd cal-tex-caldate)
1608 (cal-tex-cmd "\\def\\holidaymult{.08}")) 1550 (cal-tex-cmd cal-tex-myday)
1609 (cal-tex-cmd cal-tex-caldate) 1551 (cal-tex-b-document)
1610 (cal-tex-cmd cal-tex-myday) 1552 (cal-tex-cmd "\\pagestyle{empty}"))
1611 (cal-tex-b-document)
1612 (cal-tex-cmd "\\pagestyle{empty}")))
1613 (cal-tex-cmd "\\setlength{\\cellwidth}" width) 1553 (cal-tex-cmd "\\setlength{\\cellwidth}" width)
1614 (insert (format "\\setlength{\\cellwidth}{%f\\cellwidth}\n" 1554 (insert (format "\\setlength{\\cellwidth}{%f\\cellwidth}\n"
1615 (/ 1.1 (length cal-tex-which-days)))) 1555 (/ 1.1 (length cal-tex-which-days))))
@@ -1621,8 +1561,10 @@ without erasing current contents."
1621 1561
1622(defvar cal-tex-LaTeX-subst-list 1562(defvar cal-tex-LaTeX-subst-list
1623 '(("\"". "``") 1563 '(("\"". "``")
1624 ("\"". "''");; Quote changes meaning when list is reversed. 1564 ("\"". "''") ; quote changes meaning when list is reversed
1625 ("@" . "\\verb|@|") 1565 ;; Don't think this is necessary, and in any case, does not work:
1566 ;; "LaTeX Error: \verb illegal in command argument".
1567;;; ("@" . "\\verb|@|")
1626 ("&" . "\\&") 1568 ("&" . "\\&")
1627 ("%" . "\\%") 1569 ("%" . "\\%")
1628 ("$" . "\\$") 1570 ("$" . "\\$")
@@ -1632,8 +1574,8 @@ without erasing current contents."
1632 ("}" . "\\}") 1574 ("}" . "\\}")
1633 ("<" . "$<$") 1575 ("<" . "$<$")
1634 (">" . "$>$") 1576 (">" . "$>$")
1635 ("\n" . "\\ \\\\")) ;\\ needed for e.g \begin{center}\n AA\end{center} 1577 ("\n" . "\\ \\\\")) ; \\ needed for e.g \begin{center}\n AA\end{center}
1636 "List of symbols and their replacements.") 1578 "List of symbols and their LaTeX replacements.")
1637 1579
1638(defun cal-tex-LaTeXify-string (string) 1580(defun cal-tex-LaTeXify-string (string)
1639 "Protect special characters in STRING from LaTeX." 1581 "Protect special characters in STRING from LaTeX."
@@ -1646,20 +1588,26 @@ without erasing current contents."
1646 (let* ((ch (substring tail 0 1)) 1588 (let* ((ch (substring tail 0 1))
1647 (pair (assoc ch list))) 1589 (pair (assoc ch list)))
1648 (if (and pair (string-equal ch "\"")) 1590 (if (and pair (string-equal ch "\""))
1649 (setq list (reverse list)));; Quote changes meaning each time. 1591 (setq list (reverse list))) ; quote changes meaning each time
1650 (setq tail (substring tail 1)) 1592 (setq tail (substring tail 1)
1651 (setq head (concat head (if pair (cdr pair) ch))))) 1593 head (concat head (if pair (cdr pair) ch)))))
1652 head))) 1594 head)))
1653 1595
1654(defun cal-tex-month-name (month) 1596(defun cal-tex-month-name (month)
1655 "The name of MONTH, LaTeXified." 1597 "The name of MONTH, LaTeXified."
1656 (cal-tex-LaTeXify-string (calendar-month-name month))) 1598 (cal-tex-LaTeXify-string (calendar-month-name month)))
1657 1599
1658(defun cal-tex-hfill () "Insert hfill." (insert "\\hfill")) 1600(defun cal-tex-hfill ()
1601 "Insert hfill."
1602 (insert "\\hfill"))
1659 1603
1660(defun cal-tex-newpage () "Insert newpage." (insert "\\newpage%\n")) 1604(defun cal-tex-newpage ()
1605 "Insert newpage."
1606 (insert "\\newpage%\n"))
1661 1607
1662(defun cal-tex-noindent () "Insert noindent." (insert "\\noindent")) 1608(defun cal-tex-noindent ()
1609 "Insert noindent."
1610 (insert "\\noindent"))
1663 1611
1664(defun cal-tex-vspace (space) 1612(defun cal-tex-vspace (space)
1665 "Insert vspace command to move SPACE vertically." 1613 "Insert vspace command to move SPACE vertically."
@@ -1672,8 +1620,7 @@ without erasing current contents."
1672 (cal-tex-comment)) 1620 (cal-tex-comment))
1673 1621
1674(defun cal-tex-comment (&optional comment) 1622(defun cal-tex-comment (&optional comment)
1675 "Insert % at end of line, include COMMENT if present, and move 1623 "Insert % at end of line, include COMMENT if present, and move to next line."
1676 to next line."
1677 (insert "% ") 1624 (insert "% ")
1678 (if comment 1625 (if comment
1679 (insert comment)) 1626 (insert comment))
@@ -1689,7 +1636,7 @@ without erasing current contents."
1689 1636
1690(defun cal-tex-nl (&optional skip comment) 1637(defun cal-tex-nl (&optional skip comment)
1691 "End a line with \\. If SKIP, then add that much spacing. 1638 "End a line with \\. If SKIP, then add that much spacing.
1692 Add COMMENT if present" 1639Add COMMENT if present."
1693 (insert "\\\\") 1640 (insert "\\\\")
1694 (if skip 1641 (if skip
1695 (insert "[" skip "]")) 1642 (insert "[" skip "]"))
@@ -1702,7 +1649,7 @@ without erasing current contents."
1702 (insert "}")) 1649 (insert "}"))
1703 1650
1704(defun cal-tex-cmd (cmd &optional arg) 1651(defun cal-tex-cmd (cmd &optional arg)
1705 "Insert LaTeX CMD, with optional ARG, and end with %" 1652 "Insert LaTeX CMD, with optional argument ARG, and end with %."
1706 (insert cmd) 1653 (insert cmd)
1707 (cal-tex-arg arg) 1654 (cal-tex-arg arg)
1708 (cal-tex-comment)) 1655 (cal-tex-comment))
@@ -1740,15 +1687,15 @@ without erasing current contents."
1740 (cal-tex-comment)) 1687 (cal-tex-comment))
1741 1688
1742(defun cal-tex-e-parbox (&optional height) 1689(defun cal-tex-e-parbox (&optional height)
1743 "Insert end of parbox. Force it to be a given HEIGHT." 1690 "Insert end of parbox. Optionally, force it to be a given HEIGHT."
1744 (cal-tex-comment) 1691 (cal-tex-comment)
1745 (if height 1692 (if height
1746 (cal-tex-rule "0mm" "0mm" height)) 1693 (cal-tex-rule "0mm" "0mm" height))
1747 (insert "}") 1694 (insert "}")
1748 (cal-tex-comment "end parbox")) 1695 (cal-tex-comment "end parbox"))
1749 1696
1750(defun cal-tex-b-framebox ( width position ) 1697(defun cal-tex-b-framebox (width position)
1751 "Insert framebox with parameters WIDTH and POSITION (clr)." 1698 "Insert framebox with parameters WIDTH and POSITION (clr)."
1752 (insert "\\framebox[" width "][" position "]{" ) 1699 (insert "\\framebox[" width "][" position "]{" )
1753 (cal-tex-comment)) 1700 (cal-tex-comment))
1754 1701
@@ -1760,7 +1707,7 @@ without erasing current contents."
1760 1707
1761 1708
1762(defun cal-tex-b-makebox ( width position ) 1709(defun cal-tex-b-makebox ( width position )
1763 "Insert makebox with parameters WIDTH and POSITION (clr)." 1710 "Insert makebox with parameters WIDTH and POSITION (clr)."
1764 (insert "\\makebox[" width "][" position "]{" ) 1711 (insert "\\makebox[" width "][" position "]{" )
1765 (cal-tex-comment)) 1712 (cal-tex-comment))
1766 1713
@@ -1780,12 +1727,12 @@ without erasing current contents."
1780;;; 1727;;;
1781 1728
1782(defun cal-tex-em (string) 1729(defun cal-tex-em (string)
1783 "Insert STRING in bf font." 1730 "Insert STRING in italic font."
1784 (insert "{\\em " string "}")) 1731 (insert "\\textit{" string "}"))
1785 1732
1786(defun cal-tex-bf (string) 1733(defun cal-tex-bf (string)
1787 "Insert STRING in bf font." 1734 "Insert STRING in bf font."
1788 (insert "{\\bf " string "}")) 1735 (insert "\\textbf{ " string "}"))
1789 1736
1790(defun cal-tex-scriptsize (string) 1737(defun cal-tex-scriptsize (string)
1791 "Insert STRING in scriptsize font." 1738 "Insert STRING in scriptsize font."
@@ -1801,7 +1748,7 @@ without erasing current contents."
1801 1748
1802(defun cal-tex-Huge-bf (string) 1749(defun cal-tex-Huge-bf (string)
1803 "Insert STRING in Huge bf size." 1750 "Insert STRING in Huge bf size."
1804 (insert "{\\Huge\\bf " string "}")) 1751 (insert "\\textbf{\\Huge " string "}"))
1805 1752
1806(defun cal-tex-large (string) 1753(defun cal-tex-large (string)
1807 "Insert STRING in large size." 1754 "Insert STRING in large size."
@@ -1809,7 +1756,7 @@ without erasing current contents."
1809 1756
1810(defun cal-tex-large-bf (string) 1757(defun cal-tex-large-bf (string)
1811 "Insert STRING in large bf size." 1758 "Insert STRING in large bf size."
1812 (insert "{\\large\\bf " string "}")) 1759 (insert "\\textbf{\\large " string "}"))
1813 1760
1814(provide 'cal-tex) 1761(provide 'cal-tex)
1815 1762