add option to define opening and closing of org export letter

This commit is contained in:
2021-05-16 17:01:11 +02:00
parent 4a338ca774
commit 0c13b4dd6e
2 changed files with 31 additions and 7 deletions

View File

@@ -568,6 +568,7 @@ IMPORTANT en version must be defined")
"[paper=a4,fontsize=11pt,DIV=12,BCOR=10mm,headsepline,<<documentclass>>,captions=tableheading,version=first,bibliography=totoc,dvipsnames]" "[paper=a4,fontsize=11pt,DIV=12,BCOR=10mm,headsepline,<<documentclass>>,captions=tableheading,version=first,bibliography=totoc,dvipsnames]"
"The default LaTeX class options. "The default LaTeX class options.
Replaces <<...>> with values defined in
`my-org-article-latex-lang-template-plist'" `my-org-article-latex-lang-template-plist'"
:group 'my-org-export-article :group 'my-org-export-article
:type '(string :tag "LaTeX class")) :type '(string :tag "LaTeX class"))
@@ -2084,6 +2085,7 @@ IMPORTANT en version must be defined")
" "
"Preamble options. "Preamble options.
Text like <<...>>> will be replaced according to
`my-org-article-latex-lang-template-plist'" `my-org-article-latex-lang-template-plist'"
:group 'my-org-export-article) :group 'my-org-export-article)

View File

@@ -48,7 +48,9 @@
(defvar my-org-letter-latex-default-class-options) (defvar my-org-letter-latex-default-class-options)
(defvar my-org-letter-latex-default-header) (defvar my-org-letter-latex-default-header)
(defvar my-org-letter-latex-default-header-extra) (defvar my-org-letter-latex-default-header-extra)
(defvar my-org-letter-latex-opening-format)
(defvar my-org-letter-latex-opening) (defvar my-org-letter-latex-opening)
(defvar my-org-letter-latex-closing-format)
(defvar my-org-letter-latex-closing) (defvar my-org-letter-latex-closing)
(defvar my-org-letter-latex-subject) (defvar my-org-letter-latex-subject)
(defvar my-org-letter-latex-subject-extra) (defvar my-org-letter-latex-subject-extra)
@@ -103,7 +105,9 @@
(:latex-header "LATEX_HEADER" nil my-org-letter-latex-default-header newline) (:latex-header "LATEX_HEADER" nil my-org-letter-latex-default-header newline)
(:latex-header-extra "LATEX_HEADER_EXTRA" nil my-org-letter-latex-default-header-extra newline) (:latex-header-extra "LATEX_HEADER_EXTRA" nil my-org-letter-latex-default-header-extra newline)
(:latex-compiler "LATEX_COMPILER" nil my-org-letter-latex-compiler) (:latex-compiler "LATEX_COMPILER" nil my-org-letter-latex-compiler)
(:letter-closing-format "CLOSING_FORMAT" nil my-org-letter-latex-closing-format newline)
(:letter-closing "CLOSING" nil my-org-letter-latex-closing newline) (:letter-closing "CLOSING" nil my-org-letter-latex-closing newline)
(:letter-opening-format "OPENING_FORMAT" nil my-org-letter-latex-opening-format newline)
(:letter-opening "OPENING" nil my-org-letter-latex-opening newline) (:letter-opening "OPENING" nil my-org-letter-latex-opening newline)
(:letter-subject "SUBJECT" nil my-org-letter-latex-subject newline) (:letter-subject "SUBJECT" nil my-org-letter-latex-subject newline)
(:letter-subject-extra "SUBJECT_EXTRA" nil my-org-letter-latex-subject-extra newline) (:letter-subject-extra "SUBJECT_EXTRA" nil my-org-letter-latex-subject-extra newline)
@@ -244,7 +248,7 @@
;;;; Document ;;;; Document
(defcustom my-org-letter-latex-opening (defcustom my-org-letter-latex-opening-format
"\\firsthead{ "\\firsthead{
\\begin{flushright}\\textsf{\\begin{tabular}{l} \\begin{flushright}\\textsf{\\begin{tabular}{l}
\\fromassociation \\\\ \\usekomavar{fromname} \\\\ \\fromstreet \\\\ \\fromassociation \\\\ \\usekomavar{fromname} \\\\ \\fromstreet \\\\
@@ -262,13 +266,23 @@
\\setkomavar{subject}{\\subject \\\\ {\\normalfont \\subjectextra}} \\setkomavar{subject}{\\subject \\\\ {\\normalfont \\subjectextra}}
\\opening{Sehr geehrter \\toname,}" \\opening{<<opening>>}"
"Letter opening." "Letter opening structure, will replace <<opening>> with `my-org-letter-latex-opening'."
:group 'my-org-letter-latex)
(defcustom my-org-letter-latex-opening
"Sehr geehrter \\toname,"
"Letter opening, see also `my-org-letter-latex-opening-format'."
:group 'my-org-letter-latex)
(defcustom my-org-letter-latex-closing-format
"\\closing{<<closing>>}"
"Letter closing structure, will replace <<closing>> with `my-org-letter-latex-closing'."
:group 'my-org-letter-latex) :group 'my-org-letter-latex)
(defcustom my-org-letter-latex-closing (defcustom my-org-letter-latex-closing
"\\closing{Freundliche Grüße,}" "Freundliche Grüße,"
"Letter closing." "Letter closing, see also `my-org-letter-latex-closing-format'."
:group 'my-org-letter-latex) :group 'my-org-letter-latex)
@@ -385,9 +399,17 @@
(format "\\setcounter{tocdepth}{%d}\n" depth)) (format "\\setcounter{tocdepth}{%d}\n" depth))
(plist-get info :latex-toc-command)))) (plist-get info :latex-toc-command))))
;; Document's body. ;; Document's body.
(concat (plist-get info :letter-opening) "\n") (concat (string-replace
"<<opening>>"
(plist-get info :letter-opening)
(plist-get info :letter-opening-format))
"\n")
contents contents
(concat (plist-get info :letter-closing) "\n") (concat (string-replace
"<<closing>>"
(plist-get info :letter-closing)
(plist-get info :letter-closing-format))
"\n")
;; attachments ;; attachments
(let ((attachments (plist-get info :letter-attachment))) (let ((attachments (plist-get info :letter-attachment)))
(unless (string-equal attachments "") (unless (string-equal attachments "")