gerard.vermeulen@posteo.net writes: > 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). Thanks! > 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? This was a bug in `org-element-copy'. Fixed, on main now. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dfeff03c5 > I also did not yet look into how to propagate a switch like -n10. -n10 is not a valid switch, AFAIK. We demand space: -n 10. See 12.6 Literal Examples section of the manual. I made some adjustments to the patch, making use of org-element API. See the attached updated version of the patch. I am not yet merging it as I found some weirdness with indentation. Consider the following (indentation is important): #+BEGIN_SRC emacs-lisp -n 20 ;; This exports with line number 20. (message "This is line 21") #+END_SRC After M-x org-babel-demarcate-block, I am getting #+BEGIN_SRC emacs-lisp -n 20 ;; This exports with line number 20. #+END_SRC #+begin_src emacs-lisp -n 20 (message "This is line 21") #+end_src