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.

Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
This commit is contained in:
rasmus.pank 2013-05-19 17:32:44 +02:00 committed by Alan Schmitt
parent 7542aabb44
commit 26a9b02483
1 changed files with 52 additions and 11 deletions

View File

@ -4,6 +4,8 @@
;; Author: Nicolas Goaziou <n.goaziou AT gmail DOT com>
;; 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
@ -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"))