From 44babaf6569898deaa9ba02b1f3170e7144e6791 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Mon, 31 Jul 2017 11:32:28 +0200 Subject: [PATCH] Properly warn on missing pygmentize command - Do not warn when the document properties pane is opened but only when minted is selected and the pygmentize command was not found. - Warn before launching latex if minted is selected and the document actually uses listings insets. --- src/Converter.cpp | 38 +++++++++++++++++++++++++++++++ src/frontends/qt4/GuiDocument.cpp | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Converter.cpp b/src/Converter.cpp index 489f5df439..66a71c26f3 100644 --- a/src/Converter.cpp +++ b/src/Converter.cpp @@ -19,14 +19,18 @@ #include "Encoding.h" #include "ErrorList.h" #include "Format.h" +#include "InsetList.h" #include "Language.h" #include "LaTeX.h" #include "LyXRC.h" #include "Mover.h" +#include "ParagraphList.h" #include "Session.h" #include "frontends/alert.h" +#include "insets/InsetInclude.h" + #include "support/debug.h" #include "support/FileNameList.h" #include "support/filetools.h" @@ -459,6 +463,40 @@ bool Converters::convert(Buffer const * buffer, "tmpfile.out")); } + if (buffer && buffer->params().use_minted + && lyxrc.pygmentize_command.empty() && conv.latex()) { + bool dowarn = false; + // Warn only if listings insets are actually used + for (Paragraph const & par : buffer->paragraphs()) { + InsetList const & insets = par.insetList(); + pos_type lstpos = insets.find(LISTINGS_CODE, 0); + pos_type incpos = insets.find(INCLUDE_CODE, 0); + if (incpos >= 0) { + InsetInclude const * include = + static_cast + (insets.get(incpos)); + if (include->params().getCmdName() != + "inputminted") { + incpos = -1; + } + } + if (lstpos >= 0 || incpos >= 0) { + dowarn = true; + break; + } + } + if (dowarn) { + Alert::warning(_("Pygments driver command not found!"), + _("The driver command necessary to use the minted package\n" + "(pygmentize) has not been found. Make sure you have\n" + "the python-pygments module installed or, if the driver\n" + "is named differently, to add the following line to the\n" + "document preamble:\n\n" + "\\AtBeginDocument{\\renewcommand{\\MintedPygmentize}{driver}}\n\n" + "where 'driver' is name of the driver command.")); + } + } + if (!checkAuth(conv, buffer ? buffer->absFileName() : string())) return false; diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index e8d66ec3a3..c21ce4f077 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -1469,7 +1469,7 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(setListingsMessage())); connect(listingsModule->packageCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); - connect(listingsModule->packageCO, SIGNAL(currentIndexChanged(int)), + connect(listingsModule->packageCO, SIGNAL(activated(int)), this, SLOT(listingsPackageChanged(int))); connect(listingsModule->listingsED, SIGNAL(textChanged()), this, SLOT(setListingsMessage())); -- 2.39.2