emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniel P Gomez <gomez.danp@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: How to keep correct filepaths when using the #+INCLUDE derivative?
Date: Thu, 1 Mar 2018 19:56:58 +0100	[thread overview]
Message-ID: <CAJTMgxjrxw=bvjVw_xtz+YJt=7qt-Of05hf7JOSkPOjELYmO5w@mail.gmail.com> (raw)
In-Reply-To: <87o9k7ir3i.fsf@nicolasgoaziou.fr>

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 <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Daniel P Gomez <gomez.danp@gmail.com> 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

  reply	other threads:[~2018-03-01 18:57 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 [this message]
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
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='CAJTMgxjrxw=bvjVw_xtz+YJt=7qt-Of05hf7JOSkPOjELYmO5w@mail.gmail.com' \
    --to=gomez.danp@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).