Paul Bryan <[email protected]> writes: > So the issue is trying to reference the macros defined in base.org from > files included by base.org? So base.org includes include.org and you > try reference base.org macros in include.org? I confirm I get the same > behaviour as you. No problem exporting, but publishing gives an error: > > Publishing file /home/paul/tmp/myproject/include2.org using > ‘org-html-publish-to-html’ > org-macro-replace-all: Undefined Org macro: mymacro; aborting > > I guess that could be considered as a bug in publishing since it does work > when exporting. I'm not sure what the intended behaviour is for chaining > macros when including files though. > [... MWE ...]
> Publishing has no errors and produces the expected html when the lines are > commented as above. > > *However*, uncommenting any of the lines in include.org or include2.org gives > an error while publishing Great working example! But this is expected, not a bug. This is because the macros are defined per-document, the include2.org document doesn't have an include for the macros defined in include.org or test.org, and include.org does not have an include for the macro defined in test.org. Nor can they, because that will trigger a "recursive file inclusion" error. This is not specific to publishing; if the non-included macros are uncommented, document export (without publishing) will not work either for include.org or include2.org. So macros defined lower down the include chain can be invoked higher up, but not vice versa. For global macros, use org-export-global-macros instead of =#+MACRO:= keywords. Note that the included documents include.org and include2.org will also be published with the publishing configuration in your MWE, which is unlikely to be the intention IRL, since they only store macros. You could add =:exclude "include"= to the publishing-project definition to exclude them, and publish test.org with no error messages. Regards, Christian
