jkitchin / scimax

An emacs starterkit for scientists and engineers
Other
1.04k stars 123 forks source link

Org id is not being used for links #303

Closed shrysr closed 1 year ago

shrysr commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

jkitchin commented 5 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

thanks!