Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Editing a windows file under Linux

7 views
Skip to first unread message

Cecil Westerhof

unread,
Sep 8, 2011, 3:58:53 AM9/8/11
to
I have defined a function to convert a buffer to Windows format. But
when I edit it again I need to remember to run the function again. Is
there a way to edit a file and keep the windows format? (^M^J)

I also wrote functions to convert to Unix and Apple. Would people be
interested in those functions?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Stefan Monnier

unread,
Sep 8, 2011, 9:36:56 AM9/8/11
to
> I have defined a function to convert a buffer to Windows format. But
> when I edit it again I need to remember to run the function again. Is
> there a way to edit a file and keep the windows format? (^M^J)

Normally, Emacs handles the conversion transparently for you,
automatically detecting the format of the file you're editing.


Stefan

Cecil Westerhof

unread,
Sep 8, 2011, 12:18:35 PM9/8/11
to
Op donderdag 8 sep 2011 15:36 CEST schreef Stefan Monnier:
I just opened the file, but when giving enter I do not see the ^M. So
in my case it is not working.

Stefan Monnier

unread,
Sep 8, 2011, 1:57:11 PM9/8/11
to
> I just opened the file, but when giving enter I do not see the ^M. So
> in my case it is not working.

The ^M is undesirable in the buffer, so it's indeed not there, but it
will be in the file. Just check in the lower-left corner (in the left
part of the mode-line) whether it says :, (unix), (dos), ...


Stefan

Jason Earl

unread,
Sep 8, 2011, 8:30:45 PM9/8/11
to
On Thu, Sep 08 2011, Cecil Westerhof wrote:

> Op donderdag 8 sep 2011 15:36 CEST schreef Stefan Monnier:
>
>>> I have defined a function to convert a buffer to Windows format. But
>>> when I edit it again I need to remember to run the function again. Is
>>> there a way to edit a file and keep the windows format? (^M^J)
>>
>> Normally, Emacs handles the conversion transparently for you,
>> automatically detecting the format of the file you're editing.
>
> I just opened the file, but when giving enter I do not see the ^M. So
> in my case it is not working.

My experience has been that if you see ^M in the buffer then something
is wrong with the file. Either there is a missing carriage return, or
there is an extra one.

Jason

Jorgen Grahn

unread,
Sep 11, 2011, 7:10:16 PM9/11/11
to
On Thu, 2011-09-08, Cecil Westerhof wrote:
> I have defined a function to convert a buffer to Windows format. But
> when I edit it again I need to remember to run the function again. Is
> there a way to edit a file and keep the windows format? (^M^J)
>
> I also wrote functions to convert to Unix and Apple. Would people be
> interested in those functions?

Not really -- Emacs has plenty of support. Others explained that. One
thing I use sometimes with broken files is
M-x universal-coding-system-argument, or

C-x RET c

and then I might say 'dos' and then open a file, forcing Emacs to
assume it has DOS line endings.

BTW, I thought MacOS stopped doing their own funny line endings about
a decade ago? Wikipedia knows, of course; I'm too lazy to check.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
0 new messages