diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 9efb2d4c79..f52423d24d 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -820,7 +820,6 @@ bool Buffer::readDocument(Lexer & lex) // read main text bool const res = text().read(lex, errorList, d->inset); - usermacros.clear(); updateMacros(); updateMacroInstances(); return res; diff --git a/src/Buffer.h b/src/Buffer.h index d0d787687c..e79856609f 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -542,10 +542,6 @@ public: /// 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 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, diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 4767dc1536..f86a762be8 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -1060,9 +1060,6 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, cell->push_back(MathAtom(new MathMacroTemplate(buf, name, nargs, 0, MacroTypeDef, vector(), def, display))); - - if (buf && (mode_ & Parse::TRACKMACRO)) - buf->usermacros.insert(name); } else if (t.cs() == "newcommand" || @@ -1108,9 +1105,6 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, 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" || @@ -1229,9 +1223,6 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, 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() == "(") { @@ -1830,14 +1821,14 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, } else if (t.cs().size()) { - bool const no_mhchem = - (t.cs() == "ce" || t.cs() == "cf") && buf - && buf->params().use_mhchem == BufferParams::package_off; - bool const is_user_macro = no_mhchem || - (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 (buf && (mode_ & Parse::TRACKMACRO) && l) + buf->updateMacros(); + + bool const is_user_macro = + (buf && buf->getMacro(t.cs(), false) != 0); + if (l && !is_user_macro) { if (l->inset == "big") { skipSpaces();