X-Git-Url: https://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=texi%2Ftexi2latex.el;h=91ccda6e27c2b66f88032d3c922315a9e1787768;hp=a53e6f5edfd2c45929fd34b1df7f75dd0c05a817;hb=c9a393eeb329a99695566342a9f03b8a30000898;hpb=8acbbac3dea9abe9e079b580b613604497b4899b diff --git a/texi/texi2latex.el b/texi/texi2latex.el index a53e6f5ed..91ccda6e2 100644 --- a/texi/texi2latex.el +++ b/texi/texi2latex.el @@ -1,5 +1,5 @@ ;;; texi2latex.el --- convert a texi file into a LaTeX file. -;; Copyright (C) 1996 Lars Magne Ingebrigtsen +;; Copyright (C) 1996, 2004, 2008 Lars Magne Ingebrigtsen (require 'cl) @@ -38,7 +38,10 @@ (latexi-translate-file "gnus-faq") (latexi-translate-file "message" t) (latexi-translate-file "emacs-mime" t) - (latexi-translate-file "sieve" t)) + (latexi-translate-file "sieve" t) + (latexi-translate-file "pgg" t) + (latexi-translate-file "sasl" t) + (latexi-translate-file "gnus-news" t)) (defun latexi-translate-file (file &optional as-a-chapter) "Translate file a LaTeX file." @@ -61,7 +64,18 @@ (erase-buffer) (insert-buffer-substring cur) (goto-char (point-min)) + (when (search-forward "@copying" nil t) + (latexi-copying)) + (while (search-forward "@insertcopying" nil t) + (delete-region (match-beginning 0) (match-end 0)) + (latexi-insertcopying)) + (goto-char (point-min)) (latexi-strip-line) + (latexi-translate-string "@'e" "\\'{e}") + (latexi-translate-string "@`a" "\\`{a}") + (latexi-translate-string "@,{c}" "\\c{c}") + (latexi-translate-string "@aa{}" "{\\aa}") + (latexi-translate-string "@\"{@dotless{i}}" "ï") (latexi-translate-string "%@{" "\\gnuspercent{}\\gnusbraceleft{}") (latexi-translate-string "%@}" "\\gnuspercent{}\\gnusbraceright{}") (latexi-translate-string "%1@{" "\\gnuspercent{}1\\gnusbraceright{}") @@ -71,6 +85,7 @@ (latexi-translate-string "@code{\\264}" "@code{\\gnusbackslash{}264}") (latexi-translate-string "@samp{\\Deleted}" "@samp{\\gnusbackslash{}Deleted}") (latexi-translate-string "@samp{\\Seen}" "@samp{\\gnusbackslash{}Seen}") + (latexi-translate-string "@file{c:\\myhome}" "@file{c:\\gnusbackslash{}myhome}") ; (while (re-search-forward "{\"[^\"]*\\(\\\\\\)[^\"]*\"}\\\\" nil t) ; (replace-match "\\verb+\\\\+ " t t)) (while (not (zerop (decf times))) @@ -94,12 +109,13 @@ (progn (end-of-line) (point)))) (if (equal arg "@head") (insert "\\gnusinteresting"))) - ((member command '("setfilename" + ((member command '("setfilename" "set" "synindex" "setchapternewpage" "summarycontents" "bye" "top" "iftex" "cartouche" "iflatex" "finalout" "vskip" - "dircategory")) + "dircategory" "group" "syncodeindex" + "documentencoding")) (latexi-strip-line)) ((member command '("menu" "tex" "ifinfo" "ignore" "ifnottex" "direntry")) @@ -108,6 +124,18 @@ (if as-a-chapter (latexi-switch-line (format "sub%s" command) arg) (latexi-switch-line command arg))) + ((member command '("heading")) + (if as-a-chapter + (latexi-switch-line "subsection*" arg) + (latexi-switch-line "section*" arg))) + ((member command '("subheading")) + (if as-a-chapter + (latexi-switch-line "subsubsection*" arg) + (latexi-switch-line "subsection*" arg))) + ((member command '("subsubheading")) + (if as-a-chapter + (latexi-switch-line "subsubsubsection*" arg) + (latexi-switch-line "subsubsection*" arg))) ((member command '("chapter")) (if (string-match "Index" arg) (latexi-strip-line) @@ -130,6 +158,10 @@ (insert "\\\\")) ((equal command "sp") (replace-match "" t t)) + ((equal command ":") + (replace-match "" t t)) + ((member command '("deffn" "defvar" "defun")) + (replace-match "" t t)) ((equal command "node") (latexi-strip-line) (unless (string-match "Index" arg) @@ -140,7 +172,7 @@ ) ((member command '("titlepage")) (latexi-begin-command command)) - ((member command '("lisp" "example")) + ((member command '("lisp" "example" "smallexample" "display")) (latexi-strip-line) (insert (format "\\begin{verbatim}\n")) (setq verbatim (point))) @@ -156,7 +188,7 @@ ((equal arg "quotation") (latexi-strip-line) (insert (format "\\end{verse}\n"))) - ((member arg '("lisp" "example")) + ((member arg '("lisp" "example" "smallexample" "display")) (latexi-strip-line) (save-excursion (save-restriction @@ -177,7 +209,9 @@ (setq item-string (pop item-stack)) (latexi-strip-line) (insert (format "\\end{%s}\n" arg))) - ((member arg '("iflatex" "iftex" "cartouche")) + ((member arg '("iflatex" "iftex" "cartouche" "group")) + (latexi-strip-line)) + ((member arg '("deffn" "defvar" "defun")) (latexi-strip-line)) (t (error "Unknown end arg: %s" arg)))) @@ -222,7 +256,7 @@ (latexi-begin-command "verse")) ((equal command "page") (latexi-strip-line) - (insert (format "\\newpage\n" arg))) + (insert "\\newpage\n")) ((equal command "'s") (goto-char (match-beginning 0)) (delete-char 1)) @@ -241,7 +275,8 @@ ;; "\\begin{theindex}\\input{gnus.%s}\\end{theindex}\n" arg)) ) (t - (error "Unknown command (line %d): %s" + (error "Unknown command (file %s line %d): %s" + file (save-excursion (widen) (1+ (count-lines (point-min) (progn @@ -255,13 +290,16 @@ (latexi-strip-line)) ((member command '("ref" "xref" "pxref")) (latexi-exchange-command (concat "gnus" command) arg)) - ((member command '("sc" "file" "dfn" "emph" "kbd" "uref" + ((member command '("sc" "file" "dfn" "emph" "kbd" "key" "uref" "code" "samp" "var" "strong" "i" - "result")) + "result" "email" "env" "r" "command" "asis" + "url")) (goto-char (match-beginning 0)) (delete-char 1) (insert "\\gnus")) - ((member command '("copyright" "footnote")) + ((member command '("acronym")) + (latexi-exchange-command (concat "gnus" command) (downcase arg))) + ((member command '("copyright" "footnote" "TeX")) (goto-char (match-beginning 0)) (delete-char 1) (insert "\\")) @@ -274,7 +312,8 @@ (delete-char 2) (insert "duppat{}")) (t - (error "Unknown command (line %d): %s" + (error "Unknown command (file %s line %d): %s" + file (save-excursion (widen) (1+ (count-lines (point-min) (progn @@ -359,4 +398,23 @@ "\\\\\n")) (insert "\\end{tabular}\n") (widen)))) - + +(defvar latexi-copying-text "" + "Text of the copyright notice and copying permissions.") + +(defun latexi-copying () + "Copy the copyright notice and copying permissions from the Texinfo file, +as indicated by the @copying ... @end copying command; +insert the text with the @insertcopying command." + (let ((beg (progn (beginning-of-line) (point))) + (end (progn (re-search-forward "^@end copying[ \t]*\n") (point)))) + (setq latexi-copying-text + (buffer-substring-no-properties + (save-excursion (goto-char beg) (forward-line 1) (point)) + (save-excursion (goto-char end) (forward-line -1) (point)))) + (delete-region beg end))) + +(defun latexi-insertcopying () + "Insert the copyright notice and copying permissions from the Texinfo file, +which are indicated by the @copying ... @end copying command." + (insert (concat "\n" latexi-copying-text)))