all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [patch][ox-koma-letter] set opening via headline
@ 2013-08-17 19:20 Rasmus
  2013-08-17 19:42 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Rasmus @ 2013-08-17 19:20 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: alan.schmitt

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Set-opening-via-headline.patch --]
[-- Type: text/x-diff, Size: 2563 bytes --]

From 7036479f45c2d34d8e9cd1efbc5e7e775ab7122d Mon Sep 17 00:00:00 2001
From: rasmus <rasmus@gmx.us>
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


[-- Attachment #3: Type: text/plain, Size: 59 bytes --]

-- 
Hvor meget poesi tror De kommer ud af et glas isvand?


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-17 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-17 19:20 [patch][ox-koma-letter] set opening via headline Rasmus
2013-08-17 19:42 ` Nicolas Goaziou
2013-08-17 20:07   ` Rasmus
2013-08-17 20:55     ` [patch][ox-koma-letter] checkdoc compatible (was: [patch][ox-koma-letter] set opening via headline) Rasmus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.