3 ms·
What is "node/graph" based APIs that's not the next-heading etc functions that it does have?
by kqr 4y ago
What is "node/graph" based APIs that's not the next-heading etc functions that it does have?
- BeetleB 4y agoLet me see if I can remember some of them: Say I have a node. I want all the children in some form (tree, list, whatever). Say I want to move a node and all its children from one location to another. Given a node, I want its text, but not its children. Given a node with a subtree, I want to manipulate the document so that it becomes flat. All its (nested) children are elevated to the level just under the node. I want to compare if two nodes are "equal" (same text, and recurse downwards). Given a node with a subtree, I want to traverse in some order of my choosing (DFS, BFS, etc). I want a count of how many child nodes there are (1st level) I want a count of how many children there are (all levels). The API may have some of these, but likely not all of them. All of these are trivial in Leo, as Leo gives this to you as a tree. Most of Org's API involve some level of parsing, manipulating the cursor, etc.
- aasasd 4y agoI ended up writing a few functions that implement that kind of an API on top of what Org provides—just a handful of them so far, ones that I needed for the last customizations. I'm probably not the first to do that, and vaguely remember seeing something like that on Github.