0

Recently, I added to this answer to the question “How to specify a directory to tangle all code blocks into”, the following comment: “AFAICS, specifying a subdirectory in the argument of :tangle doesn't have any effect”.

At least that is what I see with the following property:

#+PROPERTY: header-args :padline no :mkdirp yes :tangle my/sub/directory/myfile.foo :exports both :noweb yes :eval always

and tangling triggered with org-babel-tangle (C-c C-v t), the file myfile.foo is created in the current directory and not in the subdirectory my/sub/directory/.

But I discovered that if the tangling is run non-interactively (in batch mode, outside of Emacs) with the command:

emacs -Q letgut.org --batch -f org-babel-tangle --kill

then the file myfile.foo is, as expected, created in the subdirectory my/sub/directory/.

Do you understand the reason for the difference between these two ways of tangling and how to make org-babel-tangle behave like the command above?

5
  • 1
    I cannot reproduce the problem: interactively tangling the file creates the subdirectory my/sub/directorory and creates the file myfile.foo in that subdirectory. Check what default-directory is (with C-h v default-directory), make sure that you can create the subdirectory in that directory (mkdir -p my/sub/directory from the shell - you can delete it afterwards to try again). Also, the #+PROPERTY: keyword line needs to be active: if you just added it, make sure you do C-c C-c on it to activate it; or close the file and reopen it.
    – NickD
    May 19 at 15:22
  • 2
    BTW, you can do M-x org-babel-view-src-block-info on a source block to see e.g. whether the header-args property is set to what you think it is set.
    – NickD
    May 19 at 15:37
  • Did you C-c C-c on the #+PROPERTY line to activate it? Or close and re-open the file? It seems to work. I suggest removing your comment on the other answer.
    – mankoff
    May 20 at 17:53
  • @NickD (and @mankoff) You're right: the #+PROPERTY: keyword line wasn't active. Strangely, C-c C-c on it has the effect to change the mode from Org to LaTeX (AUCTeX). You can make you comment an answer and I'll accept it. May 20 at 20:16
  • There is something really strange about your setup: this should not happend at all.
    – NickD
    May 20 at 21:20

1 Answer 1

1

[These are my original comments made into an answer -- but note that there is a mysterious mode change that is so far unexplained.]

I cannot reproduce the problem: interactively tangling the file creates the subdirectory my/sub/directorory and creates the file myfile.foo in that subdirectory.

Check what the value of default-directory is (with C-h v default-directory), make sure that you can create the subdirectory in that directory (mkdir -p my/sub/directory from the shell - you can delete it afterwards to try again) - this should catch e.g. bad permissions that don't let you create the subdirectories or the file.

Also, the #+PROPERTY: keyword line needs to be active: if you just added it, make sure you do C-c C-c on it to activate it; or close the file and reopen it.

You can do M-x org-babel-view-src-block-info on a source block to see e.g. whether the header-args property is set to what you think it is set.


The OP reports that the header-args property was not set. But doing C-c C-c on it to activate it, changes the major mode of the file from Org to LaTeX. It's not at all clear why that happens: I'm surmising setup problems, but I have no data to even theorize how that could happen. Presumably, closing and reopening the Org file also resolves the problem and does not cause the mode change - but only the OP knows for sure at this point.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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