diff options
author | Rasmus <rasmus@gmx.us> | 2015-10-03 20:12:45 +0200 |
---|---|---|
committer | Rasmus <rasmus@gmx.us> | 2015-10-04 15:54:28 +0200 |
commit | 002499b26b614824f95c979f6f0a8f2580cfbefb (patch) | |
tree | 4ae83314d26981bd3ca6b69c463a52f837f4792d | |
parent | bb51d25defe172b605b15b3d9c232aed78a19730 (diff) | |
download | org-mode-002499b26b614824f95c979f6f0a8f2580cfbefb.tar.gz |
ox-latex: Small refactor
* ox-latex.el (org-latex--make-preamble): Renamed
org-latex--make-header.
(org-latex--insert-compiler): New function.
(org-latex-template):
* ox-koma-letter.el: Use new function.
-rw-r--r-- | contrib/lisp/ox-koma-letter.el | 2 | ||||
-rw-r--r-- | lisp/ox-latex.el | 31 |
2 files changed, 20 insertions, 13 deletions
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index f1ccc46..e51fab3 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -617,7 +617,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. - (org-latex--make-header info) + (org-latex--make-preamble 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 5119770..297b563 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1523,8 +1523,8 @@ INFO is a plist used as a communication channel." (?L . ,(capitalize language)) (?D . ,(org-export-get-date info))))) -(defun org-latex--make-header (info) - "Return a formatted LaTeX header. +(defun org-latex--make-preamble (info) + "Return a formatted LaTeX preamble. INFO is a plist used as a communication channel." (let* ((class (plist-get info :latex-class)) (class-options (plist-get info :latex-class-options)) @@ -1543,15 +1543,25 @@ INFO is a plist used as a communication channel." (org-element-normalize-string (org-splice-latex-header document-class-string - (org-latex--remove-packages org-latex-default-packages-alist info) - (org-latex--remove-packages org-latex-packages-alist info) + (org-latex--remove-packages + org-latex-default-packages-alist info) + (org-latex--remove-packages + org-latex-packages-alist info) nil - (concat (org-element-normalize-string - (plist-get info :latex-header)) - (plist-get info :latex-header-extra))))) + (mapconcat 'org-element-normalize-string + (list (plist-get info :latex-header) + (plist-get info :latex-header-extra)) "")))) info) info)))) +(defun org-latex--insert-compiler (info) + "Insert LaTeX_compiler info into the document. +INFO is a plist used as a communication channel." + (let ((compiler (plist-get info :latex-compiler))) + (and (org-string-nw-p org-latex-compiler-file-string) + (string-match-p (regexp-opt org-latex-compilers) (or compiler "")) + (format org-latex-compiler-file-string compiler)))) + ;;; Template @@ -1566,12 +1576,9 @@ holding export options." (and (plist-get info :time-stamp-file) (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) ;; LaTeX compiler. - (let ((compiler (plist-get info :latex-compiler))) - (and (org-string-nw-p org-latex-compiler-file-string) - (string-match-p (regexp-opt org-latex-compilers) (or compiler "")) - (format org-latex-compiler-file-string compiler))) + (org-latex--insert-compiler info) ;; Document class and packages. - (org-latex--make-header info) + (org-latex--make-preamble info) ;; Possibly limit depth for headline numbering. (let ((sec-num (plist-get info :section-numbers))) (when (integerp sec-num) |