I have started using org-babel for a larger project, and have found the readthedocs to be a great resource. I have been using tangling to generate code from documentation, however setting the export filename using :tangle
is gettting cumbersome, since for each block I need to set all of the relative paths and whatnot.
I know that setting the :dir
header argument allows you to choose what directory code blocks will be executed in, but it does not set the tangle directory. Ideally I would like to have something like this:
#+STARTUP: showall
#+PROPERTY: header-args :dir "/home/user/project/path1/path2/path3"
* Test
** myfile.h
:PROPERTIES:
:header-args: :tangle filename1.cpp :no-expand t
:END:
#+BEGIN_SRC C++
#+END_SRC
** myotherfile.cpp
:PROPERTIES:
:header-args: :tangle filename2.cpp :no-expand t
:END:
#+BEGIN_SRC C++
#+END_SRC
Rather than:
#+STARTUP: showall
* Test
** myfile.h
:PROPERTIES:
:header-args: :tangle ../../path2/path3 :no-expand t
:END:
#+BEGIN_SRC C++
#+END_SRC
** myotherfile.cpp
:PROPERTIES:
:header-args: :tangle ../../filename2.cpp :no-expand t
:END:
#+BEGIN_SRC C++
#+END_SRC
Imagine how frustrating this could get if another person takes over the project, or one needs to change the directory layout? I have poked around various sources but haven't found a way to do this. This question is related, but doesn't solve my issue
org-babel-tangle
code did not uncover a method for doing this. You may be able to do what you want with a function added toorg-babel-post-tangle-hook
. Or you can submit an RFE to the org-mode mailing list.