In this question someone asked if there was any way to eliminate user defined macros from a TeX document and replace them with the appropriate primitives. The answer seemed to be that while some programs did this for simple macros there was no general solution.
I'm in need of a less complex feature. Most journals I submit to are happy with user defined macros but they all must be included in the document to make it self-contained and the journals get upset if you throw in all sorts of unnecessary macros. This leads to the unpleasant task of manually discerning what macros from your files where used in a particular document and copying them over. I'd like to know if there is anything to automate this process.
This is potentially much easier. One has a finite list of \input{blah.tex} files that may contain the macro definition and one need only decide if the document might require that macro, i.e., it is referenced from a macro referenced in the document.
So under the assumptions that
1) No non-user code calls user macros that aren't explicitly passed in the arguments.
2) User code doesn't dynamically reference other user macros via \csname style constructs.
3) All user macros are either in the document itself or in the finite list of user macro files passed to the utility/package.
Is there any automatic way of listing those user macros that MIGHT be needed for compilation of the current document.