V2 Migration: issues with roam-refs, org-open-at-point and the graph

After publicly contemplating to stay on v1 for as long as possible, I gave v2 another spin yesterday. :wink: The migration was successfully in that my notes have been transformed to the new format and the basics of the system seem to work. Still, I experience some issues that are probably linked to my particular setup and would be thankful for any ideas on how to fix them.

  1. org-id and org-open-at-point

I run a “one frame-two window” setup (see also below), which served me well in the last year. In this, I want all links in one window to open in other-window. In v1 I had to set this in my .emasc:

(setq org-link-frame-setup '(
  (file . find-file-other-window))

I have no idea how to get this to work with org-id links in v2, as all links open in the same window. This earlier discussion suggests that a bug in org-id might be responsible.

  1. roam-refs and zotero-links

I use org-roam to take notes on other documents (newspaper articles, scientific publications and laws). These are stored in Zotero. Using the add-on Zutilo in Zotero I get links such as this one “zotero://select/groups/2425626/items/7PXILIN4”, which I can open in Emacs by adding this to my .emacs:

(defun zotero-open-ext (path-to-media)
  (shell-command (concat "open zotero:" path-to-media)))
(org-add-link-type "zotero" 'zotero-open-ext)

I added these links to #+roam_ref in v1 and it worked great. In v2, org-roam struggles and I get following warning:

"Invalid ref, skipping…" for almost all Zotero links stored in :PROPERTIES:.

  1. org-roam-graph

I understand that org-roam-graph in v2 is still under development - but right now I get very different results between v2 and v1. Compare these two versions of the graph for a preliminary note on “political culture” in v1 and v2 (C-u 1 M-x org-roam-graph). (For me, the v1 graph is the correct one).

v1:

v2:

  1. org-id and org-open-at-point
    An easy way is to override an Org-roam function.

  2. roam-refs and zotero-links
    This can be achieved via customizing of Org mode.
    EDIT: Quickly reviewed what I wrote.
    Use org-link-set-parameters instead of org-add-link-type (its documentation says it’s obsolete)

  3. org-roam-graph
    I agree that it looks weird compared with V1. Can be a customizing or a technical defect. Sorry; no idea (I don’t use org-roam-graph)

org-id and org-open-at-point

Override org-roam-open-id-at-point as below.

It requires only one line of change (change one argument from nil to non-nil).
Source with the relevant line marked

I believe there should be a more elegant way (less impact; this is a global change). Maybe it should be looked at by the project but I cannot think of a good way for a pull request…

  (defun org-roam-open-id-at-point ()
  "Try to navigate \"id:\" link to find and visit node with an assigned ID.
Assumes that the cursor was put where the link is."
  (let* ((context (org-element-context))
         (type (org-element-property :type context))
         (id (org-element-property :path context)))
    (when (string= type "id")
      (let ((node (org-roam-populate (org-roam-node-create :id id))))
        (cond
         ((org-roam-node-file node)
          (org-mark-ring-push)
          (org-roam-node-visit node 'other-window 'force) ; change the second argument from nil to non-nil
          t)
         (t nil))))))

roam-refs and zotero-links

EDIT: Use org-link-set-parameters instead of org-add-link-type, which is obsolete (see its documentation). The new function takes care of (org-link-make-regexps).

I have done a quick test and this change correctly lets Org-roam insert a zotero ref to the DB.

I cannot test the zotero-open-ext function so it may not follow the link correctly but this change works for roam_refs.

org-roam-graph

Sorry I cannot help you here; I don’t use it at all.

One obvious suggestion would be to have a look at org-roam-ui project.

If you would like to get org-roam-graph “fixed”, a good starting point would be to see the differences between the nodes that are correctly displayed and those that are not, and see if there is any pattern.

Thanks again for a great answer and all of your effort. Very much appreciated!

This solves the org-id and org-open-at-point issue.

This is also a great advice. I still see the occasional Zotero-link in org-roam-graph (when it works), but I think this is by design. In v2 org-roam-graph seems to extract all links and presents them to the user (see below).

Thanks anyway. One of the previous changes may have made org-roam-graph in v2 even more unreliable - it now only works every other time I try it (maybe one in four times). Perhaps the best advice for org-roam-graph users of v1 is to just wait a bit longer and/or to check org-roam-ui.