From d743e01fe6cd8a17f40140b0f33e8550c37740a4 Mon Sep 17 00:00:00 2001 From: Rasmus 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 | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 2705d86..d6a037b 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -36,12 +36,13 @@ ;; keywords: ;; - "CLOSING" (see `org-koma-letter-closing'), ;; - "FROM_ADDRESS" (see `org-koma-letter-from-address'), +;; - "TO_ADDRESS". If unspecified this is set to "\mbox{}". ;; - "LCO" (see `org-koma-letter-class-option-file'), ;; - "OPENING" (see `org-koma-letter-opening'), ;; - "PHONE_NUMBER" (see `org-koma-letter-phone-number'), ;; - "SIGNATURE" (see `org-koma-letter-signature') ;; - "PLACE" (see `org-koma-letter-place') -;; - and "TO_ADDRESS". If unspecified this is set to "\mbox{}". +;; - "SUBJECT" (see `org-koma-letter-title-is-subject-maybe') ;; ;; TO_ADDRESS and FROM_ADDRESS can also be specified using heading ;; with the special tags specified in @@ -50,6 +51,9 @@ ;; both a headline and a keyword specify a to or from address the ;; value is determined in accordance with ;; `org-koma-letter-prefer-special-headings'. +;; If `org-koma-letter-title-is-subject-maybe' is t both SUBJECT and +;; TITLE can be used to set the subject. If both are set they take +;; the value as indicated by name. ;; ;; A number of OPTIONS settings can be set to change which contents is ;; exported. @@ -60,6 +64,7 @@ ;; - place (see `org-koma-letter-use-place') ;; - subject, a list of format options ;; (see `org-koma-letter-subject-format') +;; - title (see `org-koma-letter-use-title') ;; - after-closing-order, a list of the ordering of headings with ;; special tags after closing (see ;; `org-koma-letter-special-tags-after-closing') @@ -271,6 +276,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'. @@ -285,6 +297,12 @@ 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 t + "Whether the TITLE keyword should be interpreted as subject +when no subject is 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.") @@ -313,6 +331,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) @@ -336,7 +355,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) @@ -657,14 +678,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.4.2