Function: org-koma-letter-template
org-koma-letter-template is a byte-compiled function defined in
ox-koma-letter.el.gz.
Signature
(org-koma-letter-template CONTENTS INFO)
Documentation
Return complete document string after KOMA Scrlttr2 conversion.
CONTENTS is the transcoded contents string. INFO is a plist holding export options.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-koma-letter.el.gz
;;;; Template
(defun org-koma-letter-template (contents info)
"Return complete document string after KOMA Scrlttr2 conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
(concat
;; Timestamp.
(and (plist-get info :time-stamp-file)
(format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
;; LaTeX compiler
(org-latex--insert-compiler info)
;; Document class and packages.
(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
;; variables, then we insert LCO files, and, eventually, we insert
;; settings coming from buffer keywords.
(org-koma-letter--build-settings 'global info)
(mapconcat (lambda (file) (format "\\LoadLetterOption{%s}\n" file))
(split-string (or (plist-get info :lco) ""))
"")
(org-koma-letter--build-settings 'buffer info)
;; Date.
(format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
;; Hyperref, document start, and subject and title.
(let* ((with-subject (plist-get info :with-subject))
(with-title (plist-get info :with-title))
(title-as-subject (and with-subject
(plist-get info :with-title-as-subject)))
(subject* (org-string-nw-p
(org-export-data (plist-get info :subject) info)))
(title* (and with-title
(org-string-nw-p
(org-export-data (plist-get info :title) info))))
(subject (cond ((not with-subject) nil)
(title-as-subject (or subject* title*))
(t subject*)))
(title (cond ((not with-title) nil)
(title-as-subject (and subject* title*))
(t title*)))
(hyperref-template (plist-get info :latex-hyperref-template))
(spec (append (list (cons ?t (or title subject "")))
(org-latex--format-spec info))))
(concat
(when (and with-subject (not (eq with-subject t)))
(format "\\KOMAoption{subject}{%s}\n"
(if (symbolp with-subject) with-subject
(mapconcat #'symbol-name with-subject ","))))
;; Hyperref.
(and (stringp hyperref-template)
(format-spec hyperref-template spec))
;; Document start.
"\\begin{document}\n\n"
;; Subject and title.
(when subject (format "\\setkomavar{subject}{%s}\n" subject))
(when title (format "\\setkomavar{title}{%s}\n" title))
(when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n")))
;; Letter start.
(let ((keyword-val (plist-get info :to-address))
(heading-val (org-koma-letter--get-tagged-contents 'to)))
(format "\\begin{letter}{%%\n%s}\n\n"
(org-koma-letter--add-latex-newlines
(or (if (plist-get info :special-headings)
(or heading-val keyword-val)
(or keyword-val heading-val))
"\\mbox{}"))))
;; Opening.
(format "\\opening{%s}\n\n"
(org-koma-letter--keyword-or-headline
:opening
(lambda (h i)
(not (org-koma-letter--special-tag h i)))
info))
;; Letter body.
contents
;; Closing.
(format "\\closing{%s}\n"
(org-koma-letter--keyword-or-headline
:closing
(lambda (h i)
(let ((special-tag (org-koma-letter--special-tag h i)))
(and special-tag
(string= "closing" special-tag))))
info))
(org-koma-letter--special-contents-inline
(plist-get info :special-tags-after-closing) info)
;; Letter end.
"\n\\end{letter}\n"
(org-koma-letter--special-contents-inline
(plist-get info :special-tags-after-letter) info)
;; Document end.
"\n\\end{document}"))