From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [patch][ox-koma-letter] set opening via headline Date: Sat, 17 Aug 2013 21:20:28 +0200 Message-ID: <877gfk6s5f.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAm3L-0000ba-8A for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 15:20:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAm3F-0008Kr-1P for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 15:20:47 -0400 Received: from plane.gmane.org ([80.91.229.3]:55043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAm3E-0008Kn-QO for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 15:20:40 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VAm3D-0007Pr-Bo for emacs-orgmode@gnu.org; Sat, 17 Aug 2013 21:20:39 +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 21:20:39 +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 21:20:39 +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; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, 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. With this patch, the following example: --8<---------------cut here---------------start------------->8--- #+TITLE: Test * my opening my letter --8<---------------cut here---------------end--------------->8--- now exports something like --8<---------------cut here---------------start------------->8--- [...] \opening{my opening} my letter [...] --8<---------------cut here---------------end--------------->8--- It applies against master and /not/ Alan's patch from a month ago. –Rasmus --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Set-opening-via-headline.patch >From 7036479f45c2d34d8e9cd1efbc5e7e775ab7122d 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 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el index d149f9d..33062cc 100644 --- a/contrib/lisp/ox-koma-letter.el +++ b/contrib/lisp/ox-koma-letter.el @@ -175,7 +175,10 @@ 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 +267,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 +492,9 @@ 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-element-property :raw-value headline))) contents))) @@ -584,11 +597,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 -- Hvor meget poesi tror De kommer ud af et glas isvand? --=-=-=--