From d5230f0ec72d157d9a92d99521793aca47752abc Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Fri, 27 Nov 2009 14:48:03 +0100 Subject: [PATCH] Allow LaTeX_CLASS_OPTIONS to set options, also from a property --- lisp/ChangeLog | 4 ++++ lisp/org-latex.el | 23 ++++++++++++++++++++++- lisp/org.el | 3 ++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9e22dce53..c9def2671 100755 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,7 +1,11 @@ 2009-11-27 Carsten Dominik + * org-latex.el (org-export-latex-class-options): New variable. + (org-export-latex-set-initial-vars): Use the class options. + * org.el (org-forward-same-level): Stop at headings that start with an invisible character. + (org-additional-option-like-keywords): Add LaTeX_CLASS_OPTIONS. * org-clock.el (org-clock-in): Do not restart the clock in the same entry where it is running now. diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 516aac7db..ce697a3d1 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -53,6 +53,7 @@ ;;; Variables: (defvar org-export-latex-class nil) +(defvar org-export-latex-class-options nil) (defvar org-export-latex-header nil) (defvar org-export-latex-append-header nil) (defvar org-export-latex-options-plist nil) @@ -935,6 +936,19 @@ LEVEL indicates the default depth for export." (match-string 1)))) (plist-get org-export-latex-options-plist :latex-class) org-export-latex-default-class) + org-export-latex-class-options + (or (and (org-region-active-p) + (save-excursion + (goto-char (region-beginning)) + (and (looking-at org-complex-heading-regexp) + (org-entry-get nil "LaTeX_CLASS_OPTIONS" 'selective)))) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (and (re-search-forward "^#\\+LaTeX_CLASS_OPTIONS:[ \t]*\\(.*?\\)[ \t]*$" nil t) + (match-string 1)))) + (plist-get org-export-latex-options-plist :latex-class-options)) org-export-latex-class (or (car (assoc org-export-latex-class org-export-latex-classes)) (error "No definition for class `%s' in `org-export-latex-classes'" @@ -948,7 +962,14 @@ LEVEL indicates the default depth for export." (let ((hl-levels (plist-get org-export-latex-options-plist :headline-levels)) (sec-depth (length org-export-latex-sectioning))) - (if (> hl-levels sec-depth) sec-depth hl-levels))))) + (if (> hl-levels sec-depth) sec-depth hl-levels)))) + (when (and org-export-latex-class-options + (string-match "\\S-" org-export-latex-class-options) + (string-match "^[ \t]*\\(\\\\documentclass\\)\\(\\[.*?\\]\\)?" org-export-latex-header)) + (setq org-export-latex-header + (concat (substring org-export-latex-header 0 (match-end 1)) + org-export-latex-class-options + (substring org-export-latex-header (match-end 0)))))) (defun org-export-latex-make-header (title opt-plist) "Make the LaTeX header and return it as a string. diff --git a/lisp/org.el b/lisp/org.el index d9040158b..5616c5e71 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -9481,7 +9481,8 @@ This function can be used in a hook." (defconst org-additional-option-like-keywords '("BEGIN_HTML" "END_HTML" "HTML:" "ATTR_HTML" "BEGIN_DocBook" "END_DocBook" "DocBook:" "ATTR_DocBook" - "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:" "LATEX_CLASS:" "ATTR_LaTeX" + "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:" + "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX" "BEGIN:" "END:" "ORGTBL" "TBLFM:" "TBLNAME:" "BEGIN_EXAMPLE" "END_EXAMPLE" -- 2.11.4.GIT