Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about org-element vs. om #4

Closed
alphapapa opened this issue Feb 29, 2020 · 3 comments
Closed

Question about org-element vs. om #4

alphapapa opened this issue Feb 29, 2020 · 3 comments

Comments

@alphapapa
Copy link

@alphapapa alphapapa commented Feb 29, 2020

Hi,

Quick question if I may: of course, Nate's om library is great. But I'm curious, why do you use om-parse-element-at here:

(setq elem (om-parse-element-at om-point))

Would org-element-parse-buffer be sufficient? AFAIK om is more intended for manipulating the structures that org-element produces than doing the parsing itself.

BTW, very cool project, even though I kind of recoil at XML in general. :) Always glad to see more projects in the Org ecosystem.

@ndw

This comment has been minimized.

Copy link
Owner

@ndw ndw commented Feb 29, 2020

I struggled mightily with decoding the org-element-* structures. Perhaps my elisp skills weren't up to the task, perhaps I failed to find the relevant documentation. If you look in org-to-xml.el, you'll see my crude attempts to work with the underlying org structures. It never worked very well and there were cases where it failed in odd ways.

The short answer is: I discovered the om library and concluded that it gave me more regular, more understandable structure to work with.

@alphapapa

This comment has been minimized.

Copy link
Author

@alphapapa alphapapa commented Mar 1, 2020

I sympathize, as I have also struggled with the org-element structures. For some reason they seemed unnatural to me for a long time. I even tried to use treepy's zipper tools to work on them and failed (though maybe I should try that again since I've learned more).

Eventually they sort of clicked with me. Perhaps ironically, I think it was noticing how the structures returned by Emacs's libxml parsing functions are similar to the ones returned by org-element that helped me. As well, I started using destructuring whenever I need to work with them, e.g. in these functions, which makes it much easier for me to keep the elements in my head than using car/cdr-type accessors.

The short answer is: I discovered the om library and concluded that it gave me more regular, more understandable structure to work with.

That's what confuses me: I thought that the structures om uses are the same org-element structures, but maybe I'm wrong.

Thanks.

@ndw

This comment has been minimized.

Copy link
Owner

@ndw ndw commented Mar 1, 2020

They are similar. It's possible that they're just different enough to have got me thinking in the right way about them, but it's also possible that I was just thinking more clearly about the problem when I started using them.

@alphapapa alphapapa closed this Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.