Reputation: 5365
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.
Upvotes: 5
Views: 1893
Reputation: 13432
Try changing the value of the variable ediff-diff-ok-lines-regexp
to include the German text ("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?$" "\\)"))
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 wrapping diff
in a shell script, e.g:
#!/bin/bash LANG=C diff $*
..then customising the ediff-diff-program
to call the wrapper instead:
(setq ediff-diff-program "~/bin/my-diff.sh")
Other code in the Emacs source directory lisp/vc does seem to handle this, for example 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))) ...
It seems a bit strange that Ediff doesn't also do this, but perhaps I'm missing something.
Upvotes: 8
Reputation: 5365
Ok, I found out what's wrong, and sadly, it's quite obvious: my environment has LANG=de
, therefore when Emacs invokes diff
, 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.
Upvotes: 3