Skip to content

Create orgfile links with relative paths (org-link-file-path-type) #1114

@seflue

Description

@seflue

Does this feature exist in Emacs orgmode core?

Yes

Orgmode link

org-link-file-path-type in ol.el - controls whether links created via org-store-link use relative or absolute file paths.

Additional context

org_store_link and get_link() always produce absolute file paths:

[[file:/home/user/notes/work.org::*My headline][My headline]]

Emacs has org-link-file-path-type to control this:

Value Behavior
adaptive (default) Relative for same/sub dirs, absolute otherwise
relative Always relative to current file
absolute Absolute with ~/

So linking between files in the same directory would give [[file:work.org::*My headline]] instead.

Back when we fixed relative link navigation (#583), we only covered the reading side. The writing side behind org_store_link still hardcodes absolute paths. A small helper in links/init.lua could apply the configured format before building the file: link.

I would like to have this for telescope-orgmode's insert-link. I could work around it downstream, but since it's part of Emacs orgmode core it makes sense to have it here. Happy to do a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions