From 16fe81deb90bd7eca503a94bc3cd53b366a3259a Mon Sep 17 00:00:00 2001 From: Rasmus Pank Roulund Date: Mon, 25 Nov 2013 00:23:09 +0100 Subject: [PATCH 3/3] Allow separate subject and title in ox-koma-letter * ox-koma-letter.el (org-koma-letter-use-title): New variable. (org-koma-letter-title-is-subject-maybe): New variable. (koma-letter-template): Allow seperate subject and title. (org-koma-letter-template): Allow seperate subject and title. Depending on the variable `org-koma-letter-title-is-subject-maybe' the komavar "subject" may be set either with the TITLE keyword or with the SUBJECT keyword. It is now possible to typeset komavar title. --- contrib/lisp/ox-koma-letter.el | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index ef9f624..4f3fc57 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -275,6 +275,13 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'boolean) +(defcustom org-koma-letter-use-title t + "Use a title in the letter. + +See also `org-koma-letter-title-is-subject-maybe'." + :group 'org-export-koma-letter + :type 'boolean) + (defcustom org-koma-letter-default-class nil "Default class for `org-koma-letter'. @@ -290,6 +297,14 @@ A headline is only used if #+OPENING is not set. See also :group 'org-export-koma-letter :type 'boolean) +(defcustom org-koma-letter-title-is-subject-maybe nil + "Let TITLE keyword be interpreted as subject when no subject is present if non-nil. + +This may be useful for older documents where the SUBJECT keyword +was not present." + :group 'org-export-koma-letter + :type 'boolean) + (defconst org-koma-letter-special-tags-in-letter '(to from) "Header tags related to the letter itself.") @@ -318,6 +333,7 @@ A headline is only used if #+OPENING is not set. See also org-koma-letter-default-class org-latex-default-class) t) (:author "AUTHOR" nil (org-koma-letter--get-value org-koma-letter-author) t) + (:subject "SUBJECT" nil nil space) (:from-address "FROM_ADDRESS" nil nil newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) (:email "EMAIL" nil (org-koma-letter--get-value org-koma-letter-email) t) @@ -341,7 +357,9 @@ A headline is only used if #+OPENING is not set. See also (:with-phone nil "phone" org-koma-letter-use-phone) (:with-email nil "email" org-koma-letter-use-email) (:with-place nil "place" org-koma-letter-use-place) - (:with-subject nil "subject" org-koma-letter-subject-format)) + (:with-subject nil "subject" org-koma-letter-subject-format) + (:with-title nil "title" org-koma-letter-use-title) + ) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (headline . org-koma-letter-headline) @@ -662,14 +680,20 @@ holding export options." (cond ((member with-subject '("true" "t" t)) nil) ((listp with-subject) with-subject) (t (list with-subject))))) - (subject (org-export-data (plist-get info :title) info))) + (prefer-subject org-koma-letter-title-is-subject-maybe) + (subject* (org-export-data (plist-get info :subject) info)) + (title* (org-export-data (plist-get info :title) info)) + (subject (if prefer-subject (or subject* title*) subject*)) + (title (if prefer-subject (and subject* title*) title*)) + ) (concat (when (and with-subject subject-format) (concat "\\KOMAoption{subject}{" (mapconcat 'identity subject-format ",") "}\n" )) (when (and subject with-subject) - (format "\\setkomavar{subject}{%s}\n\n" subject)))) + (format "\\setkomavar{subject}{%s}\n\n" subject)) + (when title (format "\\setkomavar{title}{%s}\n\n" title)))) ;; Document start "\\begin{document}\n\n" ;; Letter start -- 1.8.5.3