By default, Org-mode will override current babel src block content on file original content (when the file already has content).
For example, I have an org-mode file content as the bellowing block:
#+BEGIN_SRC org
,* config file
,** config 1
,#+BEGIN_SRC clojure :tangle "data/code/tangle-append-test.clj"
(println "hello")
,#+END_SRC
,** config 2
,#+BEGIN_SRC clojure :tangle "data/code/tangle-append-test.clj"
(println "world")
,#+END_SRC
#+END_SRC
If you tangle the whole buffer file, then the result will looks like this:
The tangled file result content:
#+NAME: data/code/tangle-append-test.clj
#+BEGIN_SRC clojure
(println "hello")
(println "world")
#+END_SRC
This is fine. But here is my problem:
But if you tangle only current src block with [C-u C-c C-v t]
. Then
the current tangled src block will overwrite the whole destination file, like
this:
$ cat data/code/tangle-append-test.clj
(println "world")
UPDATED
My question: The single babel block override original file content, I hope to only append current tangled block without overwriting.
C-c C-v t
) and tangle all blocks in the file. My tangled files are in the .gitignore anyway because I treat them only as an artifact to run the application. They are essentially throwaway code, I regenerate them whenever I need to. The real code is in the source blocks.