emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
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: Thu, 01 Mar 2018 23:42:00 +0100	[thread overview]
Message-ID: <87h8pzifk7.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CAJTMgxjrxw=bvjVw_xtz+YJt=7qt-Of05hf7JOSkPOjELYmO5w@mail.gmail.com> (Daniel P. Gomez's message of "Thu, 1 Mar 2018 19:56:58 +0100")

Hello,

Daniel P Gomez <gomez.danp@gmail.com> writes:

> Currently when passing the :absolute-paths toggle to an include
> derivative, as in :
>
> #+INCLUDE: file.org :absolute-paths t
>
> The function `org-export--prepare-file-contents` will automatically
> deduce the directory from file.org and adapt links by calling:
> `(new-path (expand-file-name old-path (file-name-directory file)))`.
> I could either make this a default option, such that links get
> corrected but users can overwrite this by calling `:absolute-paths
> nil`, or I could completely remove this toggle and always correct
> links no matter what.

I am wondering about the latter. If there is no reason to keep broken
file names, it makes sense to automatically apply it.

Also, rewriting needs not be always absolute path, if both directories
share a common root.

> One question regarding the implementation, currently I'm deleting the
> link with a call to `delete-region` and using `(insert "[[file:"
> new-path "]]")` to insert the corrected one. This does not take into
> consideration whether links are bracketed or not ( is there a
> functional difference if links are not bracketed?).

Yes. White spaces are handled differently in each link type.

> Also, my approach completely disregards link descriptions, which may
> be relevant if the linked file would be, for example, an html
> document. Would there be a cleaner org approach to replace the path
> keeping the description?

You could check :contents-begin and :contents-end for the link. If they
are not nil, extract this region, and insert it again in the new link.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

  reply	other threads:[~2018-03-01 22:42 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 [this message]
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
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=87h8pzifk7.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).