ox-koma-letter: Tiny refactoring and cosmetics
This commit is contained in:
parent
a8677adb49
commit
f5d5a95018
|
@ -125,6 +125,7 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'ox-latex)
|
||||
|
||||
;; Install a default letter class.
|
||||
|
@ -551,12 +552,12 @@ return a string or nil."
|
|||
|
||||
(defun org-koma-letter--special-contents-inline (keywords info)
|
||||
"Process KEYWORDS members of `org-koma-letter-special-contents'.
|
||||
|
||||
KEYWORDS is a list of symbols. Return them as a string to be
|
||||
formatted.
|
||||
|
||||
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
|
||||
(lambda (keyword)
|
||||
(let* ((name (org-koma-letter--get-value keyword))
|
||||
|
@ -585,7 +586,8 @@ such as the one tagged with PS.
|
|||
"Transcode an EXPORT-BLOCK element into KOMA Scrlttr2 code.
|
||||
CONTENTS is nil. INFO is a plist used as a communication
|
||||
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))))
|
||||
|
||||
;;;; Export Snippet
|
||||
|
@ -635,10 +637,8 @@ special tag headline."
|
|||
(plist-get info :special-tags-in-letter)
|
||||
(plist-get info :special-tags-after-closing)
|
||||
(plist-get info :special-tags-after-letter))))
|
||||
(catch 'exit
|
||||
(dolist (tag (org-export-get-tags headline info))
|
||||
(let ((tag (assoc-string tag special-tags)))
|
||||
(when tag (throw 'exit tag)))))))
|
||||
(cl-some (lambda (tag) (and (assoc-string tag special-tags) tag))
|
||||
(org-export-get-tags headline info))))
|
||||
|
||||
(defun org-koma-letter--keyword-or-headline (plist-key pred info)
|
||||
"Return the correct version of opening or closing.
|
||||
|
@ -654,8 +654,8 @@ PLIST-KEY."
|
|||
(not keyword-candidate)))
|
||||
(org-element-map (plist-get info :parse-tree)
|
||||
'headline
|
||||
(lambda (head)
|
||||
(when (funcall pred head info)
|
||||
(lambda (h)
|
||||
(and (funcall pred h info)
|
||||
(org-element-property :title head)))
|
||||
info t))))
|
||||
(org-export-data (or headline-candidate keyword-candidate "") info)))
|
||||
|
@ -737,8 +737,9 @@ holding export options."
|
|||
;; Closing.
|
||||
(format "\\closing{%s}\n"
|
||||
(org-koma-letter--keyword-or-headline
|
||||
:closing (lambda (h i) (eq (org-koma-letter--special-tag h i)
|
||||
'closing))
|
||||
:closing
|
||||
(lambda (h i)
|
||||
(eq (org-koma-letter--special-tag h i) 'closing))
|
||||
info))
|
||||
(org-koma-letter--special-contents-inline
|
||||
(plist-get info :special-tags-after-closing) info)
|
||||
|
@ -754,15 +755,13 @@ holding export options."
|
|||
SCOPE is either `global' or `buffer'. INFO is a plist used as
|
||||
a communication channel."
|
||||
(let* ((check-scope
|
||||
(function
|
||||
;; 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)))))))
|
||||
(not (eq (plist-get info property) 'koma-letter:empty))))))
|
||||
(heading-or-key-value
|
||||
(function
|
||||
(lambda (heading key &optional scoped)
|
||||
(let* ((heading-val
|
||||
(org-koma-letter--get-tagged-contents heading))
|
||||
|
@ -770,7 +769,7 @@ a communication channel."
|
|||
(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)))))))
|
||||
(if scopedp key-val heading-val))))))
|
||||
(concat
|
||||
;; Name.
|
||||
(let ((author (plist-get info :author)))
|
||||
|
|
Loading…
Reference in New Issue