From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [patch][ox-koma-letter] set opening via headline Date: Sat, 17 Aug 2013 22:07:04 +0200 Message-ID: <87zjsgqdxz.fsf@gmx.us> References: <877gfk6s5f.fsf@gmx.us> <8761v4umsd.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAmmS-0005eJ-M0 for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 16:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAmmM-0004vK-FN for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 16:07:24 -0400 Received: from plane.gmane.org ([80.91.229.3]:38415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAmmM-0004v6-4j for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 16:07:18 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VAmmL-00034T-3d for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 22:07:17 +0200 Received: from 87-57-37-13-dynamic.dk.customer.tdc.net ([87.57.37.13]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Aug 2013 22:07:17 +0200 Received: from rasmus by 87-57-37-13-dynamic.dk.customer.tdc.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 17 Aug 2013 22:07:17 +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 Cc: alan.schmitt@polytechnique.org --=-=-= Content-Type: text/plain Hi, Nicolas Goaziou writes: >> With the following patch one can set the opening via a headline. >> Currently, it's pretty conservative and will only set opening if it >> isn't set already. I'm open to discussion on that point. > > Here are some comments about its internals. Thanks! I appreciate the feedback. It should be fixed in the new version. I'll post another patch that adhere to this everywhere in the file. >> (defcustom org-koma-letter-opening nil >> - "Letter's opening, as a string." >> + "Letter's opening, as a string. If (1) this value is nil; (2) > > Please start a new line after the first sentence. > >> +(defcustom org-koma-letter-headline-is-opening-maybe t >> + "Whether a headline may be used as an opening. A headline is > > Ditto. > >> + (unless (or (plist-get info :opening) >> + (not org-koma-letter-headline-is-opening-maybe)) >> + (plist-put info :opening (org-element-property :raw-value headline))) > > I suggest to use > > (org-export-data (org-element-property :title headline) info) > > instead, so you can correctly export Org syntax included in the > headline, if any. Good point. See attached. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Set-opening-via-headline.patch >From 0b4b019e176898b09f95ac6bae2e5d61da2a6ae4 Mon Sep 17 00:00:00 2001 From: rasmus Date: Sat, 17 Aug 2013 20:24:36 +0200 Subject: [PATCH] Set opening via headline * ox-koma-letter.el (org-koma-letter-headline-is-opening-maybe): new variable. If `t' let headlines set subject. (org-koma-letter-headline): let headline set opening. (org-koma-letter-template): let opening and closing be empty if nil. --- contrib/lisp/ox-koma-letter.el | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index d149f9d..bb68771 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -175,7 +175,11 @@ function may be given. Functions must return a string." :type 'string) (defcustom org-koma-letter-opening nil - "Letter's opening, as a string." + "Letter's opening, as a string. + +If (1) this value is nil; (2) the letter is started with a +headline; and (3) `org-koma-letter-headline-is-opening-maybe' is +t the value opening will be implicit set as the headline title." :group 'org-export-koma-letter :type 'string) @@ -264,6 +268,13 @@ Use `foldmarks:true' to activate default fold marks or :group 'org-export-koma-letter :type 'string) +(defcustom org-koma-letter-headline-is-opening-maybe t + "Whether a headline may be used as an opening. +A headline is only used if #+OPENING is not set. See also +`org-koma-letter-opening'." + :group 'org-export-koma-letter + :type 'boolean) + (defconst org-koma-letter-special-tags-in-letter '(to from) "header tags related to the letter itself") @@ -482,6 +493,10 @@ appropriate place." (push (cons tag contents) org-koma-letter-special-contents) nil) + (unless (or (plist-get info :opening) + (not org-koma-letter-headline-is-opening-maybe)) + (plist-put info :opening + (org-export-data (org-element-property :title headline) info))) contents))) @@ -584,11 +599,11 @@ holding export options." (format "\\begin{letter}{%%\n%s}\n\n" (org-koma-letter--determine-special-value info 'to)) ;; Opening. - (format "\\opening{%s}\n\n" (plist-get info :opening)) + (format "\\opening{%s}\n\n" (or (plist-get info :opening) "")) ;; Letter body. contents ;; Closing. - (format "\n\\closing{%s}\n" (plist-get info :closing)) + (format "\n\\closing{%s}\n" (or (plist-get info :closing) "")) (org-koma-letter--prepare-special-contents-as-macro (plist-get info :with-after-closing)) ;; Letter end. -- 1.8.3.4 --=-=-= Content-Type: text/plain -- Summon the Mothership! --=-=-=--