From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [patch] ox-koma-letter.el: subject changes [2/4] Date: Mon, 20 May 2013 20:23:00 +0200 Message-ID: <87y5b9o6ij.fsf@pank.eu> References: <87wqqusder.fsf@pank.eu> <87obc6scty.fsf@pank.eu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeUjr-0005CM-Q2 for emacs-orgmode@gnu.org; Mon, 20 May 2013 14:23:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UeUjq-00074R-CY for emacs-orgmode@gnu.org; Mon, 20 May 2013 14:23:15 -0400 Received: from plane.gmane.org ([80.91.229.3]:36477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeUjq-00073F-1V for emacs-orgmode@gnu.org; Mon, 20 May 2013 14:23:14 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UeUjp-0007Gw-3K for emacs-orgmode@gnu.org; Mon, 20 May 2013 20:23:13 +0200 Received: from ip-pool-135.iue.it ([192.167.90.135]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 May 2013 20:23:13 +0200 Received: from rasmus.pank by ip-pool-135.iue.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 20 May 2013 20:23:13 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit >> This could be a problematic change. It changes the way :with-subject >> works. I've added changes to allow the subject style to be choose as >> a radio list with customize. The reason is that LaTeX becomes unhappy >> if it is not a supported value. If #+OPTIONS subject:t the default is >> used. If #+OPTIONS subject:my-crazy-string it tries that and most >> likely hell will break loose. >> >> Viktor, you're usage of ox-koma-letter.el is quite different from mine >> in that you rely (heavily?) on LCO files. If you could test this and >> see what you think of it it would be great. On my system it doesn't >> break anything vital but I might have missed something. > > According to my very limited emacs-lisp knowledge, this looks fine. I found a "bug" in that the subject variable should be a list cf. the KOMA manual. This patch fixes this. It's pretty complex for something so simple, and I might be inclined to admit to the "put it in a LCO"-file approach might be better. >From the commit message: If =#+OPTIONS:subject:nil= neither =\setkomavar{subject}{.}= nor =\KOMAoption{subject}{.}= are exported. If =#+OPTIONS:subject:t= =`org-koma-letter-subject-format'= is used for =\KOMAoption{subject}{.}=. If =#+OPTIONS:subject:(x y z)= then =\KOMAoption{subject}{x,y,z}=. > beavior -> behavior > fteropening -> afteropening > No-export -> noexport (so that it looks like the other ones). Thanks! I should run wcheck when coding . . . –Rasmus -- Powered by magic pixies! --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-ox-koma-letter-changed-handling-of-subject.patch >From d11e4fd682ac593da04c3e4c8edf5eb84c9d0c59 Mon Sep 17 00:00:00 2001 From: "rasmus.pank" Date: Sun, 19 May 2013 17:32:44 +0200 Subject: [PATCH 2/4] ox-koma-letter: changed handling of subject * ox-koma-letter.el: =`org-koma-letter-subject-format'= is now a set list. If nil neither subject format nor type is exported. * ox-koma-letter.el: allow for t value of =#+OPTIONS: subject:VALUE= * ox-koma-letter.el: 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. New behavior: If =#+OPTIONS:subject:nil= neither =\setkomavar{subject}{.}= nor =\KOMAoption{subject}{.}= are exported. If =#+OPTIONS:subject:t= =`org-koma-letter-subject-format'= is used for =\KOMAoption{subject}{.}=. If =#+OPTIONS:subject:(x y z)= then \KOMAoption{subject}{x,y,z}. --- contrib/lisp/ox-koma-letter.el | 65 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 2389025..6a3811f 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -6,7 +6,6 @@ ;; Alan Schmitt ;; Viktor Rosenfeld ;; Rasmus Pank Roulund - ;; Keywords: org, wp, tex ;; This program is free software: you can redistribute it and/or modify @@ -123,10 +122,35 @@ :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 '("beforeopening" "left" "untitled") + "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) + (string)) + :group 'org-export-koma-letter) + + (defcustom org-koma-letter-use-backaddress t "Print return address in small line above to address." @@ -179,7 +203,7 @@ Use `foldmarks:true' to activate default fold marks or (: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) (keyword . org-koma-letter-keyword) @@ -300,12 +324,29 @@ 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 + (if (member + ;; test if subject-format is t + (cond ((symbolp with-subject) (downcase (symbol-name with-subject))) + ((stringp with-subject) (downcase with-subject)) + (t nil)) + '("true" "t")) + org-koma-letter-subject-format + with-subject)) + (subject (org-export-data (plist-get info :title) info)) + (l (if (stringp subject-format) 1 (length subject-format))) + (y "")) + (concat + (when with-subject + (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")) -- 1.8.2.3 --=-=-=--