From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: [PATCH 5/5] Control insertion point for footnote definitions during pre-process Date: Thu, 23 Jun 2011 21:27:33 +0530 Message-ID: <81oc1o7d76.fsf@gmail.com> References: <81aad88s5j.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:37168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZmH5-00072C-D0 for emacs-orgmode@gnu.org; Thu, 23 Jun 2011 11:57:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZmH3-0003ew-VT for emacs-orgmode@gnu.org; Thu, 23 Jun 2011 11:56:59 -0400 Received: from mail-pz0-f51.google.com ([209.85.210.51]:53926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZmH3-0003ei-Lz for emacs-orgmode@gnu.org; Thu, 23 Jun 2011 11:56:57 -0400 Received: by pzk26 with SMTP id 26so1335787pzk.38 for ; Thu, 23 Jun 2011 08:56:56 -0700 (PDT) In-Reply-To: <81aad88s5j.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 23 Jun 2011 21:19:12 +0530") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain PATCH-5/5 org-odt compatibility patch --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0005-Control-insertion-point-for-footnote-definitions-dur.patch >From 22c4feee78ff9a1ab7cc48275ec29d322a3472a1 Mon Sep 17 00:00:00 2001 From: Jambunathan K 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 --=-=-=--