ox-koma-letter: Tiny refactoring and cosmetics

This commit is contained in:
Nicolas Goaziou 2018-06-23 23:33:37 +02:00
parent a8677adb49
commit f5d5a95018
1 changed files with 157 additions and 158 deletions

View File

@ -125,12 +125,13 @@
;;; Code: ;;; Code:
(require 'cl-lib)
(require 'ox-latex) (require 'ox-latex)
;; Install a default letter class. ;; Install a default letter class.
(unless (assoc "default-koma-letter" org-latex-classes) (unless (assoc "default-koma-letter" org-latex-classes)
(add-to-list 'org-latex-classes (add-to-list 'org-latex-classes
'("default-koma-letter" "\\documentclass[11pt]{scrlttr2}"))) '("default-koma-letter" "\\documentclass[11pt]{scrlttr2}")))
;;; User-Configurable Variables ;;; User-Configurable Variables
@ -157,9 +158,9 @@ Functions must return a string.
This option can also be set with the AUTHOR keyword." This option can also be set with the AUTHOR keyword."
:group 'org-export-koma-letter :group 'org-export-koma-letter
:type '(radio (function-item user-full-name) :type '(radio (function-item user-full-name)
(string) (string)
(function) (function)
(const :tag "Do not export author" nil))) (const :tag "Do not export author" nil)))
(defcustom org-koma-letter-email 'org-koma-letter-email (defcustom org-koma-letter-email 'org-koma-letter-email
"Sender's email address. "Sender's email address.
@ -171,9 +172,9 @@ a function may be given. Functions must return a string.
This option can also be set with the EMAIL keyword." This option can also be set with the EMAIL keyword."
:group 'org-export-koma-letter :group 'org-export-koma-letter
:type '(radio (function-item org-koma-letter-email) :type '(radio (function-item org-koma-letter-email)
(string) (string)
(function) (function)
(const :tag "Do not export email" nil))) (const :tag "Do not export email" nil)))
(defcustom org-koma-letter-from-address "" (defcustom org-koma-letter-from-address ""
"Sender's address, as a string. "Sender's address, as a string.
@ -305,14 +306,14 @@ This option can also be set with the OPTIONS keyword, e.g.:
(const :tag "No export" nil) (const :tag "No export" nil)
(const :tag "Default options" t) (const :tag "Default options" t)
(set :tag "Configure options" (set :tag "Configure options"
(const :tag "Subject after opening" afteropening) (const :tag "Subject after opening" afteropening)
(const :tag "Subject before opening" beforeopening) (const :tag "Subject before opening" beforeopening)
(const :tag "Subject centered" centered) (const :tag "Subject centered" centered)
(const :tag "Subject left-justified" left) (const :tag "Subject left-justified" left)
(const :tag "Subject right-justified" right) (const :tag "Subject right-justified" right)
(const :tag "Add title or description to subject" underlined) (const :tag "Add title or description to subject" underlined)
(const :tag "Set subject underlined" titled) (const :tag "Set subject underlined" titled)
(const :tag "Do not add title or description to subject" untitled))) (const :tag "Do not add title or description to subject" untitled)))
:group 'org-export-koma-letter) :group 'org-export-koma-letter)
(defcustom org-koma-letter-use-backaddress nil (defcustom org-koma-letter-use-backaddress nil
@ -354,24 +355,24 @@ This option can also be set with the OPTIONS keyword, e.g.:
\"foldmarks:(b l m t)\"." \"foldmarks:(b l m t)\"."
:group 'org-export-koma-letter :group 'org-export-koma-letter
:type '(choice :type '(choice
(const :tag "Activate default folding marks" t) (const :tag "Activate default folding marks" t)
(const :tag "Deactivate folding marks" nil) (const :tag "Deactivate folding marks" nil)
(set (set
:tag "Configure folding marks" :tag "Configure folding marks"
(const :tag "Activate upper horizontal mark on left paper edge" B) (const :tag "Activate upper horizontal mark on left paper edge" B)
(const :tag "Deactivate upper horizontal mark on left paper edge" b) (const :tag "Deactivate upper horizontal mark on left paper edge" b)
(const :tag "Activate all horizontal marks on left paper edge" H) (const :tag "Activate all horizontal marks on left paper edge" H)
(const :tag "Deactivate all horizontal marks on left paper edge" h) (const :tag "Deactivate all horizontal marks on left paper edge" h)
(const :tag "Activate left vertical mark on upper paper edge" L) (const :tag "Activate left vertical mark on upper paper edge" L)
(const :tag "Deactivate left vertical mark on upper paper edge" l) (const :tag "Deactivate left vertical mark on upper paper edge" l)
(const :tag "Activate middle horizontal mark on left paper edge" M) (const :tag "Activate middle horizontal mark on left paper edge" M)
(const :tag "Deactivate middle horizontal mark on left paper edge" m) (const :tag "Deactivate middle horizontal mark on left paper edge" m)
(const :tag "Activate punch or center mark on left paper edge" P) (const :tag "Activate punch or center mark on left paper edge" P)
(const :tag "Deactivate punch or center mark on left paper edge" p) (const :tag "Deactivate punch or center mark on left paper edge" p)
(const :tag "Activate lower horizontal mark on left paper edge" T) (const :tag "Activate lower horizontal mark on left paper edge" T)
(const :tag "Deactivate lower horizontal mark on left paper edge" t) (const :tag "Deactivate lower horizontal mark on left paper edge" t)
(const :tag "Activate all vertical marks on upper paper edge" V) (const :tag "Activate all vertical marks on upper paper edge" V)
(const :tag "Deactivate all vertical marks on upper paper edge" v)))) (const :tag "Deactivate all vertical marks on upper paper edge" v))))
(defcustom org-koma-letter-use-phone nil (defcustom org-koma-letter-use-phone nil
"Non-nil prints sender's phone number. "Non-nil prints sender's phone number.
@ -427,8 +428,8 @@ See also `org-koma-letter-opening' and
"Non-nil means title should be interpreted as subject if subject is missing. "Non-nil means title should be interpreted as subject if subject is missing.
This option can also be set with the OPTIONS keyword, This option can also be set with the OPTIONS keyword,
e.g. \"title-subject:t\"." e.g. \"title-subject:t\"."
:group 'org-export-koma-letter :group 'org-export-koma-letter
:type 'boolean) :type 'boolean)
(defconst org-koma-letter-special-tags-in-letter '(to from closing location) (defconst org-koma-letter-special-tags-in-letter '(to from closing location)
"Header tags related to the letter itself.") "Header tags related to the letter itself.")
@ -446,8 +447,8 @@ e.g. \"title-subject:t\"."
"Holds special content temporarily.") "Holds special content temporarily.")
(make-obsolete-variable 'org-koma-letter-use-title (make-obsolete-variable 'org-koma-letter-use-title
'org-export-with-title 'org-export-with-title
"25.1" 'set) "25.1" 'set)
;;; Define Back-End ;;; Define Back-End
@ -474,9 +475,9 @@ e.g. \"title-subject:t\"."
(:special-tags-as-macro nil nil org-koma-letter-special-tags-as-macro) (:special-tags-as-macro nil nil org-koma-letter-special-tags-as-macro)
(:special-tags-in-letter nil nil org-koma-letter-special-tags-in-letter) (:special-tags-in-letter nil nil org-koma-letter-special-tags-in-letter)
(:special-tags-after-closing nil "after-closing-order" (:special-tags-after-closing nil "after-closing-order"
org-koma-letter-special-tags-after-closing) org-koma-letter-special-tags-after-closing)
(:special-tags-after-letter nil "after-letter-order" (:special-tags-after-letter nil "after-letter-order"
org-koma-letter-special-tags-after-letter) org-koma-letter-special-tags-after-letter)
(:with-backaddress nil "backaddress" org-koma-letter-use-backaddress) (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress)
(:with-email nil "email" org-koma-letter-use-email) (:with-email nil "email" org-koma-letter-use-email)
(:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks) (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks)
@ -507,19 +508,19 @@ e.g. \"title-subject:t\"."
(:inbuffer-with-from-logo nil "from-logo" 'koma-letter:empty) (:inbuffer-with-from-logo nil "from-logo" 'koma-letter:empty)
(:inbuffer-with-place nil "place" 'koma-letter:empty)) (:inbuffer-with-place nil "place" 'koma-letter:empty))
:translate-alist '((export-block . org-koma-letter-export-block) :translate-alist '((export-block . org-koma-letter-export-block)
(export-snippet . org-koma-letter-export-snippet) (export-snippet . org-koma-letter-export-snippet)
(headline . org-koma-letter-headline) (headline . org-koma-letter-headline)
(keyword . org-koma-letter-keyword) (keyword . org-koma-letter-keyword)
(template . org-koma-letter-template)) (template . org-koma-letter-template))
:menu-entry :menu-entry
'(?k "Export with KOMA Scrlttr2" '(?k "Export with KOMA Scrlttr2"
((?L "As LaTeX buffer" org-koma-letter-export-as-latex) ((?L "As LaTeX buffer" org-koma-letter-export-as-latex)
(?l "As LaTeX file" org-koma-letter-export-to-latex) (?l "As LaTeX file" org-koma-letter-export-to-latex)
(?p "As PDF file" org-koma-letter-export-to-pdf) (?p "As PDF file" org-koma-letter-export-to-pdf)
(?o "As PDF file and open" (?o "As PDF file and open"
(lambda (a s v b) (lambda (a s v b)
(if a (org-koma-letter-export-to-pdf t s v b) (if a (org-koma-letter-export-to-pdf t s v b)
(org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) (org-open-file (org-koma-letter-export-to-pdf nil s v b))))))))
@ -536,7 +537,7 @@ e.g. \"title-subject:t\"."
"Get contents from a headline tagged with KEY. "Get contents from a headline tagged with KEY.
The contents is stored in `org-koma-letter-special-contents'." The contents is stored in `org-koma-letter-special-contents'."
(let ((value (cdr (assoc-string (org-koma-letter--get-value key) (let ((value (cdr (assoc-string (org-koma-letter--get-value key)
org-koma-letter-special-contents)))) org-koma-letter-special-contents))))
(when value (org-string-nw-p (org-trim value))))) (when value (org-string-nw-p (org-trim value)))))
(defun org-koma-letter--get-value (value) (defun org-koma-letter--get-value (value)
@ -545,26 +546,26 @@ Determines if VALUE is nil, a string, a function or a symbol and
return a string or nil." return a string or nil."
(when value (when value
(cond ((stringp value) value) (cond ((stringp value) value)
((functionp value) (funcall value)) ((functionp value) (funcall value))
((symbolp value) (symbol-name value)) ((symbolp value) (symbol-name value))
(t value)))) (t value))))
(defun org-koma-letter--special-contents-inline (keywords info) (defun org-koma-letter--special-contents-inline (keywords info)
"Process KEYWORDS members of `org-koma-letter-special-contents'. "Process KEYWORDS members of `org-koma-letter-special-contents'.
KEYWORDS is a list of symbols. Return them as a string to be KEYWORDS is a list of symbols. Return them as a string to be
formatted. formatted.
The function is used for inserting content of special headings The function is used for inserting content of special headings
such as the one tagged with PS. such as the one tagged with PS."
"
(mapconcat (mapconcat
(lambda (keyword) (lambda (keyword)
(let* ((name (org-koma-letter--get-value keyword)) (let* ((name (org-koma-letter--get-value keyword))
(value (org-koma-letter--get-tagged-contents name)) (value (org-koma-letter--get-tagged-contents name))
(macrop (memq keyword (plist-get info :special-tags-as-macro)))) (macrop (memq keyword (plist-get info :special-tags-as-macro))))
(cond ((not value) nil) (cond ((not value) nil)
(macrop (format "\\%s{%s}\n" name value)) (macrop (format "\\%s{%s}\n" name value))
(t value)))) (t value))))
keywords keywords
"\n")) "\n"))
@ -585,7 +586,8 @@ such as the one tagged with PS.
"Transcode an EXPORT-BLOCK element into KOMA Scrlttr2 code. "Transcode an EXPORT-BLOCK element into KOMA Scrlttr2 code.
CONTENTS is nil. INFO is a plist used as a communication CONTENTS is nil. INFO is a plist used as a communication
channel." channel."
(when (member (org-element-property :type export-block) '("KOMA-LETTER" "LATEX")) (when (member (org-element-property :type export-block)
'("KOMA-LETTER" "LATEX"))
(org-remove-indentation (org-element-property :value export-block)))) (org-remove-indentation (org-element-property :value export-block))))
;;;; Export Snippet ;;;; Export Snippet
@ -604,7 +606,7 @@ channel."
CONTENTS is nil. INFO is a plist used as a communication CONTENTS is nil. INFO is a plist used as a communication
channel." channel."
(let ((key (org-element-property :key keyword)) (let ((key (org-element-property :key keyword))
(value (org-element-property :value keyword))) (value (org-element-property :value keyword)))
;; Handle specifically KOMA-LETTER keywords. Otherwise, fallback ;; Handle specifically KOMA-LETTER keywords. Otherwise, fallback
;; to `latex' back-end. ;; to `latex' back-end.
(if (equal key "KOMA-LETTER") value (if (equal key "KOMA-LETTER") value
@ -623,7 +625,7 @@ stored in `org-koma-letter-special-contents' and included at the
appropriate place." appropriate place."
(let ((special-tag (org-koma-letter--special-tag headline info))) (let ((special-tag (org-koma-letter--special-tag headline info)))
(if (not special-tag) (if (not special-tag)
contents contents
(push (cons special-tag contents) org-koma-letter-special-contents) (push (cons special-tag contents) org-koma-letter-special-contents)
""))) "")))
@ -632,13 +634,11 @@ appropriate place."
INFO is a plist holding contextual information. Return first INFO is a plist holding contextual information. Return first
special tag headline." special tag headline."
(let ((special-tags (append (let ((special-tags (append
(plist-get info :special-tags-in-letter) (plist-get info :special-tags-in-letter)
(plist-get info :special-tags-after-closing) (plist-get info :special-tags-after-closing)
(plist-get info :special-tags-after-letter)))) (plist-get info :special-tags-after-letter))))
(catch 'exit (cl-some (lambda (tag) (and (assoc-string tag special-tags) tag))
(dolist (tag (org-export-get-tags headline info)) (org-export-get-tags headline info))))
(let ((tag (assoc-string tag special-tags)))
(when tag (throw 'exit tag)))))))
(defun org-koma-letter--keyword-or-headline (plist-key pred info) (defun org-koma-letter--keyword-or-headline (plist-key pred info)
"Return the correct version of opening or closing. "Return the correct version of opening or closing.
@ -649,15 +649,15 @@ and an info plist. INFO is a plist holding contextual
information. Return the preferred candidate for the exported of information. Return the preferred candidate for the exported of
PLIST-KEY." PLIST-KEY."
(let* ((keyword-candidate (plist-get info plist-key)) (let* ((keyword-candidate (plist-get info plist-key))
(headline-candidate (when (and (plist-get info :with-headline-opening) (headline-candidate (when (and (plist-get info :with-headline-opening)
(or (plist-get info :special-headings) (or (plist-get info :special-headings)
(not keyword-candidate))) (not keyword-candidate)))
(org-element-map (plist-get info :parse-tree) (org-element-map (plist-get info :parse-tree)
'headline 'headline
(lambda (head) (lambda (h)
(when (funcall pred head info) (and (funcall pred h info)
(org-element-property :title head))) (org-element-property :title head)))
info t)))) info t))))
(org-export-data (or headline-candidate keyword-candidate "") info))) (org-export-data (or headline-candidate keyword-candidate "") info)))
;;;; Template ;;;; Template
@ -681,35 +681,35 @@ holding export options."
;; settings coming from buffer keywords. ;; settings coming from buffer keywords.
(org-koma-letter--build-settings 'global info) (org-koma-letter--build-settings 'global info)
(mapconcat (lambda (file) (format "\\LoadLetterOption{%s}\n" file)) (mapconcat (lambda (file) (format "\\LoadLetterOption{%s}\n" file))
(split-string (or (plist-get info :lco) "")) (split-string (or (plist-get info :lco) ""))
"") "")
(org-koma-letter--build-settings 'buffer info) (org-koma-letter--build-settings 'buffer info)
;; Date. ;; Date.
(format "\\date{%s}\n" (org-export-data (org-export-get-date info) info)) (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
;; Hyperref, document start, and subject and title. ;; Hyperref, document start, and subject and title.
(let* ((with-subject (plist-get info :with-subject)) (let* ((with-subject (plist-get info :with-subject))
(with-title (plist-get info :with-title)) (with-title (plist-get info :with-title))
(title-as-subject (and with-subject (title-as-subject (and with-subject
(plist-get info :with-title-as-subject))) (plist-get info :with-title-as-subject)))
(subject* (org-string-nw-p (subject* (org-string-nw-p
(org-export-data (plist-get info :subject) info))) (org-export-data (plist-get info :subject) info)))
(title* (and with-title (title* (and with-title
(org-string-nw-p (org-string-nw-p
(org-export-data (plist-get info :title) info)))) (org-export-data (plist-get info :title) info))))
(subject (cond ((not with-subject) nil) (subject (cond ((not with-subject) nil)
(title-as-subject (or subject* title*)) (title-as-subject (or subject* title*))
(t subject*))) (t subject*)))
(title (cond ((not with-title) nil) (title (cond ((not with-title) nil)
(title-as-subject (and subject* title*)) (title-as-subject (and subject* title*))
(t title*))) (t title*)))
(hyperref-template (plist-get info :latex-hyperref-template)) (hyperref-template (plist-get info :latex-hyperref-template))
(spec (append (list (cons ?t (or title subject ""))) (spec (append (list (cons ?t (or title subject "")))
(org-latex--format-spec info)))) (org-latex--format-spec info))))
(concat (concat
(when (and with-subject (not (eq with-subject t))) (when (and with-subject (not (eq with-subject t)))
(format "\\KOMAoption{subject}{%s}\n" (format "\\KOMAoption{subject}{%s}\n"
(if (symbolp with-subject) with-subject (if (symbolp with-subject) with-subject
(mapconcat #'symbol-name with-subject ",")))) (mapconcat #'symbol-name with-subject ","))))
;; Hyperref. ;; Hyperref.
(format-spec hyperref-template spec) (format-spec hyperref-template spec)
;; Document start. ;; Document start.
@ -720,26 +720,27 @@ holding export options."
(when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n"))) (when (or (org-string-nw-p title) (org-string-nw-p subject)) "\n")))
;; Letter start. ;; Letter start.
(let ((keyword-val (plist-get info :to-address)) (let ((keyword-val (plist-get info :to-address))
(heading-val (org-koma-letter--get-tagged-contents 'to))) (heading-val (org-koma-letter--get-tagged-contents 'to)))
(format "\\begin{letter}{%%\n%s}\n\n" (format "\\begin{letter}{%%\n%s}\n\n"
(org-koma-letter--add-latex-newlines (org-koma-letter--add-latex-newlines
(or (if (plist-get info :special-headings) (or (if (plist-get info :special-headings)
(or heading-val keyword-val) (or heading-val keyword-val)
(or keyword-val heading-val)) (or keyword-val heading-val))
"\\mbox{}")))) "\\mbox{}"))))
;; Opening. ;; Opening.
(format "\\opening{%s}\n\n" (format "\\opening{%s}\n\n"
(org-koma-letter--keyword-or-headline (org-koma-letter--keyword-or-headline
:opening (lambda (h i) (not (org-koma-letter--special-tag h i))) :opening (lambda (h i) (not (org-koma-letter--special-tag h i)))
info)) info))
;; Letter body. ;; Letter body.
contents contents
;; Closing. ;; Closing.
(format "\\closing{%s}\n" (format "\\closing{%s}\n"
(org-koma-letter--keyword-or-headline (org-koma-letter--keyword-or-headline
:closing (lambda (h i) (eq (org-koma-letter--special-tag h i) :closing
'closing)) (lambda (h i)
info)) (eq (org-koma-letter--special-tag h i) 'closing))
info))
(org-koma-letter--special-contents-inline (org-koma-letter--special-contents-inline
(plist-get info :special-tags-after-closing) info) (plist-get info :special-tags-after-closing) info)
;; Letter end. ;; Letter end.
@ -754,23 +755,21 @@ holding export options."
SCOPE is either `global' or `buffer'. INFO is a plist used as SCOPE is either `global' or `buffer'. INFO is a plist used as
a communication channel." a communication channel."
(let* ((check-scope (let* ((check-scope
(function ;; Non-nil value when SETTING was defined in SCOPE.
;; Non-nil value when SETTING was defined in SCOPE. (lambda (setting)
(lambda (setting) (let ((property (intern (format ":inbuffer-%s" setting))))
(let ((property (intern (format ":inbuffer-%s" setting)))) (if (eq scope 'global)
(if (eq scope 'global) (eq (plist-get info property) 'koma-letter:empty)
(eq (plist-get info property) 'koma-letter:empty) (not (eq (plist-get info property) 'koma-letter:empty))))))
(not (eq (plist-get info property) 'koma-letter:empty))))))) (heading-or-key-value
(heading-or-key-value (lambda (heading key &optional scoped)
(function (let* ((heading-val
(lambda (heading key &optional scoped) (org-koma-letter--get-tagged-contents heading))
(let* ((heading-val (key-val (org-string-nw-p (plist-get info key)))
(org-koma-letter--get-tagged-contents heading)) (scopedp (funcall check-scope (or scoped heading))))
(key-val (org-string-nw-p (plist-get info key))) (and (or (and key-val scopedp) heading-val)
(scopedp (funcall check-scope (or scoped heading)))) (not (and (eq scope 'global) heading-val))
(and (or (and key-val scopedp) heading-val) (if scopedp key-val heading-val))))))
(not (and (eq scope 'global) heading-val))
(if scopedp key-val heading-val)))))))
(concat (concat
;; Name. ;; Name.
(let ((author (plist-get info :author))) (let ((author (plist-get info :author)))
@ -781,8 +780,8 @@ a communication channel."
;; From. ;; From.
(let ((from (funcall heading-or-key-value 'from :from-address))) (let ((from (funcall heading-or-key-value 'from :from-address)))
(and from (and from
(format "\\setkomavar{fromaddress}{%s}\n" (format "\\setkomavar{fromaddress}{%s}\n"
(org-koma-letter--add-latex-newlines from)))) (org-koma-letter--add-latex-newlines from))))
;; Email. ;; Email.
(let ((email (plist-get info :email))) (let ((email (plist-get info :email)))
(and email (and email
@ -817,41 +816,41 @@ a communication channel."
(if (plist-get info :with-from-logo) "true" "false"))) (if (plist-get info :with-from-logo) "true" "false")))
;; Signature. ;; Signature.
(let* ((heading-val (let* ((heading-val
(and (plist-get info :with-headline-opening) (and (plist-get info :with-headline-opening)
(pcase (org-koma-letter--get-tagged-contents 'closing) (pcase (org-koma-letter--get-tagged-contents 'closing)
((and (pred org-string-nw-p) closing) (org-trim closing)) ((and (pred org-string-nw-p) closing) (org-trim closing))
(_ nil)))) (_ nil))))
(signature (org-string-nw-p (plist-get info :signature))) (signature (org-string-nw-p (plist-get info :signature)))
(signature-scope (funcall check-scope 'signature))) (signature-scope (funcall check-scope 'signature)))
(and (or (and signature signature-scope) (and (or (and signature signature-scope)
heading-val) heading-val)
(not (and (eq scope 'global) heading-val)) (not (and (eq scope 'global) heading-val))
(format "\\setkomavar{signature}{%s}\n" (format "\\setkomavar{signature}{%s}\n"
(if signature-scope signature heading-val)))) (if signature-scope signature heading-val))))
;; Back address. ;; Back address.
(and (funcall check-scope 'with-backaddress) (and (funcall check-scope 'with-backaddress)
(format "\\KOMAoption{backaddress}{%s}\n" (format "\\KOMAoption{backaddress}{%s}\n"
(if (plist-get info :with-backaddress) "true" "false"))) (if (plist-get info :with-backaddress) "true" "false")))
;; Place. ;; Place.
(let ((with-place-set (funcall check-scope 'with-place)) (let ((with-place-set (funcall check-scope 'with-place))
(place-set (funcall check-scope 'place))) (place-set (funcall check-scope 'place)))
(and (or (and with-place-set place-set) (and (or (and with-place-set place-set)
(and (eq scope 'buffer) (or with-place-set place-set))) (and (eq scope 'buffer) (or with-place-set place-set)))
(format "\\setkomavar{place}{%s}\n" (format "\\setkomavar{place}{%s}\n"
(if (plist-get info :with-place) (plist-get info :place) (if (plist-get info :with-place) (plist-get info :place)
"")))) ""))))
;; Location. ;; Location.
(let ((location (funcall heading-or-key-value 'location :location))) (let ((location (funcall heading-or-key-value 'location :location)))
(and location (and location
(format "\\setkomavar{location}{%s}\n" location))) (format "\\setkomavar{location}{%s}\n" location)))
;; Folding marks. ;; Folding marks.
(and (funcall check-scope 'with-foldmarks) (and (funcall check-scope 'with-foldmarks)
(let ((foldmarks (plist-get info :with-foldmarks))) (let ((foldmarks (plist-get info :with-foldmarks)))
(cond ((consp foldmarks) (cond ((consp foldmarks)
(format "\\KOMAoptions{foldmarks=true,foldmarks=%s}\n" (format "\\KOMAoptions{foldmarks=true,foldmarks=%s}\n"
(mapconcat #'symbol-name foldmarks ""))) (mapconcat #'symbol-name foldmarks "")))
(foldmarks "\\KOMAoptions{foldmarks=true}\n") (foldmarks "\\KOMAoptions{foldmarks=true}\n")
(t "\\KOMAoptions{foldmarks=false}\n"))))))) (t "\\KOMAoptions{foldmarks=false}\n")))))))
@ -859,7 +858,7 @@ a communication channel."
;;;###autoload ;;;###autoload
(defun org-koma-letter-export-as-latex (defun org-koma-letter-export-as-latex
(&optional async subtreep visible-only body-only ext-plist) (&optional async subtreep visible-only body-only ext-plist)
"Export current buffer as a KOMA Scrlttr2 letter. "Export current buffer as a KOMA Scrlttr2 letter.
If narrowing is active in the current buffer, only export its If narrowing is active in the current buffer, only export its
@ -896,7 +895,7 @@ non-nil."
;;;###autoload ;;;###autoload
(defun org-koma-letter-export-to-latex (defun org-koma-letter-export-to-latex
(&optional async subtreep visible-only body-only ext-plist) (&optional async subtreep visible-only body-only ext-plist)
"Export current buffer as a KOMA Scrlttr2 letter (tex). "Export current buffer as a KOMA Scrlttr2 letter (tex).
If narrowing is active in the current buffer, only export its If narrowing is active in the current buffer, only export its
@ -928,13 +927,13 @@ directory.
Return output file's name." Return output file's name."
(interactive) (interactive)
(let ((outfile (org-export-output-file-name ".tex" subtreep)) (let ((outfile (org-export-output-file-name ".tex" subtreep))
(org-koma-letter-special-contents)) (org-koma-letter-special-contents))
(org-export-to-file 'koma-letter outfile (org-export-to-file 'koma-letter outfile
async subtreep visible-only body-only ext-plist))) async subtreep visible-only body-only ext-plist)))
;;;###autoload ;;;###autoload
(defun org-koma-letter-export-to-pdf (defun org-koma-letter-export-to-pdf
(&optional async subtreep visible-only body-only ext-plist) (&optional async subtreep visible-only body-only ext-plist)
"Export current buffer as a KOMA Scrlttr2 letter (pdf). "Export current buffer as a KOMA Scrlttr2 letter (pdf).
If narrowing is active in the current buffer, only export its If narrowing is active in the current buffer, only export its
@ -963,7 +962,7 @@ file-local settings.
Return PDF file's name." Return PDF file's name."
(interactive) (interactive)
(let ((file (org-export-output-file-name ".tex" subtreep)) (let ((file (org-export-output-file-name ".tex" subtreep))
(org-koma-letter-special-contents)) (org-koma-letter-special-contents))
(org-export-to-file 'koma-letter file (org-export-to-file 'koma-letter file
async subtreep visible-only body-only ext-plist async subtreep visible-only body-only ext-plist
(lambda (file) (org-latex-compile file))))) (lambda (file) (org-latex-compile file)))))