Emacs ediff error "no newline at end of file"

In Debian Wheezy, Emacs 23.3.1, running ediff files with a file that skips a new line at the end leads to the error \ No newline at end of file (I hope the correct translation, German \ Kein Zeilenumbruch am Dateiende. On my computer .)

Is it possible to have only a warning so that I can see the diff and work on it (and fix the missing new line)? It's just a little tiring to disable ediff first, then open the file, add a new line, ediff again.

+4
source share
2 answers

Try changing the value of the ediff-diff-ok-lines-regexp variable to include German text ("Kein Zeilenumbruch am Dateiende"):

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

Update:. Looking at the source code, it seems that Ediff is not trying to solve the problem of localizing messages from diff . It should also be possible to get around this by wrapping the diff in a shell script, for example:

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

.. then configure ediff-diff-program to invoke the shell:

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

Other code in the Emacs lisp / vc source directory seems to handle this, such as 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 little strange that Ediff doesn't do it either, but maybe something is missing for me.

+7
source

Well, I realized that it’s wrong, and, unfortunately, it’s quite obvious: my environment has LANG=de , so when Emacs calls diff , the warning message is also returned in German, and Emacs, without recognizing it as “unkown”, doesn’t works.

Running emacs with LANG=C emacs works around this issue. However, I find this to be a (rather stupid) emacs error to make the assumption that the user language is English.

0
source

Source: https://habr.com/ru/post/1395944/


All Articles