From 2a943b40c024df092cc2cf020bdf2646e7ab4b2c 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 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 9d9e794..bf2ce4d 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -3260,8 +3260,27 @@ 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-re + (concat "^\\*+[ \t]+" org-footnote-section "[ \t]*$")) + (footnote-sections + (save-match-data + (save-excursion + (goto-char (point-min)) + (loop do + (or (search-forward-regexp footnote-section-re nil t) + (end-of-buffer)) + while (not (eobp)) + collect + (buffer-substring + (line-beginning-position) + (or (and + (search-forward-regexp org-heading-regexp nil t) + (goto-char (match-beginning 0))) + (point-max)))))))) + (narrow-to-region beg end) + (and footnote-sections + (insert "\n" (mapconcat 'identity footnote-sections "\n"))))) ;; 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