#include "support/SignalSlot.h"
#include <list>
+#include <set>
#include <string>
#include <vector>
/// Return macro defined before the inclusion of the child
MacroData const * getMacro(docstring const & name, Buffer const & child, bool global = true) const;
+ /// Collect user macro names at loading time
+ typedef std::set<docstring> UserMacroSet;
+ UserMacroSet usermacros;
+
/// Replace the inset contents for insets which InsetCode is equal
/// to the passed \p inset_code.
void changeRefsIfUnique(docstring const & from, docstring const & to,
: lineno_(lexer.lineNumber()), pos_(0), mode_(mode), success_(true),
buffer_(buf)
{
- if (buf)
- buf->updateMacros();
tokenize(lexer.getStream());
lexer.eatLine();
}
Parser::Parser(istream & is, parse_mode mode, Buffer * buf)
: lineno_(0), pos_(0), mode_(mode), success_(true), buffer_(buf)
{
- if (buf)
- buf->updateMacros();
tokenize(is);
}
Parser::Parser(docstring const & str, parse_mode mode, Buffer * buf)
: lineno_(0), pos_(0), mode_(mode), success_(true), buffer_(buf)
{
- if (buf)
- buf->updateMacros();
tokenize(str);
}
cell->push_back(MathAtom(new MathMacroTemplate(buf,
name, nargs, 0, MacroTypeDef,
vector<MathData>(), def, display)));
+
+ if (buf && (mode_ & Parse::TRACKMACRO))
+ buf->usermacros.insert(name);
}
else if (t.cs() == "newcommand" ||
cell->push_back(MathAtom(new MathMacroTemplate(buf,
name, nargs, optionals, MacroTypeNewcommand,
optionalValues, def, display)));
+
+ if (buf && (mode_ & Parse::TRACKMACRO))
+ buf->usermacros.insert(name);
}
else if (t.cs() == "newcommandx" ||
cell->push_back(MathAtom(new MathMacroTemplate(buf,
name, nargs, optionals, MacroTypeNewcommandx,
optionalValues, def, display)));
+
+ if (buf && (mode_ & Parse::TRACKMACRO))
+ buf->usermacros.insert(name);
}
else if (t.cs() == "(") {
else if (t.cs().size()) {
bool const is_user_macro =
- buf && buf->getMacro(t.cs(), false);
+ buf && (mode_ & Parse::TRACKMACRO
+ ? buf->usermacros.count(t.cs()) != 0
+ : buf->getMacro(t.cs(), false) != 0);
latexkeys const * l = in_word_set(t.cs());
if (l && !is_user_macro) {
if (l->inset == "big") {