diff options
| author | Glenn Morris | 2007-07-25 08:52:43 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-07-25 08:52:43 +0000 |
| commit | 3e8e9c6a4aa1edb57158162da4f6241fa92890ab (patch) | |
| tree | 6b979155900952402d37690e1a1e312cf278bb52 | |
| parent | 4cf5577eaeb660a242e4c42afaee53f56ade710f (diff) | |
| download | emacs-3e8e9c6a4aa1edb57158162da4f6241fa92890ab.tar.gz emacs-3e8e9c6a4aa1edb57158162da4f6241fa92890ab.zip | |
(cal-tex-which-days, cal-tex-holidays)
(cal-tex-diary, cal-tex-daily-string, cal-tex-daily-start)
(cal-tex-daily-end, cal-tex-hook)
(cal-tex-cal-one-month, cal-tex-cal-multi-month)
(cal-tex-year, 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-day, cal-tex-insert-preamble): Doc fix.
(cal-tex-day-prefix, cal-tex-day-name-format)
(cal-tex-cal-one-month, cal-tex-cal-multi-month, cal-tex-myday)
(cal-tex-caldate, cal-tex-LaTeX-hourbox)
(cal-tex-LaTeX-subst-list): Change from variables to constants.
(cal-tex-preamble, cal-tex-arg, cal-tex-nl): Simplify with `format'.
(cal-tex-cursor-filofax-year, cal-tex-weekly4-box): Use \textbf,
etc, rather than \bf.
(cal-tex-mini-calendar): Fix typos in previous change.
(cal-tex-latexify-list): Remove inner let binding.
(cal-tex-end-document, cal-tex-banner): Use multi-line
cal-tex-comment.
(cal-tex-comment): Handle embedded newlines.
(cal-tex-LaTeXify-string): Use substring-no-properties.
| -rw-r--r-- | lisp/calendar/cal-tex.el | 240 |
1 files changed, 134 insertions, 106 deletions
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el index 4eaa22ecad0..82c0d90dea7 100644 --- a/lisp/calendar/cal-tex.el +++ b/lisp/calendar/cal-tex.el | |||
| @@ -31,6 +31,21 @@ | |||
| 31 | ;; This collection of functions implements the creation of LaTeX calendars | 31 | ;; This collection of functions implements the creation of LaTeX calendars |
| 32 | ;; based on the user's holiday choices and diary file. | 32 | ;; based on the user's holiday choices and diary file. |
| 33 | 33 | ||
| 34 | ;; The user commands are: | ||
| 35 | ;; cal-tex-cursor-year | ||
| 36 | ;; cal-tex-cursor-year-landscape | ||
| 37 | ;; cal-tex-cursor-filofax-year | ||
| 38 | ;; cal-tex-cursor-month-landscape | ||
| 39 | ;; cal-tex-cursor-month | ||
| 40 | ;; cal-tex-cursor-week | ||
| 41 | ;; cal-tex-cursor-week2 | ||
| 42 | ;; cal-tex-cursor-week-iso | ||
| 43 | ;; cal-tex-cursor-week-monday | ||
| 44 | ;; cal-tex-cursor-filofax-2week | ||
| 45 | ;; cal-tex-cursor-filofax-week | ||
| 46 | ;; cal-tex-cursor-filofax-daily | ||
| 47 | ;; cal-tex-cursor-day | ||
| 48 | |||
| 34 | ;; TO DO | 49 | ;; TO DO |
| 35 | ;; | 50 | ;; |
| 36 | ;; (*) Add holidays and diary entries to daily calendar. | 51 | ;; (*) Add holidays and diary entries to daily calendar. |
| @@ -56,24 +71,21 @@ | |||
| 56 | (defcustom cal-tex-which-days '(0 1 2 3 4 5 6) | 71 | (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. | 72 | "The days of the week that are displayed on the portrait monthly calendar. |
| 58 | Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to | 73 | Sunday is 0, Monday is 1, and so on. The default is to print from Sunday to |
| 59 | Saturday. For example, use | 74 | Saturday. For example, use '(1 3 5) to only print Monday, Wednesday, Friday." |
| 60 | |||
| 61 | (setq cal-tex-which-days '(1 3 5)) | ||
| 62 | |||
| 63 | to only print Monday, Wednesday, Friday." | ||
| 64 | :type '(repeat integer) | 75 | :type '(repeat integer) |
| 65 | :group 'calendar-tex) | 76 | :group 'calendar-tex) |
| 66 | 77 | ||
| 67 | (defcustom cal-tex-holidays t | 78 | (defcustom cal-tex-holidays t |
| 68 | "Non-nil means holidays are printed in the LaTeX calendars that support it. | 79 | "Non-nil means holidays are printed in the LaTeX calendars that support it. |
| 69 | If finding the holidays is too slow, set this to nil." | 80 | Setting this to nil may speed up calendar generation." |
| 70 | :type 'boolean | 81 | :type 'boolean |
| 71 | :group 'calendar-tex) | 82 | :group 'calendar-tex) |
| 72 | 83 | ||
| 73 | (defcustom cal-tex-diary nil | 84 | (defcustom cal-tex-diary nil |
| 74 | "Non-nil means diary entries are printed in LaTeX calendars that support it. | 85 | "Non-nil means diary entries are printed in LaTeX calendars that support it. |
| 75 | At present, this only affects the monthly, filofax, and iso-week | 86 | At present, this only affects the monthly, filofax, and iso-week |
| 76 | calendars (i.e. not the yearly, plain weekly, or daily calendars)." | 87 | calendars (i.e. not the yearly, plain weekly, or daily calendars). |
| 88 | Setting this to nil may speed up calendar generation." | ||
| 77 | :type 'boolean | 89 | :type 'boolean |
| 78 | :group 'calendar-tex) | 90 | :group 'calendar-tex) |
| 79 | 91 | ||
| @@ -88,17 +100,18 @@ At present, this only affects the daily filofax calendar." | |||
| 88 | (day (calendar-day-number date)) | 100 | (day (calendar-day-number date)) |
| 89 | (days-remaining (- (calendar-day-number (list 12 31 year)) day))) | 101 | (days-remaining (- (calendar-day-number (list 12 31 year)) day))) |
| 90 | (format "%d/%d" day days-remaining)) | 102 | (format "%d/%d" day days-remaining)) |
| 91 | "An expression in the variable `date' whose value is placed on date. | 103 | "Lisp expression giving the date format to use in the LaTeX calendars. |
| 92 | The string resulting from evaluating this expression is placed at the bottom | 104 | This should be an expression involving the variable `date'. When |
| 93 | center of `date' on the monthly calendar, next to the date in the weekly | 105 | this expression is called, `date' is a list of the form '(MONTH DAY YEAR)'. |
| 94 | calendars, and in the top center of daily calendars. | 106 | |
| 107 | The string resulting from evaluating this expression is placed at | ||
| 108 | the bottom center of each date in monthly calendars, next to the | ||
| 109 | date in the weekly calendars, and in the top center of daily calendars. | ||
| 95 | 110 | ||
| 96 | Default is ordinal day number of the year and the number of days remaining. | 111 | The default is ordinal day number of the year and the number of |
| 97 | As an example, setting this to | 112 | days remaining. As an example, setting this to |
| 98 | 113 | ||
| 99 | '(progn | 114 | '(calendar-hebrew-date-string date) |
| 100 | (require 'cal-hebrew) | ||
| 101 | (calendar-hebrew-date-string date)) | ||
| 102 | 115 | ||
| 103 | will put the Hebrew date at the bottom of each day." | 116 | will put the Hebrew date at the bottom of each day." |
| 104 | :type 'sexp | 117 | :type 'sexp |
| @@ -115,12 +128,14 @@ will put the Hebrew date at the bottom of each day." | |||
| 115 | :group 'calendar-tex) | 128 | :group 'calendar-tex) |
| 116 | 129 | ||
| 117 | (defcustom cal-tex-daily-start 8 | 130 | (defcustom cal-tex-daily-start 8 |
| 118 | "The first hour of the daily LaTeX calendar page." | 131 | "The first hour of the daily LaTeX calendar page. |
| 132 | At present, this only affects `cal-tex-cursor-day'." | ||
| 119 | :type 'integer | 133 | :type 'integer |
| 120 | :group 'calendar-tex) | 134 | :group 'calendar-tex) |
| 121 | 135 | ||
| 122 | (defcustom cal-tex-daily-end 20 | 136 | (defcustom cal-tex-daily-end 20 |
| 123 | "The last hour of the daily LaTeX calendar page." | 137 | "The last hour of the daily LaTeX calendar page. |
| 138 | At present, this only affects `cal-tex-cursor-day'" | ||
| 124 | :type 'integer | 139 | :type 'integer |
| 125 | :group 'calendar-tex) | 140 | :group 'calendar-tex) |
| 126 | 141 | ||
| @@ -136,8 +151,8 @@ For example, to include extra packages: | |||
| 136 | "List of functions called after any LaTeX calendar buffer is generated. | 151 | "List of functions called after any LaTeX calendar buffer is generated. |
| 137 | You can use this to do postprocessing on the buffer. For example, to change | 152 | You can use this to do postprocessing on the buffer. For example, to change |
| 138 | characters with diacritical marks to their LaTeX equivalents, use | 153 | characters with diacritical marks to their LaTeX equivalents, use |
| 139 | (add-hook 'cal-tex-hook | 154 | (add-hook 'cal-tex-hook |
| 140 | '(lambda () (iso-iso2tex (point-min) (point-max))))" | 155 | (lambda () (iso-iso2tex (point-min) (point-max))))" |
| 141 | :type 'hook | 156 | :type 'hook |
| 142 | :group 'calendar-tex) | 157 | :group 'calendar-tex) |
| 143 | 158 | ||
| @@ -165,15 +180,15 @@ characters with diacritical marks to their LaTeX equivalents, use | |||
| 165 | ;;; Definitions for LaTeX code | 180 | ;;; Definitions for LaTeX code |
| 166 | ;;; | 181 | ;;; |
| 167 | 182 | ||
| 168 | (defvar cal-tex-day-prefix "\\caldate{%s}{%s}" | 183 | (defconst cal-tex-day-prefix "\\caldate{%s}{%s}" |
| 169 | "The initial LaTeX code for a day. | 184 | "The initial LaTeX code for a day. |
| 170 | The holidays, diary entries, bottom string, and the text follow.") | 185 | The holidays, diary entries, bottom string, and the text follow.") |
| 171 | 186 | ||
| 172 | (defvar cal-tex-day-name-format "\\myday{%s}%%" | 187 | (defconst cal-tex-day-name-format "\\myday{%s}%%" |
| 173 | "The format for LaTeX code for a day name. | 188 | "The format for LaTeX code for a day name. |
| 174 | The names are taken from `calendar-day-name-array'.") | 189 | The names are taken from `calendar-day-name-array'.") |
| 175 | 190 | ||
| 176 | (defvar cal-tex-cal-one-month | 191 | (defconst cal-tex-cal-one-month |
| 177 | "\\def\\calmonth#1#2% | 192 | "\\def\\calmonth#1#2% |
| 178 | {\\begin{center}% | 193 | {\\begin{center}% |
| 179 | \\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]% | 194 | \\Huge\\bf\\uppercase{#1} #2 \\\\[1cm]% |
| @@ -181,9 +196,9 @@ The names are taken from `calendar-day-name-array'.") | |||
| 181 | \\vspace*{-1.5cm}% | 196 | \\vspace*{-1.5cm}% |
| 182 | % | 197 | % |
| 183 | " | 198 | " |
| 184 | "LaTeX code for the month header.") | 199 | "LaTeX code for the month header, for a single month calendar.") |
| 185 | 200 | ||
| 186 | (defvar cal-tex-cal-multi-month | 201 | (defconst cal-tex-cal-multi-month |
| 187 | "\\def\\calmonth#1#2#3#4% | 202 | "\\def\\calmonth#1#2#3#4% |
| 188 | {\\begin{center}% | 203 | {\\begin{center}% |
| 189 | \\Huge\\bf #1 #2---#3 #4\\\\[1cm]% | 204 | \\Huge\\bf #1 #2---#3 #4\\\\[1cm]% |
| @@ -191,16 +206,16 @@ The names are taken from `calendar-day-name-array'.") | |||
| 191 | \\vspace*{-1.5cm}% | 206 | \\vspace*{-1.5cm}% |
| 192 | % | 207 | % |
| 193 | " | 208 | " |
| 194 | "LaTeX code for the month header.") | 209 | "LaTeX code for the month header, for a multi-month calendar.") |
| 195 | 210 | ||
| 196 | (defvar cal-tex-myday | 211 | (defconst cal-tex-myday |
| 197 | "\\renewcommand{\\myday}[1]% | 212 | "\\renewcommand{\\myday}[1]% |
| 198 | {\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}} | 213 | {\\makebox[\\cellwidth]{\\hfill\\large\\bf#1\\hfill}} |
| 199 | % | 214 | % |
| 200 | " | 215 | " |
| 201 | "LaTeX code for a day heading.") | 216 | "LaTeX code for a day heading.") |
| 202 | 217 | ||
| 203 | (defvar cal-tex-caldate | 218 | (defconst cal-tex-caldate |
| 204 | "\\fboxsep=0pt | 219 | "\\fboxsep=0pt |
| 205 | \\long\\def\\caldate#1#2#3#4#5#6{% | 220 | \\long\\def\\caldate#1#2#3#4#5#6{% |
| 206 | \\fbox{\\hbox to\\cellwidth{% | 221 | \\fbox{\\hbox to\\cellwidth{% |
| @@ -254,15 +269,15 @@ This definition is the heart of the calendar!") | |||
| 254 | (1+ (- d2 d1))))) | 269 | (1+ (- d2 d1))))) |
| 255 | 270 | ||
| 256 | (defun cal-tex-preamble (&optional args) | 271 | (defun cal-tex-preamble (&optional args) |
| 257 | "Insert the LaTeX calendar preamble. | 272 | "Insert the LaTeX calendar preamble into `cal-tex-buffer'. |
| 258 | Preamble includes initial definitions for various LaTeX commands. | 273 | Preamble includes initial definitions for various LaTeX commands. |
| 259 | Optional ARGS are included as article document class options." | 274 | Optional string ARGS are included as options for the article document class." |
| 275 | ;; FIXME use generate-new-buffer, and adjust cal-tex-end-document. | ||
| 260 | (set-buffer (get-buffer-create cal-tex-buffer)) | 276 | (set-buffer (get-buffer-create cal-tex-buffer)) |
| 261 | (erase-buffer) | 277 | (insert (format "\\documentclass%s{article}\n" |
| 262 | (insert "\\documentclass") | 278 | (if (stringp args) |
| 263 | (if args | 279 | (format "[%s]" args) |
| 264 | (insert "[" args "]")) | 280 | ""))) |
| 265 | (insert "{article}\n") | ||
| 266 | (if (stringp cal-tex-preamble-extra) | 281 | (if (stringp cal-tex-preamble-extra) |
| 267 | (insert cal-tex-preamble-extra "\n")) | 282 | (insert cal-tex-preamble-extra "\n")) |
| 268 | (insert "\\hbadness 20000 | 283 | (insert "\\hbadness 20000 |
| @@ -308,9 +323,9 @@ Optional prefix argument ARG specifies number of years." | |||
| 308 | 323 | ||
| 309 | (defun cal-tex-year (year n &optional landscape) | 324 | (defun cal-tex-year (year n &optional landscape) |
| 310 | "Make a one page yearly calendar of YEAR; do this for N years. | 325 | "Make a one page yearly calendar of YEAR; do this for N years. |
| 311 | There are four rows of three months each, unless optional LANDSCAPE is t, | 326 | There are four rows of three months each, unless optional |
| 312 | in which case the calendar is printed in landscape mode with three rows of | 327 | LANDSCAPE is non-nil, in which case the calendar is printed in |
| 313 | four months each." | 328 | landscape mode with three rows of four months each." |
| 314 | (cal-tex-insert-preamble 1 landscape "12pt") | 329 | (cal-tex-insert-preamble 1 landscape "12pt") |
| 315 | (if landscape | 330 | (if landscape |
| 316 | (cal-tex-vspace "-.6cm") | 331 | (cal-tex-vspace "-.6cm") |
| @@ -360,7 +375,7 @@ Optional prefix argument ARG specifies number of years." | |||
| 360 | (cal-tex-b-document) | 375 | (cal-tex-b-document) |
| 361 | (cal-tex-cmd "\\vspace*{0.25in}") | 376 | (cal-tex-cmd "\\vspace*{0.25in}") |
| 362 | (dotimes (j n) | 377 | (dotimes (j n) |
| 363 | (insert (format "\\hfil {\\Large \\bf %s} \\hfil\\\\\n" year)) | 378 | (insert (format "\\hfil \\textbf{\\Large %s} \\hfil\\\\\n" year)) |
| 364 | (cal-tex-b-center) | 379 | (cal-tex-b-center) |
| 365 | (cal-tex-b-parbox "l" "\\textwidth") | 380 | (cal-tex-b-parbox "l" "\\textwidth") |
| 366 | (insert "\n") | 381 | (insert "\n") |
| @@ -640,18 +655,19 @@ this is only an upper bound." | |||
| 640 | ;;; Weekly calendars | 655 | ;;; Weekly calendars |
| 641 | ;;; | 656 | ;;; |
| 642 | 657 | ||
| 643 | (defvar cal-tex-LaTeX-hourbox | 658 | (defconst cal-tex-LaTeX-hourbox |
| 644 | "\\newcommand{\\hourbox}[2]% | 659 | "\\newcommand{\\hourbox}[2]% |
| 645 | {\\makebox[2em]{\\rule{0cm}{#2ex}#1}\\rule{3in}{.15mm}}\n" | 660 | {\\makebox[2em]{\\rule{0cm}{#2ex}#1}\\rule{3in}{.15mm}}\n" |
| 646 | "One hour and a line on the right.") | 661 | "One hour and a line on the right.") |
| 647 | 662 | ||
| 648 | ;; TODO cal-tex-diary-support. | 663 | ;; TODO cal-tex-diary-support. |
| 664 | ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours). | ||
| 649 | (defun cal-tex-cursor-week (&optional arg) | 665 | (defun cal-tex-cursor-week (&optional arg) |
| 650 | "Make a LaTeX calendar buffer for a two-page one-week calendar. | 666 | "Make a LaTeX calendar buffer for a two-page one-week calendar. |
| 651 | It applies to the week that point is in. The optional prefix | 667 | It applies to the week that point is in. The optional prefix |
| 652 | argument ARG specifies the number of weeks (default 1). The calendar | 668 | argument ARG specifies the number of weeks (default 1). The calendar |
| 653 | shows holidays if `cal-tex-holidays' is t (note that diary | 669 | shows holidays if `cal-tex-holidays' is non-nil (note that diary |
| 654 | entries are not shown)." | 670 | entries are not shown). The calendar shows the hours 8-12am, 1-5pm." |
| 655 | (interactive "p") | 671 | (interactive "p") |
| 656 | (let* ((n (or arg 1)) | 672 | (let* ((n (or arg 1)) |
| 657 | (date (calendar-gregorian-from-absolute | 673 | (date (calendar-gregorian-from-absolute |
| @@ -697,12 +713,13 @@ entries are not shown)." | |||
| 697 | (run-hooks 'cal-tex-hook))) | 713 | (run-hooks 'cal-tex-hook))) |
| 698 | 714 | ||
| 699 | ;; TODO cal-tex-diary support. | 715 | ;; TODO cal-tex-diary support. |
| 716 | ;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours). | ||
| 700 | (defun cal-tex-cursor-week2 (&optional arg) | 717 | (defun cal-tex-cursor-week2 (&optional arg) |
| 701 | "Make a LaTeX calendar buffer for a two-page one-week calendar. | 718 | "Make a LaTeX calendar buffer for a two-page one-week calendar. |
| 702 | It applies to the week that point is in. Optional prefix | 719 | It applies to the week that point is in. Optional prefix |
| 703 | argument ARG specifies number of weeks (default 1). The calendar | 720 | argument ARG specifies number of weeks (default 1). The calendar |
| 704 | shows holidays if `cal-tex-holidays' is non-nil (note that diary | 721 | shows holidays if `cal-tex-holidays' is non-nil (note that diary |
| 705 | entries are not shown)." | 722 | entries are not shown). The calendar shows the hours 8-12am, 1-5pm" |
| 706 | (interactive "p") | 723 | (interactive "p") |
| 707 | (let* ((n (or arg 1)) | 724 | (let* ((n (or arg 1)) |
| 708 | (date (calendar-gregorian-from-absolute | 725 | (date (calendar-gregorian-from-absolute |
| @@ -780,7 +797,8 @@ entries are not shown)." | |||
| 780 | "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar. | 797 | "Make a LaTeX calendar buffer for a one page ISO-style weekly calendar. |
| 781 | Optional prefix argument ARG specifies number of weeks (default 1). | 798 | Optional prefix argument ARG specifies number of weeks (default 1). |
| 782 | The calendar shows holiday and diary entries if | 799 | The calendar shows holiday and diary entries if |
| 783 | `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil." | 800 | `cal-tex-holidays' and `cal-tex-diary', respectively, are non-nil. |
| 801 | It does not show hours of the day." | ||
| 784 | (interactive "p") | 802 | (interactive "p") |
| 785 | (let* ((n (or arg 1)) | 803 | (let* ((n (or arg 1)) |
| 786 | (date (calendar-gregorian-from-absolute | 804 | (date (calendar-gregorian-from-absolute |
| @@ -863,9 +881,12 @@ The calendar shows holiday and diary entries if | |||
| 863 | (cal-tex-end-document) | 881 | (cal-tex-end-document) |
| 864 | (run-hooks 'cal-tex-hook))) | 882 | (run-hooks 'cal-tex-hook))) |
| 865 | 883 | ||
| 884 | ;; TODO respect cal-tex-daily-start,end? | ||
| 885 | ;; Using different numbers of hours will probably break some layouts. | ||
| 866 | (defun cal-tex-week-hours (date holidays height) | 886 | (defun cal-tex-week-hours (date holidays height) |
| 867 | "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT. | 887 | "Insert hourly entries for DATE with HOLIDAYS, with line height HEIGHT. |
| 868 | Uses the 24-hour clock if `cal-tex-24' is non-nil." | 888 | Uses the 24-hour clock if `cal-tex-24' is non-nil. Note that the hours |
| 889 | shown are hard-coded to 8-12, 13-17." | ||
| 869 | (let ((month (extract-calendar-month date)) | 890 | (let ((month (extract-calendar-month date)) |
| 870 | (day (extract-calendar-day date)) | 891 | (day (extract-calendar-day date)) |
| 871 | (year (extract-calendar-year date)) | 892 | (year (extract-calendar-year date)) |
| @@ -902,12 +923,14 @@ Uses the 24-hour clock if `cal-tex-24' is non-nil." | |||
| 902 | (cal-tex-nl)))) | 923 | (cal-tex-nl)))) |
| 903 | 924 | ||
| 904 | ;; TODO cal-tex-diary support. | 925 | ;; TODO cal-tex-diary support. |
| 926 | ;; TODO respect cal-tex-daily-start,end (see cal-tex-weekly4-box). | ||
| 905 | (defun cal-tex-cursor-week-monday (&optional arg) | 927 | (defun cal-tex-cursor-week-monday (&optional arg) |
| 906 | "Make a LaTeX calendar buffer for a two-page one-week calendar. | 928 | "Make a LaTeX calendar buffer for a two-page one-week calendar. |
| 907 | It applies to the week that point is in, and starts on Monday. | 929 | It applies to the week that point is in, and starts on Monday. |
| 908 | Optional prefix argument ARG specifies number of weeks (default 1). | 930 | Optional prefix argument ARG specifies number of weeks (default 1). |
| 909 | The calendar shows holidays if `cal-tex-holidays' is | 931 | The calendar shows holidays if `cal-tex-holidays' is |
| 910 | non-nil (note that diary entries are not shown)." | 932 | non-nil (note that diary entries are not shown). The calendar shows |
| 933 | the hours 8-12am, 1-5pm." | ||
| 911 | (interactive "p") | 934 | (interactive "p") |
| 912 | (let ((n (or arg 1)) | 935 | (let ((n (or arg 1)) |
| 913 | (date (calendar-gregorian-from-absolute | 936 | (date (calendar-gregorian-from-absolute |
| @@ -939,9 +962,12 @@ non-nil (note that diary entries are not shown)." | |||
| 939 | (cal-tex-end-document) | 962 | (cal-tex-end-document) |
| 940 | (run-hooks 'cal-tex-hook))) | 963 | (run-hooks 'cal-tex-hook))) |
| 941 | 964 | ||
| 965 | ;; TODO respect cal-tex-daily-start,end? | ||
| 966 | ;; Using different numbers of hours will probably break some layouts. | ||
| 942 | (defun cal-tex-weekly4-box (date weekend) | 967 | (defun cal-tex-weekly4-box (date weekend) |
| 943 | "Make one box for DATE, different if WEEKEND. | 968 | "Make one box for DATE, different if WEEKEND. |
| 944 | Uses the 24-hour clock if `cal-tex-24' is non-nil." | 969 | Uses the 24-hour clock if `cal-tex-24' is non-nil. Note that the hours |
| 970 | shown are hard-coded to 8-12, 13-17." | ||
| 945 | (let* ((day (extract-calendar-day date)) | 971 | (let* ((day (extract-calendar-day date)) |
| 946 | (month (extract-calendar-month date)) | 972 | (month (extract-calendar-month date)) |
| 947 | (year (extract-calendar-year date)) | 973 | (year (extract-calendar-year date)) |
| @@ -953,14 +979,15 @@ Uses the 24-hour clock if `cal-tex-24' is non-nil." | |||
| 953 | (dayname1 (cal-tex-LaTeXify-string (calendar-day-name date1)))) | 979 | (dayname1 (cal-tex-LaTeXify-string (calendar-day-name date1)))) |
| 954 | (cal-tex-b-framebox "8cm" "l") | 980 | (cal-tex-b-framebox "8cm" "l") |
| 955 | (cal-tex-b-parbox "b" "7.5cm") | 981 | (cal-tex-b-parbox "b" "7.5cm") |
| 956 | (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" dayname month day year)) | 982 | (insert (format "\\textbf{\\Large %s,} %s/%s/%s\\\\\n" |
| 983 | dayname month day year)) | ||
| 957 | (cal-tex-rule "0pt" "7.5cm" ".5mm") | 984 | (cal-tex-rule "0pt" "7.5cm" ".5mm") |
| 958 | (cal-tex-nl) | 985 | (cal-tex-nl) |
| 959 | (unless weekend | 986 | (unless weekend |
| 960 | (dotimes (i 5) | 987 | (dotimes (i 5) |
| 961 | (insert (format "{\\large\\sf %d}\\\\\n" (+ i 8)))) | 988 | (insert (format "\\textsf{\\large %d}\\\\\n" (+ i 8)))) |
| 962 | (dotimes (i 5) | 989 | (dotimes (i 5) |
| 963 | (insert (format "{\\large\\sf %d}\\\\\n" | 990 | (insert (format "\\textsf{\\large %d}\\\\\n" |
| 964 | (if cal-tex-24 | 991 | (if cal-tex-24 |
| 965 | (+ i 13) ; 13-17 incl | 992 | (+ i 13) ; 13-17 incl |
| 966 | (1+ i)))))) ; 1-5 incl | 993 | (1+ i)))))) ; 1-5 incl |
| @@ -968,7 +995,7 @@ Uses the 24-hour clock if `cal-tex-24' is non-nil." | |||
| 968 | (when weekend | 995 | (when weekend |
| 969 | (cal-tex-vspace "1cm") | 996 | (cal-tex-vspace "1cm") |
| 970 | (insert "\\ \\vfill") | 997 | (insert "\\ \\vfill") |
| 971 | (insert (format "{\\Large\\bf %s,} %s/%s/%s\\\\\n" | 998 | (insert (format "\\textbf{\\Large %s,} %s/%s/%s\\\\\n" |
| 972 | dayname1 month1 day1 year1)) | 999 | dayname1 month1 day1 year1)) |
| 973 | (cal-tex-rule "0pt" "7.5cm" ".5mm") | 1000 | (cal-tex-rule "0pt" "7.5cm" ".5mm") |
| 974 | (cal-tex-nl "1.5cm") | 1001 | (cal-tex-nl "1.5cm") |
| @@ -1325,12 +1352,14 @@ are non-nil. Pages are ruled if `cal-tex-rules' is non-nil." | |||
| 1325 | 1352 | ||
| 1326 | (defun cal-tex-cursor-day (&optional arg) | 1353 | (defun cal-tex-cursor-day (&optional arg) |
| 1327 | "Make a buffer with LaTeX commands for the day cursor is on. | 1354 | "Make a buffer with LaTeX commands for the day cursor is on. |
| 1328 | Optional prefix argument ARG specifies number of days." | 1355 | Optional prefix argument ARG specifies number of days. The calendar shows |
| 1356 | the hours between `cal-tex-daily-start' and `cal-tex-daily-end', using | ||
| 1357 | the 24-hour clock if `cal-tex-24' is non-nil." | ||
| 1329 | (interactive "p") | 1358 | (interactive "p") |
| 1330 | (let ((n (or arg 1)) | 1359 | (let ((n (or arg 1)) |
| 1331 | (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t)))) | 1360 | (date (calendar-absolute-from-gregorian (calendar-cursor-to-date t)))) |
| 1332 | (cal-tex-preamble "12pt") | 1361 | (cal-tex-preamble "12pt") |
| 1333 | (cal-tex-cmd "\\textwidth 6.5in") | 1362 | (cal-tex-cmd "\\textwidth 6.5in") |
| 1334 | (cal-tex-cmd "\\textheight 10.5in") | 1363 | (cal-tex-cmd "\\textheight 10.5in") |
| 1335 | (cal-tex-b-document) | 1364 | (cal-tex-b-document) |
| 1336 | (cal-tex-cmd "\\pagestyle{empty}") | 1365 | (cal-tex-cmd "\\pagestyle{empty}") |
| @@ -1441,7 +1470,7 @@ Optional string COLSEP gives the column separation (default \"1mm\")." | |||
| 1441 | " " | 1470 | " " |
| 1442 | (int-to-string year) | 1471 | (int-to-string year) |
| 1443 | "}\\\\[1mm]\n"))) | 1472 | "}\\\\[1mm]\n"))) |
| 1444 | (dotimes (i 6) | 1473 | (dotimes (i 7) |
| 1445 | (setq str | 1474 | (setq str |
| 1446 | (concat str | 1475 | (concat str |
| 1447 | (cal-tex-LaTeXify-string | 1476 | (cal-tex-LaTeXify-string |
| @@ -1457,8 +1486,9 @@ Optional string COLSEP gives the column separation (default \"1mm\")." | |||
| 1457 | (dotimes (i last) | 1486 | (dotimes (i last) |
| 1458 | (setq str (concat str (int-to-string (1+ i))) | 1487 | (setq str (concat str (int-to-string (1+ i))) |
| 1459 | str (concat str (if (zerop (mod (+ i 1 blank-days) 7)) | 1488 | str (concat str (if (zerop (mod (+ i 1 blank-days) 7)) |
| 1460 | (unless (= i (1- last)) | 1489 | (if (= i (1- last)) |
| 1461 | "\\\\[0.5mm]\n" "") | 1490 | "" |
| 1491 | "\\\\[0.5mm]\n") | ||
| 1462 | " & ")))) | 1492 | " & ")))) |
| 1463 | (setq str (concat str "\n\\end{tabular}\\hfil}\\vfil}}}%\n")) | 1493 | (setq str (concat str "\n\\end{tabular}\\hfil}\\vfil}}}%\n")) |
| 1464 | str)) | 1494 | str)) |
| @@ -1477,16 +1507,16 @@ If optional N is given, the date of N days after DATE." | |||
| 1477 | "Return string with concatenated, LaTeX-ified entries in DATE-LIST for DATE. | 1507 | "Return string with concatenated, LaTeX-ified entries in DATE-LIST for DATE. |
| 1478 | Use double backslash as a separator unless optional SEPARATOR is given. | 1508 | Use double backslash as a separator unless optional SEPARATOR is given. |
| 1479 | If resulting string is not empty, put separator at end if optional | 1509 | If resulting string is not empty, put separator at end if optional |
| 1480 | FINAL-SEPARATOR is t." | 1510 | FINAL-SEPARATOR is non-nil." |
| 1481 | (or separator (setq separator "\\\\")) | 1511 | (or separator (setq separator "\\\\")) |
| 1482 | (let ((result | 1512 | (let (result) |
| 1483 | (mapconcat (lambda (x) (cal-tex-LaTeXify-string x)) | 1513 | (setq result |
| 1484 | (let (result) | 1514 | (mapconcat (lambda (x) (cal-tex-LaTeXify-string x)) |
| 1485 | (dolist (d date-list (reverse result)) | 1515 | (dolist (d date-list (reverse result)) |
| 1486 | (and (car d) | 1516 | (and (car d) |
| 1487 | (calendar-date-equal date (car d)) | 1517 | (calendar-date-equal date (car d)) |
| 1488 | (setq result (cons (cadr d) result))))) | 1518 | (setq result (cons (cadr d) result)))) |
| 1489 | separator))) | 1519 | separator)) |
| 1490 | (if (and final-separator | 1520 | (if (and final-separator |
| 1491 | (not (string-equal result ""))) | 1521 | (not (string-equal result ""))) |
| 1492 | (concat result separator) | 1522 | (concat result separator) |
| @@ -1518,18 +1548,19 @@ informative header, and run HOOK." | |||
| 1518 | (latex-mode) | 1548 | (latex-mode) |
| 1519 | (pop-to-buffer cal-tex-buffer) | 1549 | (pop-to-buffer cal-tex-buffer) |
| 1520 | (goto-char (point-min)) | 1550 | (goto-char (point-min)) |
| 1521 | (cal-tex-comment " This buffer was produced by cal-tex.el.") | 1551 | ;; FIXME auctex equivalents? |
| 1522 | (cal-tex-comment " To print a calendar, type") | 1552 | (cal-tex-comment |
| 1523 | (cal-tex-comment " M-x tex-buffer RET") | 1553 | (format "\tThis buffer was produced by cal-tex.el. |
| 1524 | (cal-tex-comment " M-x tex-print RET") | 1554 | \tTo print a calendar, type |
| 1525 | (goto-char (point-min))) | 1555 | \t\tM-x tex-buffer RET |
| 1556 | \t\tM-x tex-print RET"))) | ||
| 1526 | 1557 | ||
| 1527 | (defun cal-tex-insert-preamble (weeks landscape size &optional append) | 1558 | (defun cal-tex-insert-preamble (weeks landscape size &optional append) |
| 1528 | "Initialize the output buffer. | 1559 | "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'. |
| 1529 | Select the output buffer, and insert the preamble for a calendar of | 1560 | Select the output buffer, and insert the preamble for a calendar |
| 1530 | WEEKS weeks. Insert code for landscape mode if LANDSCAPE is true. | 1561 | of WEEKS weeks. Insert code for landscape mode if LANDSCAPE is |
| 1531 | Use pointsize SIZE. Optional argument APPEND, if t, means add to end of | 1562 | non-nil. Use pointsize SIZE. Optional argument APPEND, if |
| 1532 | without erasing current contents." | 1563 | non-nil, means add to end of buffer without erasing current contents." |
| 1533 | (let ((width "18cm") | 1564 | (let ((width "18cm") |
| 1534 | (height "24cm")) | 1565 | (height "24cm")) |
| 1535 | (when landscape | 1566 | (when landscape |
| @@ -1542,12 +1573,12 @@ without erasing current contents." | |||
| 1542 | (cal-tex-cmd "\\oddsidemargin -1.75cm") | 1573 | (cal-tex-cmd "\\oddsidemargin -1.75cm") |
| 1543 | (cal-tex-cmd "\\def\\holidaymult{.06}")) | 1574 | (cal-tex-cmd "\\def\\holidaymult{.06}")) |
| 1544 | (cal-tex-cmd "\\special{landscape}") | 1575 | (cal-tex-cmd "\\special{landscape}") |
| 1545 | (cal-tex-cmd "\\textwidth 9.5in") | 1576 | (cal-tex-cmd "\\textwidth 9.5in") |
| 1546 | (cal-tex-cmd "\\textheight 7in") | 1577 | (cal-tex-cmd "\\textheight 7in") |
| 1547 | (cal-tex-comment) | 1578 | (cal-tex-comment) |
| 1548 | (cal-tex-cmd "\\def\\holidaymult{.08}")) | 1579 | (cal-tex-cmd "\\def\\holidaymult{.08}")) |
| 1549 | (cal-tex-cmd cal-tex-caldate) | 1580 | (cal-tex-cmd cal-tex-caldate) |
| 1550 | (cal-tex-cmd cal-tex-myday) | 1581 | (cal-tex-cmd cal-tex-myday) |
| 1551 | (cal-tex-b-document) | 1582 | (cal-tex-b-document) |
| 1552 | (cal-tex-cmd "\\pagestyle{empty}")) | 1583 | (cal-tex-cmd "\\pagestyle{empty}")) |
| 1553 | (cal-tex-cmd "\\setlength{\\cellwidth}" width) | 1584 | (cal-tex-cmd "\\setlength{\\cellwidth}" width) |
| @@ -1559,7 +1590,7 @@ without erasing current contents." | |||
| 1559 | (cal-tex-cmd "\\ \\par") | 1590 | (cal-tex-cmd "\\ \\par") |
| 1560 | (cal-tex-vspace "-3cm"))) | 1591 | (cal-tex-vspace "-3cm"))) |
| 1561 | 1592 | ||
| 1562 | (defvar cal-tex-LaTeX-subst-list | 1593 | (defconst cal-tex-LaTeX-subst-list |
| 1563 | '(("\"". "``") | 1594 | '(("\"". "``") |
| 1564 | ("\"". "''") ; quote changes meaning when list is reversed | 1595 | ("\"". "''") ; quote changes meaning when list is reversed |
| 1565 | ;; Don't think this is necessary, and in any case, does not work: | 1596 | ;; Don't think this is necessary, and in any case, does not work: |
| @@ -1575,7 +1606,7 @@ without erasing current contents." | |||
| 1575 | ("<" . "$<$") | 1606 | ("<" . "$<$") |
| 1576 | (">" . "$>$") | 1607 | (">" . "$>$") |
| 1577 | ("\n" . "\\ \\\\")) ; \\ needed for e.g \begin{center}\n AA\end{center} | 1608 | ("\n" . "\\ \\\\")) ; \\ needed for e.g \begin{center}\n AA\end{center} |
| 1578 | "List of symbols and their LaTeX replacements.") | 1609 | "Alist of symbols and their LaTeX replacements.") |
| 1579 | 1610 | ||
| 1580 | (defun cal-tex-LaTeXify-string (string) | 1611 | (defun cal-tex-LaTeXify-string (string) |
| 1581 | "Protect special characters in STRING from LaTeX." | 1612 | "Protect special characters in STRING from LaTeX." |
| @@ -1585,11 +1616,11 @@ without erasing current contents." | |||
| 1585 | (tail string) | 1616 | (tail string) |
| 1586 | (list cal-tex-LaTeX-subst-list)) | 1617 | (list cal-tex-LaTeX-subst-list)) |
| 1587 | (while (not (string-equal tail "")) | 1618 | (while (not (string-equal tail "")) |
| 1588 | (let* ((ch (substring tail 0 1)) | 1619 | (let* ((ch (substring-no-properties tail 0 1)) |
| 1589 | (pair (assoc ch list))) | 1620 | (pair (assoc ch list))) |
| 1590 | (if (and pair (string-equal ch "\"")) | 1621 | (if (and pair (string-equal ch "\"")) |
| 1591 | (setq list (reverse list))) ; quote changes meaning each time | 1622 | (setq list (reverse list))) ; quote changes meaning each time |
| 1592 | (setq tail (substring tail 1) | 1623 | (setq tail (substring-no-properties tail 1) |
| 1593 | head (concat head (if pair (cdr pair) ch))))) | 1624 | head (concat head (if pair (cdr pair) ch))))) |
| 1594 | head))) | 1625 | head))) |
| 1595 | 1626 | ||
| @@ -1620,33 +1651,29 @@ without erasing current contents." | |||
| 1620 | (cal-tex-comment)) | 1651 | (cal-tex-comment)) |
| 1621 | 1652 | ||
| 1622 | (defun cal-tex-comment (&optional comment) | 1653 | (defun cal-tex-comment (&optional comment) |
| 1623 | "Insert % at end of line, include COMMENT if present, and move to next line." | 1654 | "Insert `% ', followed by optional string COMMENT, followed by newline. |
| 1624 | (insert "% ") | 1655 | COMMENT may contain newlines, which are prefixed by `% ' in the output." |
| 1625 | (if comment | 1656 | (insert (format "%% %s\n" |
| 1626 | (insert comment)) | 1657 | (if comment |
| 1627 | (insert "\n")) | 1658 | (replace-regexp-in-string "\n" "\n% " comment) |
| 1659 | "")))) | ||
| 1628 | 1660 | ||
| 1629 | (defun cal-tex-banner (comment) | 1661 | (defun cal-tex-banner (comment) |
| 1630 | "Insert the COMMENT separated by blank lines." | 1662 | "Insert string COMMENT, separated by blank lines." |
| 1631 | (cal-tex-comment) | 1663 | (cal-tex-comment (format "\n\n\n\t\t\t%s\n" comment))) |
| 1632 | (cal-tex-comment) | ||
| 1633 | (cal-tex-comment (concat "\t\t\t" comment)) | ||
| 1634 | (cal-tex-comment)) | ||
| 1635 | |||
| 1636 | 1664 | ||
| 1637 | (defun cal-tex-nl (&optional skip comment) | 1665 | (defun cal-tex-nl (&optional skip comment) |
| 1638 | "End a line with \\. If SKIP, then add that much spacing. | 1666 | "End a line with \\. If SKIP, then add that much spacing. |
| 1639 | Add COMMENT if present." | 1667 | Add trailing COMMENT if present." |
| 1640 | (insert "\\\\") | 1668 | (insert (format "\\\\%s" |
| 1641 | (if skip | 1669 | (if skip |
| 1642 | (insert "[" skip "]")) | 1670 | (format "[%s]" skip) |
| 1671 | ""))) | ||
| 1643 | (cal-tex-comment comment)) | 1672 | (cal-tex-comment comment)) |
| 1644 | 1673 | ||
| 1645 | (defun cal-tex-arg (&optional text) | 1674 | (defun cal-tex-arg (&optional text) |
| 1646 | "Insert optional TEXT surrounded by braces." | 1675 | "Insert a brace {} pair containing the optional string TEXT." |
| 1647 | (insert "{") | 1676 | (insert (format "{%s}" (or text "")))) |
| 1648 | (if text (insert text)) | ||
| 1649 | (insert "}")) | ||
| 1650 | 1677 | ||
| 1651 | (defun cal-tex-cmd (cmd &optional arg) | 1678 | (defun cal-tex-cmd (cmd &optional arg) |
| 1652 | "Insert LaTeX CMD, with optional argument ARG, and end with %." | 1679 | "Insert LaTeX CMD, with optional argument ARG, and end with %." |
| @@ -1739,25 +1766,26 @@ Add COMMENT if present." | |||
| 1739 | (insert "{\\scriptsize " string "}")) | 1766 | (insert "{\\scriptsize " string "}")) |
| 1740 | 1767 | ||
| 1741 | (defun cal-tex-huge (string) | 1768 | (defun cal-tex-huge (string) |
| 1742 | "Insert STRING in huge size." | 1769 | "Insert STRING in huge font." |
| 1743 | (insert "{\\huge " string "}")) | 1770 | (insert "{\\huge " string "}")) |
| 1744 | 1771 | ||
| 1745 | (defun cal-tex-Huge (string) | 1772 | (defun cal-tex-Huge (string) |
| 1746 | "Insert STRING in Huge size." | 1773 | "Insert STRING in Huge font." |
| 1747 | (insert "{\\Huge " string "}")) | 1774 | (insert "{\\Huge " string "}")) |
| 1748 | 1775 | ||
| 1749 | (defun cal-tex-Huge-bf (string) | 1776 | (defun cal-tex-Huge-bf (string) |
| 1750 | "Insert STRING in Huge bf size." | 1777 | "Insert STRING in Huge bf font." |
| 1751 | (insert "\\textbf{\\Huge " string "}")) | 1778 | (insert "\\textbf{\\Huge " string "}")) |
| 1752 | 1779 | ||
| 1753 | (defun cal-tex-large (string) | 1780 | (defun cal-tex-large (string) |
| 1754 | "Insert STRING in large size." | 1781 | "Insert STRING in large font." |
| 1755 | (insert "{\\large " string "}")) | 1782 | (insert "{\\large " string "}")) |
| 1756 | 1783 | ||
| 1757 | (defun cal-tex-large-bf (string) | 1784 | (defun cal-tex-large-bf (string) |
| 1758 | "Insert STRING in large bf size." | 1785 | "Insert STRING in large bf font." |
| 1759 | (insert "\\textbf{\\large " string "}")) | 1786 | (insert "\\textbf{\\large " string "}")) |
| 1760 | 1787 | ||
| 1788 | |||
| 1761 | (provide 'cal-tex) | 1789 | (provide 'cal-tex) |
| 1762 | 1790 | ||
| 1763 | ;;; arch-tag: ca8168a4-5a00-4508-a565-17e3bccce6d0 | 1791 | ;;; arch-tag: ca8168a4-5a00-4508-a565-17e3bccce6d0 |