Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Org id is not being used for links #303

Closed
shrysr opened this issue Aug 28, 2019 · 14 comments
Closed

Org id is not being used for links #303

shrysr opened this issue Aug 28, 2019 · 14 comments

Comments

@shrysr
Copy link

shrysr commented Aug 28, 2019

I'm unable to use org-id's for storing links - with scimax loaded and zero user customisation scripts (except the snippet below). Link targets come out to something like nb:my_org::notes.org::c721452. Would be grateful for advice on fixing this.

Snippet for org id:

(require 'org-id)
(setq org-id-link-to-org-use-id t)

;; Update ID file .org-id-locations on startup
(org-id-update-id-locations)

(setq org-id-method (quote uuidgen))
(add-hook 'org-capture-prepare-finalize-hook 'org-id-get-create)
@jkitchin
Copy link
Owner

It looks like you should add (org-link-set-parameters "id" :store #'org-id-store-link).

If you don't want the notebook links, you can also use (org-link-set-parameters "nb" :store nil)

@shrysr
Copy link
Author

shrysr commented Aug 28, 2019

Ah. That worked for the org-id link. However - each time I call org-store-link : I get the question 'which function for creating the link?' and there's only one option there org-id-store-link. Is there a way for me to not have to select the function each time?

@jkitchin
Copy link
Owner

If you delete org-id-store-link you will see two options, the other one for the nb link. I am not sure why there is a preloaded choice. if you set the nb :store link to nil I think that will go away.

@shrysr
Copy link
Author

shrysr commented Aug 28, 2019

Yes, it did go away after setting nb :store link to nil. I have not really used the nb links before - any advantages of using nb links that I should be aware of ? I use nb-new for any new project and org-projectile to capture project specific tasks.

@jkitchin
Copy link
Owner

nb links are more portable than id links in some ways. For example, in a git repo if someone makes a heading and links to it by an id, you will not necessarily be able to follow that link if you haven't opened the org-file and had the id registered. This happens a lot to me in shared project files with my students. The nb link avoids that issue and allows you to make a link relative to a project root that works on other machines that also have the project, but maybe in another place (so neither relative nor absolute links would work) as long as you have visited the project with projectile (so that it knows where the root is).

nb links make it easy to make links between projects that don't break when project move around. in principle id links can do this too, but in practice if the id isn't in the id database, it triggers a very long search that the nb link avoids.

nb links have some different actions associated with them also which might be useful, e.g. open bash in the directory with M-b, or finder/explorer with M-e, etc.

@shrysr
Copy link
Author

shrysr commented Sep 9, 2019

I see now what you mean. It appears the nb link references a position? How do you deal with updates in the document?

@jkitchin
Copy link
Owner

It can reference a position but if you do that with a character or line number it is fragile and if the document updates the link will not point to the same place anymore. You can also use org references (I think) to headlines. I am thinking of adding some git link capabilities so you can link to past versions of files.

It is possible to link to an image, and see an overlay of the image on the link.

@uliw
Copy link

uliw commented Jan 22, 2023

Is there a way to make nb-links compatible with https://github.com/nobiot/org-transclusion?
nb-links only have the information relative to the project root, so one cannot plug into the code that is used for transclusions. For now, I am using org-link-set-parameters "nb" :store nil) but it would be neat,

@jkitchin
Copy link
Owner

I don't know a way to make them compatible. It would probably have to be the other way around, which is figure out how to make org-transclusion work with that kind of link.

@uliw
Copy link

uliw commented Jan 23, 2023

OK, just for my understanding, how does emacs resolve a link like nb:esbmtk::esbmtk/esbmtk.py::c1 to the actual location in the filesystem (i.e., ~python/esbmtk/esbmtk.py) ?

@jkitchin
Copy link
Owner

It runs the function nb-follow. Loosely, that function gets the link path and parses it, then looks through projects defined by projectile to get a root path, and opens the file relative to that, using the location bit at the end for jumping to a character, line, etc.

@uliw
Copy link

uliw commented Jan 23, 2023

I saw this function in the docs, but if I run this outside of a project it claims that nb:esbmtk is not a known project. Yet, if click on the same link, emacs open the correct buffer. Probably todo with context?

@jkitchin
Copy link
Owner

The only way you can run it outside a project is like (nb-follow "esbmtk::esbmtk/esbmtk.py::c1") That should open the file in your project. You don't include nb: in it, that is the link type, and not part of the path.

@uliw
Copy link

uliw commented Jan 23, 2023

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants