[OS X Emacs] opening old mac files (CR end of line char)

Thomas Käufl kaeufl at ira.uka.de
Wed Dec 5 12:26:27 EST 2007


Am 05.12.2007 um 17:20 schrieb Bill Rising:

> On Dec 5, 2007, at 9:29 , xah lee wrote:
>
>>> Are you sure that the files don't have a mixture of EOL  
>>> characters? I see this from time to time with files that start  
>>> with something other than a Mac EOL, but then have Mac EOLs later.
>>
>> yeah... it's pure mac file. (open a unix file, change all LF to  
>> CR, then reopen it)
>
>
> [...]
>
> I have no trouble opening Mac files that were made by Mac  
> applications with Mac EOLs. I see the problem only if I do the  
> substitutions in the first case above or if I have files with mixed  
> EOLs.
>
> I cannot say if this existed in earlier versions of Emacs (any  
> variety), because I always have changed the encoding using the easy- 
> to-remember (hah!) key-binding C-x RET f

sometimes in the past I also encountered the problem of
wrong EOL characters. I always had the impression that it
was a problem of the file in question and not of EMACS.

The method Bill suggests is well suited to get rid of
the problem.

Maybe using
    tr '\r' '\n' < problem-file > new-file
in the terminal might be possible too. All Mac EOLs are
changed to Unix EOLs. (So, if the problem file contained a
mixture of Mac and Unix EOLs, now only Unix EOLs appear.)
After that
    tr '\n' '\r' < new-file > file
introduces Mac EOLs if necessary.

Thomas Käufl




More information about the MacOSX-Emacs mailing list