From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [PATCH] Improve configurability of ox-koma-letter Date: Mon, 22 Apr 2013 11:57:29 +0200 Message-ID: <878v4adh12.fsf@pank.eu> References: <20130421175957.GA7821@cartman> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUDVE-0007qW-Ns for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 05:57:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUDVC-0003cC-IH for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 05:57:40 -0400 Received: from plane.gmane.org ([80.91.229.3]:48742) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUDVC-0003c5-6y for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 05:57:38 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UUDVB-0001pQ-7j for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 11:57:37 +0200 Received: from ip-pool-141.iue.it ([192.167.90.141]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Apr 2013 11:57:37 +0200 Received: from rasmus by ip-pool-141.iue.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Apr 2013 11:57:37 +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 Viktor, Looks nice! > Also, I could not find an ox-koma-letter tutorial on Worg. I would be > willing to create such a tutorial, maybe next weekend. Can anybody edit > the contents on Worg or do I need special priviledges? Ask Bastien or perhaps Carsten now for write access (you need to provide your public key). I can look through it when uploaded. > KOMA scrlttr2 export: Improve export configuration options. > > [...] > > * Same hotkeys as the LaTeX exporter > > Use =L= (instead of =K=) to export to a buffer, =l= (instead of =k=) > to export to a file, and =O= (instead of =o=) to open the PDF file. > > This was already suggested by Rasmus > (http://thread.gmane.org/gmane.emacs.orgmode/67026). Thanks. And sorry for not providing a final patch myself; school/work suddenly exploded. > * Setting of KOMA variables > > LCO files are loaded first and KOMA variables are only set in the > LaTeX output if their value is not nil. This way most configuration > options can be set once in an LCO file and overwritten if needed. This was certainly an outstanding bug that I've also been annoyed with. > [...] > * Setting of KOMA options > > The presence of the sender's phone and email, the letter's place and > subject, as well as foldmarks and the backaddress are > configurable. Consider: > > #+OPTIONS: subject:titled place:nil phone:t email:t foldmarks:nil backaddress:nil In a similar spirit to subject is firsthead. First head is displayed by default in scrlttr2 as far as I recall, which is annoying. If we make foldmark an option should it not be a string accepting values from "Table 4.3.: Combinable values for the configuration of folding marks with option foldmarks" in the KOMA-Script manual? > Note, that except for =subject=, all options are boolean, e.g., they > accept the values =t= and =nil=. Subject can also be nil to surpress > printing, or otherwise any possible value for the KOMA option subject, > i.e., afteropening, beforeopening, centered, left, right, titled, > underlined, or untitled. I wasn't aware of these options. Thanks. > * Multiple LCO files > > Multiple LCO files, separated by spaces, can be specified. This way > one can add optional behavior to the letter export. Consider, e.g., an > LCO file with a default address and a simple textual signature: Cool. > diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el > index 1ffb455..31ccd89 100644 > --- a/contrib/lisp/ox-koma-letter.el > +++ b/contrib/lisp/ox-koma-letter.el > @@ -80,23 +80,38 @@ > :group 'org-export-koma-letter > :type 'string) > > -(defcustom org-koma-letter-closing "See you soon," > - "Koma-Letter's closing, as a string." > +(defcustom org-koma-letter-sender nil I agree with getting rid of silly defaults. > +(defcustom org-koma-letter-opening "Dear Madam or Sir," > "Letter's opening, as a string." > :group 'org-export-koma-letter > :type 'string) While I also mainly write English letters I don't think we need to assume everyone does. I'd also opt for a default nil here. > +(defcustom org-koma-letter-closing "Sincerely yours," > + "Koma-Letter's closing, as a string." > :group 'org-export-koma-letter > :type 'string) ditto. > +(defcustom org-koma-letter-use-subject "untitled" > + "Use the title as the letter's subject." > + :group 'org-export-koma-letter > + :type 'string) Perhaps the default should depend on whether a title is present? > +(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) > + Sorry for not testing this myself, but what is the behavior if e.g. org-koma-letter-use-place is t but I didn't specify a place? Will it print a nil or nothing? > '(?k "Export with KOMA Scrlttr2" > - ((?K "As LaTeX buffer" org-koma-letter-export-as-latex) > - (?k "As LaTeX file" org-koma-letter-export-to-latex) > + ((?L "As LaTeX buffer" org-koma-letter-export-as-latex) > + (?l "As LaTeX file" org-koma-letter-export-to-latex) > (?p "As PDF file" org-koma-letter-export-to-pdf) > - (?O "As PDF file and open" > + (?o "As PDF file and open" > (lambda (a s v b) Another approach (which I also somehow like) is to put it under the LaTeX menu. E.g. like beamer or like org-ravel ¹ > + (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 "")))) Wouldn't this work better: E.g. it wouldn't allow a place when place is nil or when with-place is nil? (when (and place (not with-place)) (format "\\setkomavar{place}{%s}\n" 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")))) Relating to configurable foldmarks: (if with-foldmarks (format "\\KOMAoption{foldmarks}{%s}\n" (if foldmarks foldmarks true))) (untested). –Rasmus Footnotes:  ¹ https://github.com/chasberry/orgmode-accessories -- When the facts change, I change my mind. What do you do, sir?