From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: [bug, patch, ox] INCLUDE and footnotes Date: Tue, 09 Dec 2014 12:44:55 +0100 Message-ID: <87h9x5hwso.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyJEB-0004gA-SV for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 06:45:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyJE6-0001RL-NZ for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 06:45:15 -0500 Received: from plane.gmane.org ([80.91.229.3]:56514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyJE6-0001QZ-Bp for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 06:45:10 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XyJE3-0000iV-2V for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 12:45:07 +0100 Received: from 109.201.154.210 ([109.201.154.210]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Dec 2014 12:45:07 +0100 Received: from rasmus by 109.201.154.210 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Dec 2014 12:45:07 +0100 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 Hi, When using LINES in `org-export--prepare-file-contents' the footnotes section is not preserved causing export to fail. Minimal example $> cat t{1,2}.org # this is t1.org * intro foo[fn:1] * sec2 bar * Footnotes [fn:1] baz # this is t2.org #+INCLUDE: "./t1.org::#intro" And export t2.org. The attached patch fixes this by explicitly saving the footnote section (Aside: org-footnote-section is used in hackish ways; should we make a function that returns to correct regexp for the footnotes section?). It works in a rather large document of mine and in the minimal test. Should I apply it, or is there a better way to fix this bug? Thanks, Rasmus -- Slowly unravels in a ball of yarn and the devil collects it --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox.el-Fix-footnote-bug-in-INCLUDE-keyword.patch >From 3f352159d9011e6a00af853fa6dadb04a5b46c87 Mon Sep 17 00:00:00 2001 From: rasmus Date: Tue, 9 Dec 2014 12:40:52 +0100 Subject: [PATCH] ox.el: Fix footnote-bug in #+INCLUDE-keyword * ox.el (org-export--prepare-file-contents): Preserve footnote-section when using the LINES argument. --- lisp/ox.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 9d9e794..8d4fd6c 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3260,8 +3260,22 @@ with footnotes is included in a document." (end (if (zerop lend) (point-max) (goto-char (point-min)) (forward-line (1- lend)) - (point)))) - (narrow-to-region beg end))) + (point))) + (footnote-section + (save-excursion + (goto-char (point-min)) + (when (search-forward-regexp + (concat "^\\*+[ \t]+" org-footnote-section "[ \t]*$") + nil t) + (buffer-substring + (point-at-bol) + (or + (and (search-forward-regexp org-heading-regexp nil t) + (point-at-bol)) + (point-max))))))) + (narrow-to-region beg end) + (and footnote-section + (insert "\n" footnote-section)))) ;; Remove blank lines at beginning and end of contents. The logic ;; behind that removal is that blank lines around include keyword ;; override blank lines in included file. -- 2.1.3 --=-=-=--