emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christian Kellermann <ckeen@pestilenz.org>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Improve usage of odt content templates
Date: Mon, 19 May 2014 12:42:54 +0200	[thread overview]
Message-ID: <20140519104254.GX15335@pestilenz.org> (raw)

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

Hi all,

I have been using org-mode's odt exporter heavily for the last days
with the attached patches. These scratch an itch I have and I submit
them to this list in the hope of being useful to others.


I am using the odt exporter to fill in a project description document
at work with has strict specified layout and template. Fortunately
just using an existing empty document and org-mode's content template
setting is sufficient for my needs to create the OO documents without
having to touch OpenOffice. However the current master code misses
two things I need:

* Possibility to override the globally defined
org-odt-content-template-file variable in the document

* Avoid inserting the document title as the first thing in the
document contents, as there already is a title set in a title page
in the template. As org-mode already sets the title data tag this
can be used in the template to generate the correct title. However
inserting the title as text is not desireable in that scenario.

I have attached patches that address these two issues. The latter
adds yet another option to the exporter mode to suppress title

I offer these patches as the base of a discussion as I am not sure
whether these small changes fit the overall "org-mode" way. Or maybe
there already is an easier way to achieve what I want, I don't know.

As these are my first org-mode patches I hope I have read the
guidelines for commit messages correctly. I am grateful for any
comments or advise you may have.

Kind regards,


May you be peaceful, may you live in safety, may you be free from
suffering, and may you live with ease.

[-- Attachment #2: 0001-ox-odt-Expose-content-template-file-setting.patch --]
[-- Type: text/plain, Size: 1490 bytes --]

From a6a84ae372ce1d755292da7559afde1c9bfbfc7d Mon Sep 17 00:00:00 2001
From: Christian Kellermann <ckeen@pestilenz.org>
Date: Mon, 19 May 2014 12:11:28 +0200
Subject: [PATCH 1/2] ox-odt: Expose content template file setting

* ox-odt.el (odt): Add ODT_CONTENT_TEMPLATE_FILE option.

org-odt-content-template-file is not changeable in the org

* ox-odt.el (org-odt-template): Prefer local content template

Prefer the locally set #+ODT_CONTENT_TEMPLATE_FILE over the global
org-odt-content-template-file variable.

 lisp/ox-odt.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 4d2f257..1d4e796 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -97,6 +97,7 @@
 		(org-open-file (org-odt-export-to-odt nil s v) 'system))))))
   '((:odt-styles-file "ODT_STYLES_FILE" nil nil t)
+    (:odt-content-template-file "ODT_CONTENT_TEMPLATE_FILE" nil nil t)
     ;; Redefine regular option.
     (:with-latex nil "tex" org-odt-with-latex)))
@@ -1450,7 +1451,8 @@ original parsed data.  INFO is a plist holding export options."
 	    '("%Y-%M-%d %a" . "%Y-%M-%d %a %H:%M"))))
-       (or org-odt-content-template-file
+       (or (plist-get info :odt-content-template-file)
+           org-odt-content-template-file
 	   (expand-file-name "OrgOdtContentTemplate.xml"
       ;; Write automatic styles.

[-- Attachment #3: 0002-ox-odt-Optionally-suppress-title-insertion.patch --]
[-- Type: text/plain, Size: 1652 bytes --]

From e1e171a12b0ad0d29881a27688d578fba1ac4a75 Mon Sep 17 00:00:00 2001
From: Christian Kellermann <ckeen@pestilenz.org>
Date: Mon, 19 May 2014 12:14:50 +0200
Subject: [PATCH 2/2] ox-odt: Optionally suppress title insertion

* ox-odt.el (odt): Add ODT_INSERT_TITLE to option list.

This allows the user to suppress the insertion of the document title
in the openoffice document.

* ox-odt.el (org-odt-template): optionally skip title insertion.

If ODT_INSERT_TITLE is set to a false value, skip title insertion.  As
the odt exporter also sets the title metadata tag, this allows the
user to use the title elsewhere, for example in a fancier title page.

 lisp/ox-odt.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 1d4e796..6268e51 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -97,6 +97,7 @@
 		(org-open-file (org-odt-export-to-odt nil s v) 'system))))))
   '((:odt-styles-file "ODT_STYLES_FILE" nil nil t)
+    (:odt-insert-title "ODT_INSERT_TITLE" nil nil t)
     (:odt-content-template-file "ODT_CONTENT_TEMPLATE_FILE" nil nil t)
     ;; Redefine regular option.
     (:with-latex nil "tex" org-odt-with-latex)))
@@ -1504,7 +1505,7 @@ original parsed data.  INFO is a plist holding export options."
 	      (email (and (plist-get info :with-email) email)))
 	  ;; Title.
-	  (when (org-string-nw-p title)
+	  (when (and (plist-get info :odt-insert-title) (org-string-nw-p title))
 	     (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
 		     "OrgTitle" (format "\n<text:title>%s</text:title>" title))

             reply	other threads:[~2014-05-19 11:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 10:42 Christian Kellermann [this message]
2014-05-19 16:17 ` [PATCH] Improve usage of odt content templates Nicolas Goaziou
2014-05-19 16:34   ` Rasmus
2014-05-20  7:56     ` Christian Kellermann
2014-05-20  8:37     ` Eric Abrahamsen
2014-05-20 10:39       ` Detlef Steuer
2014-05-19 16:41   ` Christian Kellermann
2014-05-21 12:47     ` Nicolas Goaziou
2014-05-22  8:00       ` Detlef Steuer
2014-05-22  8:23         ` Rasmus
2014-05-20 15:12   ` Bastien

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:

  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=20140519104254.GX15335@pestilenz.org \
    --to=ckeen@pestilenz.org \
    --cc=emacs-orgmode@gnu.org \


* 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


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).