From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel P Gomez Subject: Re: How to keep correct filepaths when using the #+INCLUDE derivative? Date: Thu, 1 Mar 2018 19:56:58 +0100 Message-ID: References: <87woyxhuk2.fsf@nicolasgoaziou.fr> <87o9k7ir3i.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erTO0-0002Ts-M0 for emacs-orgmode@gnu.org; Thu, 01 Mar 2018 13:57:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erTNz-0003jU-OI for emacs-orgmode@gnu.org; Thu, 01 Mar 2018 13:57:00 -0500 Received: from mail-qt0-x233.google.com ([2607:f8b0:400d:c0d::233]:35738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1erTNz-0003iM-Ia for emacs-orgmode@gnu.org; Thu, 01 Mar 2018 13:56:59 -0500 Received: by mail-qt0-x233.google.com with SMTP id z14so8900638qti.2 for ; Thu, 01 Mar 2018 10:56:59 -0800 (PST) In-Reply-To: <87o9k7ir3i.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-orgmode@gnu.org 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. 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?). 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? Thank you. Regards, Daniel On Thu, Mar 1, 2018 at 7:32 PM, Nicolas Goaziou wrote: > Hello, > > Daniel P Gomez writes: > >> If there is any interest, I've created a patch adding support for a >> :absolute-paths functionality. >> As I said, I don't have much experience writing Elisp, so any >> suggestions on how to improve the code would be appreciated. If there >> is any interest in adding this feature to Org I could try to clean it >> up. > > Thank you. > > Would it make sense to automatically deduce this directory from included > file and apply this automatically? > > Regards, > > -- > Nicolas Goaziou