From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: ox-koma bug in subtree export Date: Thu, 16 Jul 2015 11:40:06 +0200 Message-ID: <87pp3sxwy1.fsf@gmx.us> References: <20150715112057.GI18343@chitra.no-ip.org> <87y4ihk5ho.fsf@gmx.us> <20150715211317.GO18343@chitra.no-ip.org> <878uahyr5q.fsf@gmx.us> <20150716085442.GQ18343@chitra.no-ip.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFfeP-0007D7-2L for emacs-orgmode@gnu.org; Thu, 16 Jul 2015 05:40:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFfeL-0006cT-Kz for emacs-orgmode@gnu.org; Thu, 16 Jul 2015 05:40:20 -0400 Received: from plane.gmane.org ([80.91.229.3]:41902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFfeL-0006cA-BB for emacs-orgmode@gnu.org; Thu, 16 Jul 2015 05:40:17 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZFfeH-0006oX-SF for emacs-orgmode@gnu.org; Thu, 16 Jul 2015 11:40:13 +0200 Received: from ip5b4025d5.dynamic.kabel-deutschland.de ([91.64.37.213]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Jul 2015 11:40:13 +0200 Received: from rasmus by ip5b4025d5.dynamic.kabel-deutschland.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Jul 2015 11:40: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 Suvayu Ali writes: > The closing bit works well, the signature however does not work for me. > Do I need any special config to enable it? Maybe it was not robust enough. Try this patch. Rasmus Example: * Preamble :noexport: #+TITLE: Mis-shapen chaos of well-seeming forms! #+SUBJECT: Or: Org-mode and KOMA-Script Letters #+DATE: <1580-07-03 Thu> #+BIND: org-export-date-timestamp-format "%Y" #+AUTHOR: Romeo #+PLACE: Verona, Italy #+LCO: DINmtext #+OPTIONS: after-closing-order:(ps cc encl) ':t backaddress:t subject:centered #+LATEX_HEADER: \setkomavar{firsthead}{} * To-address of the lovely Juliet :to: Juliet House of Capulet Verona * From :from: House of Montague Verona * Dear Juliet, #+BEGIN_VERSE Then plainly know my heart's dear love is set On the fair daughter of rich Capulet: As mine on hers, so hers is set on mine; And all combin'd, save what thou must combine By holy marriage: when, and where, and how We met, we woo'd, and made exchange of vow, I'll tell thee as we pass; but this I pray, That thou consent to marry us to-day. #+END_VERSE * Yours truly, :closing: Romeo of house Montague -- Not everything that goes around comes back around, you know --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-koma-letter-Add-closing-special-heading.patch >From 3b61450e916136edda49047b8616ac815da09edf Mon Sep 17 00:00:00 2001 From: Rasmus Date: Thu, 16 Jul 2015 00:38:06 +0200 Subject: [PATCH] ox-koma-letter: Add closing special heading * ox-koma-letter.el (org-koma-letter-special-tags-in-letter): Add closing. (org-koma-letter-template): Potentially take closing value from closing spcical heading. (org-koma-letter--build-settings): Potentially take signature value from closing special heading. (org-koma-letter-closing): (org-koma-letter-signature): Update docstring. Suggested-by: Suvayu Ali --- contrib/lisp/ox-koma-letter.el | 44 +++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index d0a8109..24624ca 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -204,13 +204,29 @@ then the opening will be implicitly set as the headline title." (defcustom org-koma-letter-closing "" "Letter's closing, as a string. -This option can also be set with the CLOSING keyword." +This option can also be set with the CLOSING keyword. Moreover, +when: + (1) this value is the empty string; + (2) there's no CLOSING keyword or it is empty; + (3) `org-koma-letter-headline-is-opening-maybe' is non-nil; + (4) the letter contains a headline with the special + tag closing; +then the opening will be set as the title of the closing special +heading." :group 'org-export-koma-letter :type 'string) (defcustom org-koma-letter-signature "" "Signature, as a string. -This option can also be set with the SIGNATURE keyword." +This option can also be set with the SIGNATURE keyword. +Moreover, when: + (1) this value is the empty string; + (2) there's no CLOSING keyword or it is empty; + (3) `org-koma-letter-headline-is-opening-maybe' is non-nil; + (4) the letter contains a headline with the special + tag closing; +then the signature will be set as the content of the +closing special heading." :group 'org-export-koma-letter :type 'string) @@ -358,7 +374,7 @@ e.g. \"title-subject:t\"." :group 'org-export-koma-letter :type 'boolean) -(defconst org-koma-letter-special-tags-in-letter '(to from) +(defconst org-koma-letter-special-tags-in-letter '(to from closing) "Header tags related to the letter itself.") (defconst org-koma-letter-special-tags-after-closing '(ps encl cc) @@ -665,7 +681,17 @@ holding export options." ;; Letter body. contents ;; Closing. - (format "\n\\closing{%s}\n" (org-export-data (plist-get info :closing) info)) + (format "\n\\closing{%s}\n" + (org-export-data + (or (org-string-nw-p (plist-get info :closing)) + (when (plist-get info :with-headline-opening) + (org-element-map (plist-get info :parse-tree) 'headline + (lambda (head) + (when (eq (org-koma-letter--special-tag head info) + 'closing) + (org-element-property :title head))) + info t))) + info)) (org-koma-letter--special-contents-as-macro (plist-get info :with-after-closing)) ;; Letter end. @@ -711,10 +737,14 @@ a communication channel." (format "\\KOMAoption{fromphone}{%s}\n" (if (plist-get info :with-phone) "true" "false"))) ;; Signature. - (let ((signature (plist-get info :signature))) + (let* ((heading-val (and (plist-get info :with-headline-opening) + (eq scope 'buffer) + (org-koma-letter--get-tagged-contents 'closing))) + (signature (or (plist-get info :signature) + heading-val))) (and (org-string-nw-p signature) - (funcall check-scope 'signature) - (format "\\setkomavar{signature}{%s}\n" signature))) + (or (funcall check-scope 'signature) heading-val) + (format "\\setkomavar{signature}{%s}\n" (org-trim signature)))) ;; Back address. (and (funcall check-scope 'with-backaddress) (format "\\KOMAoption{backaddress}{%s}\n" -- 2.4.5 --=-=-=--