On 02.01.2024 11:48, Ihor Radchenko wrote:
gerard.vermeu...@posteo.net writes:
[...]
IMHO, this is a bug.The current approach with regexp matching in `org-babel-demarcate-block'is clearly not accurate. What would be more robust is using org-element-at-point + org-element-copy + set :value +org-element-interpret-data to carry over all the affiliated keywords andheader arguments.
[...]
(org-babel--get-vars (nth 2 (org-babel-get-src-block-info)))
Attached you'll find a new patch trying to implement your suggestions. Interactive splitting by demarcation seems to work quite well (see the before and after splitting snippets in the PS). However, I cannot run the test because org-babel-demarcate-block always errors "org-element--cache: Emergency exit" while the same input works interactively. Could there be a problem of cache synchronization or something like that? Is there something I can do? I also did not yet look into how to propagate a switch like -n10. PS: # begin before splitting snippet #+caption[Demarcation splitting test]: #+caption: Demarcation splitting test. #+header: :var edge="also copied" #+header: :wrap "src any-spanish -n" #+name: lst:test #+begin_src python -i -n :var here="copied" :wrap "src any-english -n" # above-split # below-split #+end_src # end before splitting snippet # begin after splitting snippet #+caption[Demarcation splitting test]: #+caption: Demarcation splitting test. #+header: :var edge="also copied" #+header: :wrap "src any-spanish -n" #+name: lst:test #+begin_src python -i -n :var here="copied" :wrap "src any-english -n" # above-split #+end_src #+header: :var edge="also copied" #+header: :wrap "src any-spanish -n" #+begin_src python -i -n :var here="copied" :wrap "src any-english -n" # below-split #+end_src # end after splitting snippet
0001-org-babel-demarcate-block-split-using-org-element-in.patch
Description: Binary data