0

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?

2
  • 1
    I don't think there is any simple way. Look at 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).
    – NickD
    Aug 14 at 2:10
  • I see, thanks Nick!
    – daedsidog
    Aug 14 at 2:17

0

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.

Browse other questions tagged or ask your own question.