Hacker News new | ask | show | jobs
by BeetleB 1575 days ago
I found a similar problem with Org mode when it comes to writing elisp code to handle org documents - it's almost all based on text parsing vs nodes. So simple automations I can program in a node based editor like the Leo Editor took a lot of effort in Org mode.

As an example, if you want the body (text) of a node, you have to get the substring from the beginning to the end. There wasn't (probably still isn't) an API to get the body. If you want to do a depth-first/breadth-first traversal of nodes, it's not as straightforward as one would think.

I hope someone comes up with a node based API for Org mode.

1 comments

I implemented my own NoSql database for Crossline which supports an efficient storage and traversal of outline items (see https://github.com/rochus-keller/Udb). Even if there was a dedicated API in Emacs/Org-mode it's still file based text buffer interpretation and management behind the scenes.
Nah - the only pain would be in loading/saving. The idea would be that all this information would be in memory and updated live. So when you use node based APIs, it doesn't need to do any parsing. It would have a node object, and the body would be an attribute, and subnodes would be links to other nodes, etc. Only when saving/loading would it then need to convert (serialize) to a text representation.

This is how the Leo editor does it - it's in Python and it can handle a fairly large number of nodes before any slowdown is noticeable.

If you're trying to do non-parsing automations in org, take a look at vulpea. It's roughly the same engine that powers the current version of org-roam. A good example application of this is the vino wine database: https://github.com/d12frosted/vino
Thanks, but is there something like that for plain org? I use org-roam for a few limited use cases. Most of my org stuff is not related to notes, and I don't put it in org-roam.
vulpea is designed to be usable under plain org; it's a separate package from org-roam.