Function: org-koma-letter--build-settings
org-koma-letter--build-settings is a byte-compiled function defined in
ox-koma-letter.el.gz.
Signature
(org-koma-letter--build-settings SCOPE INFO)
Documentation
Build settings string according to type.
SCOPE is either global or buffer. INFO is a plist used as
a communication channel.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-koma-letter.el.gz
(defun org-koma-letter--build-settings (scope info)
"Build settings string according to type.
SCOPE is either `global' or `buffer'. INFO is a plist used as
a communication channel."
(let* ((check-scope
;; Non-nil value when SETTING was defined in SCOPE.
(lambda (setting)
(let ((property (intern (format ":inbuffer-%s" setting))))
(if (eq scope 'global)
(eq (plist-get info property) 'koma-letter:empty)
(not (eq (plist-get info property) 'koma-letter:empty))))))
(heading-or-key-value
(lambda (heading key &optional scoped)
(let* ((heading-val
(org-koma-letter--get-tagged-contents heading))
(key-val (org-string-nw-p (plist-get info key)))
(scopedp (funcall check-scope (or scoped heading))))
(and (or (and key-val scopedp) heading-val)
(not (and (eq scope 'global) heading-val))
(if scopedp key-val heading-val))))))
(concat
;; Name.
(let ((author (plist-get info :author)))
(and author
(funcall check-scope 'author)
(format "\\setkomavar{fromname}{%s}\n"
(org-export-data author info))))
;; From.
(let ((from (funcall heading-or-key-value 'from :from-address)))
(and from
(format "\\setkomavar{fromaddress}{%s}\n"
(org-koma-letter--add-latex-newlines from))))
;; Email.
(let ((email (plist-get info :email)))
(and email
(funcall check-scope 'email)
(format "\\setkomavar{fromemail}{%s}\n" email)))
(and (funcall check-scope 'with-email)
(format "\\KOMAoption{fromemail}{%s}\n"
(if (plist-get info :with-email) "true" "false")))
;; Phone number.
(let ((phone-number (plist-get info :phone-number)))
(and (org-string-nw-p phone-number)
(funcall check-scope 'phone-number)
(format "\\setkomavar{fromphone}{%s}\n" phone-number)))
(and (funcall check-scope 'with-phone)
(format "\\KOMAoption{fromphone}{%s}\n"
(if (plist-get info :with-phone) "true" "false")))
;; URL
(let ((url (plist-get info :url)))
(and (org-string-nw-p url)
(funcall check-scope 'url)
(format "\\setkomavar{fromurl}{%s}\n" url)))
(and (funcall check-scope 'with-url)
(format "\\KOMAoption{fromurl}{%s}\n"
(if (plist-get info :with-url) "true" "false")))
;; From Logo
(let ((from-logo (plist-get info :from-logo)))
(and (org-string-nw-p from-logo)
(funcall check-scope 'from-logo)
(format "\\setkomavar{fromlogo}{%s}\n" from-logo)))
(and (funcall check-scope 'with-from-logo)
(format "\\KOMAoption{fromlogo}{%s}\n"
(if (plist-get info :with-from-logo) "true" "false")))
;; Signature.
(let* ((heading-val
(and (plist-get info :with-headline-opening)
(pcase (org-koma-letter--get-tagged-contents 'closing)
((and (pred org-string-nw-p) closing) (org-trim closing))
(_ nil))))
(signature (org-string-nw-p (plist-get info :signature)))
(signature-scope (funcall check-scope 'signature)))
(and (or (and signature signature-scope)
heading-val)
(not (and (eq scope 'global) heading-val))
(format "\\setkomavar{signature}{%s}\n"
(if signature-scope signature heading-val))))
;; Back address.
(and (funcall check-scope 'with-backaddress)
(format "\\KOMAoption{backaddress}{%s}\n"
(if (plist-get info :with-backaddress) "true" "false")))
;; Place.
(let ((with-place-set (funcall check-scope 'with-place))
(place-set (funcall check-scope 'place)))
(and (or (and with-place-set place-set)
(and (eq scope 'buffer) (or with-place-set place-set)))
(format "\\setkomavar{place}{%s}\n"
(if (plist-get info :with-place) (plist-get info :place)
""))))
;; Location.
(let ((location (funcall heading-or-key-value 'location :location)))
(and location
(format "\\setkomavar{location}{%s}\n" location)))
;; Folding marks.
(and (funcall check-scope 'with-foldmarks)
(let ((foldmarks (plist-get info :with-foldmarks)))
(cond ((consp foldmarks)
(format "\\KOMAoptions{foldmarks=true,foldmarks=%s}\n"
(mapconcat #'symbol-name foldmarks "")))
(foldmarks "\\KOMAoptions{foldmarks=true}\n")
(t "\\KOMAoptions{foldmarks=false}\n")))))))