4

I have a code blocks for a domain specific input files that I want to have in a single org file and tangle them out to separate files (see Tangling non-code files to separate files). However, my source has things in it that look like org-mode headings, e.g.:

#+BEGIN_SRC fundamental :tangle test.inp
* minimize
*

open unit 10 read form name methanol.rtf
read rtf card unit 10
close unit 10
...
#+END_SRC

and these don't get tangled. Removing the * minimize line or putting any amount of text before it does not solve the problem. The "headers" aren't highlighted but they still have folding etc., and emacs won't let me put spaces in front of them.

Seems like a bug, but a workaround would be helpful.

1 Answer 1

5

The problem is that you did trick org-mode. You did not use C-' to input the text block.

If you do so, the org-mode syntax is escaped as the following example shows. Note the commas before the stars! They are automatically added by org-babel.

#+BEGIN_SRC fundamental :tangle test.inp
,* minimize
,*

open unit 10 read form name methanol.rtf
read rtf card unit 10
close unit 10
...

#+END_SRC

If you input a new source code block the sequence is:

  1. Start on a new line and press tab to get the right indentation.
  2. Input <s and press tab for the easy template that generates a source code block.
  3. Input fundamental :tangle test.inp to complete the header of the source code block
  4. Press C-' to edit the source code block.
  5. In the newly opened buffer paste your text.
  6. Finish editing the source code block with C-'
2
  • Lesson learned, haha!
    – salotz
    Jan 18, 2016 at 21:19
  • @Tobias, thank you for this info. I was trying to grasp where did these commas in my code blocks came from, and this was the first good hint I found in this respect.
    – gusbrs
    Jan 14, 2019 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.