1 ;;; ox-koma-letter.el --- KOMA Scrlttr2 Back-End for Org Export Engine
3 ;; Copyright (C) 2007-2012 Free Software Foundation, Inc.
5 ;; Author: Nicolas Goaziou <n.goaziou AT gmail DOT com>
6 ;; Alan Schmitt <alan.schmitt AT polytechnique DOT org>
7 ;; Viktor Rosenfeld <listuser36 AT gmail DOT com>
8 ;; Rasmus Pank Roulund <emacs AT pank DOT eu>
9 ;; Keywords: org, wp, tex
11 ;; This program is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This library implements a KOMA Scrlttr2 back-end, derived from the
29 ;; Depending on the desired output format, three commands are provided
30 ;; for export: `org-koma-letter-export-as-latex' (temporary buffer),
31 ;; `org-koma-letter-export-to-latex' ("tex" file) and
32 ;; `org-koma-letter-export-to-pdf' ("pdf" file).
34 ;; On top of buffer keywords supported by `latex' back-end (see
35 ;; `org-latex-options-alist'), this back-end introduces the following
37 ;; - "CLOSING" (see `org-koma-letter-closing'),
38 ;; - "FROM_ADDRESS" (see `org-koma-letter-from-address'),
39 ;; - "LCO" (see `org-koma-letter-class-option-file'),
40 ;; - "OPENING" (see `org-koma-letter-opening'),
41 ;; - "PHONE_NUMBER" (see `org-koma-letter-phone-number'),
42 ;; - "SIGNATURE" (see `org-koma-letter-signature')
43 ;; - "PLACE" (see `org-koma-letter-place')
44 ;; - and "TO_ADDRESS". If unspecified this is set to "\mbox{}".
46 ;; TO_ADDRESS and FROM_ADDRESS can also be specified using heading
47 ;; with the special tags specified in
48 ;; `org-koma-letter-special-tags-in-letter', namely "to" and "from".
49 ;; LaTeX line breaks are not necessary if using these headings. If
50 ;; both a headline and a keyword specify a to or from address the
51 ;; value is determined in accordance with
52 ;; `org-koma-letter-prefer-special-headings'.
54 ;; A number of OPTIONS settings can be set to change which contents is
56 ;; - backaddress (see `org-koma-letter-use-backaddress')
57 ;; - foldmarks (see `org-koma-letter-use-foldmarks')
58 ;; - phone (see `org-koma-letter-use-phone')
59 ;; - email (see `org-koma-letter-use-email')
60 ;; - place (see `org-koma-letter-use-place')
61 ;; - subject, a list of format options
62 ;; (see `org-koma-letter-subject-format')
63 ;; - after-closing-order, a list of the ordering of headings with
64 ;; special tags after closing (see
65 ;; `org-koma-letter-special-tags-after-closing') -
66 ;; after-letter-order, as above, but after the end of the letter
67 ;; (see `org-koma-letter-special-tags-after-letter').
69 ;; The following variables works differently from the main LaTeX class
70 ;; - "AUTHOR": default to user-full-name but may be disabled. (see org-koma-letter-author),
71 ;; - "EMAIL": same as AUTHOR, (see org-koma-letter-email),
73 ;; Headlines are in general ignored. However, headlines with special
74 ;; tags can be used for specified contents like postscript (ps),
75 ;; carbon copy (cc), enclosures (encl) and code to be inserted after
76 ;; \end{letter} (after_letter). Specials tags are defined in
77 ;; `org-koma-letter-special-tags-after-closing' and
78 ;; `org-koma-letter-special-tags-after-letter'. Currently members of
79 ;; `org-koma-letter-special-tags-after-closing' used as macros and the
80 ;; content of the headline is the argument.
82 ;; Headlines with two and from may also be used rather than the
83 ;; keyword approach described above. If both a keyword and a headline
84 ;; with information is present precedence is determined by
85 ;; `org-koma-letter-prefer-special-headings'.
87 ;; You will need to add an appropriate association in
88 ;; `org-latex-classes' in order to use the KOMA Scrlttr2 class.
89 ;; The easiest way to do this is by adding
91 ;; (eval-after-load "ox-koma-letter"
92 ;; '(org-koma-letter-plug-into-ox))
94 ;; to your init file. This will add a very sparse scrlttr2 class and
95 ;; set it as the default `org-koma-latex-default-class'. You can also
96 ;; add you own letter class. For instace:
98 ;; (add-to-list 'org-latex-classes
100 ;; "\\documentclass\[%
105 ;; backaddress=false,
108 ;; fromphone=true\]\{scrlttr2\}
109 ;; \[DEFAULT-PACKAGES]
113 ;; Then, in your Org document, be sure to require the proper class
116 ;; #+LATEX_CLASS: my-letter
118 ;; Or by setting `org-koma-letter-default-class'.
125 ;;; User-Configurable Variables
127 (defgroup org-export-koma-letter nil
128 "Options for exporting to KOMA scrlttr2 class in LaTeX export."
129 :tag
"Org Koma-Letter"
132 (defcustom org-koma-letter-class-option-file
"NF"
133 "Letter Class Option File."
134 :group
'org-export-koma-letter
137 (defcustom org-koma-letter-author
'user-full-name
140 This variable defaults to calling the function `user-full-name'
141 which just returns the current `user-full-name'. Alternatively a
142 string, nil or a function may be given. Functions must return a
144 :group
'org-export-koma-letter
145 :type
'(radio (function-item user-full-name
)
148 (const :tag
"Do not export author" nil
)))
150 (defcustom org-koma-letter-email
'org-koma-letter-email
151 "The sender's email address.
153 This variable defaults to the value `org-koma-letter-email' which
154 returns `user-mail-address'. Alternatively a string, nil or a
155 function may be given. Functions must return a string."
156 :group
'org-export-koma-letter
157 :type
'(radio (function-item org-koma-letter-email
)
160 (const :tag
"Do not export email" nil
)))
162 (defcustom org-koma-letter-from-address nil
163 "Sender's address, as a string."
164 :group
'org-export-koma-letter
167 (defcustom org-koma-letter-phone-number nil
168 "Sender's phone number, as a string."
169 :group
'org-export-koma-letter
172 (defcustom org-koma-letter-place nil
173 "Place from which the letter is sent."
174 :group
'org-export-koma-letter
177 (defcustom org-koma-letter-opening nil
178 "Letter's opening, as a string."
179 :group
'org-export-koma-letter
182 (defcustom org-koma-letter-closing nil
183 "Koma-Letter's closing, as a string."
184 :group
'org-export-koma-letter
187 (defcustom org-koma-letter-prefer-special-headings nil
188 "If both a TO or FROM is specified two places should the
189 heading version be preferred?"
190 :group
'org-export-koma-letter
193 (defcustom org-koma-letter-signature nil
194 "String used as the signature."
195 :group
'org-export-koma-letter
198 (defcustom org-koma-letter-subject-format t
199 "Use the title as the subject of the letter. At the time of
200 writing the following values are allowed:
202 - afteropening: subject after opening
203 - beforeopening: subject before opening
204 - centered: subject centered
205 - left:subject left-justified
206 - right: subject right-justified
207 - titled: add title/description to subject
208 - underlined: set subject underlined (see note in text please)
209 - untitled: do not add title/description to subject.
210 - No-export: do no insert a subject even if present.
212 Please refer to the KOMA-script manual (Table 4.16. in the
213 English manual of 2012-07-22)"
215 (const :tag
"No export" nil
)
216 (const :tag
"Default options" t
)
217 (set :tag
"selection"
218 (const 'afteropening
)
219 (const 'beforeopening
)
227 :group
'org-export-koma-letter
)
231 (defcustom org-koma-letter-use-backaddress t
232 "Print return address in small line above to address."
233 :group
'org-export-koma-letter
236 (defcustom org-koma-letter-use-foldmarks
"true"
237 "Configure appearence of fold marks.
239 Accepts any valid value for the KOMA-Script `foldmarks' option.
241 Use `foldmarks:true' to activate default fold marks or
242 `foldmarks:nil' to deactivate fold marks."
243 :group
'org-export-koma-letter
246 (defcustom org-koma-letter-use-phone t
247 "Print sender's phone number."
248 :group
'org-export-koma-letter
251 (defcustom org-koma-letter-use-email t
252 "Print sender's email address."
253 :group
'org-export-koma-letter
256 (defcustom org-koma-letter-use-place t
257 "Print the letter's place next to the date."
258 :group
'org-export-koma-letter
261 (defcustom org-koma-letter-default-class nil
262 "Default class for `org-koma-letter'. Must be a member of
264 :group
'org-export-koma-letter
267 (defconst org-koma-letter-special-tags-in-letter
'(to from
)
268 "header tags related to the letter itself")
270 (defconst org-koma-letter-special-tags-after-closing
'(ps encl cc
)
271 "Header tags to be inserted after closing")
273 (defconst org-koma-letter-special-tags-after-letter
'(after_letter)
274 "Header tags to be inserted after closing")
276 (defvar org-koma-letter-special-contents nil
277 "holds special content temporarily.")
283 (org-export-define-derived-backend 'koma-letter
'latex
285 '((:lco
"LCO" nil org-koma-letter-class-option-file
)
286 (:latex-class
"LATEX_CLASS" nil
(if org-koma-letter-default-class
287 org-koma-letter-default-class
288 org-latex-default-class
) t
)
289 (:author
"AUTHOR" nil
(org-koma-letter--get-custom org-koma-letter-author
) t
)
290 (:from-address
"FROM_ADDRESS" nil nil newline
)
291 (:phone-number
"PHONE_NUMBER" nil org-koma-letter-phone-number
)
292 (:email
"EMAIL" nil
(org-koma-letter--get-custom org-koma-letter-email
) t
)
293 (:to-address
"TO_ADDRESS" nil nil newline
)
294 (:place
"PLACE" nil org-koma-letter-place
)
295 (:opening
"OPENING" nil org-koma-letter-opening
)
296 (:closing
"CLOSING" nil org-koma-letter-closing
)
297 (:signature
"SIGNATURE" nil org-koma-letter-signature newline
)
298 (:special-tags nil nil
(append
299 org-koma-letter-special-tags-in-letter
300 org-koma-letter-special-tags-after-closing
301 org-koma-letter-special-tags-after-letter
))
302 (:special-headings nil
"special-headings"
303 org-koma-letter-prefer-special-headings
)
304 (:with-after-closing nil
"after-closing-order"
305 org-koma-letter-special-tags-after-closing
)
306 (:with-after-letter nil
"after-letter-order"
307 org-koma-letter-special-tags-after-letter
)
308 (:with-backaddress nil
"backaddress" org-koma-letter-use-backaddress
)
309 (:with-foldmarks nil
"foldmarks" org-koma-letter-use-foldmarks
)
310 (:with-phone nil
"phone" org-koma-letter-use-phone
)
311 (:with-email nil
"email" org-koma-letter-use-email
)
312 (:with-place nil
"place" org-koma-letter-use-place
)
313 (:with-subject nil
"subject" org-koma-letter-subject-format
))
314 :translate-alist
'((export-block . org-koma-letter-export-block
)
315 (export-snippet . org-koma-letter-export-snippet
)
316 (headline . org-koma-letter-headline
)
317 (keyword . org-koma-letter-keyword
)
318 (template . org-koma-letter-template
))
320 '(?k
"Export with KOMA Scrlttr2"
321 ((?L
"As LaTeX buffer" org-koma-letter-export-as-latex
)
322 (?l
"As LaTeX file" org-koma-letter-export-to-latex
)
323 (?p
"As PDF file" org-koma-letter-export-to-pdf
)
324 (?o
"As PDF file and open"
326 (if a
(org-koma-letter-export-to-pdf t s v b
)
327 (org-open-file (org-koma-letter-export-to-pdf nil s v b
))))))))
330 ;;; Initialize class function
332 (defun org-koma-letter-plug-into-ox ()
333 "Add a sparse `default-koma-letter' to `org-latex-classes' and set
334 `org-koma-letter-default-class' to `default-koma-letter'"
335 (let ((class "default-koma-letter"))
336 (eval-after-load "ox-latex"
337 '(unless (member ,class
'org-latex-classes
)
338 (add-to-list 'org-latex-classes
340 "\\documentclass[11pt]{scrlttr2}") ())
341 (setq org-koma-letter-default-class class
)))))
345 (defun org-koma-letter-email ()
346 "Return the current `user-mail-address'"
349 ;; The following is taken from/inspired by ox-grof.el
352 (defun org-koma-letter--get-tagged-contents (key)
353 "Get tagged content from `org-koma-letter-special-contents'"
354 (cdr (assoc (org-koma-letter--get-custom key
)
355 org-koma-letter-special-contents
)))
357 (defun org-koma-letter--get-custom (value)
358 "Determines whether a value is nil, a string or a
359 function (a symobl). If it is a function it it evaluates it."
361 (cond ((stringp value
) value
)
362 ((functionp value
) (funcall value
))
363 ((symbolp value
) (symbol-name value
))
367 (defun org-koma-letter--prepare-special-contents-as-macro (a-list &optional keep-newlines no-tag
)
368 "Finds all the components of `org-koma-letter-special-contents'
369 corresponding to members of the `a-list' and return them as a
370 string to be formatted. The function is used for inserting
371 content of speciall headings such as PS.
373 If keep-newlines is t newlines will not be removed. If no-tag is
374 is t the content in `org-koma-letter-special-contents' will not
375 be wrapped in a macro named whatever the members of a-list are called.
378 (dolist (ac* a-list output
)
380 ((ac (org-koma-letter--get-custom ac
*))
381 (x (org-koma-letter--get-tagged-contents ac
)))
386 ;; sometimes LaTeX complains about newlines
387 ;; at the end or beginning of macros. Remove them.
388 (org-koma-letter--format-string-as-macro
389 (if keep-newlines x
(org-koma-letter--remove-offending-new-lines x
))
390 (unless no-tag ac
)))))))))
392 (defun org-koma-letter--format-string-as-macro (string &optional macro
)
393 "If a macro is given format as string as \"\\macro{string}\" else as \"string\""
395 (format "\\%s{%s}" macro string
)
396 (format "%s" string
)))
398 (defun org-koma-letter--remove-offending-new-lines (string)
399 "Remove new lines in the begging and end of `string'"
400 (replace-regexp-in-string "\\`[ \n\t]+\\|[\n\t ]*\\'" "" string
))
402 (defun org-koma-letter--determine-special-value (info key
)
403 "Determine who the letter is to and whom it is from.
404 oxkoma-letter allows two ways to specify these things. If both
405 are present return the preferred one as determined by
406 `org-koma-letter-prefer-special-headings'."
407 (let* ((plist-alist '((from .
:from-address
)
409 (default-alist `((from ,org-koma-letter-from-address
)
411 (option-value (plist-get info
(cdr-safe (assoc key plist-alist
))))
412 (head-value (org-koma-letter--get-tagged-contents key
))
415 (if (plist-get info
:special-headings
)
417 `(,option-value
,head-value
))
418 (cdr-safe (assoc key default-alist
))))
420 (adr (dolist (x order tmp
)
421 (when (and (not tmp
) x
)
424 (replace-regexp-in-string
426 (org-koma-letter--remove-offending-new-lines adr
)))))
428 ;;; Transcode Functions
432 (defun org-koma-letter-export-block (export-block contents info
)
433 "Transcode an EXPORT-BLOCK element into KOMA Scrlttr2 code.
434 CONTENTS is nil. INFO is a plist used as a communication
436 (when (member (org-element-property :type export-block
) '("KOMA-LETTER" "LATEX"))
437 (org-remove-indentation (org-element-property :value export-block
))))
441 (defun org-koma-letter-export-snippet (export-snippet contents info
)
442 "Transcode an EXPORT-SNIPPET object into KOMA Scrlttr2 code.
443 CONTENTS is nil. INFO is a plist used as a communication
445 (when (memq (org-export-snippet-backend export-snippet
) '(latex koma-letter
))
446 (org-element-property :value export-snippet
)))
450 (defun org-koma-letter-keyword (keyword contents info
)
451 "Transcode a KEYWORD element into KOMA Scrlttr2 code.
452 CONTENTS is nil. INFO is a plist used as a communication
454 (let ((key (org-element-property :key keyword
))
455 (value (org-element-property :value keyword
)))
456 ;; Handle specifically BEAMER and TOC (headlines only) keywords.
457 ;; Otherwise, fallback to `latex' back-end.
458 (if (equal key
"KOMA-LETTER") value
459 (org-export-with-backend 'latex keyword contents info
))))
464 (defun org-koma-letter-headline (headline contents info
)
465 "Transcode a HEADLINE element from Org to LaTeX.
466 CONTENTS holds the contents of the headline. INFO is a plist
467 holding contextual information.
469 Note that if a headline is tagged with a tag from
470 `org-koma-letter-special-tags' it will not be exported, but
471 stored in `org-koma-letter-special-contents' and included at the
474 ((tags (org-export-get-tags headline info
))
477 (car (member-ignore-case
479 (mapcar 'symbol-name
(plist-get info
:special-tags
)))))))
482 (push (cons tag contents
)
483 org-koma-letter-special-contents
)
490 (defun org-koma-letter-template (contents info
)
491 "Return complete document string after KOMA Scrlttr2 conversion.
492 CONTENTS is the transcoded contents string. INFO is a plist
493 holding export options."
494 ;; FIXME: instead of setq'ing org-koma-letter-special-contents and
495 ;; callying varioues stuff it might be nice to put a big let* around the templace
496 ;; as in org-groff...
499 (and (plist-get info
:time-stamp-file
)
500 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
501 ;; Document class and packages.
502 (let* ((class (plist-get info
:latex-class
))
503 (class-options (plist-get info
:latex-class-options
))
504 (header (nth 1 (assoc class org-latex-classes
)))
505 (document-class-string
506 (and (stringp header
)
507 (if (not class-options
) header
508 (replace-regexp-in-string
509 "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
510 class-options header t nil
1)))))
511 (if (not document-class-string
)
512 (user-error "Unknown LaTeX class `%s'" class
)
513 (org-latex-guess-babel-language
514 (org-latex-guess-inputenc
515 (org-element-normalize-string
516 (org-splice-latex-header
517 document-class-string
518 org-latex-default-packages-alist
; Defined in org.el.
519 org-latex-packages-alist nil
; Defined in org.el.
520 (concat (org-element-normalize-string (plist-get info
:latex-header
))
521 (plist-get info
:latex-header-extra
)))))
523 (let ((lco (plist-get info
:lco
))
524 (author (plist-get info
:author
))
525 (from-address (org-koma-letter--determine-special-value info
'from
))
526 (phone-number (plist-get info
:phone-number
))
527 (email (plist-get info
:email
))
528 (signature (plist-get info
:signature
)))
530 ;; Letter Class Option File
532 (let ((lco-files (split-string lco
" "))
534 (dolist (lco-file lco-files lco-def
)
535 (setq lco-def
(format "%s\\LoadLetterOption{%s}\n" lco-def lco-file
)))
537 ;; Define "From" data.
538 (when author
(format "\\setkomavar{fromname}{%s}\n"
539 (org-export-data author info
)))
540 (when from-address
(format "\\setkomavar{fromaddress}{%s}\n" from-address
))
541 (when phone-number
(format "\\setkomavar{fromphone}{%s}\n" phone-number
))
542 (when email
(format "\\setkomavar{fromemail}{%s}\n" email
))
543 (when signature
(format "\\setkomavar{signature}{%s}\n" signature
))))
545 (format "\\date{%s}\n" (org-export-data (org-export-get-date info
) info
))
547 (let ((with-place (plist-get info
:with-place
))
548 (place (plist-get info
:place
)))
549 (when (or place
(not with-place
))
550 (format "\\setkomavar{place}{%s}\n" (if with-place place
""))))
552 (let ((with-backaddress (plist-get info
:with-backaddress
))
553 (with-foldmarks (plist-get info
:with-foldmarks
))
554 (with-phone (plist-get info
:with-phone
))
555 (with-email (plist-get info
:with-email
)))
557 (format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress
"true" "false"))
558 (format "\\KOMAoption{foldmarks}{%s}\n" (if with-foldmarks with-foldmarks
"false"))
559 (format "\\KOMAoption{fromphone}{%s}\n" (if with-phone
"true" "false"))
560 (format "\\KOMAoption{fromemail}{%s}\n" (if with-email
"true" "false"))))
562 "\\begin{document}\n\n"
564 (let* ((with-subject (plist-get info
:with-subject
))
565 (subject-format (cond ((member with-subject
'("true" "t" t
)) nil
)
566 ((stringp with-subject
) (list with-subject
))
567 ((symbolp with-subject
)
568 (list (symbol-name with-subject
)))
570 (subject (org-export-data (plist-get info
:title
) info
))
571 (l (length subject-format
))
574 (when (and with-subject subject-format
)
576 "\\KOMAoption{subject}{"
579 (setq y
(concat (if (> x
0) "%s," "%s") y
)))
580 subject-format
) "}\n"))
581 (when (and subject with-subject
)
582 (format "\\setkomavar{subject}{%s}\n\n" subject
))))
584 (format "\\begin{letter}{%%\n%s}\n\n"
585 (org-koma-letter--determine-special-value info
'to
))
587 (format "\\opening{%s}\n\n" (plist-get info
:opening
))
591 (format "\n\\closing{%s}\n" (plist-get info
:closing
))
592 (org-koma-letter--prepare-special-contents-as-macro
593 (plist-get info
:with-after-closing
))
596 (org-koma-letter--prepare-special-contents-as-macro
597 (plist-get info
:with-after-letter
) t t
)
606 (defun org-koma-letter-export-as-latex
607 (&optional async subtreep visible-only body-only ext-plist
)
608 "Export current buffer as a KOMA Scrlttr2 letter.
610 If narrowing is active in the current buffer, only export its
613 If a region is active, export that region.
615 A non-nil optional argument ASYNC means the process should happen
616 asynchronously. The resulting buffer should be accessible
617 through the `org-export-stack' interface.
619 When optional argument SUBTREEP is non-nil, export the sub-tree
620 at point, extracting information from the headline properties
623 When optional argument VISIBLE-ONLY is non-nil, don't export
624 contents of hidden elements.
626 When optional argument BODY-ONLY is non-nil, only write code
627 between \"\\begin{letter}\" and \"\\end{letter}\".
629 EXT-PLIST, when provided, is a proeprty list with external
630 parameters overriding Org default settings, but still inferior to
633 Export is done in a buffer named \"*Org KOMA-LETTER Export*\". It
634 will be displayed if `org-export-show-temporary-export-buffer' is
637 (let (org-koma-letter-special-contents)
639 (org-export-async-start
641 (with-current-buffer (get-buffer-create "*Org KOMA-LETTER Export*")
644 (goto-char (point-min))
646 (org-export-add-to-stack (current-buffer) 'koma-letter
)))
647 `(org-export-as 'koma-letter
,subtreep
,visible-only
,body-only
649 (let ((outbuf (org-export-to-buffer
650 'koma-letter
"*Org KOMA-LETTER Export*"
651 subtreep visible-only body-only ext-plist
)))
652 (with-current-buffer outbuf
(LaTeX-mode))
653 (when org-export-show-temporary-export-buffer
654 (switch-to-buffer-other-window outbuf
))))))
657 (defun org-koma-letter-export-to-latex
658 (&optional async subtreep visible-only body-only ext-plist
)
659 "Export current buffer as a KOMA Scrlttr2 letter (tex).
661 If narrowing is active in the current buffer, only export its
664 If a region is active, export that region.
666 A non-nil optional argument ASYNC means the process should happen
667 asynchronously. The resulting file should be accessible through
668 the `org-export-stack' interface.
670 When optional argument SUBTREEP is non-nil, export the sub-tree
671 at point, extracting information from the headline properties
674 When optional argument VISIBLE-ONLY is non-nil, don't export
675 contents of hidden elements.
677 When optional argument BODY-ONLY is non-nil, only write code
678 between \"\\begin{letter}\" and \"\\end{letter}\".
680 EXT-PLIST, when provided, is a property list with external
681 parameters overriding Org default settings, but still inferior to
684 When optional argument PUB-DIR is set, use it as the publishing
687 Return output file's name."
689 (let ((outfile (org-export-output-file-name ".tex" subtreep
))
690 org-koma-letter-special-contents
)
692 (org-export-async-start
693 (lambda (f) (org-export-add-to-stack f
'koma-letter
))
696 'koma-letter
,outfile
,subtreep
,visible-only
,body-only
699 'koma-letter outfile subtreep visible-only body-only ext-plist
))))
702 (defun org-koma-letter-export-to-pdf
703 (&optional async subtreep visible-only body-only ext-plist
)
704 "Export current buffer as a KOMA Scrlttr2 letter (pdf).
706 If narrowing is active in the current buffer, only export its
709 If a region is active, export that region.
711 A non-nil optional argument ASYNC means the process should happen
712 asynchronously. The resulting file should be accessible through
713 the `org-export-stack' interface.
715 When optional argument SUBTREEP is non-nil, export the sub-tree
716 at point, extracting information from the headline properties
719 When optional argument VISIBLE-ONLY is non-nil, don't export
720 contents of hidden elements.
722 When optional argument BODY-ONLY is non-nil, only write code
723 between \"\\begin{letter}\" and \"\\end{letter}\".
725 EXT-PLIST, when provided, is a property list with external
726 parameters overriding Org default settings, but still inferior to
729 Return PDF file's name."
732 (let ((outfile (org-export-output-file-name ".tex" subtreep
)))
733 (org-export-async-start
734 (lambda (f) (org-export-add-to-stack f
'koma-letter
))
738 'koma-letter
,outfile
,subtreep
,visible-only
,body-only
741 (org-koma-letter-export-to-latex
742 nil subtreep visible-only body-only ext-plist
))))
745 (provide 'ox-koma-letter
)
746 ;;; ox-koma-letter.el ends here