Reputation: 1727
I have several .org files, and I'd like to be able to create links between them using an ID. I am using DOIs as unique identifiers. I can link within a file by using properties:
* Paper 1
:PROPERTIES:
:CUSTOM_ID: 10.1088/0953-8984/23/21/213001
:END:
* Paper 2
:PROPERTIES:
:CUSTOM_ID: 10.1038/nphys2935
See also [[#10.1088/0953-8984/23/21/213001]]
Is there a way to make the custom_id global, so I can reference it from another file?
I think that org-id is what I need to go further, but I've found the documentation a little confusing. I tried adding the following lines in my .emacs
;; Use global IDs
(require 'org-id)
(setq org-id-link-to-org-use-id use-existing)
;; Update ID file .org-id-locations on startup
(org-id-update-id-locations)
but the file .emacs.d/.org-id-locations
only has nil
.
It seems like global links won't be automatically generated (Assign IDs to every entry in Org-mode). I tried (with cursor on the heading) to use M-x org-id-get-create
, but this does not seem to do anything.
EDIT: (Based on helpful comment)
Within one session, I can store and create links using M-x org-store-link
while on the heading (Paper 1
in my example above). Then I can use M-x org-insert-link
, and type the ID to insert the link. The link looks like [[id:10.1088/0953-8984/23/21/213001][Paper 1]]
. But I am running into two problems: (1) I'd like the ids to be stored automatically. (2) The links don't work when I close and re-open the file.
EDIT: A related question:
Upvotes: 7
Views: 5984
Reputation: 1727
So here's the solution I came up with.
In my .emacs
configuration, I have kept the same settings as in my question:
(require 'org-id)
(setq org-id-link-to-org-use-id use-existing)
;; Update ID file on startup
(org-id-update-id-locations)
The files need to be part of the agenda list (or added to the list of additional files using org-id-extra-files
(See org-id
documentation))
Use ID
instead of CUSTOM_ID
in the PROPERTIES
drawer:
* Paper 1
:PROPERTIES:
:ID: 10.1088/0953-8984/23/21/213001
:END:
Each ID needs to be created (if necessary; in my case I already have them), and a link added to the ID file (links are stored in .emacs.d/.org-id-locations
). This is done using org-id-get-create
: with the cursor on the heading, call it using
M-x org-id-get-create
Link to an ID using [[id:10.1088/0953-8984/23/21/213001][Paper 1]]
.
I have to think a little bit more about when I'd like the ID to be created; I can automate the process by tying the ID storing to another function that I'll do to all the headings.
Upvotes: 6