emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jambunathan K <kjambunathan@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH 5/5] Control insertion point for footnote definitions during pre-process
Date: Thu, 23 Jun 2011 21:27:33 +0530	[thread overview]
Message-ID: <81oc1o7d76.fsf@gmail.com> (raw)
In-Reply-To: <81aad88s5j.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 23 Jun 2011 21:19:12 +0530")

[-- 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'.")
 (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

  parent reply	other threads:[~2011-06-23 15:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jambunathan K [this message]
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

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=81oc1o7d76.fsf@gmail.com \
    --to=kjambunathan@gmail.com \
    --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).