unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* cal-tex.el landscape patch
@ 2017-08-21 14:19 Vincent Belaïche
  2017-08-22  7:04 ` Marcin Borkowski
  2017-08-25  1:10 ` Glenn Morris
  0 siblings, 2 replies; 14+ messages in thread
From: Vincent Belaïche @ 2017-08-21 14:19 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

Hello,

Not being the maintainer of calendar, I would like to get your
approval/brickbats/comments before commiting this : the objective is to
make landscape by landscape class option + \usepackage{geometry}, rather
than \special{landscape} in the preamble.

The advantage of this way is that this it works directly if you compile
with pdflatex, rather than latex+dvips+ps2pdf.  To achieve this I had to
change some of the function prototypes, the landscape argument is
removed, and landscape option is passed just as another class option.

BR,
  Vincent.

PS : This would go in the master branch.

[-- Attachment #2: cal-tex.diff.txt --]
[-- Type: text/plain, Size: 4533 bytes --]

diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 1ea10bf..3abc53f 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -256,15 +256,17 @@ cal-tex-list-diary-entries
     (diary-list-entries (calendar-gregorian-from-absolute d1)
                         (1+ (- d2 d1)) t)))
 
-(defun cal-tex-preamble (&optional args)
+(defun cal-tex-preamble (&optional class-options)
   "Insert the LaTeX calendar preamble into `cal-tex-buffer'.
 Preamble includes initial definitions for various LaTeX commands.
-Optional string ARGS are included as options for the article document class."
+Optional string CLASS-OPTIONS are included as options for the article document class."
   (set-buffer (generate-new-buffer cal-tex-buffer))
   (insert (format "\\documentclass%s{article}\n"
-                  (if (stringp args)
-                      (format "[%s]" args)
+                  (if (stringp class-options)
+                      (format "[%s]" class-options)
                     "")))
+  (if (and (stringp class-options) (string-match "\\<landscape\\>" class-options))
+      (insert "\\usepackage{geometry}\n"))
   (if (stringp cal-tex-preamble-extra)
       (insert cal-tex-preamble-extra "\n"))
   ;; FIXME boxwidth and boxheight unused?
@@ -320,7 +322,7 @@ cal-tex-year
 There are four rows of three months each, unless optional
 LANDSCAPE is non-nil, in which case the calendar is printed in
 landscape mode with three rows of four months each."
-  (cal-tex-insert-preamble 1 landscape "12pt")
+  (cal-tex-insert-preamble 1 (if landscape "12pt,landscape" "12pt"))
   (if landscape
       (cal-tex-vspace "-.6cm")
     (cal-tex-vspace "-3.1cm"))
@@ -476,7 +478,7 @@ cal-tex-cursor-month-landscape
          (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2)))
          (holidays (if cal-tex-holidays (holiday-in-range d1 d2)))
          other-month other-year small-months-at-start)
-    (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) t "12pt")
+    (cal-tex-insert-preamble (cal-tex-number-weeks month year 1) "12pt,landscape")
     (cal-tex-cmd cal-tex-cal-one-month)
     (dotimes (i n)
       (setq other-month month
@@ -515,7 +517,7 @@ cal-tex-cursor-month-landscape
         (calendar-increment-month month year 1)
         (cal-tex-vspace "-2cm")
         (cal-tex-insert-preamble
-         (cal-tex-number-weeks month year 1) t "12pt" t))))
+         (cal-tex-number-weeks month year 1) "12pt,landscape" t))))
   (cal-tex-end-document)
   (run-hooks 'cal-tex-hook))
 
@@ -545,7 +547,7 @@ cal-tex-cursor-month
                       end-year))))
          (diary-list (if cal-tex-diary (cal-tex-list-diary-entries d1 d2)))
          (holidays (if cal-tex-holidays (holiday-in-range d1 d2))))
-    (cal-tex-insert-preamble (cal-tex-number-weeks month year n) nil "12pt")
+    (cal-tex-insert-preamble (cal-tex-number-weeks month year n) "12pt")
     (if (> n 1)
         (cal-tex-cmd cal-tex-cal-multi-month)
       (cal-tex-cmd cal-tex-cal-one-month))
@@ -1615,24 +1617,26 @@ cal-tex-end-document
 \t\tM-x tex-buffer RET
 \t\tM-x tex-print  RET")))
 
-(defun cal-tex-insert-preamble (weeks landscape size &optional append)
+(defun cal-tex-insert-preamble (weeks class-options &optional append)
   "Initialize the output LaTeX calendar buffer, `cal-tex-buffer'.
 Select the output buffer, and insert the preamble for a calendar
-of WEEKS weeks.  Insert code for landscape mode if LANDSCAPE is
-non-nil.  Use point-size SIZE.  Optional argument APPEND, if
-non-nil, means add to end of buffer without erasing current contents."
-  (let ((width "18cm")
+of WEEKS weeks.  Insert code for landscape mode if CLASS-OPTIONS
+contains landscape option. 
+Optional argument APPEND, if non-nil, means add to end of buffer
+without erasing current contents."
+  (let ((landscape  (and class-options
+                         (string-match "\\<landscape\\>" class-options)))
+        (width "18cm")
         (height "24cm"))
     (when landscape
-      (setq width "24cm"
-            height "18cm"))
+      (let ((swap  width))
+       (setq width height height swap)))
     (unless append
-      (cal-tex-preamble size)
+      (cal-tex-preamble class-options)
       (if (not landscape)
           (progn
             (cal-tex-cmd "\\oddsidemargin -1.75cm")
             (cal-tex-cmd "\\def\\holidaymult" ".06"))
-        (cal-tex-cmd "\\special" "landscape")
         (cal-tex-cmd "\\textwidth 9.5in")
         (cal-tex-cmd "\\textheight 7in")
         (cal-tex-comment)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-09-14 20:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 14:19 cal-tex.el landscape patch Vincent Belaïche
2017-08-22  7:04 ` Marcin Borkowski
2017-08-22 22:05   ` Vincent Belaïche
2017-08-25  1:10 ` Glenn Morris
2017-08-25  9:07   ` Vincent Belaïche
2017-08-25 17:58     ` Vincent Belaïche
2017-08-25 18:25       ` Edward Reingold
2017-08-26 15:06         ` Vincent Belaïche
2017-08-26 15:29           ` Vincent Belaïche
2017-08-28 17:20             ` Paul Eggert
2017-08-28 17:55             ` Glenn Morris
2017-08-30  9:45               ` Vincent Belaïche
2017-09-14 12:46                 ` Vincent Belaïche
2017-09-14 20:31                   ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).