Jean-Marc Lasgouttes wrote:
> The answer really depend on the macro you want to define. In the case of
> \pmod, I did not find any inset (in src/mathed) that seems to be similar
> enough. You want an inset with only one cell, like in
> InsetMathDecoration, which implements accents. So the inset would be a
> /very/ simplified version of this.
>
> However, it seems a bit strange to create a new inset class for this
> simple example. I am not sure what the simplest solution would be. A
> math macro inset gives a not too bad interface, so a solution might be
> to have a way to define a set of default macros that are known to LyX
> from start. Then the macro inset machinery would be sue for the display
> part.
>
> What do the others think?
Something like a set of default macros is already implemented. It is read
from lib/symbols (where \pmod is already defined, that is why you don't see
it in the sources). Unfortunately the syntax of lib/symbols is completely
undocumented, but if you want to define a new predefined macro named \foo,
you can do it like this:
\def\foo{a^2+b^2} myfeature
The first token is the "display" part of the macro and must not contain
spaces. The second token is a feature from LaTeXFeatures.cpp which can
either be a package (e.g. "mathtools"), or use a hard coded definition in
LaTeXFeatures.cpp (e.g. "binom").
Maybe this is enough for your use case. If not, please give a more detailed
example what you want to do, then we might be able to help.
Georg