From mboxrd@z Thu Jan 1 00:00:00 1970 From: Viktor Rosenfeld Subject: Re: [PATCH] Improve configurability of ox-koma-letter Date: Mon, 22 Apr 2013 21:14:48 +0200 Message-ID: <20130422191448.GC725@kenny.fritz.box> References: <20130421175957.GA7821@cartman> <87ppxnkl4d.fsf@gmail.com> <20130422105742.GD7821@cartman> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="BwCQnh7xodEAoBMC" Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUMCY-0000I1-La for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 15:15:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUMCW-0008Oi-80 for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 15:14:58 -0400 Received: from mail-bk0-x231.google.com ([2a00:1450:4008:c01::231]:47282) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUMCV-0008OQ-PN for emacs-orgmode@gnu.org; Mon, 22 Apr 2013 15:14:56 -0400 Received: by mail-bk0-f49.google.com with SMTP id w5so633505bku.36 for ; Mon, 22 Apr 2013 12:14:54 -0700 (PDT) Content-Disposition: inline In-Reply-To: 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: Alan Schmitt Cc: emacs-orgmode@gnu.org --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Alan, Alan Schmitt wrote: > Or you could do a git rebase interactive to merge all the commits > together. Wow, this is great! I didn't know that you can modify the commit history so easily. I have attached four patches to this mail which correspond to the four points in my earlier email. They have to be applied consecutively. > >> - I think there is an issue with the handling of signatures. I tried > >> with an old letter that uses a LCO with a graphical signature in it, but > >> it gets overridden upon export. Here is the generated TeX. > >> > >> #+BEGIN_SRC latex > >> \LoadLetterOption{InriaRennesFR} > >> \setkomavar{signature}{\usekomavar{fromname}} > >> #+END_SRC > >> > > > > Have you tried clearing the signature? > > > > #+BEGIN_SRC emacs-lisp > > (setq org-koma-letter-signature nil) > > #+END_SRC > > Yes, I changed it globally and I still get the same thing. I also > tried doing a > > #+BEGIN_SRC org > #+signature: "" > #+END_SRC > > and it inserts it in the LaTeX file as such, after my LCO declaration. I can't reproduce this. I have attached a minimal letter as an example. If I evaluate the emacs-lisp block and export it I can see a graphic signature that is defined in `Signed.lco' in my `texmf' directory. What happens on your end? Cheers, Viktor > > Alan > --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-ox-koma-letter-Use-same-hotkeys-as-LaTeX-export.patch" >From 02727b4259b2530d7e878aeaed6b2d235d271f2a Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld Date: Sun, 21 Apr 2013 13:40:09 +0200 Subject: [PATCH 1/4] ox-koma-letter: Use same hotkeys as LaTeX export * ox-koma-letter.el (koma-letter): Use `L' to export to LaTeX buffer, `l' to export to LaTeX file, and `o' to export to PDF file and open. Patch suggested by Rasmus. --- contrib/lisp/ox-koma-letter.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 1ffb455..d8d32e7 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -123,10 +123,10 @@ (template . org-koma-letter-template)) :menu-entry '(?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) (if a (org-koma-letter-export-to-pdf t s v b) (org-open-file (org-koma-letter-export-to-pdf nil s v b)))))))) -- 1.8.2 --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-ox-koma-letter.el-Set-LCO-option-before-other-KOMA-v.patch" >From 1513beb2ba4aa847eaeb3f5e9c86414e7f8d5cd3 Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld Date: Sun, 21 Apr 2013 13:41:22 +0200 Subject: [PATCH 2/4] ox-koma-letter.el: Set LCO option before other KOMA variables * ox-koma-letter.el (org-koma-letter-closing): More business-like closing. (org-koma-letter-from-address): Do not set default personal information. (org-koma-letter-opening): Gendered opening. (org-koma-letter-phone-number): Do not set default personal information. (org-koma-letter-sender): Use `#+SENDER:' instead of `#+AUTHOR:' because the latter is always set by the LaTeX exporter. (org-koma-letter-email): Duplicte `#+EMAIL:' in this exporter because it is always set by the LaTeX exporter. (koma-letter): Add additional `#+SENDER:' and `#+EMAIL:' to exporter (see above). (org-koma-letter-template): Set LCO before evaluating other KOMA variables if they are set; add `#+SENDER:' and `#+EMAIL:' to template (see above). The LCO file is set loaded first and KOMA variables are only set if their value is not `nil'. Example: #+LCO: Default #+SIGNATURE: A friend will result in the following LaTeX code: #+BEGIN_SRC latex \LoadLetterOption{Default} % LCO file, with default signature \setkomavar{signature}{A friend} % Overwrite signature #+END_SRC Other KOMA variables defined in the LCO file, e.g., `fromaddress', will not be overwritten. --- contrib/lisp/ox-koma-letter.el | 55 +++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index d8d32e7..5397cf0 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -80,22 +80,22 @@ :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-closing "See you soon," +(defcustom org-koma-letter-closing "Sincerely yours," "Koma-Letter's closing, as a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-from-address "Somewhere \\ Over the rainbow." +(defcustom org-koma-letter-from-address nil "Sender's address, as a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-opening "Dear Sir," +(defcustom org-koma-letter-opening "Dear Madam or Sir," "Letter's opening, as a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-phone-number "00-00-00-00" +(defcustom org-koma-letter-phone-number nil "Sender's phone number, as a string." :group 'org-export-koma-letter :type 'string) @@ -105,18 +105,30 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-sender nil + "Sender's name, as a string." + :group 'org-export-koma-letter + :type 'string) + +(defcustom org-koma-letter-email nil + "Sender's email, as a string." + :group 'org-export-koma-letter + :type 'string) + ;;; Define Back-End (org-export-define-derived-backend 'koma-letter 'latex :options-alist - '((:closing "CLOSING" nil org-koma-letter-closing) + '((:lco "LCO" nil org-koma-letter-class-option-file) + (:sender "SENDER" nil org-koma-letter-sender newline) (:from-address "FROM_ADDRESS" nil org-koma-letter-from-address newline) - (:lco "LCO" nil org-koma-letter-class-option-file) - (:opening "OPENING" nil org-koma-letter-opening) (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) - (:signature "SIGNATURE" nil nil newline) - (:to-address "TO_ADDRESS" nil nil newline)) + (:email "EMAIL" nil org-koma-letter-email) + (:to-address "TO_ADDRESS" nil nil newline) + (:opening "OPENING" nil org-koma-letter-opening) + (:closing "CLOSING" nil org-koma-letter-closing) + (:signature "SIGNATURE" nil org-koma-letter-signature newline)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (keyword . org-koma-letter-keyword) @@ -197,18 +209,23 @@ holding export options." (concat (plist-get info :latex-header) (plist-get info :latex-header-extra)))) info))))) - ;; Define "From" data. - (format "\\setkomavar{fromname}{%s}\n" - (org-export-data (plist-get info :author) info)) - (format "\\setkomavar{fromaddress}{%s}\n" (plist-get info :from-address)) - (format "\\setkomavar{signature}{%s}\n" (plist-get info :signature)) - (format "\\setkomavar{fromemail}{%s}\n" - (org-export-data (plist-get info :email) info)) - (format "\\setkomavar{fromphone}{%s}\n" (plist-get info :phone-number)) + (let ((lco (plist-get info :lco)) + (sender (plist-get info :sender)) + (from-address (plist-get info :from-address)) + (phone-number (plist-get info :phone-number)) + (email (plist-get info :email)) + (signature (plist-get info :signature))) + (concat + ;; Letter Class Option File + (when lco (format "\\LoadLetterOption{%s}\n" lco)) + ;; Define "From" data. + (when sender (format "\\setkomavar{fromname}{%s}\n" sender)) + (when from-address (format "\\setkomavar{fromaddress}{%s}\n" from-address)) + (when phone-number (format "\\setkomavar{fromphone}{%s}\n" phone-number)) + (when email (format "\\setkomavar{fromemail}{%s}\n" email)) + (when signature (format "\\setkomavar{signature}{%s}\n" signature)))) ;; Date. (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info)) - ;; Letter Class Option File - (format "\\LoadLetterOption{%s}\n" (plist-get info :lco)) ;; Letter start. "\\begin{document}\n\n" (format "\\setkomavar{subject}{%s}\n\n" -- 1.8.2 --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0003-ox-koma-letter-Export-options-to-control-letter.patch" >From 1cb50d2db617f79477365db2bc6251a59636d9bf Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld Date: Sun, 21 Apr 2013 16:34:35 +0200 Subject: [PATCH 3/4] ox-koma-letter: Export options to control letter * ox-koma-letter.el ((org-koma-letter-use-subject): Configure printing of subject line. (org-koma-letter-use-backaddress): Configure presence of back address. (org-koma-letter-use-foldmarks): Configure presence of foldmarks. (org-koma-letter-use-phone): Configure printing of phone number. (org-koma-letter-use-email): Configure printing of email. (org-koma-letter-use-place): Configure printing of place. (koma-letter): Add export option to exporter backend. (org-koma-letter-template): Evaluate export options in exporter template. Usage: #+OPTIONS: backaddress:t foldmarks:t subject:titled phone:t email:t place:t Except for `subject', all options are boolean, i.e., the accept the values `nil' and `t'. `subject' accepts the values defined in `scrlttr2`, i.e., `afteropening', `beforeopening', `centered', `left', `right', `titled', `underlined', and `untitled'. --- contrib/lisp/ox-koma-letter.el | 90 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 13 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index 5397cf0..f313ac7 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -80,8 +80,8 @@ :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-closing "Sincerely yours," - "Koma-Letter's closing, as a string." +(defcustom org-koma-letter-sender nil + "Sender's name, as a string." :group 'org-export-koma-letter :type 'string) @@ -90,13 +90,28 @@ :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-phone-number nil + "Sender's phone number, as a string." + :group 'org-export-koma-letter + :type 'string) + +(defcustom org-koma-letter-email nil + "Sender's email, as a string." + :group 'org-export-koma-letter + :type 'string) + +(defcustom org-koma-letter-place nil + "Place from which the letter is sent." + :group 'org-export-koma-letter + :type 'string) + (defcustom org-koma-letter-opening "Dear Madam or Sir," "Letter's opening, as a string." :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-phone-number nil - "Sender's phone number, as a string." +(defcustom org-koma-letter-closing "Sincerely yours," + "Koma-Letter's closing, as a string." :group 'org-export-koma-letter :type 'string) @@ -105,15 +120,35 @@ :group 'org-export-koma-letter :type 'string) -(defcustom org-koma-letter-sender nil - "Sender's name, as a 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-email nil - "Sender's email, as a string." +(defcustom org-koma-letter-use-backaddress t + "Print return address in small line above to address." :group 'org-export-koma-letter - :type 'string) + :type 'boolean) + +(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) ;;; Define Back-End @@ -126,9 +161,17 @@ (:phone-number "PHONE_NUMBER" nil org-koma-letter-phone-number) (: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) (:closing "CLOSING" nil org-koma-letter-closing) - (:signature "SIGNATURE" nil org-koma-letter-signature newline)) + (:signature "SIGNATURE" nil org-koma-letter-signature newline) + + (:with-backaddress nil "backaddress" org-koma-letter-use-backaddress) + (:with-foldmarks nil "foldmarks" org-koma-letter-use-foldmarks) + (: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)) :translate-alist '((export-block . org-koma-letter-export-block) (export-snippet . org-koma-letter-export-snippet) (keyword . org-koma-letter-keyword) @@ -226,10 +269,31 @@ holding export options." (when signature (format "\\setkomavar{signature}{%s}\n" signature)))) ;; Date. (format "\\date{%s}\n" (org-export-data (org-export-get-date info) info)) - ;; Letter start. + ;; Place + (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 "")))) + ;; 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")))) + ;; Document start "\\begin{document}\n\n" - (format "\\setkomavar{subject}{%s}\n\n" - (org-export-data (plist-get info :title) info)) + ;; 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))))) + ;; Letter start (format "\\begin{letter}{%%\n%s}\n\n" (or (plist-get info :to-address) "no address given")) ;; Opening. -- 1.8.2 --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0004-ox-koma-letter.el-Support-multiple-LCO-files.patch" >From c042209c4ebde0aa20571e87d67ef8e6e57c8bfa Mon Sep 17 00:00:00 2001 From: Viktor Rosenfeld Date: Sun, 21 Apr 2013 18:43:11 +0200 Subject: [PATCH 4/4] ox-koma-letter.el: Support multiple LCO files * ox-koma-letter.el (org-koma-letter-template): Treat `#+LCO:' variable as a list of multiple LCO files separated by spaces. Example: #+LCO: Default Signed will result in the following LaTeX fragment #+BEGIN_SRC latex \LoadLetterOption{Default} \LoadLetterOption{Signed} #+END_SRC --- contrib/lisp/ox-koma-letter.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index f313ac7..31ccd89 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -260,7 +260,12 @@ holding export options." (signature (plist-get info :signature))) (concat ;; Letter Class Option File - (when lco (format "\\LoadLetterOption{%s}\n" lco)) + (when lco + (let ((lco-files (split-string lco " ")) + (lco-def "")) + (dolist (lco-file lco-files lco-def) + (setq lco-def (format "%s\\LoadLetterOption{%s}\n" lco-def lco-file))) + lco-def)) ;; Define "From" data. (when sender (format "\\setkomavar{fromname}{%s}\n" sender)) (when from-address (format "\\setkomavar{fromaddress}{%s}\n" from-address)) -- 1.8.2 --BwCQnh7xodEAoBMC Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename="letter.org" Content-Transfer-Encoding: 8bit #+LATEX_CLASS: my-letter #+LCO: ViktorRosenfeldPrivate Signed #+TO_ADDRESS: Max Mustermann\\ Musterstraße 1\\ 12345 Musterstadt #+OPENING: Sehr geehrte Damen und Herren, #+CLOSING: Mit freundlichen Grüßen #+LANGUAGE: de-de #+OPTIONS: phone:t email:t place:t foldmarks:t backaddress:t subject:nil Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enimad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. #+BEGIN_SRC emacs-lisp :results silent (setq org-koma-letter-class-option-file nil org-koma-letter-opening nil org-koma-letter-closing nil org-koma-letter-signature nil org-koma-letter-use-subject nil org-koma-letter-use-backaddress nil org-koma-letter-use-foldmarks nil org-koma-letter-use-phone nil org-koma-letter-use-email nil org-koma-letter-use-place nil) #+END_SRC --BwCQnh7xodEAoBMC--