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: Re: [patch][ox-koma-letter] set opening via headline
Date: Sat, 17 Aug 2013 22:07:04 +0200	[thread overview]
Message-ID: <87zjsgqdxz.fsf@gmx.us> (raw)
In-Reply-To: 8761v4umsd.fsf@gmail.com

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


Hi,

Nicolas Goaziou <n.goaziou@gmail.com> 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. 


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

From 0b4b019e176898b09f95ac6bae2e5d61da2a6ae4 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 | 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


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


-- 
Summon the Mothership!

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=87zjsgqdxz.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).