[OS X Emacs] Aquamacs windows to mac encoding

M A markoilcan at gmail.com
Tue Feb 16 10:28:26 EST 2010

On Mon, Feb 15, 2010 at 9:48 PM, David Romano <romanod at math.grinnell.edu> wrote:
> On Tue, 16 Feb 2010, Peter Dyballa wrote:
>> Am 15.02.2010 um 23:30 schrieb David Romano:
>>> Thanks -- this works, although it introduces lots of blank lines.  I'll
>>> see if I can get the init file to prevent this.
>> Then try this file with Apple's (/usr/bin/)emacs in Terminal! Could be
>> Aquamacs Emacs is doing some nonsense.
> I get the same effect by using C-x RET r with "mac" or "big5-mac" as input
> in emacs in Terminal.  If I use "mac-roman-mac" the file doesn't change in
> appearance -- the ^M^Ms stay and no blank lines are introduced.  Maybe the
> init file solution is the only one?

Why not just translate the DOS line endings into unix ones outside of emacs?
If it's really a DOS file this will make it a unix one:

perl -pe 'tr/\015//' dosfile > unixfile

The \015 is the octal for the CR character (also known as \r). If you want to be
sure this is the correct replacement use:

head -1 dosfile | od -c

to get a representation of every character on the first line. Look at the end of
the output and see what is being used as the line endings. If it's a DOS file
it will have \r\n and the above perl line will work.

Mark A

More information about the MacOSX-Emacs mailing list