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