emacs - 使用带有 Flymake 的 .tex 文件的 emacs - 不平衡大括号错误

标签 emacs latex tex pdflatex flymake

我正在尝试在 emacs 中使用 flymake 来编辑 .tex 文件。

在输入不平衡的大括号 {} 之前,我已经启动并运行了所有内容。当 flymake 启动时,它返回错误:

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

为了完整起见,这里是我的 .emacs 文件的相关部分:

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

看flymake manual提示正在发生的事情:

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).

因此,深入研究日志 (flymake-log-value = 3) 我发现问题出在运行 pdflatex 上,因为解析器返回一个非零退出代码,但没有生成一些 flymake 认为是错误的东西。具体来说:

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

因此,pdflatex 对我的“失控论点”感到生气,但不会生成 flymake 识别为错误的内容。深入研究 flymake.el 文件显示 flymake-err-line-patterns 中有这个模式:

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

所以...最后一个问题似乎是 flymake 无法将 Runaway argument? 识别为错误消息。

现在,我的问题是:我错过了什么吗?我不是第一个遇到这个问题的人,但我找不到任何相关信息。我发现很难相信每个人都只是构建一个自定义解决方案来修改错误模式,特别是因为我没有做任何不寻常的事情,只是想让它开箱即用。

以防万一,我在 Ubuntu 12.04 上使用 emacs 24.3 并运行 pdflatex (pdftex) 2012。

我错过了什么?感谢大家提供的任何建议。

最佳答案

好吧,我猜 3 天内有 13 次浏览意味着我不太可能得到答案,所以这就是最终对我有用的...

与大多数 emacs 问题一样,这可以通过编辑 .emacs 文件来解决。将此 block 添加到您的文件中:

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

这应该可以解决 latexpdflatex 的问题。

请注意,(pdf)latex 在产生此错误时不会列出行号(这是 nil nil nil 所代表的),因此如果发生这种情况,flymake 会告诉您错误在您的 .tex 文件的第一行。

M-C-f (forward-sexp) 和 M-C-b (backward-sexp) 将跳过平衡括号,让您搜索不匹配的括号。 source

为了完整起见,以下是 flymake 检查我的 .tex 文件的方式:

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

如果您的语法检查器不同,或产生不同的错误消息,则将 “Runaway argument?” 文本替换为您的检查器的错误消息。

关于emacs - 使用带有 Flymake 的 .tex 文件的 emacs - 不平衡大括号错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18776079/

相关文章:

haskell - Intero:来自堆栈配置的 ghc 不匹配

用于解析 Latex 或 MathML 字符串的 Java 或 scala 库

latex - TeX:在每个内容页后添加空白页

latex - 为什么 Tex/Latex 在后续运行中没有加速?

latex - 跳过数字图形和表格标题

emacs - Orgmode 议程 View 中未正确显示类别

emacs - SLIME 未从 Emacs 加载

emacs - 如何在 Emacs 中突出显示选项卡

latex - 如何用它们的定义替换 latex 宏(使用 latex )

macos - 升级到 OSX 10.8.2 "latex: command not found"后