Hi, This patch fixes some problems when using listings : - First, Entering "backgroundcolor=\color{red}" into the Listings settings box will result in "backgroundcolor={\color{red}}" in the output file. This makes the latex file uncompilable. To solve this I just used the already defined, but unused, function "getParamValue" in InsetListingsParams.cpp to remove the {}'s. Does this also solve bug 4884: http://bugzilla.lyx.org/show_bug.cgi?id=4884 - Second, after removing the {}'s, the file is still not compilable because the color package is not loaded. Since LyX enthusiastically tells the user to specify the colors in the settings, I think we should require the package color when a color is specified. - Third, specifying listings settings and using a listing in the document leads to two lines yielding "\usepackage{listings}". Vincent
Index: src/LaTeXFeatures.cpp =================================================================== --- src/LaTeXFeatures.cpp (revision 26301) +++ src/LaTeXFeatures.cpp (working copy) @@ -471,7 +471,7 @@ "endnotes", "ifthen", "amsthm", - "listings", + // listings is handled in BufferParams.cpp "bm", "pdfpages", "relsize", Index: src/insets/InsetListingsParams.cpp =================================================================== --- src/insets/InsetListingsParams.cpp (revision 26301) +++ src/insets/InsetListingsParams.cpp (working copy) @@ -729,7 +729,7 @@ if (it->second.empty()) par += rtrim(it->first, "_"); else - par += rtrim(it->first, "_") + '=' + it->second; + par += rtrim(it->first, "_") + '=' + getParamValue(it->first); } return par; } Index: src/BufferParams.cpp =================================================================== --- src/BufferParams.cpp (revision 26301) +++ src/BufferParams.cpp (working copy) @@ -1081,14 +1081,19 @@ // handle inputenc etc. writeEncodingPreamble(os, features, texrow); - if (!listings_params.empty()) { + if (!listings_params.empty() || features.isRequired("listings")) { os << "\\usepackage{listings}\n"; texrow.newline(); + } + if (!listings_params.empty()) { os << "\\lstset{"; // do not test validity because listings_params is // supposed to be valid string par = InsetListingsParams(listings_params).separatedParams(true); + // we can't support all packages, but we should load the color package + if (par.find("\\color",0) != string::npos) + features.require("color"); os << from_ascii(par); // count the number of newlines for (size_t i = 0; i < par.size(); ++i)