summaryrefslogtreecommitdiff
path: root/lisp/calendar/cal-tex.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2012-08-20 22:29:25 -0400
committerGlenn Morris <rgm@gnu.org>2012-08-20 22:29:25 -0400
commitc68cd5d433e1bbb4478dca51ef5c7ec53259e77e (patch)
tree43ee1bdb6cce65364ab7313fd2eb0b2cc2ba6922 /lisp/calendar/cal-tex.el
parent9dca480127a5642b94b2736b855099cf302c90d4 (diff)
downloademacs-c68cd5d433e1bbb4478dca51ef5c7ec53259e77e.tar.gz
Reduce some cal-tex code duplication
* lisp/calendar/cal-tex.el (cal-tex-filofax-paper): New function. (cal-tex-cursor-filofax-year, cal-tex-cursor-filofax-2week) (cal-tex-cursor-filofax-week, cal-tex-cursor-filofax-daily): Use it. (cal-tex-weekly-paper): New function. (cal-tex-cursor-week, cal-tex-cursor-week2) (cal-tex-cursor-week-iso, cal-tex-cursor-week-monday) (cal-tex-cursor-day): Use it.
Diffstat (limited to 'lisp/calendar/cal-tex.el')
-rw-r--r--lisp/calendar/cal-tex.el85
1 files changed, 37 insertions, 48 deletions
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 8868c2495f9..fc813040537 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -344,6 +344,25 @@ landscape mode with three rows of four months each."
(run-hooks 'cal-tex-year-hook))
(run-hooks 'cal-tex-hook))
+
+(defun cal-tex-filofax-paper (&optional year)
+ "Insert some page size settings for filofax layouts."
+ (insert "\\textwidth 3.25in
+\\textheight 6.5in
+\\headheight -0.875in
+\\topmargin 0pt
+")
+ (insert
+ ;; Why is this one subtly different? Who knows...
+ (if year "\\oddsidemargin 1.675in
+\\evensidemargin 1.675in
+"
+ "\\oddsidemargin 1.75in
+\\evensidemargin 1.5in
+\\headsep 0.125in
+\\footskip 0.125in
+")))
+
;;;###cal-autoload
(defun cal-tex-cursor-filofax-year (&optional n event)
"Make a Filofax one page yearly calendar of year indicated by cursor.
@@ -354,12 +373,7 @@ Optional EVENT indicates a buffer position to use instead of point."
(or n (setq n 1))
(let ((year (calendar-extract-year (calendar-cursor-to-date t event))))
(cal-tex-preamble "twoside")
- (cal-tex-cmd "\\textwidth 3.25in")
- (cal-tex-cmd "\\textheight 6.5in")
- (cal-tex-cmd "\\oddsidemargin 1.675in")
- (cal-tex-cmd "\\evensidemargin 1.675in")
- (cal-tex-cmd "\\topmargin 0pt")
- (cal-tex-cmd "\\headheight -0.875in")
+ (cal-tex-filofax-paper 'year)
(cal-tex-cmd "\\fboxsep 0.5mm")
(cal-tex-cmd "\\pagestyle{empty}")
(cal-tex-b-document)
@@ -653,6 +667,15 @@ this is only an upper bound."
{\\makebox[2em]{\\rule{0cm}{#2ex}#1}\\rule{3in}{.15mm}}\n"
"One hour and a line on the right.")
+(defun cal-tex-weekly-paper (&optional nomargins)
+ "Insert some page size settings for weekly layouts."
+ (insert "\\textwidth 6.5in
+\\textheight 10.5in
+")
+ (or nomargins (insert "\\oddsidemargin 0in
+\\evensidemargin 0in
+")))
+
;; TODO cal-tex-diary-support.
;; TODO respect cal-tex-daily-start,end (see cal-tex-week-hours).
;;;###cal-autoload
@@ -677,10 +700,7 @@ entries are not shown). The calendar shows the hours 8-12am, 1-5pm."
(holidays (if cal-tex-holidays
(holiday-in-range d1 d2))))
(cal-tex-preamble "11pt")
- (cal-tex-cmd "\\textwidth 6.5in")
- (cal-tex-cmd "\\textheight 10.5in")
- (cal-tex-cmd "\\oddsidemargin 0in")
- (cal-tex-cmd "\\evensidemargin 0in")
+ (cal-tex-weekly-paper)
(insert cal-tex-LaTeX-hourbox)
(cal-tex-b-document)
(cal-tex-cmd "\\pagestyle{empty}")
@@ -732,10 +752,7 @@ Optional EVENT indicates a buffer position to use instead of point."
(holidays (if cal-tex-holidays
(holiday-in-range d1 d2))))
(cal-tex-preamble "12pt")
- (cal-tex-cmd "\\textwidth 6.5in")
- (cal-tex-cmd "\\textheight 10.5in")
- (cal-tex-cmd "\\oddsidemargin 0in")
- (cal-tex-cmd "\\evensidemargin 0in")
+ (cal-tex-weekly-paper)
(insert cal-tex-LaTeX-hourbox)
(cal-tex-b-document)
(cal-tex-cmd "\\pagestyle{empty}")
@@ -819,10 +836,7 @@ position to use instead of point."
(cal-tex-list-diary-entries d1 d2)))
s)
(cal-tex-preamble "11pt")
- (cal-tex-cmd "\\textwidth 6.5in")
- (cal-tex-cmd "\\textheight 10.5in")
- (cal-tex-cmd "\\oddsidemargin 0in")
- (cal-tex-cmd "\\evensidemargin 0in")
+ (cal-tex-weekly-paper)
(cal-tex-b-document)
(cal-tex-cmd "\\pagestyle{empty}")
(dotimes (i n)
@@ -941,10 +955,7 @@ to use instead of point."
(calendar-absolute-from-gregorian
(calendar-cursor-to-date t event))))))
(cal-tex-preamble "11pt")
- (cal-tex-cmd "\\textwidth 6.5in")
- (cal-tex-cmd "\\textheight 10.5in")
- (cal-tex-cmd "\\oddsidemargin 0in")
- (cal-tex-cmd "\\evensidemargin 0in")
+ (cal-tex-weekly-paper)
(cal-tex-b-document)
(dotimes (i n)
(cal-tex-vspace "-1cm")
@@ -1192,14 +1203,7 @@ Optional EVENT indicates a buffer position to use instead of point."
(diary-list (if cal-tex-diary
(cal-tex-list-diary-entries d1 d2))))
(cal-tex-preamble "twoside")
- (cal-tex-cmd "\\textwidth 3.25in")
- (cal-tex-cmd "\\textheight 6.5in")
- (cal-tex-cmd "\\oddsidemargin 1.75in")
- (cal-tex-cmd "\\evensidemargin 1.5in")
- (cal-tex-cmd "\\topmargin 0pt")
- (cal-tex-cmd "\\headheight -0.875in")
- (cal-tex-cmd "\\headsep 0.125in")
- (cal-tex-cmd "\\footskip .125in")
+ (cal-tex-filofax-paper)
(insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
\\long\\def\\rightday#1#2#3#4#5{%
\\rule{\\textwidth}{0.3pt}\\\\%
@@ -1286,14 +1290,7 @@ Optional EVENT indicates a buffer position to use instead of point."
(diary-list (if cal-tex-diary
(cal-tex-list-diary-entries d1 d2))))
(cal-tex-preamble "twoside")
- (cal-tex-cmd "\\textwidth 3.25in")
- (cal-tex-cmd "\\textheight 6.5in")
- (cal-tex-cmd "\\oddsidemargin 1.75in")
- (cal-tex-cmd "\\evensidemargin 1.5in")
- (cal-tex-cmd "\\topmargin 0pt")
- (cal-tex-cmd "\\headheight -0.875in")
- (cal-tex-cmd "\\headsep 0.125in")
- (cal-tex-cmd "\\footskip .125in")
+ (cal-tex-filofax-paper)
(insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
\\long\\def\\rightday#1#2#3#4#5{%
\\rule{\\textwidth}{0.3pt}\\\\%
@@ -1425,14 +1422,7 @@ Optional EVENT indicates a buffer position to use instead of point."
(diary-list (if cal-tex-diary
(cal-tex-list-diary-entries d1 d2))))
(cal-tex-preamble "twoside")
- (cal-tex-cmd "\\textwidth 3.25in")
- (cal-tex-cmd "\\textheight 6.5in")
- (cal-tex-cmd "\\oddsidemargin 1.75in")
- (cal-tex-cmd "\\evensidemargin 1.5in")
- (cal-tex-cmd "\\topmargin 0pt")
- (cal-tex-cmd "\\headheight -0.875in")
- (cal-tex-cmd "\\headsep 0.125in")
- (cal-tex-cmd "\\footskip .125in")
+ (cal-tex-filofax-paper)
(insert "\\def\\righthead#1{\\hfill {\\normalsize \\bf #1}\\\\[-6pt]}
\\long\\def\\rightday#1#2#3{%
\\rule{\\textwidth}{0.3pt}\\\\%
@@ -1525,8 +1515,7 @@ a buffer position to use instead of point."
(let ((date (calendar-absolute-from-gregorian
(calendar-cursor-to-date t event))))
(cal-tex-preamble "12pt")
- (cal-tex-cmd "\\textwidth 6.5in")
- (cal-tex-cmd "\\textheight 10.5in")
+ (cal-tex-weekly-paper 'nomargins)
(cal-tex-b-document)
(cal-tex-cmd "\\pagestyle{empty}")
(dotimes (i n)