I have a master doc (master.org
) and child docs (A.org
, B.org
, etc.) I have a macro which uses the name of the current file to create chapters, so for example when I do {{{sections}}}
, the macro evaluates an ELisp function to get the name of the file and then creates appropriate (e.g. * A - Intro
).
Now, I want to know if there is a simple way to make this work when including child documents. Obviously, if I use this macro in A.org
, then include it from master.org
, the macro will expand into * Master - Intro
.
Any way of evaluating the macros with the name of the file they were in?
org-export-as
: it copies the file you are exporting to a new buffer, and the first thing it does is it expands#+INCLUDE
keywords. After that, there are no child documents: it is all one big buffer. Macros are expanded after that, so they don't have any filenames to play with (other than perhaps the name of the top level file).