Remove unsupported macros from autocompletion

We have some math macros that exist only because LyX can display them easily,
but which require user preamble code. These commands should not appear in
autocompletion, they are only there to make the formulas of users who actually
need these symbols and know what to put into the preamble more beautiful.
This commit is contained in:
Georg Baum 2015-03-10 21:04:24 +01:00
parent 226c6f6b17
commit 141f13a9cc
7 changed files with 48 additions and 15 deletions

View File

@ -49,7 +49,7 @@ underrightarrow decoration none amsmath
#Do not load automatically, it redefines some other symbols, and we don't #Do not load automatically, it redefines some other symbols, and we don't
#have a possibility to turn automatic loading off like for ams #have a possibility to turn automatic loading off like for ams
#undertilde decoration none accents #undertilde decoration none accents
undertilde decoration none undertilde decoration none hiddensymbol
utilde decoration none undertilde utilde decoration none undertilde
vec decoration none vec decoration none
widehat decoration none widehat decoration none
@ -60,7 +60,7 @@ dots dots none
#Do not load automatically, it redefines some other symbols, and we don't #Do not load automatically, it redefines some other symbols, and we don't
#have a possibility to turn automatic loading off like for ams #have a possibility to turn automatic loading off like for ams
#adots dots none yhmath #adots dots none yhmath
adots dots none adots dots none hiddensymbol
cdots dots none cdots dots none
ddots dots none ddots dots none
dotsb dots none amsmath dotsb dots none amsmath
@ -93,12 +93,12 @@ Biggr big none
# packages. No 'm' versions! # packages. No 'm' versions!
# See lucidabr.dtx for a possible implementation if you want to use these # See lucidabr.dtx for a possible implementation if you want to use these
# with other fonts. # with other fonts.
biggg big none biggg big none hiddensymbol
bigggl big none bigggl big none hiddensymbol
bigggr big none bigggr big none hiddensymbol
Biggg big none Biggg big none hiddensymbol
Bigggl big none Bigggl big none hiddensymbol
Bigggr big none Bigggr big none hiddensymbol
# font changes # font changes
# name "font" math/text family series shape color # name "font" math/text family series shape color

View File

@ -2111,7 +2111,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
// fill in global macros // fill in global macros
macros.clear(); macros.clear();
MacroTable::globalMacros().getMacroNames(macros); MacroTable::globalMacros().getMacroNames(macros, false);
//lyxerr << "Globals completion macros: "; //lyxerr << "Globals completion macros: ";
for (it = macros.begin(); it != macros.end(); ++it) { for (it = macros.begin(); it != macros.end(); ++it) {
//lyxerr << "\\" + *it << " "; //lyxerr << "\\" + *it << " ";
@ -2183,7 +2183,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
MathWordList::const_iterator it2; MathWordList::const_iterator it2;
//lyxerr << "Globals completion commands: "; //lyxerr << "Globals completion commands: ";
for (it2 = words.begin(); it2 != words.end(); ++it2) { for (it2 = words.begin(); it2 != words.end(); ++it2) {
if (it2->second.inset != "macro") { if (it2->second.inset != "macro" && !it2->second.hidden) {
// macros are already read from MacroTable::globalMacros() // macros are already read from MacroTable::globalMacros()
globals.push_back('\\' + it2->first); globals.push_back('\\' + it2->first);
//lyxerr << '\\' + it2->first << ' '; //lyxerr << '\\' + it2->first << ' ';

View File

@ -119,6 +119,14 @@ string const MacroData::requires() const
} }
bool MacroData::hidden() const
{
if (sym_)
return sym_->hidden;
return false;
}
docstring const MacroData::xmlname() const docstring const MacroData::xmlname() const
{ {
if (sym_) if (sym_)
@ -242,10 +250,11 @@ MacroTable::insert(Buffer * buf, docstring const & def)
} }
void MacroTable::getMacroNames(std::set<docstring> & names) const void MacroTable::getMacroNames(std::set<docstring> & names, bool gethidden) const
{ {
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
names.insert(it->first); if (gethidden || !it->second.hidden())
names.insert(it->first);
} }

View File

@ -62,6 +62,8 @@ public:
/// ///
std::string const requires() const; std::string const requires() const;
/// ///
bool hidden() const;
///
docstring const xmlname() const; docstring const xmlname() const;
/// ///
char const * MathMLtype() const; char const * MathMLtype() const;
@ -162,7 +164,7 @@ public:
/// ///
void dump(); void dump();
/// ///
void getMacroNames(std::set<docstring> & names) const; void getMacroNames(std::set<docstring> & names, bool gethidden) const;
/// the global list /// the global list
static MacroTable & globalMacros(); static MacroTable & globalMacros();

View File

@ -186,6 +186,7 @@ void initSymbols()
string requires; string requires;
string extra; string extra;
string xmlname; string xmlname;
bool hidden = false;
is >> macro >> requires; is >> macro >> requires;
if ((is >> xmlname)) { if ((is >> xmlname)) {
extra = requires; extra = requires;
@ -207,6 +208,11 @@ void initSymbols()
tmp.extra = from_utf8(extra); tmp.extra = from_utf8(extra);
tmp.xmlname = from_utf8(xmlname); tmp.xmlname = from_utf8(xmlname);
tmp.requires = from_utf8(requires); tmp.requires = from_utf8(requires);
if (requires == "hiddensymbol") {
requires = "";
tmp.hidden = hidden = true;
} else
tmp.requires = from_utf8(requires);
theMathWordList[it->first] = tmp; theMathWordList[it->first] = tmp;
wit = theMathWordList.find(it->first); wit = theMathWordList.find(it->first);
it->second.setSymbol(&(wit->second)); it->second.setSymbol(&(wit->second));
@ -219,7 +225,8 @@ void initSymbols()
<< " draw: 0" << " draw: 0"
<< " extra: " << extra << " extra: " << extra
<< " xml: " << xmlname << " xml: " << xmlname
<< " requires: " << requires << '\''); << " requires: " << requires
<< " hidden: " << hidden << '\'');
continue; continue;
} }
@ -290,6 +297,12 @@ void initSymbols()
<< " used for " << to_utf8(tmp.name)); << " used for " << to_utf8(tmp.name));
} }
if (tmp.requires == "hiddensymbol")
{
tmp.requires.clear();
tmp.hidden = true;
}
if (theMathWordList.find(tmp.name) != theMathWordList.end()) if (theMathWordList.find(tmp.name) != theMathWordList.end())
LYXERR(Debug::MATHED, "readSymbols: inset " << to_utf8(tmp.name) LYXERR(Debug::MATHED, "readSymbols: inset " << to_utf8(tmp.name)
<< " already exists."); << " already exists.");
@ -303,7 +316,8 @@ void initSymbols()
<< " draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0]) << " draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0])
<< " extra: " << to_utf8(tmp.extra) << " extra: " << to_utf8(tmp.extra)
<< " xml: " << to_utf8(tmp.xmlname) << " xml: " << to_utf8(tmp.xmlname)
<< " requires: " << to_utf8(tmp.requires) << '\''); << " requires: " << to_utf8(tmp.requires)
<< " hidden: " << tmp.hidden << '\'');
} }
docstring tmp = from_ascii("cmm"); docstring tmp = from_ascii("cmm");
docstring tmp2 = from_ascii("cmsy"); docstring tmp2 = from_ascii("cmsy");

View File

@ -30,6 +30,8 @@ class Lexer;
/// ///
class latexkeys { class latexkeys {
public: public:
///
latexkeys() : hidden(false) {}
/// ///
char const * MathMLtype() const; char const * MathMLtype() const;
/// name of the macro or primitive /// name of the macro or primitive
@ -56,6 +58,9 @@ public:
docstring xmlname; docstring xmlname;
/// required LaTeXFeatures /// required LaTeXFeatures
docstring requires; docstring requires;
/// Should this macro be hidden from autocompletion (since it requires
/// user preamble code)?
bool hidden;
}; };

View File

@ -106,6 +106,9 @@ What's new
- Record undo properly when changing multiple paragraphs parameters - Record undo properly when changing multiple paragraphs parameters
(bug 9437). (bug 9437).
- Do not offer unsupported macros like \biggg in autocompletion
* INTERNALS * INTERNALS