From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: [patch, koma-letter] Change of subject behavior
Date: Wed, 18 Mar 2015 13:39:41 +0100 [thread overview]
Message-ID: <878ueuv5rm.fsf@gmx.us> (raw)
In-Reply-To: <877fue1qjm.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 18 Mar 2015 12:41:17 +0100")
[-- Attachment #1: Type: text/plain, Size: 380 bytes --]
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
>> I have only tested the patch briefly as I need to actually produce a
>> letter. But for the letter I'm writing export works fine.
>
> You sent a wrong patch.
Ups. Let's try again.
In the second patch I fix the no interpretation of #+SUBJECT.
—Rasmus
--
Lasciate ogni speranza, voi che leggete questo.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-ox-koma-letter-Interpret-SUBJECT.patch --]
[-- Type: text/x-diff, Size: 1108 bytes --]
From 0d8e0f21f3c120afef3e08628962f7fa99337aef Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Wed, 18 Mar 2015 13:33:42 +0100
Subject: [PATCH 2/2] ox-koma-letter: Interpret #+SUBJECT.
* ox-koma-letter.el (org-koma-letter-template): Interpret #+SUBJECT.
---
contrib/lisp/ox-koma-letter.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index d7572b5..e7be56a 100644
--- a/contrib/lisp/ox-koma-letter.el
+++ b/contrib/lisp/ox-koma-letter.el
@@ -626,7 +626,11 @@ holding export options."
(mapconcat #'symbol-name with-subject ","))))
(let* ((title-as-subject (plist-get info :with-title-as-subject))
(subject* (org-string-nw-p
- (org-export-data (plist-get info :subject) info)))
+ (org-export-data
+ (org-element-parse-secondary-string
+ (plist-get info :subject)
+ (org-element-restriction 'keyword))
+ info)))
(title* (and (plist-get info :with-title)
(org-string-nw-p
(org-export-data (plist-get info :title) info))))
--
2.3.3
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-ox-koma-letter-Stricter-subject-inference.patch --]
[-- Type: text/x-diff, Size: 3827 bytes --]
From a7289286b0b02310b4e3f714fc7047f7af7a027c Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Tue, 17 Mar 2015 18:32:26 +0100
Subject: [PATCH 1/2] ox-koma-letter: Stricter subject inference
* ox-koma-letter.el (org-koma-letter--special-headline): New function.
(org-koma-letter--get-tagged-contents): Refactor
(org-koma-letter-headline): Use org-koma-letter--special-headline
and do not guess opening.
(org-koma-letter-template): Directly infer subject from first
non-special headline.
---
contrib/lisp/ox-koma-letter.el | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/contrib/lisp/ox-koma-letter.el b/contrib/lisp/ox-koma-letter.el
index 1b5dd17..d7572b5 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'.
@@ -453,8 +454,8 @@ was not present."
(defun org-koma-letter--get-tagged-contents (key)
"Get contents from a headline tagged with KEY.
The contents is stored in `org-koma-letter-special-contents'."
- (cdr (assoc (org-koma-letter--get-value key)
- org-koma-letter-special-contents)))
+ (cdr (assoc-string (org-koma-letter--get-value key)
+ org-koma-letter-special-contents)))
(defun org-koma-letter--get-value (value)
"Turn value into a string whenever possible.
@@ -553,19 +554,17 @@ Note that if a headline is tagged with a tag from
`org-koma-letter-special-tags' it will not be exported, but
stored in `org-koma-letter-special-contents' and included at the
appropriate place."
- (unless (let ((tag (car (org-export-get-tags headline info))))
- (and tag
- (member-ignore-case
- 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))
+ (let ((special-tag (car (org-koma-letter--special-headline headline info))))
+ (if special-tag
+ (progn (push (cons special-tag contents) org-koma-letter-special-contents)
+ "")
+ contents)))
+
+(defun org-koma-letter--special-headline (headline info)
+ "Nonnil if HEADLINE is a special headline."
+ (let ((special-tags (plist-get info :special-tags)))
+ (mapcar (lambda (tag) (assoc-string tag special-tags))
+ (org-export-get-tags headline info))))
;;;; Template
@@ -641,7 +640,17 @@ 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))
+ (when (plist-get info :with-headline-opening)
+ (org-element-map (org-element-parse-buffer) 'headline
+ (lambda (head)
+ (unless (org-koma-letter--special-headline head info)
+ (org-element-property :title head)))
+ info t))
+ "")
+ info))
;; Letter body.
contents
;; Closing.
--
2.3.3
next prev parent reply other threads:[~2015-03-18 12:39 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878ueuv5rm.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 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.