First, a few introductory remarks. When on Windows, I use the great Sublime Text text editor. It’s the next best thing after TextMate, which is only available on the Mac. Its greatest asset (besides its killer looks…) is a well thought-out, comprehensive, and easy-to-use python-based plugin system. I spent some time developing a LaTeX package that replicates many of the best features of the TextMate LaTeX bundle. I plan on maintaining it (in my spare time), as a sort of “insurance policy”—if I ever have to leave the Mac for whatever reason, I want to make sure that I can rely on a suitable LaTeX-friendly editor. The available alternatives (WinEdt, Emacs, vim, the “e” text editor…) do not quite fit my style, for several reasons; but that’s for another post.
OK, now for the actual “news.” I just committed a small patch that improves error reporting when running the
texify command (analogous to
latexmk). Previously, if, for instance,
texify was not on the path, nothing happened. This is, of course, bad: per the Zen of Python, “Errors should never pass silently.”
The code that creates a pipe to the
texify command now captures all output directed to
STDERR. Now, the tricky thing is that there are three possible cases to take care of:
texifyruns successfully, and compilation goes through, in the sense that there are no TeX/LaTeX errors (although there may be warnings). In this case, there is no output to
STDERR, and the plugin proceeds as before, displaying a quick panel that summarizes the results of compilation.
texifyruns successfully, but there are TeX/LaTeX errors. In this case,
texifyprints out a message to
STDERRinviting the user to “see [the] log file”.
the pipe to
texifycannot be created, in which case there the Windows system prints out a message to
To cover cases 2 and 3, I use the following logic. If the output to
STDERR is non-empty, I look for the string “see log file”; if it’s there, I bring up the quick panel, which displays the information from the log file as before; otherwise, I bring up a message box that notifies the user of the Windows error message that was obtained.
Again, most of the times the problem is that
texify is not on the path, which can easily be fixed by adding the Miktex binary directory to the user or system
PATH environment variable. Remember to relaunch Sublime Text after you modify the path.
NOTE: Make sure you download the latest version of the LaTeX package (it’s r.688 on Google Code). There were a couple of bugs in the first fix I committed; now everything seems to be OK, but please let me know if you encounter any issues.
Memo to myself: I must improve error reporting. Right now errors from bibtex (e.g. misspelled bibliography file) are not shown.