reddit / emacs

Tangling a codeblock inside a codeblock. Ending with: #+end_src #+end_src...

kolerezooi · 2022-06-04 14:57
I want to tangle a codeblock inside a codeblock and include #+end\_src inside. This will not work in org-mode since it will be recognized as the end of the code block. #+begin_src :tangle snippets/org-mode/PythonBlock # -*- mode: snippet -*- # name: PythonBlock # key: <p # -- #+begin_src python :tangle ${2:NameHere}.py :results output # NOTE, this file is generated from the org file: # `(file-name-nondirectory (buffer-file-name))` # Only modify the org file and not this Python file. $0 #+end_sr${1:c} #+end_src The hack above works but I'm wondering if it there are other solutions. (note: while typing my question I thought about the ${1:c} option and kinda answered my own question. Perhaps there are other solutions? )
organic-bookworm · 2022-06-04 19:09
See [Literal Examples](https://orgmode.org/manual/Literal-Examples.html#Literal-Examples). >You must insert a comma right before lines starting with either `*`, `,*`, `#+` or `,#+`.
dpoggio · 2022-06-06 02:18
Start the empty block, then press `C-c '` to edit, edit whatever you need, then press the same to end editing and everything will be automatically escaped, including the inner block. As simple as that.