From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Daniel P Gomez <gomez.danp@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: How to keep correct filepaths when using the #+INCLUDE derivative?
Date: Tue, 06 Mar 2018 09:51:05 +0100 [thread overview]
Message-ID: <87y3j537uu.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAJTMgxhg6=h+FP1YGsZh0YYDn0mz0ytfvBEoB=7riFVGrJb6rg@mail.gmail.com> (Daniel P. Gomez's message of "Sat, 3 Mar 2018 14:06:05 +0100")
Hello,
Daniel P Gomez <gomez.danp@gmail.com> writes:
> I noticed that (buffer-file-name (buffer-base-buffer)) will always
> return nil because `org-export--prepare-file-contents` is called in
> `org-export-include-keyword` after a call to `with-temp-buffer`. Two
> possible solutions to this issue would be either 1. passing the
> includer-file as an extra parameter to
> `org-export--prepare-file-contents` and then using
> `file-relative-name` to generate a relative path, or alternatively 2 .
> passing the matched string that points to the file to be included.
> Example:
>
> #+INCLUDE: "directory/file.org"
>
> Here, if file.org contains a link [[other/image.png]], then all one
> has to do is append the (file-name-directory matched) to the old-path.
> In this example this would result in directory/other/image.png.
>
> This second solution does not require a call to (buffer-file-name
> (buffer-base-buffer)), but seems hackish in the sense that we would
> pass 2 redundant arguments to `org-export-prepare-file-contents`: both
> the expanded and the non-expanded include-file filename.
> Perhaps I'm missing a simpler 3rd solution?
I think solution 1 is fine.
> If we opt for solution 1 then new-path could be made relative here
>> ;; (org-element-put-property new :path new-path)
>
> (org-element-put-property
> new :path
> (if includer-file
> (file-relative-name
> new-path (file-name-directory includer-file))
> new-path))
Indeed. However, the (if includer-file ...) should be integrated in
new-path binding, IMO.
> I will attempt to write them once the implementation is completed.
Great. Thank you!
Regards,
--
Nicolas Goaziou 0x80A93738
next prev parent reply other threads:[~2018-03-06 8:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 13:29 How to keep correct filepaths when using the #+INCLUDE derivative? Daniel P Gomez
2018-02-28 17:51 ` Nicolas Goaziou
2018-02-28 20:11 ` Daniel P Gomez
2018-03-01 1:01 ` Daniel P Gomez
2018-03-01 18:32 ` Nicolas Goaziou
2018-03-01 18:56 ` Daniel P Gomez
2018-03-01 22:42 ` Nicolas Goaziou
2018-03-02 14:16 ` Daniel P Gomez
2018-03-03 1:24 ` Nicolas Goaziou
2018-03-03 13:06 ` Daniel P Gomez
2018-03-06 8:51 ` Nicolas Goaziou [this message]
2018-03-10 11:28 ` Daniel P. Gomez
2018-03-18 15:15 ` 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=87y3j537uu.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=gomez.danp@gmail.com \
/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).