5 ms·
Is there anything that returns a parse tree of an org document? A while ago I wrote some super hacky elisp to navigate around the structure of a giant org mode
by shanusmagnus 3y ago
Is there anything that returns a parse tree of an org document? A while ago I wrote some super hacky elisp to navigate around the structure of a giant org mode doc, but it was rickety and terrible and constantly breaking.
Part of this is surely that I don't know wtf I'm doing, but it seemed like there was not an underlying data structure held in memory that you could conveniently query / manipulate, but rather, most of the existing org functionality built some kind of structure each time you did an operation.
Would appreciate any pointers, code examples, tutorials that show how to effectively navigate / manipulate an org structure and have it reflected in the buffer, if there is such a thing.
- morelisp 3y agohttps://orgmode.org/worg/dev/org-element-api.html https://orgmode.org/worg/dev/org-element-api.html But even with this I found it pretty awful.
- ics 3y agoWhat was awful about it? It's been a while since setting up but my config uses it to pluck the important bits from my Org library into SQLite as I edit; it works well enough and wasn't difficult to set up or understand. Admittedly it is relegated to this one step so that everything else can query docs with SQL but I was quite happy that the API exists so as not to do the parsing myself with the mistakes and minor deviations that would entail.
- imaltont 3y agoWhile it doesn't properly understand the structure, you can move around pretty well with Imenu or (configured) org-goto. I assume it's also possible to make something for it so that it take nesting into consideration like it does for some programming languages. My org files are only a couple 1000 lines though, so don't know how they perform when it gets larger than that.
- elviejo 3y agoOrganice is org-mode but as react apt. they have pretty complete parser. https://github.com/200ok-ch/organice#background-information https://github.com/200ok-ch/organice#background-information
- Brentward 3y agoIn org-alert we use `org-map-entries` and a simple `org-alert--parse-entry` function for stripping out the details we're looking for. Depending on what you want, it's not exactly a data structure, but maybe it will help you get started! https://github.com/spegoraro/org-alert/blob/master/org-alert.el https://github.com/spegoraro/org-alert/blob/master/org-alert...