From 92b07bac2d707f01e48796778453b67a9ecd1daa Mon Sep 17 00:00:00 2001 From: "rasmus.pank" Date: Wed, 22 May 2013 01:16:54 +0200 Subject: [PATCH 5/5] Variables for author and email for ox-koma-letter and a bug fix. * ox-koma-letter.el (koma-letter): reintroduced koma-letter specif author and email. * ox-koma-letter.el (koma-letter): set org-koma-special-content to nil when exporting The former is needed so that author/email can be set in a LCO file. TINYCHANGE --- contrib/lisp/ox-koma-letter.el | 49 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 020df52..92cf13a 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -109,6 +109,12 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-email user-mail-address + "The default email address stored in the letter." ) + +(defcustom org-koma-letter-author user-full-name + "The default name of the sender." ) + (defcustom org-koma-letter-signature "\\usekomavar{fromname}" "String used as the signature." :group 'org-export-koma-letter @@ -143,7 +149,6 @@ English manual of 2012-07-22)" :group 'org-export-koma-letter) - (defcustom org-koma-letter-use-backaddress t "Print return address in small line above to address." :group 'org-export-koma-letter @@ -179,7 +184,6 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'string) - (defconst org-koma-letter-special-tags-after-closing '("PS" "ENCL" "CC") "Headers tags to be inserted after closing") @@ -193,7 +197,7 @@ Use `foldmarks:true' to activate default fold marks or org-koma-letter-special-tags-after-closing) "Header tags with special meaning") -(defvar org-koma-letter-special-content nil "holds special +(defvar org-koma-letter-special-contents nil "holds special content temporarily.") @@ -203,10 +207,10 @@ content temporarily.") (org-export-define-derived-backend 'koma-letter 'latex :options-alist '((:lco "LCO" nil org-koma-letter-class-option-file) - (:sender "AUTHOR" nil user-full-name t) + (:sender "AUTHOR" nil org-koma-letter-author) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:email "EMAIL" nil user-mail-address t) + (: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) @@ -275,29 +279,31 @@ channel." ;; Thanks, Luis! (defun org-koma-letter--get-tagged-content (tag info) - (cdr (assoc tag org-koma-letter-special-content))) + (cdr (assoc tag org-koma-letter-special-contents))) -(defun org-koma-letter-headline (headline conents info) +(defun org-koma-letter-headline (headline contents info) "Transcode a HEADLINE element from Org to LaTeX. CONTENTS holds the contents of the headline. INFO is a plist holding contextual informatio.n Note that if a headline is tagged with a tag from `org-koma-letter-special-tags' it will not be exported, but -stored in `org-koma-letter-special-content' and included at the +stored in `org-koma-letter-special-contents' and included at the appropriate place." (let* ((tags (and (plist-get info :with-tags) (org-export-get-tags headline info)))) - (if (member (car tags) org-koma-letter-special-tags) - (cond ((member (car tags) '("PS" "ps")) - (progn - (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) - org-koma-letter-special-content) nil)) - (t (progn - (push (cons (car tags) contents) - org-koma-letter-special-content) nil))) + (if (member (upcase (car tags)) + org-koma-letter-special-tags) + ;; (cond ((member (car tags) '("PS" "ps")) + ;; (progn + ;; (push (cons (car tags) (concat (plist-get info :ps-prefix) contents)) + ;; org-koma-letter-special-contents) nil)) + (progn + (push (cons (upcase (car tags)) contents) + org-koma-letter-special-contents) + nil) contents))) @@ -307,10 +313,9 @@ appropriate place." "Return complete document string after KOMA Scrlttr2 conversion. CONTENTS is the transcoded contents string. INFO is a plist holding export options." - ;; FIXME: instead of setq'ing org-koma-letter-special-content and + ;; 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 ;; as in org-groff... - (setq org-koma-letter-special-content nil) (concat ;; Time-stamp. (and (plist-get info :time-stamp-file) @@ -412,15 +417,14 @@ holding export options." (format "\n\\closing{%s}\n\n" (plist-get info :closing)) (let (after-closing) (dolist (ac org-koma-letter-special-tags-after-closing after-closing) - (let ((x (org-koma-letter--get-tagged-content ac info))) + (let ((x (org-koma-letter--get-tagged-content (upcase ac) info))) (when x (setq after-closing (concat after-closing ;; sometimes LaTeX complains about newlines ;; at the end of macros. Remove them. (replace-regexp-in-string "\n+$" "" - (format "\\%s{%s}" (downcase ac) x))))) - ))) + (format "\\%s{%s}" (downcase ac) x)))))))) ;; Letter end. "\\end{letter}\n" (let ((x (org-koma-letter--get-tagged-content "AFTER_LETTER" info))) @@ -464,6 +468,7 @@ Export is done in a buffer named \"*Org KOMA-LETTER Export*\". It will be displayed if `org-export-show-temporary-export-buffer' is non-nil." (interactive) + (let (org-koma-letter-special-contents) (if async (org-export-async-start (lambda (output) @@ -480,7 +485,7 @@ non-nil." subtreep visible-only body-only ext-plist))) (with-current-buffer outbuf (LaTeX-mode)) (when org-export-show-temporary-export-buffer - (switch-to-buffer-other-window outbuf))))) + (switch-to-buffer-other-window outbuf)))))) ;;;###autoload (defun org-koma-letter-export-to-latex -- 1.8.2.3