From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: How to keep correct filepaths when using the #+INCLUDE derivative? Date: Thu, 01 Mar 2018 23:42:00 +0100 Message-ID: <87h8pzifk7.fsf@nicolasgoaziou.fr> References: <87woyxhuk2.fsf@nicolasgoaziou.fr> <87o9k7ir3i.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erWto-0004SZ-8V for emacs-orgmode@gnu.org; Thu, 01 Mar 2018 17:42:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erWtn-0000J6-9V for emacs-orgmode@gnu.org; Thu, 01 Mar 2018 17:42:04 -0500 Received: from relay2-d.mail.gandi.net ([2001:4b98:c:538::194]:47241) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erWtn-0000Ep-2h for emacs-orgmode@gnu.org; Thu, 01 Mar 2018 17:42:03 -0500 In-Reply-To: (Daniel P. Gomez's message of "Thu, 1 Mar 2018 19:56:58 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Daniel P Gomez Cc: emacs-orgmode@gnu.org Hello, Daniel P Gomez 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