diff options
author | Rasmus <rasmus@gmx.us> | 2015-07-31 13:52:22 +0200 |
---|---|---|
committer | Rasmus <rasmus@gmx.us> | 2015-07-31 14:12:50 +0200 |
commit | 8d3bc7875f6a96d9329e401a290fdd6cb05d7ad3 (patch) | |
tree | 51b29a756fc6107afb57e0e74041681c1b838b78 | |
parent | 309f15887a038edd53e943cd918474a044f077be (diff) | |
download | org-mode-8d3bc7875f6a96d9329e401a290fdd6cb05d7ad3.tar.gz |
ox-latex: New function to generate header
* ox-latex.el (org-latex--make-header): New function.
(org-latex-template): Use new function.
* ox-koma-letter.el (org-koma-letter-template): Use new function.
-rw-r--r-- | contrib/lisp/ox-koma-letter.el | 22 | ||||
-rw-r--r-- | lisp/ox-latex.el | 37 |
2 files changed, 22 insertions, 37 deletions
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 8926d24..8ba380c 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -592,27 +592,7 @@ holding export options." (and (plist-get info :time-stamp-file) (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) ;; Document class and packages. - (let* ((class (plist-get info :latex-class)) - (class-options (plist-get info :latex-class-options)) - (header (nth 1 (assoc class org-latex-classes))) - (document-class-string - (and (stringp header) - (if (not class-options) header - (replace-regexp-in-string - "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)" - class-options header t nil 1))))) - (if (not document-class-string) - (user-error "Unknown LaTeX class `%s'" class) - (org-latex-guess-babel-language - (org-latex-guess-inputenc - (org-element-normalize-string - (org-splice-latex-header - document-class-string - org-latex-default-packages-alist ; Defined in org.el. - org-latex-packages-alist nil ; Defined in org.el. - (concat (org-element-normalize-string (plist-get info :latex-header)) - (plist-get info :latex-header-extra))))) - info))) + (org-latex--make-header info) ;; Settings. They can come from three locations, in increasing ;; order of precedence: global variables, LCO files and in-buffer ;; settings. Thus, we first insert settings coming from global diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 5dbfd74..7afc6d0 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1467,21 +1467,10 @@ INFO is a plist used as a communication channel." (?L . ,(capitalize language)) (?D . ,(org-export-get-date info))))) - -;;; Template - -(defun org-latex-template (contents info) - "Return complete document string after LaTeX conversion. -CONTENTS is the transcoded contents string. INFO is a plist -holding export options." - (let ((title (org-export-data (plist-get info :title) info)) - (spec (org-latex--format-spec info))) - (concat - ;; Time-stamp. - (and (plist-get info :time-stamp-file) - (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) - ;; Document class and packages. - (let* ((class (plist-get info :latex-class)) +(defun org-latex--make-header (info) + "Return a formatted LaTeX header. +INFO is a plist used as a communication channel." + (let* ((class (plist-get info :latex-class)) (class-options (plist-get info :latex-class-options)) (header (nth 1 (assoc class (plist-get info :latex-classes)))) (document-class-string @@ -1504,7 +1493,23 @@ holding export options." (plist-get info :latex-header)) (plist-get info :latex-header-extra))))) info) - info))) + info)))) + + +;;; Template + +(defun org-latex-template (contents info) + "Return complete document string after LaTeX conversion. +CONTENTS is the transcoded contents string. INFO is a plist +holding export options." + (let ((title (org-export-data (plist-get info :title) info)) + (spec (org-latex--format-spec info))) + (concat + ;; Time-stamp. + (and (plist-get info :time-stamp-file) + (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) + ;; Document class and packages. + (org-latex--make-header info) ;; Possibly limit depth for headline numbering. (let ((sec-num (plist-get info :section-numbers))) (when (integerp sec-num) |