>> This could be a problematic change. It changes the way :with-subject
>> works. I've added changes to allow the subject style to be choose as
>> a radio list with customize. The reason is that LaTeX becomes unhappy
>> if it is not a supported value. If #+OPTIONS subject:t the default is
>> used. If #+OPTIONS subject:my-crazy-string it tries that and most
>> likely hell will break loose.
>>
>> Viktor, you're usage of ox-koma-letter.el is quite different from mine
>> in that you rely (heavily?) on LCO files. If you could test this and
>> see what you think of it it would be great. On my system it doesn't
>> break anything vital but I might have missed something.
>
> According to my very limited emacs-lisp knowledge, this looks fine.
I found a "bug" in that the subject variable should be a list cf. the
KOMA manual. This patch fixes this.
It's pretty complex for something so simple, and I might be inclined
to admit to the "put it in a LCO"-file approach might be better.
>From the commit message:
If =#+OPTIONS:subject:nil= neither =\setkomavar{subject}{.}= nor
=\KOMAoption{subject}{.}= are exported.
If =#+OPTIONS:subject:t= =`org-koma-letter-subject-format'= is used
for =\KOMAoption{subject}{.}=.
If =#+OPTIONS:subject:(x y z)= then =\KOMAoption{subject}{x,y,z}=.
> beavior -> behavior
> fteropening -> afteropening
> No-export -> noexport (so that it looks like the other ones).
Thanks! I should run wcheck when coding . . .
–Rasmus
--
Powered by magic pixies!
>From d11e4fd682ac593da04c3e4c8edf5eb84c9d0c59 Mon Sep 17 00:00:00 2001
From: "rasmus.pank" <rasmus.p...@gmail.com>
Date: Sun, 19 May 2013 17:32:44 +0200
Subject: [PATCH 2/4] ox-koma-letter: changed handling of subject
* ox-koma-letter.el: =`org-koma-letter-subject-format'= is now a
set list. If nil neither subject format nor type is
exported.
* ox-koma-letter.el: allow for t value of =#+OPTIONS: subject:VALUE=
* ox-koma-letter.el: 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.
New behavior:
If =#+OPTIONS:subject:nil= neither =\setkomavar{subject}{.}= nor
=\KOMAoption{subject}{.}= are exported.
If =#+OPTIONS:subject:t= =`org-koma-letter-subject-format'= is used
for =\KOMAoption{subject}{.}=.
If =#+OPTIONS:subject:(x y z)= then \KOMAoption{subject}{x,y,z}.
---
contrib/lisp/ox-koma-letter.el | 65 ++++++++++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 12 deletions(-)
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 2389025..6a3811f 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -6,7 +6,6 @@
;; Alan Schmitt <alan.schmitt AT polytechnique DOT org>
;; Viktor Rosenfeld <listuser36 AT gmail DOT com>
;; Rasmus Pank Roulund <emacs AT pank DOT eu>
-
;; Keywords: org, wp, tex
;; This program is free software: you can redistribute it and/or modify
@@ -123,10 +122,35 @@
: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 '("beforeopening" "left" "untitled")
+ "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)
+ (string))
+ :group 'org-export-koma-letter)
+
+
(defcustom org-koma-letter-use-backaddress t
"Print return address in small line above to address."
@@ -179,7 +203,7 @@ Use `foldmarks:true' to activate default fold marks or
(: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)
(keyword . org-koma-letter-keyword)
@@ -300,12 +324,29 @@ 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
+ (if (member
+ ;; test if subject-format is t
+ (cond ((symbolp with-subject) (downcase (symbol-name with-subject)))
+ ((stringp with-subject) (downcase with-subject))
+ (t nil))
+ '("true" "t"))
+ org-koma-letter-subject-format
+ with-subject))
+ (subject (org-export-data (plist-get info :title) info))
+ (l (if (stringp subject-format) 1 (length subject-format)))
+ (y ""))
+ (concat
+ (when with-subject
+ (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