Closed
Description
Brief Abstract
org-roam-insert
currently only works inside org-roam files, but it would be useful to be able to create links to notes in other org files.
Long Description
I would like to be able to easily refer to notes from other org files that are not in org roam (for example in project todo items or outlines).
As far as I can see this makes sense as an operation, but org-roam-insert
gives an error if you are not in an org file.
Proposed Implementation (if any)
Remove the check and error call: https://github.com/jethrokuan/org-roam/blob/master/org-roam.el#L325
Please check the following:
- No similar feature requests
The error you get was mentioned in one issue #377 but it turned out to be a problem with the installation, not a request for changed behaviour.
Activity
zaeph commentedon Apr 17, 2020
We could drop the
user-error
form…https://github.com/jethrokuan/org-roam/blob/6175739b33b0abaa862c0137e216e6029f24d5cd/org-roam.el#L325
…and change it to a cond check to insert absolute paths.
At first, I was on the fence because I think that
org-roam-insert
should specifically work withorg-roam
files (i.e. insideorg-roam-directory
. After all, we can useorg-store-link
to get a link to the file. Problem is, iforg-before-first-heading-p
ist
, we would only get the file-name, which might not be very informative.We could create a new link-handler for
org-roam
which would fill the visible part of a link with the#+TITLE
of a note. We might also want to avoid the usual behaviour which, whenorg-before-first-heading-p
isnil
, would link you to the nearest parent heading.ricklupton commentedon Apr 17, 2020
I agree, I think removing the
user-error
is all that's needed. I don't think a check for absolute paths is needed because of thefile-relative-name
here: https://github.com/jethrokuan/org-roam/blob/master/org-roam.el#L316Happy to make a PR if you are happy with that.
This would also be good. I've got this working in a previous notes setup (although using a custom link type, so might not be exactly the same) so could contribute another PR if that would be a good fit here.
Another nice org-link customisation would be to show the title on hover instead of the filename.
zaeph commentedon Apr 17, 2020
You're right; I'd misread the path when I ran tests.
It's not up to me. Let's wait to see what @jethrokuan thinks about it first.
Same as above: hold off for now in case we decide to maintain the original behaviour. We might be missing something.
ricklupton commentedon Apr 17, 2020
Sure.
I suppose even though a relative path would work from an external file, an absolute path might be preferred in case the external file is moved?
Another option (which I was using before) was to use a custom link type which is relative to the org-roam directory -- so a file called
20200416191822-slug.org
could be referred to from anywhere by the link[[roam:20200416191822-slug.org]]
. That would be useful in external files (1) if the external files might be moved and hence break relative links, or (2) if the absolute path to the org-roam directory might change (e.g. on different machines).(a custom link type would work within org-roam-directory too but isn't so necessary because relative paths work fine)
zaeph commentedon Apr 17, 2020
Uhm, I don't know. I think one of the reason why we aren't explicitly supporting external links to files inside
org-roam-directory
is that, within the confines oforg-roam-directory
, we can manage the backrefs and ensure that links remain consistent, even when the files are renamed.org
has some rudimentary ways to deal with it with:ID:
and:CUSTOM_ID:
for headers, but not for files.Anyway, it's a whole different problem. If you want to create a short-lived tasks to do something on a note, like rewrite a passage, I've found contextual
org-capture
with%a
to be enough.jethrokuan commentedon Apr 17, 2020
I'm okay with removing the
user-error
, I can see the use-case of inserting org-roam links in files outside of org-roam. Not sure how useful it will be, as it may insert a rather ridiculous relative path.This I'd rather not, as without org-roam things would no longer function. As much as possible, I'd like to keep the Org syntax familiar and simple.
zaeph commentedon Apr 17, 2020
I'll make the PR now, then.
(feat) remove user-error for org-roam-insert
(feat) remove user-error for org-roam-insert
ricklupton commentedon Apr 17, 2020
Thank you both, sounds good to me.
Just one more thought: now is the chance to choose whether you get relative or absolute links from outside the org roam directory, without making a breaking change, since neither was possible before. I’m not sure which is best, so probably fine as is.
1 remaining item