Org-roam major redesign

Have a look at this code in my Gist. I still use it and works so far (V2 is dynamically changing so no guarantee it continues to).

I only extract the first sub-directory with car but you should be able to adjust what my/org-roam-get-subdirectory returns and how the returned value gets formatted in the calling function.

1 Like

I have made a spin-off topic, affecting mainly Windows users; all welcome to share expertise and experience. Thank you.

I have seen that v2 uses completion categories, which are also supported by packages like marginalia or embark. I would like to extend the usage of categorized nodes.

I am imagining that the user finds some nodes via completion, takes a snapshot with embark, and then there is a buffer available where one can work with. Actually this already works, but the only action available right now is to visit the node. I would like to act further actions like “add tag”, “remove tag”, “find backlinks”, etc.

To begin with that work, I would have to refactor the tagging functions in org-roam.el, which currently presume a purely interactive use. I would change that so that tagging can be done on any org roam file, in a non-interactive way, so that we could finally tag using the embark interface. I think this is a great alternative to interfaces like delve, since the completion ui is the ultimate entry point which everybody uses.

I could simply do a PR, but I first wanted to know

(a) if there already any plans to make use of the completion categories, so that I can rely on them being present,

(b) if there are any reasons speaking against refactoring the current tagging system,

(c) if there is any interest in adding support for using embark actions more extensively.

I don’t know the internal details, but am def interested in this in general.

I’m bdarcus on github :wink:

Just so everybody knows, embark allows you to bind a set of commands, via any keymap, to completing-read candidates. The completion category is the mechanism for contextualizing the commands.

In effect, it provides something analogous to a contextual menu.

So really the questions are what commands might make sense, and how should they work?

Hello again! :wink:

I was mainly thinking of doing “bulk” edits, like in org agenda mode, in particular adding or removing tags. Depending on how embark refresh works, that could even be done with the current setup, since each completion candidate can be displayed with a tag. So I thought one could create a snapshot of all items matching #tag1, replace them with #tags2, refresh, etc, like working in occur or the like.

IMHO, changing the tagging mechanism to something more abstract and non-interactive is generally a good idea. That would allow for all kind of extensions which e.g. tag lists of files generated in what way ever. Refactoring this would the first and as it seems pretty easy step, but I would like to have the OK from the maintainers that they think this kind of extensibility and this kind of use is something they would support.

So here’s a spontaneous list of per item actions:

  • Add or remove tags
  • Delete the node
  • Copy the complete node content incl. heading to the kill ring for further use
  • Open another buffer with all backlinks or forward links
  • Export the links or their content to an org mode buffer
  • Create a transclusion buffer from the list (woah, that sounds crazy cool)

If you can get me a buffer containing a list of links from Org-roam completion, it should be rather trivial to give you a list of transclusions with Org transclusion. Not sure if this is what you are going for.

;; A buffer 

[[id:uuid-1]]

[[id:uuid-2]]
 ...
[[id:uuid-n]]

Skipping a little detail of how the new version of a org-transclusion, essentially each ID link can become a copy of the headline and/or file content to which the link points.

That’s cool! And that’s the idea behind my proposal: Embark gives us the ability to transfer all completion candidates in an extra list to do something with them. And if we have the candidates, we have their ID. And then we can do all kind of things with this list, like editing them in a row, or transferring them to a transclusion buffer. And who knows, maybe there will be once something similar to org-ql for querying org roam nodes, and such a system seems to me perfect.

2 Likes

Hi everyone. I’ve managed to get Org-roam v2 installed and I use it regularly now.

Now that org-roam links are based on IDs, I’ve found that Latex export fails with an org file that includes those types of links. The org dispatcher tells me it’s unable to resolve the ID link.

In doing the org->Latex->pdf export, I’m not really interested in keeping active org-roam links but, maybe, only their descriptions.

Does anybody know a way to get round this issue?

Use org-export-with-broken-links. You can set it in elisp or as an option in the document header.

Documentation
Non-nil means do not raise an error on broken links.

When this variable is non-nil, broken links are ignored, without
stopping the export process. If it is set to mark, broken
links are marked as such in the output, with a string like

[BROKEN LINK: path]

where PATH is the un-resolvable reference.

This option can also be set with the OPTIONS keyword, e.g.,
“broken-links:mark”.

This variable was added, or its default value changed, in Org version
9.0.

Perfect. Thanks a lot for the advice!

If you want them to resolve, add your Org-roam files to your org-id-extra-files:

(setq org-id-extra-files (find-lisp-find-files org-roam-directory "\.org$"))

for example.

Hi @jethro, thanks for your suggestion. Yes, that’s what I needed. However, there’s a couple of issues:

  1. Using that snippet gives me a void function error. Should I put a ' in front of the second parenthesis? (sorry, I’m still relatively new to elisp);
  2. The amended snippet gives me the desired result with Latex export if the node was created with the default Org-roam template but for some reason it does not with my custom template.

Please find attached my Org-roam configuration where you can view my custom templates. Basically, I personalised the ID assignment and the filename of the note, the two are not the same. But that shouldn’t be a problem since the same happens with the default template. What am I missing?

Okay, after experimenting a bit I found a solution. I had to update the ID locations file and DB, and I used the function provided in the Hitchhiker’s Rough Guide.

(defun my/org-id-update-org-roam-files ()
      "Update Org-ID locations for all Org-roam files."
      (interactive)
      (org-id-update-id-locations (org-roam--list-all-files)))
1 Like

Seems like org-roam--list-all-files no longer exists. The following works for me:

  (defun rodelrod/resolve-id-links-for-export ()
    "Add Org Roam files to org-id locations so that export works."
    (interactive)
    (org-id-update-id-locations (org-roam-list-files)))

@rodelrod , there is also a new command: org-roam-update-org-id-locations. It does org-id-update-id-locations inside for you.

2 Likes

@nobiot ah great, I’ll use that one instead, thanks.

I’m really, really interested in being able to query my org-roam DB like with org-ql or logseq. I came across your package vulpea, but I didn’t find any documentation on how to query the database, ideally beginner-friendly?

For example, I would like to do queries that return a list of all nodes that link to nodes A and B.

Edit: I’ve realised it probably makes more sense to post this as a GitHub issue. Hope this makes sense.

It’s possible. I will try to answer you tomorrow in issue that you created in vulpea :slight_smile:

Cool, thanks!

See it here : Query all nodes that contain links to nodes A __and__ B · Issue #105 · d12frosted/vulpea · GitHub

1 Like