emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Cc: alan.schmitt@polytechnique.org
Subject: [patch][ox-koma-letter] set opening via headline
Date: Sat, 17 Aug 2013 21:20:28 +0200	[thread overview]
Message-ID: <877gfk6s5f.fsf@gmx.us> (raw)

[-- 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?


             reply	other threads:[~2013-08-17 19:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-17 19:20 Rasmus [this message]
2013-08-17 19:42 ` [patch][ox-koma-letter] set opening via headline 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gfk6s5f.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).