Pergunta

I am trying to use flymake in emacs for my .tex file editing.

I've got it all up and running up until I type in an unbalanced brace { or }. When flymake kicks off, it comes back with the error:

Flymake: Configuration error has occurred while running (pdflatex -file-line-error -draftmode -interaction=nonstopmode /home/matt/test_flymake.tex). Flymake will be switched OFF.

For completeness, here is the relevant part of my .emacs file:

(defun flymake-get-tex-args (file-name)
  (list "pdflatex"
    (list "-file-line-error" "-draftmode" "-interaction=nonstopmode" file-name)))

Looking at the flymake manual gives a hint of what is happening:

CFGERR : Syntax check process returned nonzero exit code, but no errors/warnings were reported. This indicates a possible configuration error (for example, no suitable error message patterns for the syntax check tool).

So, digging into the log (flymake-log-value = 3) I find that the issue is with running pdflatex in that the parser returns a non-zero exit code, but doesn't generate something that flymake recognizes as an error. Specifically:

parsed 'Runaway argument?', no line-err-info
parsed '{Conclusions \bibliographystyle {plain} \bibliography {ma\ETC.', no line-err-info
parsed '! File ended while scanning use of \@xdblarg.', no line-err-info
parsed '<inserted text> ', no line-err-info
parsed '                \par ', no line-err-info
parsed '<*> /home/matt/test_flymake.tex', no line-err-info
parsed '                               ', no line-err-info
parsed '! Emergency stop.', no line-err-info
parsed '<*> /home/matt/test_flymake.tex', no line-err-info
parsed '                               ', no line-err-info
parsed '!  ==> Fatal error occurred, no output PDF file produced!', no line-err-info

So, pdflatex gets mad about my "runaway argument" but doesn't generate something that flymake recognizes as an error. Digging into the flymake.el file shows that flymake-err-line-patterns has this pattern in it:

("\\(LaTeX \\(Warning\\|Error\\): .*\\) on input line \\([0-9]+\\)" 20 3 nil 1)

So... the final issue seems to be that flymake doesn't recognize Runaway argument? as an error message.

Now, my question is: Am I missing something? I can't be the first person to run into this problem but I was unable to find anything about it. I find it hard to believe that everyone just builds a custom solution to modify the error pattern, especially since I'm not doing anything unusual and am just trying to get this to work out of the box.

In case it matters, I am using emacs 24.3 on Ubuntu 12.04 and running pdflatex (pdftex) 2012.

What am I missing? Thanks all for any suggestions you can provide.

Foi útil?

Solução

Well, I'm guessing 13 views in 3 days means it's unlikely I'll get an answer, so here is what ended up working for me...

Like most emacs issues, this can be fixed by editing your .emacs file. Add this block to your file:

(add-to-list
    `flymake-err-line-patterns
    '("Runaway argument?" nil nil nil)) ; fixes unbalanced braces in LaTeX files

and this should fix the issue for latex and pdflatex.

Note that (pdf)latex doesn't list give a line number when this error is produced (which is what the nil nil nil represents), so if this happens then flymake will tell you that the error is on the first line of your .tex file.

M-C-f (forward-sexp) and M-C-b (backward-sexp) will skip over balanced parentheses, letting you search for unmatched ones. source

Just for completeness, here is how flymake is checking my .tex files:

(defun flymake-get-tex-args (file-name)
  (list "pdflatex"
        (list "-file-line-error" "-draftmode" "-interaction=nonstopmode" file-name)))

If your syntax checker is different, or produces a different error message, then swap out the "Runaway argument?" text with your checker's error message.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top