I am live-coding. I would like to be able to change the major mode to and from
org-mode without un-hiding any of the text that
org-mode has hidden. I would switch to a code mode whenever I want that mode's syntax highlighting and smart indentation, and switch to org-mode whenever I want to fold, unfold and quickly jump between org headings.
org-edit-src-code is a poor solution when live-coding
In a live-coding setting, cursor navigation time and screen space are both at a premium. Therefore, cluttering the screen with #+begin_src / #+end_src brackets around each code snippet is problematic. It reduces the amount of code that can be visible, and it increases the time one must spend cursoring through "administrative" lines in order to get to the code.
Getting bounced to an auxiliary window to code the snippet is problematic, too, because it cuts the amount of context one can see by more than half (since the code being edited is duplicated in both windows, and because there's a line dedicated to separating the windows).
Another bad option: Simply switching major modes
I can switch modes easily enough, e.g. by typing
M-x ha-mode <RET>. But when I do that, all the text that I had carefully collapsed pops back into view. Worse, if I then switch back to org-mode, everything but the top level collapses. I would like both transitions to have no effect on what text is visible.
My particular use case
I believe my question would be relevant to anyone live-coding. But about me:
I'm using https://tidalcycles.org. TidalCycles is a DSL for music written in Haskell. One can evaluate TidalCycles expressions interactively from within Emacs. I would like to keep my TidalCycles code in an org file, so that I can more easily hop around between stashed snippets.
I'm also visually impaired. There are only about 18 lines and 64 columns on my screen. Therefore wrapping a one-line code snippet in a heading and two _SRC brackets is very costly.