emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: [patch, koma-letter] Change of subject behavior
Date: Tue, 17 Mar 2015 23:48:31 +0100	[thread overview]
Message-ID: <87mw3bdyv4.fsf@gmx.us> (raw)
In-Reply-To: <87wq2f1gqz.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Tue, 17 Mar 2015 22:00:36 +0100")

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

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:


> However, I don't think :opening setting belongs to
> `org-koma-letter-headline', as it means it is potentially set each time
> a headline is being processed.

The property is at most set once cf. the second clause.

> The (when ...) could be moved within `org-koma-letter-template', where
> "\opening{...}" is filled and the first headline without a special tag
> in the parse tree could be used (assuming there's no special
> keyword...). That headline can be found using `org-element-map'.

Yes.  Less ugly.

> Another (smallish) advantage is that the following case would be
> allowed:
>
>   ***** Dear myself,
>   * Part 1

Is the advantage that it won't fold?

> WDYT?

The current stuff is ugly.  I didn't know much lisp when I worked on
ox-koma-letter.

I updated the patch.  Perhaps the loop determination shod be moved to a
separate function to keep the template clean.  I thinking this cause we
(or at least I) sometimes point to ox-koma-letter as an example of a
derived backend.  WDTY on that?

In the attached at least this work as expected.

*** ps                                                                 :ps:
*** dear you,
* part 1

—Rasmus

-- 
Send from my Emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-koma-letter-Stricter-subject-inference.patch --]
[-- Type: text/x-diff, Size: 2541 bytes --]

From dacee19cce07a75735298dcb3f3730d6220248c5 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Tue, 17 Mar 2015 18:32:26 +0100
Subject: [PATCH] ox-koma-letter: Stricter subject inference

* ox-koma-letter.el (org-koma-letter-headline): Remove opening guessing.
  (org-koma-letter-template): Directly infer subject from first
  non-special headline.
---
 contrib/lisp/ox-koma-letter.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 1b5dd17..59616c7 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -412,6 +412,7 @@ was not present."
     (:with-place nil "place" org-koma-letter-use-place)
     (:with-subject nil "subject" org-koma-letter-subject-format)
     (:with-title-as-subject nil "title-subject" org-koma-letter-prefer-subject)
+    (:with-headline-opening nil nil org-koma-letter-headline-is-opening-maybe)
     ;; Special properties non-nil when a setting happened in buffer.
     ;; They are used to prioritize in-buffer settings over "lco"
     ;; files.  See `org-koma-letter-template'.
@@ -559,11 +560,6 @@ appropriate place."
 		  tag (mapcar #'symbol-name (plist-get info :special-tags)))
 		 ;; Store association for later use and bail out.
 		 (push (cons tag contents) org-koma-letter-special-contents)))
-    ;; Opening is not defined yet: use headline's title.
-    (when (and org-koma-letter-headline-is-opening-maybe
-	       (not (org-string-nw-p (plist-get info :opening))))
-      (plist-put info :opening
-		 (org-export-data (org-element-property :title headline) info)))
     ;; In any case, insert contents in letter's body.
     contents))
 
@@ -641,7 +637,21 @@ holding export options."
    (format "\\begin{letter}{%%\n%s}\n\n"
 	   (org-koma-letter--determine-to-and-from info 'to))
    ;; Opening.
-   (format "\\opening{%s}\n\n" (plist-get info :opening))
+   (format "\\opening{%s}\n\n"
+	   (org-export-data
+	    (or (org-string-nw-p (plist-get info :opening))
+		(if (plist-get info :with-headline-opening)
+		    (let ((special-tags (plist-get info :special-tags)))
+			(org-element-map (org-element-parse-buffer) 'headline
+			  (lambda (head)
+			    (unless
+				(org-some 'identity
+					  (mapcar (lambda (tag) (memq (intern tag) special-tags))
+						  (org-element-property :tags head)))
+			      (org-element-property :title head)))
+			  info t)))
+		"")
+	    info))
    ;; Letter body.
    contents
    ;; Closing.
-- 
2.3.3


  reply	other threads:[~2015-03-17 22:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 17:37 [patch, koma-letter] Change of subject behavior Rasmus
2015-03-17 21:00 ` Nicolas Goaziou
2015-03-17 22:48   ` Rasmus [this message]
2015-03-17 23:08     ` Nicolas Goaziou
2015-03-17 23:41       ` Rasmus
2015-03-18 11:41         ` Nicolas Goaziou
2015-03-18 12:39           ` Rasmus
2015-03-18 20:27             ` Nicolas Goaziou
2015-03-19 11:35               ` Rasmus
2015-03-19 23:15                 ` Nicolas Goaziou
2015-03-20 20:22                   ` 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=87mw3bdyv4.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --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).