Subject: Re: bug#13705: 24.2.93; "^M" characters in diff buffers

From: Eli Zaretskii <[email-masked]>
Date: Wed, 13 Feb 2013 18:25:31 +0200

> Date: Wed, 13 Feb 2013 10:40:22 +0100
> From: Dani Moncayo <[email-masked]>
> 
> Recipe from "emacs -Q":
> 1. Download the two attached files `fa' and `fb'.
> 2. M-x diff RET fb RET fa RET
> 
> In the *Diff* buffer, I see annoying/inappropriate "^M" characters at
> the end of the compared lines. (see attached screenshot)

It's most probably your Diff, not Emacs.  I cannot reproduce the
problem with the version of Diff I have here (which is a GnuWin32
port).  My crystal says that yours is from MSYS or maybe Cygwin, and
writes its output with Unix-style LF-only EOL format.  That presents
to Emacs text that has inconsistent EOLs (because the files you diff
have DOS CR-LF EOLs), so Emacs punts and doesn't decode the EOL
format.

To see if my crystal ball is as clear as it gets, try this:

  (let ((coding-system-for-read 'no-conversion))
    (call-process shell-file-name nil t nil
		  shell-command-switch "diff -c fa fb"))

and look at the lines generated by Diff, like these:

 *** fa	2013-02-12 18:41:03.201375000 +0200
 --- fb	2013-02-08 16:25:03.161000000 +0200

If they don't have the ^M character at their end, your problem is as I
described.

With my Diff, the above snippet gives me _all_ the lines with ^M,
which is consistent.