Jean-Marc Lasgouttes wrote:
What I'm suggesting is that command insets should behave the same way.
So we'd have:
    \begin_inset Citation
    command citet
    key etctec
    \end_inset
More or less.
This looks reasonable, in general.
A question: how will the parser know that this is an insetcommand?
Still hardcoded?
More or less, yes. The action here is in readInset() in factory.cpp. At the moment, there's a special branch for command insets: ones where you see \begin_inset LatexCommand. Having the separate branch is useful but, so far as I can see, not essential, and if we want to keep it, we can just check against a list of the command insets first before entering the long if..else if..else construct. Alternatively, we could have a form like this:
\begin_inset CommandInset citation
command citet
key etctec
\end_inset
Speaking of which, I realized that all the inset types already have been given names in the giant translator in Inset.cpp. So I'll use those.

What it'd be really nice to do is something like this:
insetName = string-following-\begin_inset;
foreach insetType
if insetType->name() == insetName;
newInset = insetType(..)
But there's no natural way to recurse through the inset types in C++, is there?

Richard

Reply via email to