# HG changeset patch # User Carsten Dominik # Date 1205398584 0 # Node ID 00b30bac18c236c21c5b74682c5d324c1c9bbb33 # Parent 3ff23628bcb98ffdb25b716f4d015cd9a01113cf * org-export-latex.el (org-export-as-latex): Revert the change that killed the LaTeX buffer. diff -r 3ff23628bcb9 -r 00b30bac18c2 lisp/textmodes/org-export-latex.el --- a/lisp/textmodes/org-export-latex.el Thu Mar 13 08:56:04 2008 +0000 +++ b/lisp/textmodes/org-export-latex.el Thu Mar 13 08:56:24 2008 +0000 @@ -4,7 +4,7 @@ ;; ;; Emacs Lisp Archive Entry ;; Filename: org-export-latex.el -;; Version: 5.19 +;; Version: 5.23 ;; Author: Bastien Guerry ;; Maintainer: Bastien Guerry ;; Keywords: org, wp, tex @@ -42,7 +42,7 @@ ;; M-x `org-export-as-latex-to-buffer' ;; M-x `org-export-region-as-latex' ;; M-x `org-replace-region-by-latex' -;; +;; ;;; Code: (eval-when-compile @@ -329,7 +329,7 @@ ;;;###autoload (defun org-export-as-latex (arg &optional hidden ext-plist - to-buffer body-only) + to-buffer body-only pub-dir) "Export current buffer to a LaTeX file. If there is an active region, export only the region. The prefix ARG specifies how many levels of the outline should become @@ -344,7 +344,8 @@ buffer behind but just return the resulting LaTeX as a string. When BODY-ONLY is set, don't produce the file header and footer, simply return the content of \begin{document}...\end{document}, -without even the \begin{document} and \end{document} commands." +without even the \begin{document} and \end{document} commands. +when PUB-DIR is set, use this as the publishing directory." (interactive "P") ;; Make sure we have a file name when we need it. (when (and (not (or to-buffer body-only)) @@ -375,7 +376,8 @@ (file-name-sans-extension (file-name-nondirectory buffer-file-name)))) (filename (concat (file-name-as-directory - (org-export-directory :LaTeX ext-plist)) + (or pub-dir + (org-export-directory :LaTeX ext-plist))) (file-name-sans-extension (file-name-nondirectory ;sans-extension buffer-file-name)) ".tex")) @@ -391,9 +393,10 @@ (find-file-noselect filename))) (odd org-odd-levels-only) (header (org-export-latex-make-header title opt-plist)) - (skip (if subtree-p nil + (skip (cond (subtree-p nil) + (region-p t) ;; never skip first lines when exporting a subtree - (plist-get opt-plist :skip-before-1st-heading))) + (t (plist-get opt-plist :skip-before-1st-heading)))) (text (plist-get opt-plist :text)) (first-lines (if skip "" (org-export-latex-first-lines))) (coding-system (and (boundp 'buffer-file-coding-system) @@ -1117,8 +1120,8 @@ (if (match-string 2) "" (match-string 1)))) t t)) ;; Delete @<...> constructs + ;; Thanks to Daniel Clemente for this regexp (goto-char (point-min)) - ;; Thanks to Daniel Clemente for this regexp (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t) (replace-match "")) @@ -1140,7 +1143,7 @@ (let ((end (save-excursion (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t) (match-beginning 0) (point-max))))) - (setq footnote (concat (org-trim (buffer-substring (point) end)) + (setq footnote (concat (org-trim (buffer-substring (point) end)) " ")) ; prevent last } being part of a link (delete-region (point) end)) (goto-char foot-beg)