0

I use org-mode to tangle code blocks in programming languages such as python into their respective code files. But I am not sure how to tangle ditaa code blocks and execute them to generate figures outside emacs.

I tried to add the :tangle tag as follows:

#+begin_src ditaa :file ./some.png :tangle tangled.ditaa :comments link :cmdline -E :exports results :results none
...

#+end_src

But, nothing gets tangled into the designated file tangled.ditaa.

What is the appropriate way to tangle and execute a ditaa code block in org mode?

(This is with Emacs 28 in Ubuntu 22.04 LTS.)

-- Edit --

There was a prompt when tangling the ditaa block, which was blocking the tangling process:

Type M-x picture-mode-exit in this buffer to return it to Fundamental mode.

No comment syntax is defined.  Use:

If I enter a random value such as #, the block is tangled into a disk file.

Can I disable this behavior, since there is no comment in my ditaa blocks?

Also, the tanged file does not seem to remember the :file ./some.png tag, and when executed with ditaa tangled.ditaa, just generates a file with default name tangled.png.

How can I make the tangled ditaa file output to the same image file as described in the original org mode file?

3
  • I cannot reproduce the first problem, even if I specify that .ditaa files be opened in picture-mode through an entry in auto-mode-alist. What happens if you open tangled.ditaa in emacs? For the second question, there is no place in the ditaa file where the output filename is stored. By default, if you run ditaa on tangled.ditaa, you are going to get tangled.png - it keeps the stem and changes the extension. You can run ditaa tangled.ditaa some.png to produce a differently name output file, but there's nothing that Org mode can do about that: you got to do that manually.
    – NickD
    Commented Dec 13, 2022 at 2:12
  • @NickD What happens if you open tangled.ditaa in emacs?. I see the ditaa file content as text in "Fundamental" mode. On the second point, I was trying to automate the tangling process and had hope to get the tangled code behave the same way as the code block. But I guess I can hard-code the filenames.
    – tinlyx
    Commented Dec 13, 2022 at 2:49
  • But it seems clear that the buffer is in picture-mode at some point in the tangling, so maybe you can edebug the picture-mode function, so that the processing will stop at that point and you can get a backtrace with d to see how exactly it got there.
    – NickD
    Commented Dec 13, 2022 at 14:38

0

Your Answer

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

Browse other questions tagged or ask your own question.