From c4adcc44f08f4e92efba1b7aabb45807cffc5f1c Mon Sep 17 00:00:00 2001 From: Rasmus Pank Roulund Date: Sun, 24 Nov 2013 17:57:37 +0100 Subject: [PATCH 1/3] Minor fixes for ox-koma-script.el * ox-koma-letter.el (org-koma-letter-headline) (org-koma-letter-email) (org-koma-letter-prefer-special-headings) (org-koma-letter-use-backaddress) (org-koma-letter-headline-is-opening-maybe): Correct docstring. (org-koma-letter-template): Insert subject before document start. (org-koma-letter-headline): Fix spelling. (org-koma-letter-template): Better subject handling. --- contrib/lisp/ox-koma-letter.el | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 240de29..3a0fa53 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -111,11 +111,15 @@ ;; \[EXTRA]")) ;; ;; Then, in your Org document, be sure to require the proper class -;; with : +;; with: ;; ;; #+LATEX_CLASS: my-letter ;; ;; Or by setting `org-koma-letter-default-class'. +;; You may possibly have to load (LaTeX) Babel as well e.g. by adding +;; it to `org-latex-packages-alist', +;; +;; (add-to-list 'org-latex-packages-alist '("AUTO" "babel" nil)) ;;; Code: @@ -148,7 +152,7 @@ string." (const :tag "Do not export author" nil))) (defcustom org-koma-letter-email 'org-koma-letter-email - "The sender's email address. + "Sender's email address. This variable defaults to the value `org-koma-letter-email' which returns `user-mail-address'. Alternatively a string, nil or a @@ -189,7 +193,11 @@ t the value opening will be implicit set as the headline title." :type 'string) (defcustom org-koma-letter-prefer-special-headings nil - "If TO and/or FROM is specified using both a heading and a keyword the heading value will be preferred if the variable is t." + "Prefer special headings in letters. + +If TO and/or FROM is specified using both a heading and a keyword +the heading value will be preferred if this variable is non-nil. +" :group 'org-export-koma-letter :type 'boolean) @@ -211,7 +219,6 @@ At this time the following values are allowed: - titled: add title/description to subject. - underlined: set subject underlined. - 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)." @@ -233,7 +240,7 @@ English manual of 2012-07-22)." (defcustom org-koma-letter-use-backaddress nil - "Print return address in small line above to address." + "Print return address above the address." :group 'org-export-koma-letter :type 'boolean) @@ -270,7 +277,8 @@ The value must be a member of `org-latex-classes'." :type 'string) (defcustom org-koma-letter-headline-is-opening-maybe t - "Whether a headline may be used as an opening. + "Let headlines be used as an opening if non-nil. + A headline is only used if #+OPENING is not set. See also `org-koma-letter-opening'." :group 'org-export-koma-letter @@ -288,7 +296,6 @@ A headline is only used if #+OPENING is not set. See also (defvar org-koma-letter-special-contents nil "Holds special content temporarily.") - ;;; Define Back-End @@ -516,7 +523,7 @@ appropriate place." CONTENTS is the transcoded contents string. INFO is a plist holding export options." ;; FIXME: instead of setq'ing org-koma-letter-special-contents and - ;; callying varioues stuff it might be nice to put a big let* around the templace + ;; callying varioues stuff it might be nice to put a big let* around the template ;; as in org-groff... (concat ;; Time-stamp. @@ -585,7 +592,7 @@ holding export options." (let ((with-backaddress (plist-get info :with-backaddress)) (with-backaddress-set (plist-get info :with-backaddress-changed-in-buffer-p)) (with-foldmarks (plist-get info :with-foldmarks)) - (with-foldmarks-set + (with-foldmarks-set (not (string-equal (plist-get info :with-foldmarks-changed-in-buffer-p) "foldmarks-not-set"))) (with-phone (plist-get info :with-phone)) @@ -601,28 +608,25 @@ holding export options." (format "\\KOMAoption{fromphone}{%s}\n" (if with-phone "true" "false"))) (when with-email-set (format "\\KOMAoption{fromemail}{%s}\n" (if with-email "true" "false"))))) - ;; Document start - "\\begin{document}\n\n" ;; Subject (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 "")) + ;; TODO: this is a bit ugly and assumes that with-subject is + ;; (a list of) symbol(s) or string(s)... + (subject-format (mapcar + (lambda (elt) (if (and elt (symbolp elt)) (symbol-name elt) elt)) + (cond ((member with-subject '("true" "t" t)) nil) + ((listp with-subject) with-subject) + (t (list with-subject))))) + (subject (org-export-data (plist-get info :title) info))) (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")) + (mapconcat 'identity subject-format ",") "}\n" )) (when (and subject with-subject) (format "\\setkomavar{subject}{%s}\n\n" subject)))) + ;; Document start + "\\begin{document}\n\n" ;; Letter start (format "\\begin{letter}{%%\n%s}\n\n" (org-koma-letter--determine-to-and-from info 'to)) -- 1.8.5.3