On Thu, Apr 13, 2000 at 10:28:09AM +0200, Jean-Marc Lasgouttes wrote: > >>>>> "Dekel" == Dekel Tsur <[EMAIL PROTECTED]> writes: > Dekel> Should we do something about this problem in the 1.1.5 > Dekel> prerelease? Namely, make LyX ignore the specific error messages > Dekel> generated in this case (until a better solution comes along) > > Well, putting an array in a caption is a very specific case. I do not > think it would be worth/possible to ignore just this one. Note that > the other cases that have been reported of new errors were real ones, > which needed to be reported. > > What we could _maybe_ do is to allow previewing the dvi even though > there have been errors. If there is a dvi file, of course. However, I > do not like that much, since people should really try to fix those > errors. I've created two patches. The first, causes LyX to ignores the error messages generated in the case of an array inside a caption. The error messages in this case are quite specific, so I don't think that this patch causes LyX to miss other (real?) errors. Even if it does, it is better to have some errors unreported than not being able to use arrays in caption. The second patch allows generating&viewing the dvi file even if there are errors (when there are errors, a yes/no popup asks you whether you want to continue). It is a little bit ugly, though.
Index: src/LaTeX.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeX.C,v retrieving revision 1.21 diff -u -p -r1.21 LaTeX.C --- src/LaTeX.C 2000/03/28 02:18:51 1.21 +++ src/LaTeX.C 2000/04/13 16:17:52 @@ -492,7 +492,12 @@ int LaTeX::scanLogFile(TeXErrors & terr) // at least longtable.sty might use this. retval |= RERUN; } - } else if (prefixIs(token, "! ")) { + } else if (prefixIs(token, "! ") + && token != "! Argument of \\@caption has an extra }." + && token != "! Paragraph ended before \\@caption was +complete." + && token != "! Argument of \\@tempf has an extra }." + && token != "! Paragraph ended before \\@tempf was +complete." + ) { // Ok, we have something that looks like a TeX Error // but what do we really have.
Index: src/LaTeX.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeX.C,v retrieving revision 1.21 diff -u -p -r1.21 LaTeX.C --- src/LaTeX.C 2000/03/28 02:18:51 1.21 +++ src/LaTeX.C 2000/04/13 20:53:59 @@ -31,6 +31,7 @@ #include "bufferlist.h" #include "minibuffer.h" #include "gettext.h" +#include "lyx_gui_misc.h" using std::ifstream; using std::endl; @@ -97,6 +98,21 @@ LaTeX::LaTeX(string const & latex, strin depfile = file + ".dep"; } +bool LaTeX::askContinue() +{ + int errors = getNumErrors(); + string s,t; + if (errors == 0) + return true; + else if (errors == 1) { + s = _("There was one error during the LaTeX run."); + t = _("You should try to fix it."); + } else { + s = _("There were ") + tostr(errors) + _(" errors during the LaTeX +run."); + t = _("You should try to fix them."); + } + return AskQuestion(s,t,_("Continue?")); +} int LaTeX::run(TeXErrors & terr, MiniBuffer * minib) // We know that this function will only be run if the lyx buffer @@ -105,6 +121,7 @@ int LaTeX::run(TeXErrors & terr, MiniBuf // in it. However it seems safe to run latex (at least) on time each // time the .tex file changes. { + bool ignore_errors = false; int scanres = LaTeX::NO_ERRORS; unsigned int count = 0; // number of times run num_errors = 0; // just to make sure. @@ -151,7 +168,11 @@ int LaTeX::run(TeXErrors & terr, MiniBuf minib->Store(); this->operator()(); scanres = scanLogFile(terr); - if (scanres & LaTeX::ERRORS) return scanres; // return on error + if (scanres & LaTeX::ERRORS) + if (askContinue()) + ignore_errors = true; + else + return scanres; // return on error run_bibtex = scanAux(head); if (run_bibtex) lyxerr[Debug::DEPEND] @@ -171,7 +192,11 @@ int LaTeX::run(TeXErrors & terr, MiniBuf minib->Store(); this->operator()(); scanres = scanLogFile(terr); - if (scanres & LaTeX::ERRORS) return scanres; // return on error + if (scanres & LaTeX::ERRORS) + if (askContinue()) + ignore_errors = true; + else + return scanres; // return on error } // update the dependencies. @@ -232,7 +257,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuf minib->Store(); this->operator()(); scanres = scanLogFile(terr); - if (scanres & LaTeX::ERRORS) return scanres; // return on error + if (scanres & LaTeX::ERRORS && !ignore_errors) + return scanres; // return on error // update the depedencies deplog(head); // reads the latex log head.update(); @@ -278,7 +304,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuf minib->Store(); this->operator()(); scanres = scanLogFile(terr); - if (scanres & LaTeX::ERRORS) return scanres; // return on error + if (scanres & LaTeX::ERRORS && !ignore_errors) + return scanres; // return on error // keep this updated head.update(); } @@ -286,6 +313,8 @@ int LaTeX::run(TeXErrors & terr, MiniBuf // Write the dependencies to file. head.write(depfile); lyxerr[Debug::LATEX] << "Done." << endl; + if (ignore_errors) + scanres |= LaTeX::IGNORE_ERRORS; return scanres; } Index: src/LaTeX.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeX.h,v retrieving revision 1.11 diff -u -p -r1.11 LaTeX.h --- src/LaTeX.h 2000/04/04 00:19:07 1.11 +++ src/LaTeX.h 2000/04/13 20:53:59 @@ -134,6 +134,8 @@ public: /// TOO_MANY_ERRORS = 4096, /// + IGNORE_ERRORS = 8192, + /// ERRORS = TEX_ERROR + LATEX_ERROR, /// WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING @@ -162,6 +164,9 @@ protected: LaTeX(LaTeX const &); /// unavail LaTeX & operator= (LaTeX const &); + + /// + bool askContinue(); /// void deplog(DepTable & head); Index: src/buffer.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v retrieving revision 1.68 diff -u -p -r1.68 buffer.C --- src/buffer.C 2000/04/12 14:20:07 1.68 +++ src/buffer.C 2000/04/13 20:54:07 @@ -3305,7 +3305,10 @@ int Buffer::runLaTeX() } AllowInput(users); - return latex.getNumErrors(); + if (res & LaTeX::IGNORE_ERRORS) + return 0; + else + return latex.getNumErrors(); } Index: src/lyx_cb.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v retrieving revision 1.71 diff -u -p -r1.71 lyx_cb.C --- src/lyx_cb.C 2000/04/12 14:20:08 1.71 +++ src/lyx_cb.C 2000/04/13 20:54:14 @@ -312,7 +312,7 @@ int MenuRunLaTeX(Buffer * buffer) else if (buffer->isDocBook()) ret = RunDocBook(1, buffer->fileName()); else - ret = buffer->runLaTeX(); + return buffer->runLaTeX(); if (ret > 0) { string s;