summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViktor Rosenfeld <hesk@cartman>2013-04-21 16:34:35 +0200
committerAlan Schmitt <alan.schmitt@polytechnique.org>2013-04-23 09:17:20 +0200
commitbb03429cf8561cb2b728a90d0cadfe7a3f8f0fa6 (patch)
tree7923da4e8483f820ec995835892d06476d1a12db
parentcab6718d4b41f1fb9127384ddeac33f3afbec338 (diff)
downloadorg-mode-bb03429cf8561cb2b728a90d0cadfe7a3f8f0fa6.tar.gz
ox-koma-letter: Export options to control letter
* ox-koma-letter.el ((org-koma-letter-use-subject): Configure printing of subject line. (org-koma-letter-use-backaddress): Configure presence of back address. (org-koma-letter-use-foldmarks): Configure presence of foldmarks. (org-koma-letter-use-phone): Configure printing of phone number. (org-koma-letter-use-email): Configure printing of email. (org-koma-letter-use-place): Configure printing of place. (koma-letter): Add export option to exporter backend. (org-koma-letter-template): Evaluate export options in exporter template. Usage: #+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t Except for `subject', all options are boolean, i.e., the accept the values `nil' and `t'. `subject' accepts the values defined in `scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left', `right', `titled', `underlined', and `untitled'. Signed-off-by: Alan Schmitt <alan.schmitt@polytechnique.org>
-rw-r--r--contrib/lisp/ox-koma-letter.el90
1 files changed, 77 insertions, 13 deletions
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 5397cf0..f313ac7 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -80,8 +80,8 @@
:group 'org-export-koma-letter
:type 'string)
-(defcustom org-koma-letter-closing "Sincerely yours,"
- "Koma-Letter's closing, as a string."
+(defcustom org-koma-letter-sender nil
+ "Sender's name, as a string."
:group 'org-export-koma-letter
:type 'string)
@@ -90,13 +90,28 @@
:group 'org-export-koma-letter
:type 'string)
+(defcustom org-koma-letter-phone-number nil
+ "Sender's phone number, as a string."
+ :group 'org-export-koma-letter
+ :type 'string)
+
+(defcustom org-koma-letter-email nil
+ "Sender's email, as a string."
+ :group 'org-export-koma-letter
+ :type 'string)
+
+(defcustom org-koma-letter-place nil
+ "Place from which the letter is sent."
+ :group 'org-export-koma-letter
+ :type 'string)
+
(defcustom org-koma-letter-opening "Dear Madam or Sir,"
"Letter's opening, as a string."
:group 'org-export-koma-letter
:type 'string)
-(defcustom org-koma-letter-phone-number nil
- "Sender's phone number, as a string."
+(defcustom org-koma-letter-closing "Sincerely yours,"
+ "Koma-Letter's closing, as a string."
:group 'org-export-koma-letter
:type 'string)
@@ -105,15 +120,35 @@
:group 'org-export-koma-letter
:type 'string)
-(defcustom org-koma-letter-sender nil
- "Sender's name, as a 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-email nil
- "Sender's email, as a string."
+(defcustom org-koma-letter-use-backaddress t
+ "Print return address in small line above to address."
:group 'org-export-koma-letter
- :type 'string)
+ :type 'boolean)
+
+(defcustom org-koma-letter-use-foldmarks t
+ "Print foldmarks."
+ :group 'org-export-koma-letter
+ :type 'boolean)
+
+(defcustom org-koma-letter-use-phone t
+ "Print sender's phone number."
+ :group 'org-export-koma-letter
+ :type 'boolean)
+
+(defcustom org-koma-letter-use-email t
+ "Print sender's email address."
+ :group 'org-export-koma-letter
+ :type 'boolean)
+
+(defcustom org-koma-letter-use-place t
+ "Print the letter's place next to the date."
+ :group 'org-export-koma-letter
+ :type 'boolean)
;;; Define Back-End
@@ -126,9 +161,17 @@
(:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number)
(:email "EMAIL" nil org-koma-letter-email)
(:to-address "TO_ADDRESS" nil nil newline)
+ (:place "PLACE" nil org-koma-letter-place)
(:opening "OPENING" nil org-koma-letter-opening)
(:closing "CLOSING" nil org-koma-letter-closing)
- (:signature "SIGNATURE" nil org-koma-letter-signature newline))
+ (:signature "SIGNATURE" nil org-koma-letter-signature newline)
+
+ (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress)
+ (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks)
+ (: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))
:translate-alist '((export-block . org-koma-letter-export-block)
(export-snippet . org-koma-letter-export-snippet)
(keyword . org-koma-letter-keyword)
@@ -226,10 +269,31 @@ holding export options."
(when signature (format "\\setkomavar{signature}{%s}\n" signature))))
;; Date.
(format "\\date{%s}\n" (org-export-data (org-export-get-date info) info))
- ;; Letter start.
+ ;; Place
+ (let ((with-place (plist-get info :with-place))
+ (place (plist-get info :place)))
+ (when (or place (not with-place))
+ (format "\\setkomavar{place}{%s}\n" (if with-place place ""))))
+ ;; KOMA options
+ (let ((with-backaddress (plist-get info :with-backaddress))
+ (with-foldmarks (plist-get info :with-foldmarks))
+ (with-phone (plist-get info :with-phone))
+ (with-email (plist-get info :with-email)))
+ (concat
+ (format "\\KOMAoption{backaddress}{%s}\n" (if with-backaddress "true" "false"))
+ (format "\\KOMAoption{foldmarks}{%s}\n" (if with-foldmarks "true" "false"))
+ (format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false"))
+ (format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false"))))
+ ;; Document start
"\\begin{document}\n\n"
- (format "\\setkomavar{subject}{%s}\n\n"
- (org-export-data (plist-get info :title) info))
+ ;; 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)))))
+ ;; Letter start
(format "\\begin{letter}{%%\n%s}\n\n"
(or (plist-get info :to-address) "no address given"))
;; Opening.