emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-odt compatibility patches
@ 2011-06-23 15:49 Jambunathan K
  2011-06-23 15:52 ` [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter Jambunathan K
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-23 15:49 UTC (permalink / raw)
  To: emacs-orgmode


I am following up this mail with 5 patches. These are small patches that
would help me float org-odt tarball with minimum of hassle (to the
users). 

The new capabilities introduced are strictly for consumption by
org-odt. Wrt master branch, these changes should essentially be NOOPs.

I would appreciate if these patches are considered for next release of
Org.

Jambunathan K.
-- 

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

* [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
@ 2011-06-23 15:52 ` Jambunathan K
  2011-06-23 15:53 ` [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends Jambunathan K
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-23 15:52 UTC (permalink / raw)
  To: emacs-orgmode

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


PATCH-1/5 for org-odt compatibility




[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-export-Reserve-a-slot-for-OpenDocumentExporter.patch --]
[-- Type: text/x-patch, Size: 1856 bytes --]

From 06379ccef996e8dabd8dcced6cbe430aacdef3f0 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Thu, 23 Jun 2011 01:53:37 +0530
Subject: [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter.

* lisp/org-exp.el (org-export): Reserve keys 'o' and 'O' for
OpenDocumentText export and bind them to org-export-as-odt and
org-export-as-odt-and-open.
---
 lisp/org-exp.el |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index b686181..3f4c468 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -49,6 +49,12 @@
 (declare-function org-table-cookie-line-p "org-table" (line))
 (declare-function org-table-colgroup-line-p "org-table" (line))
 (autoload 'org-export-generic "org-export-generic" "Export using the generic exporter" t)
+
+(autoload 'org-export-as-odt "org-odt"
+  "Export the outline to a OpenDocumentText file." t)
+(autoload 'org-export-as-odt-and-open "org-odt"
+  "Export the outline to a OpenDocumentText file and open it." t)
+
 (defgroup org-export nil
   "Options for exporting org-listings."
   :tag "Org Export"
@@ -933,6 +939,8 @@ Pressing `1' will switch between these two options."
 
 \[D] export as DocBook   [V] export as DocBook, process to PDF, and open
 
+\[o] export as OpenDocumentText                    [O] ... and open
+
 \[j] export as TaskJuggler                         [J] ... and open
 
 \[m] export as Freemind mind map
@@ -961,6 +969,8 @@ Pressing `1' will switch between these two options."
 	    (?g org-export-generic t)
 	    (?D org-export-as-docbook t)
 	    (?V org-export-as-docbook-pdf-and-open t)
+	    (?o org-export-as-odt t)
+	    (?O org-export-as-odt-and-open t)
 	    (?j org-export-as-taskjuggler t)
 	    (?J org-export-as-taskjuggler-and-open t)
 	    (?m org-export-as-freemind t)
-- 
1.7.2.3


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

* [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
  2011-06-23 15:52 ` [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter Jambunathan K
@ 2011-06-23 15:53 ` Jambunathan K
  2011-06-23 15:54 ` [PATCH 3/5] Support custom formatters for marking up source or example blocks Jambunathan K
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-23 15:53 UTC (permalink / raw)
  To: emacs-orgmode

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


PATCH-2/5: org-odt compatibility


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-org-exp.el-Allow-easy-plugging-in-of-new-backends.patch --]
[-- Type: text/x-patch, Size: 4164 bytes --]

From 2bc4854fb86a96b69e53db00603e0b2f8f47fe08 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Thu, 23 Jun 2011 02:16:30 +0530
Subject: [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends.

* lisp/org-exp.el (org-export-backends): New variable.
(org-export-select-backend-specific-text): Use above
variable. Also mark text between #+BACKEND and
#+BEGIN_BACKEND...#+END_BACKEND with org-native-text
property. This text property is currently used only by the new
line-oriented generic exporter (which is not yet part of the
repo).
---
 lisp/org-exp.el |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 3f4c468..96554a3 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1661,52 +1661,53 @@ from the buffer."
       (add-text-properties beg (if (bolp) (1- (point)) (point))
 			   '(org-protected t)))))
 
+(defvar org-export-backends
+  '(docbook html beamer ascii latex)
+  "List of Org supported export backends.")
+
 (defun org-export-select-backend-specific-text ()
-  (let ((formatters
-	 '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK")
-	   (html "HTML" "BEGIN_HTML" "END_HTML")
-	   (beamer "BEAMER" "BEGIN_BEAMER" "END_BEAMER")
-	   (ascii "ASCII" "BEGIN_ASCII" "END_ASCII")
-	   (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX")))
+  (let ((formatters org-export-backends)
 	(case-fold-search t)
-	fmt beg beg-content end end-content ind)
+	backend backend-name beg beg-content end end-content ind)
 
     (while formatters
-      (setq fmt (pop formatters))
-      ;; Handle #+backend: stuff
+      (setq backend (pop formatters)
+	    backend-name (symbol-name backend))
+
+      ;; Handle #+BACKEND: stuff
       (goto-char (point-min))
-      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt)
+      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" backend-name
 					":[ \t]*\\(.*\\)") nil t)
-	(if (not (eq (car fmt) org-export-current-backend))
+	(if (not (eq backend org-export-current-backend))
 	    (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))
 	  (replace-match "\\1\\2" t)
 	  (add-text-properties
 	   (point-at-bol) (min (1+ (point-at-eol)) (point-max))
-	   `(org-protected t original-indentation ,ind))))
-      ;; Delete #+attr_Backend: stuff of another backend. Those
+	   `(org-protected t original-indentation ,ind org-native-text t))))
+      ;; Delete #+ATTR_BACKEND: stuff of another backend. Those
       ;; matching the current backend will be taken care of by
       ;; `org-export-attach-captions-and-attributes'
       (goto-char (point-min))
-      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt)
+      (while (re-search-forward (concat "^\\([ \t]*\\)#\\+ATTR_" backend-name
 					":[ \t]*\\(.*\\)") nil t)
 	(setq ind (org-get-indentation))
-	(when (not (eq (car fmt) org-export-current-backend))
+	(when (not (eq backend org-export-current-backend))
 	  (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max)))))
-      ;; Handle #+begin_backend and #+end_backend stuff
+      ;; Handle #+BEGIN_BACKEND and #+END_BACKEND stuff
       (goto-char (point-min))
-      (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt) "\\>.*\n?")
+      (while (re-search-forward (concat "^[ \t]*#\\+BEGIN_" backend-name "\\>.*\n?")
 				nil t)
 	(setq beg (match-beginning 0) beg-content (match-end 0))
 	(setq ind (save-excursion (goto-char beg) (org-get-indentation)))
-	(when (re-search-forward (concat "^[ \t]*#\\+" (cadddr fmt) "\\>.*\n?")
+	(when (re-search-forward (concat "^[ \t]*#\\+END_" backend-name "\\>.*\n?")
 				 nil t)
 	  (setq end (match-end 0) end-content (match-beginning 0))
-	  (if (eq (car fmt) org-export-current-backend)
+	  (if (eq backend org-export-current-backend)
 	      ;; yes, keep this
 	      (progn
 		(add-text-properties
 		 beg-content end-content
-		 `(org-protected t original-indentation ,ind))
+		 `(org-protected t original-indentation ,ind org-native-text t))
 		(delete-region (match-beginning 0) (match-end 0))
 		(save-excursion
 		  (goto-char beg)
-- 
1.7.2.3


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

* [PATCH 3/5] Support custom formatters for marking up source or example blocks
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
  2011-06-23 15:52 ` [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter Jambunathan K
  2011-06-23 15:53 ` [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends Jambunathan K
@ 2011-06-23 15:54 ` Jambunathan K
  2011-06-23 15:56 ` [PATCH 4/5] Simplify org-export-format-source-code-or-example Jambunathan K
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-23 15:54 UTC (permalink / raw)
  To: emacs-orgmode

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


PATCH-3/5 org-odt compatibility patch


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-Support-custom-formatters-for-marking-up-source-or-e.patch --]
[-- Type: text/x-patch, Size: 2806 bytes --]

From a7881b8d146ddb27452b00ff19c345899d356536 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Thu, 23 Jun 2011 11:24:32 +0530
Subject: [PATCH 3/5] Support custom formatters for marking up source or example blocks.

* lisp/org-exp.el (org-export-format-source-code-or-example):
Add support for:
- custom formatters for existing backends
- seamless plugging in of new backends.
---
 lisp/org-exp.el |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 96554a3..5008b65 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2473,6 +2473,16 @@ in the list) and remove property and value from the list in LISTVAR."
 (defun org-export-format-source-code-or-example
   (lang code &optional opts indent caption)
   "Format CODE from language LANG and return it formatted for export.
+The CODE is marked up in `org-export-current-backend' format.
+
+Check if a function by name
+\"org-<backend>-format-source-code-or-example\" is bound. If yes,
+use it as the custom formatter. Otherwise, use the default
+formatter. Default formatters are provided for docbook, html,
+latex and ascii backends. For example, use
+`org-html-format-source-code-or-example' to provide a custom
+formatter for export to \"html\".
+
 If LANG is nil, do not add any fontification.
 OPTS contains formatting options, like `-n' for triggering numbering lines,
 and `+n' for continuing previous numbering.
@@ -2480,7 +2490,15 @@ Code formatting according to language currently only works for HTML.
 Numbering lines works for all three major backends (html, latex, and ascii).
 INDENT was the original indentation of the block."
   (save-match-data
-    (let (num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt)
+    (let* ((backend-name (symbol-name org-export-current-backend))
+	   (backend-formatter
+	    (intern (format "org-%s-format-source-code-or-example"
+			    backend-name)))
+	   (backend-feature (intern (concat "org-" backend-name)))
+	   (backend-formatter
+	    (and (require (intern (concat "org-" backend-name)) nil)
+		 (fboundp backend-formatter) backend-formatter))
+	   num cont rtn rpllbl keepp textareap preserve-indentp cols rows fmt)
       (setq opts (or opts "")
 	    num (string-match "[-+]n\\>" opts)
 	    cont (string-match "\\+n\\>" opts)
@@ -2517,6 +2535,9 @@ INDENT was the original indentation of the block."
       ;; Now backend-specific coding
       (setq rtn
 	    (cond
+	     (backend-formatter
+	      (funcall backend-formatter lang caption textareap cols rows num
+		       cont rpllbl fmt))
 	     ((eq org-export-current-backend 'docbook)
 	      (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
 	      (concat "\n#+BEGIN_DOCBOOK\n"
-- 
1.7.2.3


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

* [PATCH 4/5] Simplify org-export-format-source-code-or-example
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
                   ` (2 preceding siblings ...)
  2011-06-23 15:54 ` [PATCH 3/5] Support custom formatters for marking up source or example blocks Jambunathan K
@ 2011-06-23 15:56 ` Jambunathan K
  2011-06-23 15:57 ` [PATCH 5/5] Control insertion point for footnote definitions during pre-process Jambunathan K
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-23 15:56 UTC (permalink / raw)
  To: emacs-orgmode

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


PATCH-4/5 org-odt compatibility patch

Addtional Note: Diff looks primarily because of
un-indentation. Effective changes are just couple of lines.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-Simplify-org-export-format-source-code-or-example.patch --]
[-- Type: text/x-patch, Size: 6604 bytes --]

From 923402f12f30a39d54e16c0b105db2b1f20c2a7c Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Thu, 23 Jun 2011 12:06:33 +0530
Subject: [PATCH 4/5] Simplify org-export-format-source-code-or-example.

* lisp/org-exp.el (org-export-format-source-code-or-example):
Simplify. Also add `org-native-text' as a text property to the
formatted text and throw error for unknown backends.
---
 lisp/org-exp.el |  142 +++++++++++++++++++++++++++----------------------------
 1 files changed, 70 insertions(+), 72 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 5008b65..83216dc 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2540,12 +2540,9 @@ INDENT was the original indentation of the block."
 		       cont rpllbl fmt))
 	     ((eq org-export-current-backend 'docbook)
 	      (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
-	      (concat "\n#+BEGIN_DOCBOOK\n"
-		      (org-add-props (concat "<programlisting><![CDATA["
-					     rtn
-					     "]]></programlisting>\n")
-			  '(org-protected t org-example t))
-		      "#+END_DOCBOOK\n"))
+	      (concat "<programlisting><![CDATA["
+		      rtn
+		      "]]></programlisting>\n"))
 	     ((eq org-export-current-backend 'html)
 	      ;; We are exporting to HTML
 	      (when lang
@@ -2615,78 +2612,79 @@ INDENT was the original indentation of the block."
 		(setq rtn (org-export-number-lines rtn 1 1 num cont rpllbl fmt)))
 	      (if (string-match "\\(\\`<[^>]*>\\)\n" rtn)
 		  (setq rtn (replace-match "\\1" t nil rtn)))
-	      (concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t org-example t)) "\n#+END_HTML\n\n"))
+	      rtn)
 	     ((eq org-export-current-backend 'latex)
 	      (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
-	      (concat
-	       "#+BEGIN_LaTeX\n"
-	       (org-add-props
-		   (cond
-		    ((and lang org-export-latex-listings)
-                     (flet ((make-option-string
-                             (pair)
-                             (concat (first pair)
-				     (if (> (length (second pair)) 0)
-					 (concat "=" (second pair))))))
-		       (let* ((lang-sym (intern lang))
-			      (minted-p (eq org-export-latex-listings 'minted))
-			      (listings-p (not minted-p))
-			      (backend-lang
-			       (or (cadr
-				    (assq
-				     lang-sym
-				     (cond
-				      (minted-p org-export-latex-minted-langs)
-				      (listings-p org-export-latex-listings-langs))))
-				   lang))
-			      (custom-environment
-			       (cadr
-				(assq
-				 lang-sym
-				 org-export-latex-custom-lang-environments))))
-			 (concat
-			  (when (and listings-p (not custom-environment))
-			    (format
-			     "\\lstset{%s}\n"
-			     (mapconcat
-			      #'make-option-string
-			      (append org-export-latex-listings-options
-				      `(("language" ,backend-lang))) ",")))
-			  (when (and caption org-export-latex-listings-w-names)
-			    (format
-			     "\n%s $\\equiv$ \n"
-			     (replace-regexp-in-string "_" "\\\\_" caption)))
-			  (cond
-			   (custom-environment
-			    (format "\\begin{%s}\n%s\\end{%s}\n"
-				    custom-environment rtn custom-environment))
-			   (listings-p
-			    (format "\\begin{%s}\n%s\\end{%s}\n"
-				    "lstlisting" rtn "lstlisting"))
-			   (minted-p
-			    (format
-			     "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
-			     (mapconcat #'make-option-string
-					org-export-latex-minted-options ",")
-			     backend-lang rtn)))))))
-                    (t (concat (car org-export-latex-verbatim-wrap)
-                               rtn (cdr org-export-latex-verbatim-wrap))))
-                   '(org-protected t org-example t))
-               "#+END_LaTeX\n"))
+	      (cond
+	       ((and lang org-export-latex-listings)
+		(flet ((make-option-string
+			(pair)
+			(concat (first pair)
+				(if (> (length (second pair)) 0)
+				    (concat "=" (second pair))))))
+		  (let* ((lang-sym (intern lang))
+			 (minted-p (eq org-export-latex-listings 'minted))
+			 (listings-p (not minted-p))
+			 (backend-lang
+			  (or (cadr
+			       (assq
+				lang-sym
+				(cond
+				 (minted-p org-export-latex-minted-langs)
+				 (listings-p org-export-latex-listings-langs))))
+			      lang))
+			 (custom-environment
+			  (cadr
+			   (assq
+			    lang-sym
+			    org-export-latex-custom-lang-environments))))
+		    (concat
+		     (when (and listings-p (not custom-environment))
+		       (format
+			"\\lstset{%s}\n"
+			(mapconcat
+			 #'make-option-string
+			 (append org-export-latex-listings-options
+				 `(("language" ,backend-lang))) ",")))
+		     (when (and caption org-export-latex-listings-w-names)
+		       (format
+			"\n%s $\\equiv$ \n"
+			(replace-regexp-in-string "_" "\\\\_" caption)))
+		     (cond
+		      (custom-environment
+		       (format "\\begin{%s}\n%s\\end{%s}\n"
+			       custom-environment rtn custom-environment))
+		      (listings-p
+		       (format "\\begin{%s}\n%s\\end{%s}\n"
+			       "lstlisting" rtn "lstlisting"))
+		      (minted-p
+		       (format
+			"\\begin{minted}[%s]{%s}\n%s\\end{minted}\n"
+			(mapconcat #'make-option-string
+				   org-export-latex-minted-options ",")
+			backend-lang rtn)))))))
+	       (t (concat (car org-export-latex-verbatim-wrap)
+			  rtn (cdr org-export-latex-verbatim-wrap)))))
              ((eq org-export-current-backend 'ascii)
               ;; This is not HTML or LaTeX, so just make it an example.
               (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
               (concat caption "\n"
-                      "#+BEGIN_ASCII\n"
-                      (org-add-props
-                          (concat
-                           (mapconcat
-                            (lambda (l) (concat "  " l))
-                            (org-split-string rtn "\n")
-                            "\n")
-                           "\n")
-                          '(org-protected t org-example t))
-                      "#+END_ASCII\n"))))
+		      (concat
+		       (mapconcat
+			(lambda (l) (concat "  " l))
+			(org-split-string rtn "\n")
+			"\n")
+		       "\n")
+		      ))
+	     (t
+	      (error "Don't know how to markup source or example block in %s"
+		     (upcase backend-name)))))
+      (setq rtn
+	    (concat
+	     "\n#+BEGIN_" backend-name "\n"
+	     (org-add-props rtn
+		 '(org-protected t org-example t org-native-text t))
+	     "\n#+END_" backend-name "\n\n"))
       (org-add-props rtn nil 'original-indentation indent))))
 
 (defun org-export-number-lines (text &optional skip1 skip2 number cont
-- 
1.7.2.3


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

* [PATCH 5/5] Control insertion point for footnote definitions during pre-process
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
                   ` (3 preceding siblings ...)
  2011-06-23 15:56 ` [PATCH 4/5] Simplify org-export-format-source-code-or-example Jambunathan K
@ 2011-06-23 15:57 ` Jambunathan K
  2011-06-24  8:05 ` org-odt compatibility patches Carsten Dominik
  2011-06-24 10:49 ` Bastien
  6 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-23 15:57 UTC (permalink / raw)
  To: emacs-orgmode

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


PATCH-5/5 org-odt compatibility patch


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0005-Control-insertion-point-for-footnote-definitions-dur.patch --]
[-- Type: text/x-patch, Size: 2576 bytes --]

From 22c4feee78ff9a1ab7cc48275ec29d322a3472a1 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Thu, 23 Jun 2011 13:17:18 +0530
Subject: [PATCH 5/5] Control insertion point for footnote definitions during pre-process.

* lisp/org-footnote.el
(org-footnote-insert-pos-for-preprocessor): New variable.
(org-footnote-normalize): Use it.
---
 lisp/org-footnote.el |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 4fe8c91..c973924 100644
--- a/lisp/org-footnote.el
+++ b/lisp/org-footnote.el
@@ -362,6 +362,9 @@ With prefix arg SPECIAL, offer additional commands in a menu."
       (org-footnote-goto-previous-reference (nth 1 tmp)))
      (t (org-footnote-new)))))
 
+(defvar org-footnote-insert-pos-for-preprocessor 'point-max
+  "See `org-footnote-normalize'.")
+
 ;;;###autoload
 (defun org-footnote-normalize (&optional sort-only for-preprocessor)
   "Collect the footnotes in various formats and normalize them.
@@ -369,7 +372,20 @@ This finds the different sorts of footnotes allowed in Org, and
 normalizes them to the usual [N] format that is understood by the
 Org-mode exporters.
 When SORT-ONLY is set, only sort the footnote definitions into the
-referenced sequence."
+referenced sequence.
+
+When FOR-PREPROCESSOR is non nil, the default action, is to
+insert normalized footnotes towards the end of the pre-processing
+buffer. Some exporters like docbook, odt etc expect that footnote
+definitions be available before any references to them. Such
+exporters can let bind `org-footnote-insert-pos-for-preprocessor'
+to symbol 'point-min to achieve the desired behaviour.
+
+Additional note on `org-footnote-insert-pos-for-preprocessor':
+1. This variable has not effect when FOR-PREPROCESSOR is nil.
+2. This variable (potentially) obviates the need for extra scan
+   of pre-processor buffer as witnessed in
+   `org-export-docbook-get-footnotes'."
   ;; This is based on Paul's function, but rewritten.
   (let* ((limit-level
 	  (and (boundp 'org-inlinetask-min-level)
@@ -461,7 +477,12 @@ referenced sequence."
 	(setq ins-point (point))))
 
       ;; Insert the footnotes again
-      (goto-char (or ins-point (point-max)))
+      (goto-char (or (and for-preprocessor
+			  (equal org-footnote-insert-pos-for-preprocessor
+				 'point-min)
+			  (point-min))
+		     ins-point
+		     (point-max)))
       (setq ref-table (reverse ref-table))
       (when sort-only
 	;; remove anonymous and inline footnotes from the list
-- 
1.7.2.3


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

* Re: org-odt compatibility patches
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
                   ` (4 preceding siblings ...)
  2011-06-23 15:57 ` [PATCH 5/5] Control insertion point for footnote definitions during pre-process Jambunathan K
@ 2011-06-24  8:05 ` Carsten Dominik
  2011-06-24  8:42   ` Jambunathan K
                     ` (2 more replies)
  2011-06-24 10:49 ` Bastien
  6 siblings, 3 replies; 14+ messages in thread
From: Carsten Dominik @ 2011-06-24  8:05 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode


On Jun 23, 2011, at 5:49 PM, Jambunathan K wrote:

> 
> I am following up this mail with 5 patches. These are small patches that
> would help me float org-odt tarball with minimum of hassle (to the
> users). 
> 
> The new capabilities introduced are strictly for consumption by
> org-odt. Wrt master branch, these changes should essentially be NOOPs.
> 
> I would appreciate if these patches are considered for next release of
> Org.

Hi Jambunathan,

I have merged the patches, Bastien's approval is still pending, but
I do not expect a problem.  It would be good if you can stand
by during the following days in case a bug shows up, so that it
can quickly be fixed, before the release...

- Carsten

> 

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

* Re: org-odt compatibility patches
  2011-06-24  8:05 ` org-odt compatibility patches Carsten Dominik
@ 2011-06-24  8:42   ` Jambunathan K
  2011-06-24  8:55   ` Jambunathan K
  2011-06-24 10:47   ` Bastien
  2 siblings, 0 replies; 14+ messages in thread
From: Jambunathan K @ 2011-06-24  8:42 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode


Carsten

Thanks for considering the org-odt patches. I am assuring quick
turnaround from my side.

Jambunathan K.

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

* Re: org-odt compatibility patches
  2011-06-24  8:05 ` org-odt compatibility patches Carsten Dominik
  2011-06-24  8:42   ` Jambunathan K
@ 2011-06-24  8:55   ` Jambunathan K
  2011-06-24 10:52     ` Bastien
  2011-06-24 10:47   ` Bastien
  2 siblings, 1 reply; 14+ messages in thread
From: Jambunathan K @ 2011-06-24  8:55 UTC (permalink / raw)
  To: emacs-orgmode


Dear Orgers (who use git)

A note on this patch:

1. Export menu will now have a dummy entry for export to
   OpenDocumentText. (i.e., C-c C-e o anda C-c C-e O).

   If you accidentally invoke this command but do not have org-odt in
   the load-path, then Emacs will remind you that you don't have
   org-odt. This behaviour is expected.

2. Keep a special watch out for issues wrt formatting of babel/example
   blocks and footnotes.

   If you have lots of such things in your Org files you can help by
   re-running your favorite exporter on a fresh git checkout.

Jambunathan K.

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

* Re: org-odt compatibility patches
  2011-06-24  8:05 ` org-odt compatibility patches Carsten Dominik
  2011-06-24  8:42   ` Jambunathan K
  2011-06-24  8:55   ` Jambunathan K
@ 2011-06-24 10:47   ` Bastien
  2 siblings, 0 replies; 14+ messages in thread
From: Bastien @ 2011-06-24 10:47 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Jambunathan K

Hi Carsten and Jambunathan,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> I have merged the patches, Bastien's approval is still pending, but
> I do not expect a problem.  

Approval 100% given -- I'm reviewing and testing these patches over the
weekend to make sure things are okay.  Thanks to both of you!

-- 
 Bastien

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

* Re: org-odt compatibility patches
  2011-06-23 15:49 org-odt compatibility patches Jambunathan K
                   ` (5 preceding siblings ...)
  2011-06-24  8:05 ` org-odt compatibility patches Carsten Dominik
@ 2011-06-24 10:49 ` Bastien
  2011-06-25  5:19   ` Jambunathan K
  6 siblings, 1 reply; 14+ messages in thread
From: Bastien @ 2011-06-24 10:49 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode

Hi Jambunathan,

Jambunathan K <kjambunathan@gmail.com> writes:

> The new capabilities introduced are strictly for consumption by
> org-odt. Wrt master branch, these changes should essentially be NOOPs.

Seen, yes.

> I would appreciate if these patches are considered for next release of
> Org.

Of course.

The plan is to prepare the release over the weekend, to release on
monday and to commit the new 7.6 release into Emacs trunk during next
week.  

-- 
 Bastien

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

* Re: org-odt compatibility patches
  2011-06-24  8:55   ` Jambunathan K
@ 2011-06-24 10:52     ` Bastien
  0 siblings, 0 replies; 14+ messages in thread
From: Bastien @ 2011-06-24 10:52 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode

Hi Jambunathan,

Jambunathan K <kjambunathan@gmail.com> writes:

> 1. Export menu will now have a dummy entry for export to
>    OpenDocumentText. (i.e., C-c C-e o anda C-c C-e O).
>
>    If you accidentally invoke this command but do not have org-odt in
>    the load-path, then Emacs will remind you that you don't have
>    org-odt. This behaviour is expected.

A better way would be to check whether org-odt.el feature is provided
then to change the available export options depending on that.

What do you think?

-- 
 Bastien

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

* Re: org-odt compatibility patches
  2011-06-24 10:49 ` Bastien
@ 2011-06-25  5:19   ` Jambunathan K
  2011-06-25  8:54     ` Bastien
  0 siblings, 1 reply; 14+ messages in thread
From: Jambunathan K @ 2011-06-25  5:19 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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


Bastien

The attached patch "fixes" a omission in the "org-odt" compatibility
series.

Could you please commit this?

Jambunathan K.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-export-format-source-code-or-example-Fix-commit-.patch --]
[-- Type: text/x-patch, Size: 1017 bytes --]

From 403fdba8e091ba15700262192064681a3bf8ac30 Mon Sep 17 00:00:00 2001
From: Jambunathan K <kjambunathan@gmail.com>
Date: Sat, 25 Jun 2011 10:41:20 +0530
Subject: [PATCH] org-export-format-source-code-or-example: Fix commit f0177f (org-odt)

* lisp/org-exp.el (org-export-format-source-code-or-example):
Fix signature of org-<backend>-format-source-code-or-example
function.
---
 lisp/org-exp.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 83216dc..f8ea896 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2536,7 +2536,7 @@ INDENT was the original indentation of the block."
       (setq rtn
 	    (cond
 	     (backend-formatter
-	      (funcall backend-formatter lang caption textareap cols rows num
+	      (funcall backend-formatter rtn lang caption textareap cols rows num
 		       cont rpllbl fmt))
 	     ((eq org-export-current-backend 'docbook)
 	      (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt))
-- 
1.7.2.3


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


-- 

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

* Re: org-odt compatibility patches
  2011-06-25  5:19   ` Jambunathan K
@ 2011-06-25  8:54     ` Bastien
  0 siblings, 0 replies; 14+ messages in thread
From: Bastien @ 2011-06-25  8:54 UTC (permalink / raw)
  To: Jambunathan K; +Cc: emacs-orgmode

Hi Jambunathan,

Jambunathan K <kjambunathan@gmail.com> writes:

> Could you please commit this?

Done, thanks.

-- 
 Bastien

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

end of thread, other threads:[~2011-06-25  8:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-23 15:49 org-odt compatibility patches Jambunathan K
2011-06-23 15:52 ` [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter Jambunathan K
2011-06-23 15:53 ` [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends Jambunathan K
2011-06-23 15:54 ` [PATCH 3/5] Support custom formatters for marking up source or example blocks Jambunathan K
2011-06-23 15:56 ` [PATCH 4/5] Simplify org-export-format-source-code-or-example Jambunathan K
2011-06-23 15:57 ` [PATCH 5/5] Control insertion point for footnote definitions during pre-process Jambunathan K
2011-06-24  8:05 ` org-odt compatibility patches Carsten Dominik
2011-06-24  8:42   ` Jambunathan K
2011-06-24  8:55   ` Jambunathan K
2011-06-24 10:52     ` Bastien
2011-06-24 10:47   ` Bastien
2011-06-24 10:49 ` Bastien
2011-06-25  5:19   ` Jambunathan K
2011-06-25  8:54     ` Bastien

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