all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Improve usage of odt content templates
@ 2014-05-19 10:42 Christian Kellermann
  2014-05-19 16:17 ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Kellermann @ 2014-05-19 10:42 UTC (permalink / raw)
  To: emacs-orgmode

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

Rationale:

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

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,

Christian

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

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

TINYCHANGE
---
 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))))))
   :options-alist
   '((: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"))))
     (with-temp-buffer
       (insert-file-contents
-       (or org-odt-content-template-file
+       (or (plist-get info :odt-content-template-file)
+           org-odt-content-template-file
 	   (expand-file-name "OrgOdtContentTemplate.xml"
 			     org-odt-styles-dir)))
       ;; Write automatic styles.
-- 
1.9.2


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

TINYCHANGE
---
 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))))))
   :options-alist
   '((: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)))
 	 (concat
 	  ;; Title.
-	  (when (org-string-nw-p title)
+	  (when (and (plist-get info :odt-insert-title) (org-string-nw-p title))
 	    (concat
 	     (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
 		     "OrgTitle" (format "\n<text:title>%s</text:title>" title))
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-05-22  8:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19 10:42 [PATCH] Improve usage of odt content templates Christian Kellermann
2014-05-19 16:17 ` 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

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.