From f74eaae6c4610701899f7127537acbc8fa88a10f Mon Sep 17 00:00:00 2001 From: rasmus Date: Sun, 2 Jun 2013 17:59:48 +0200 Subject: [PATCH 3/3] Possible to set default class for ox koma letters. * ox-koma-letter.el (org-koma-letter-default-class): default class for =ox-koma-letter=. Default is nil. * ox-koma-letter.el (org-koma-letter-plug-into-ox): add a sparse letter class to =`org-latex-class'= and set it to default. By default it will use =`org-latex-default-class'=. --- contrib/lisp/ox-koma-letter.el | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index e70b8c4..61df703 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -65,9 +65,21 @@ ;; copy (cc), commencements (encl) and code to be inserted after ;; \end{letter} (after_letter). ;; +;; Headlines with two and from may also be used rather than the +;; keyword approach described above. If both a keyword and a headline +;; with information is present precedence is determined by +;; `org-koma-letter-prefer-special-headings'. +;; ;; You will need to add an appropriate association in -;; `org-latex-classes' in order to use the KOMA Scrlttr2 class. For -;; example, you can use the following code: +;; `org-latex-classes' in order to use the KOMA Scrlttr2 class. +;; The easiest way to do this is by adding +;; +;; (eval-after-load "ox-koma-letter" +;; '(org-koma-letter-plug-into-ox)) +;; +;; to your init file. This will add a very sparse scrlttr2 class and +;; set it as the default `org-koma-latex-default-class'. You can also +;; add you own letter class. For instace: ;; ;; (add-to-list 'org-latex-classes ;; '("my-letter" @@ -88,7 +100,8 @@ ;; with : ;; ;; #+LATEX_CLASS: my-letter - +;; +;; Or by setting `org-koma-letter-default-class'. ;;; Code: @@ -231,6 +244,12 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'boolean) +(defcustom org-koma-letter-default-class nil + "Default class for `org-koma-letter'. Must be a member of + `org-latex-classes'" + :group 'org-export-koma-letter + :type 'string) + (defconst org-koma-letter-special-tags-in-letter '(to from) "header tags related to the letter itself") @@ -250,6 +269,9 @@ Use `foldmarks:true' to activate default fold marks or (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) + (:latex-class "LATEX_CLASS" nil (if org-koma-letter-default-class + org-koma-letter-default-class + org-latex-default-class) t) (:author "AUTHOR" nil (org-koma-letter--get-custom org-koma-letter-author) t) (:from-address "FROM_ADDRESS" nil nil newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) @@ -291,6 +313,19 @@ Use `foldmarks:true' to activate default fold marks or (org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) +;;; Initialize class function + +(defun org-koma-letter-plug-into-ox () + "Add a sparse `default-koma-letter' to `org-latex-classes' and set +`org-koma-letter-default-class' to `default-koma-letter'" + (let ((class "default-koma-letter")) + (eval-after-load "ox-latex" + '(add-to-list 'org-latex-classes + `(,class + "\\documentclass[11pt]{scrlttr2}") ())) + (setq org-koma-letter-default-class class))) + + ;;; Helper functions (defun org-koma-letter-email () -- 1.8.3