]> git.lyx.org Git - lyx.git/commitdiff
Properly warn on missing pygmentize command
authorEnrico Forestieri <forenr@lyx.org>
Mon, 31 Jul 2017 09:32:28 +0000 (11:32 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 31 Jul 2017 09:32:28 +0000 (11:32 +0200)
- 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
src/frontends/qt4/GuiDocument.cpp

index 489f5df439b62da275bf54f2265bad1b3313b337..66a71c26f349935d8ec1cf348627dcf653ed1388 100644 (file)
 #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<InsetInclude *>
+                                                       (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;
 
index e8d66ec3a3845b840b61971c5fb51a0c4063754d..c21ce4f0775767f0c787e168120d955ceaad86ea 100644 (file)
@@ -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()));