Emacs ediff 错误“文件末尾没有换行符”
在 Debian Wheezy、Emacs 23.3.1 上,运行 ediff-files 时文件末尾缺少换行符会导致错误 \ No newline at end of file
(我希望这是正确的翻译;它是德语 \ Kein Zeilenumbruch am Dateiende。
在我的计算机上。)
是否可以只显示一个警告,以便我可以看到差异并对其进行处理(并且修复丢失的换行符)?首先让 ediff 失败,然后打开文件,添加换行符,再次 ediff 有点乏味。
On Debian Wheezy, Emacs 23.3.1, running ediff-files with a file that is missing a newline at the end results in the error \ No newline at end of file
(I hope that's the correct translation; it's German \ Kein Zeilenumbruch am Dateiende.
on my computer.)
Is it possible to have just a warning instead, so that I can see the diff and work on it (and fix the missing newline)? It's just a bit tedious to first have ediff fail, then open the file, add the newline, ediff again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试更改变量
ediff-diff-ok-lines-regexp
的值以包含德语文本(“Kein Zeilenumbruch am Dateiende”):更新: 查看源代码代码中,Ediff 似乎没有尝试处理来自
diff
的消息本地化问题。还应该可以通过将diff
包装在 shell 脚本中来解决此问题,例如:..然后自定义
ediff-diff-program
来调用包装器:其他Emacs 源目录 lisp/vc 中的代码似乎确实可以处理此问题,例如
vc-hg-state
:Ediff 不也这样做似乎有点奇怪,但也许我错过了某物。
Try changing the value of the variable
ediff-diff-ok-lines-regexp
to include the German text ("Kein Zeilenumbruch am Dateiende"):Update: Looking at the source code, it does seem that Ediff doesn't make any attempt to deal with the issue of localization of messages from
diff
. It should also be possible to work around this by wrappingdiff
in a shell script, e.g:..then customising the
ediff-diff-program
to call the wrapper instead:Other code in the Emacs source directory lisp/vc does seem to handle this, for example
vc-hg-state
:It seems a bit strange that Ediff doesn't also do this, but perhaps I'm missing something.
好吧,我发现出了什么问题,可悲的是,这很明显:我的环境有
LANG=de
,因此当 Emacs 调用diff
时,警告消息会以德语返回:好吧,Emacs 没有识别出这个“未知”消息,因此失败了。使用
LANG=C emacs
启动 emacs 可以解决这个问题。然而,我认为假设用户的语言是英语是 emacs 的一个(非常愚蠢的)错误。Ok, I found out what's wrong, and sadly, it's quite obvious: my environment has
LANG=de
, therefore when Emacs invokesdiff
, the warning message is returned in German as well, and Emacs, not recognising this “unkown” message, fails.Starting emacs with
LANG=C emacs
works around this problem. However, I consider it a (quite silly) bug of emacs to make assumption on the user's language being English.