Emacs ediff错误"文件末尾没有换行符"

Flo*_*enn 4 emacs diff newline

在Debian Wheezy,Emacs 23.3.1中,运行带有文件的ediff文件最后会丢失换行符导致错误\ No newline at end of file(我希望这是正确的翻译;它\ Kein Zeilenumbruch am Dateiende.在我的计算机上是德语.)

是否有可能只发出警告,以便我可以看到差异并对其进行处理(并修复丢失的换行符)?首先让ediff失败,然后打开文件,再次添加新行,ediff,这有点单调乏味.

Luk*_*vin 8

尝试更改变量的值ediff-diff-ok-lines-regexp以包含德语文本("Kein Zeilenumbruch am Dateiende"):

(setq ediff-diff-ok-lines-regexp
      (concat
       "^\\("
       "[0-9,]+[acd][0-9,]+\C-m?$"
       "\\|[] "
       "\\|---"
       "\\|.*Warning *:"
       "\\|.*No +newline"
       "\\|.*missing +newline"
       "\\|.*Kein +Zeilenumbruch +am +Dateiende"
       "\\|^\C-m?$"
       "\\)"))

更新:看看源代码,似乎Ediff没有尝试处理来自的消息本地化问题diff.还应该可以通过包装diffshell脚本来解决这个问题,例如:

#!/bin/bash
LANG=C diff $*

..然后自定义ediff-diff-program调用包装器:

(setq ediff-diff-program "~/bin/my-diff.sh")

Emacs源目录lisp/vc中的其他代码似乎确实处理了这个问题,例如vc-hg-state:

(defun vc-hg-state (file)
  "Hg-specific version of `vc-state'."
   ...
        (with-output-to-string
          (with-current-buffer
              standard-output
            (setq status
                  (condition-case nil
                      ;; Ignore all errors.
              (let ((process-environment
                 ;; Avoid localization of messages so we
                 ;; can parse the output.
                 (append (list "TERM=dumb" "LANGUAGE=C")
                     process-environment)))
   ...

Ediff不会这样做有点奇怪,但也许我错过了一些东西.