emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to keep correct filepaths when using the #+INCLUDE derivativ


From: Nicolas Goaziou
Subject: Re: [O] How to keep correct filepaths when using the #+INCLUDE derivative?
Date: Thu, 01 Mar 2018 23:42:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hello,

Daniel P Gomez <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]