emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: [bug, patch, ox] INCLUDE and footnotes
Date: Tue, 09 Dec 2014 20:10:46 +0100	[thread overview]
Message-ID: <87mw6wskp5.fsf@gmx.us> (raw)
In-Reply-To: 87h9x5hwso.fsf@gmx.us

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]

Rasmus <rasmus@gmx.us> writes:

> The attached patch fixes this by explicitly saving the footnote section

As per usual my first patch is dodgy.  It occurred to me that Org can
handle several footnote sections (that's how #+INCLUDE supports footnotes,
I guess).  The attached patch how supports export of t2.org in this
example

    $> cat t{1,2}.org

    # this is t1.org
    * foo
    bar[fn:1]
    baz[fn:2]

    * Footnotes

    [fn:1] bar.corp

    * Footnotes

    [fn:2] baz.corp

    # this is t2.org
    #+INCLUDE: "/tmp/t1.org::*foo"  


However, there is a pitch-fall when doing

    #+INCLUDE: "/tmp/t1.org::*foo0"
    #+INCLUDE: "/tmp/t1.org::*foo1"  

Now *foo1 will be inserted under the footnote-heading of *foo0 which means
it won't be exported.  If min-level is used this is not an issue of
course, but that's kind of unexpected (so is the fact that the second
include will become a child of the first include, but that's another
patch) .

Perhaps a better overall approach (if the above limitation is
unacceptable) would to translate all footnotes in an INCLUDEd file to
inline ones, e.g. when including * foo in t1.org above, what would be
inserted is

    * foo
    bar[fn::bar.corp]
    baz[fn::baz.corp]

Yet another solution would be to return a cond of

    (included-text . included-footnotes)

and make sure to insert footnotes at the very end.

WDYT?

—Rasmus

-- 
. . . The proofs are technical in nature and provides no real understanding

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox.el-Fix-footnote-bug-in-INCLUDE-keyword.patch --]
[-- Type: text/x-diff, Size: 1578 bytes --]

From 2a943b40c024df092cc2cf020bdf2646e7ab4b2c Mon Sep 17 00:00:00 2001
From: rasmus <rasmus@gmx.us>
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


  reply	other threads:[~2014-12-09 19:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 11:44 [bug, patch, ox] INCLUDE and footnotes Rasmus
2014-12-09 19:10 ` Rasmus [this message]
2014-12-09 19:14 ` Nicolas Goaziou
2014-12-09 21:21   ` Rasmus
2014-12-09 21:37     ` Nicolas Goaziou
2014-12-10  0:57       ` Rasmus
2014-12-10 11:21         ` Nicolas Goaziou
2014-12-10 11:58           ` Rasmus
2014-12-10 15:44             ` Nicolas Goaziou
2014-12-13 21:45               ` Rasmus
2014-12-17 23:30                 ` Nicolas Goaziou
2014-12-18 17:37                   ` Rasmus
2014-12-19 16:44                     ` Rasmus
2014-12-21 21:04                       ` Nicolas Goaziou
2014-12-21 22:39                         ` Rasmus
2014-12-21 23:38                           ` Nicolas Goaziou
2014-12-22  1:42                             ` Rasmus
2014-12-22  9:05                               ` Nicolas Goaziou
2014-12-24 18:03                                 ` Rasmus
2014-12-24 21:14                                   ` Nicolas Goaziou
2014-12-25  1:38                                     ` Rasmus
2014-12-25  2:04                                     ` Rasmus
2014-12-21 20:52                     ` Nicolas Goaziou
2014-12-22  1:49                       ` Rasmus
2014-12-22 11:10                         ` Nicolas Goaziou
2014-12-22 12:36                           ` Rasmus
2014-12-22 20:54                             ` Nicolas Goaziou
2014-12-22 22:11                               ` Rasmus
2014-12-22 22:51                                 ` Nicolas Goaziou
2014-12-23  2:09                                   ` Rasmus
2014-12-24 17:54                                   ` Rasmus
2014-12-24 18:10                                     ` [git-101] How to push a branch and avoid merge-message? (was: [bug, patch, ox] INCLUDE and footnotes) Rasmus
2014-12-24 21:09                                       ` [git-101] How to push a branch and avoid merge-message? Nicolas Goaziou

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=87mw6wskp5.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).