Hi again, Some time ago I was asking about creating macros that defined macros & in particular having usage of the dynamically defined macro display properly. So, with the latex code:
\newcommand{\createDynamicCmd}[1]{\newcommand{\dynamicCmd}{cmdName: #1}} $\createDynamicCmd{frank}$ $\dynamicCmd$ \dynamicCmd would be displayed as cmdName: frank Well, I've made some progress in the display stuff. Basically, I implemented the code at the end of this message & was looking for some feedback. Specifically, 1. Should I be creating a new copy of the macro each time, or should I be finding the old one in the table & updating it? 2. This works fine in the example, however if \createDynamicCmd has a display specification (not sure what you call it), then this code never gets called. Any suggestions? 3. Does the erase copy delete the old argument instance - which is why I copied the cell contents first. Or can I still use a reference to the old one once it's erased from the array? Lastly, I'm going to make it so I can parse macros with dynamically created names: ie \newcommand{\createDynamicCmd}[1]{\newcommand{\fn#1}{cmdName: #1}} As part of this, I'd like to make it so that I can change the name of existing macros. Does anybody have any suggestions on how to do this? thanks, andrew ps I've done this on 1.3.6 code since it's stable & nobody seemed particularly interested in it anyway. Is it worth bothering to port it to 1.4.0? // This is only called if we are a nested macro definition // We do the following: // 1. Make a copy of ourselves // 2. substitute an arguments that should be specified by the caller // 3. Place the result in the MathMacroTable void MathMacroTemplate::substitute(MathMacro const & m) { MathNestInset::substitute(m); MathMacroTemplate *p = new MathMacroTemplate(*this); MathArray &ar = p->cell(0); for (MathArray::size_type offs = 0; offs != ar.size(); ++offs) if (ar[offs]->asMathMacroArgument()) { const MathArray arg(ar[offs]->asMathMacroArgument()->cell(0)); ar.erase(offs); ar.insert(offs, arg); } MathMacroTable::create(MathAtom(p)); } oh yeah, I also implemented asMathMacroArgument() in the same manner as the other similar functions.