polymode / poly-org

Polymode for org-mode
57 stars 13 forks source link

Org properties etc not accessible within blocks #32

Open ComedyTomedy opened 3 years ago

ComedyTomedy commented 3 years ago

Hello! Discovered this package today & love it.

My problem: Within a code block, when poly-org-mode is enabled, (org-entry-properties) returns nil. This seems to be the same for various other org-specific functions.

(My specific use case is calling org-babel-tangle, which seems to be broken by this, although I haven't tested extensively).

It would be nice to be able to execute code within the context of the "other" mode, perhaps via a macro (poly-with-org-mode ...), or if the issue affects other poly mode-pairings, (poly-with-outer-mode ...).

This issue may be related to other issues that are already on here - I looked but couldn't tell. Apologies if it's effectively a duplicate.

vspinu commented 3 years ago

Within inner (non-org) modes there is no org mode. The workaround is to advice those functions which should be working across all modes to execute in the base org-mode buffer.

This is how it is done https://github.com/polymode/polymode/blob/54888d6c15249503e1a66da7bd7761a9eda9b075/polymode-core.el#L1434-L1436

malcook commented 2 years ago

Glad to have found this discussion as it precisely addresses issue I was about to raise, namely that org-babel-demarcate-block does not work when called from inner mode. The solution is to

         (pm-around-advice #'org-babel-demarcate-block #'polymode-with-current-base-buffer)