>From dc9589140c9fdc05290efeaedff46c35e3e902e1 Mon Sep 17 00:00:00 2001
From: "rasmus.pank"
Date: Sun, 19 May 2013 17:32:44 +0200
Subject: [PATCH 4/4] ox-koma-letter: changed handling of subject
* ox-koma-letter.el: =`org-koma-letter-subject-format'= can now be a list. Default is t.
If nil neither subject format nor type is exported.
* ox-koma-letter.el (org-koma-letter-template): better subject handling.
* ox-koma-letter.el (org-koma-letter-template): allow for t value of =#+OPTIONS: subject:VALUE=
* ox-koma-letter.el (org-koma-letter-template): export of subject format is independent
of title, but title is not independent of =:with-subject=.
The issue was with =#+OPTIONS: subject:t= one would get a LaTeX error.
New behavior:
If =#+OPTIONS: subject:(x,y)= then =\KOMAoption{subject}{x, y}=.
If =subject:x= then =\KOMAoption{subject}{x}=.
If =subject:t= then =\KOMAoption{subject}{...}= is not set but
\setkomavar{subject}{...} is set (in the output file)
If =subject:nil= neither are printed.
---
contrib/lisp/ox-koma-letter.el | 63 ++++++++++++++++++++++++++++++++++--------
1 file changed, 52 insertions(+), 11 deletions(-)
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 30671e5..4af0ba7 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -4,6 +4,8 @@
;; Author: Nicolas Goaziou
;; Alan Schmitt
+;; Viktor Rosenfeld
+;; Rasmus Pank Roulund
;; Keywords: org, wp, tex
;; This program is free software: you can redistribute it and/or modify
@@ -135,10 +137,36 @@ function may be given. Functions must return a string."
:group 'org-export-koma-letter
:type 'string)
-(defcustom org-koma-letter-use-subject "untitled"
- "Use the title as the letter's subject."
- :group 'org-export-koma-letter
- :type 'string)
+(defcustom org-koma-letter-subject-format t
+ "Use the title as the subject of the letter. At the time of
+writing the following values are allowed:
+
+ - afteropening: subject after opening
+ - beforeopening: subject before opening
+ - centered: subject centered
+ - left:subject left-justified
+ - right: subject right-justified
+ - titled: add title/description to subject
+ - underlined: set subject underlined (see note in text please)
+ - untitled: do not add title/description to subject.
+ - No-export: do no insert a subject even if present.
+
+Please refer to the KOMA-script manual (Table 4.16. in the
+English manual of 2012-07-22)"
+ :type '(set (const "afteropening")
+ (const "beforeopening")
+ (const "centered")
+ (const "left")
+ (const "right")
+ (const "underlined")
+ (const "titled")
+ (const "untitled")
+ (const :tag "No export" nil)
+ (const :tag "Default options" t)
+ (string))
+ :group 'org-export-koma-letter)
+
+
(defcustom org-koma-letter-use-backaddress t
"Print return address in small line above to address."
@@ -208,7 +236,7 @@ content temporarily.")
(: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-use-subject))
+ (:with-subject nil "subject" org-koma-letter-subject-format))
:translate-alist '((export-block . org-koma-letter-export-block)
(export-snippet . org-koma-letter-export-snippet)
(headline . org-koma-letter-headline)
@@ -411,12 +439,25 @@ holding export options."
;; Document start
"\\begin{document}\n\n"
;; Subject
- (let ((with-subject (plist-get info :with-subject)))
- (when with-subject
- (concat
- (format "\\KOMAoption{subject}{%s}\n" with-subject)
- (format "\\setkomavar{subject}{%s}\n\n"
- (org-export-data (plist-get info :title) info)))))
+ (let* ((with-subject (plist-get info :with-subject))
+ (subject-format (cond ((member with-subject '("true" "t" t)) nil)
+ ((stringp with-subject) (list with-subject))
+ ((symbolp with-subject)
+ (list (symbol-name with-subject)))
+ (t with-subject)))
+ (subject (org-export-data (plist-get info :title) info))
+ (l (length subject-format))
+ (y ""))
+ (concat
+ (when (and with-subject subject-format)
+ (concat
+ "\\KOMAoption{subject}{"
+ (apply 'format
+ (dotimes (x l y)
+ (setq y (concat (if (> x 0) "%s," "%s") y)))
+ subject-format) "}\n"))
+ (when (and subject with-subject)
+ (format "\\setkomavar{subject}{%s}\n\n" subject))))
;; Letter start
(format "\\begin{letter}{%%\n%s}\n\n"
(or (plist-get info :to-address) "no address given"))
--
1.8.2.3