From 73ab743a6feeaf04ace3cd64da40734742c7b2d4 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Sat, 13 Dec 2008 00:18:35 +0100 Subject: [PATCH] Fix LaTeX export bug with regions and initial content. This is an old and nagging bug, see http://thread.gmane.org/gmane.emacs.orgmode/8809/focus=8838 for more information. This fixes the bug, hopefully. --- lisp/ChangeLog | 10 ++++++++ lisp/org-export-latex.el | 65 ++++++++++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 369b4d4c0..e5722709e 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,15 @@ 2008-12-12 Carsten Dominik + * org-export-latex.el (org-export-latex-emphasis-alist): Use \verb + instead of \texttt for the =...= and ~===~ emphasis environments. + (org-export-as-latex): Remove any old :org-license-to-kill text + properties. + (org-export-as-latex): Pass RBEG to `org-export-latex-first-lines'. + (org-export-latex-make-header): Add some hard space after the + table of contents. + (org-export-latex-first-lines): Accept RBEG argument. Mark + exported text so that it will be excuded in further steps. + * org-table.el (org-table-get-specials): Make @0 reference the last line in a table. (org-table-recalculate): Improve docstring. diff --git a/lisp/org-export-latex.el b/lisp/org-export-latex.el index fb68b4a61..b23340137 100644 --- a/lisp/org-export-latex.el +++ b/lisp/org-export-latex.el @@ -163,8 +163,8 @@ to represent the section title." ("/" "\\emph{%s}" nil) ("_" "\\underline{%s}" nil) ("+" "\\texttt{%s}" nil) - ("=" "\\texttt{%s}" nil) - ("~" "\\texttt{%s}" t)) + ("=" "\\verb|%s|" nil) + ("~" "\\verb|%s|" t)) "Alist of LaTeX expressions to convert emphasis fontifiers. Each element of the list is a list of three elements. The first element is the character used as a marker for fontification. @@ -357,6 +357,8 @@ when PUB-DIR is set, use this as the publishing directory." (error "Need a file name to be able to export"))) (message "Exporting to LaTeX...") + (remove-text-properties (point-min) (point-max) + '(:org-license-to-kill nil)) (org-update-radio-target-regexp) (org-export-latex-set-initial-vars ext-plist arg) (let* ((wcf (current-window-configuration)) @@ -405,10 +407,10 @@ when PUB-DIR is set, use this as the publishing directory." (header (org-export-latex-make-header title opt-plist)) (skip (cond (subtree-p nil) (region-p t) - ;; never skip first lines when exporting a subtree + ;; never skip first lines when exporting a subtree (t (plist-get opt-plist :skip-before-1st-heading)))) (text (plist-get opt-plist :text)) - (first-lines (if skip "" (org-export-latex-first-lines))) + (first-lines (if skip "" (org-export-latex-first-lines rbeg))) (coding-system (and (boundp 'buffer-file-coding-system) buffer-file-coding-system)) (coding-system-for-write (or org-export-latex-coding-system @@ -420,17 +422,18 @@ when PUB-DIR is set, use this as the publishing directory." (if region-p (region-end) (point-max)))) (string-for-export (org-export-preprocess-string - region :emph-multiline t - :for-LaTeX t - :comments nil - :tags (plist-get opt-plist :tags) - :priority (plist-get opt-plist :priority) - :todo-keywords (plist-get opt-plist :todo-keywords) - :add-text (if (eq to-buffer 'string) nil text) - :skip-before-1st-heading skip - :select-tags (plist-get opt-plist :select-tags) - :exclude-tags (plist-get opt-plist :exclude-tags) - :LaTeX-fragments nil))) + region + :emph-multiline t + :for-LaTeX t + :comments nil + :tags (plist-get opt-plist :tags) + :priority (plist-get opt-plist :priority) + :todo-keywords (plist-get opt-plist :todo-keywords) + :add-text (if (eq to-buffer 'string) nil text) + :skip-before-1st-heading skip + :select-tags (plist-get opt-plist :select-tags) + :exclude-tags (plist-get opt-plist :exclude-tags) + :LaTeX-fragments nil))) (set-buffer buffer) (erase-buffer) @@ -733,32 +736,35 @@ OPT-PLIST is the options plist for current buffer." (when (and org-export-with-toc (plist-get opt-plist :section-numbers)) (cond ((numberp toc) - (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n" + (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" (min toc (plist-get opt-plist :headline-levels)))) - (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\n" + (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n" (plist-get opt-plist :headline-levels)))))))) -(defun org-export-latex-first-lines (&optional comments) +(defun org-export-latex-first-lines (&optional beg) "Export the first lines before first headline. COMMENTS is either nil to replace them with the empty string or a formatting string like %%%%s if we want to comment them out." (save-excursion - (goto-char (point-min)) + (goto-char (or beg (point-min))) (if (org-at-heading-p) (beginning-of-line 2)) (let* ((pt (point)) - (end (if (and (re-search-forward "^\\* " nil t) + (end (if (and (re-search-forward "^\\*+ " nil t) (not (eq pt (match-beginning 0)))) (goto-char (match-beginning 0)) (goto-char (point-max))))) - (org-export-latex-content - (org-export-preprocess-string - (buffer-substring (point-min) end) - :for-LaTeX t - :emph-multiline t - :add-text nil - :comments nil - :skip-before-1st-heading nil - :LaTeX-fragments nil))))) + (prog1 + (org-export-latex-content + (org-export-preprocess-string + (buffer-substring (point-min) end) + :for-LaTeX t + :emph-multiline t + :add-text nil + :comments nil + :skip-before-1st-heading nil + :LaTeX-fragments nil)) + (add-text-properties (point-min) (max (point-min) (1- end)) + '(:org-license-to-kill t)))))) (defun org-export-latex-content (content &optional exclude-list) "Convert CONTENT string to LaTeX. @@ -1199,7 +1205,6 @@ If TIMESTAMPS, convert timestamps, otherwise delete them." (defun org-export-latex-preprocess () "Clean stuff in the LaTeX export." - ;; Preserve line breaks (goto-char (point-min)) (while (re-search-forward "\\\\\\\\" nil t) -- 2.11.4.GIT