[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I get rid of control-M characters?

From: Eli Zaretskii
Subject: Re: How do I get rid of control-M characters?
Date: Mon, 23 Oct 2000 14:06:38 +0200 (IST)

On Mon, 23 Oct 2000, Martin Gustavsson wrote:

> I do not know if this is correct, but I think that a change from
> version 19 to 20 is that Emacs interprets a file with control-M
> characters as a MS-DOS or Microsoft Windows file and tries to not
> change this.

This is correct.  See the section "Recognize coding" in the Emacs

> 1) how to know if there are control-M characters present?

When Emacs visits a file with DOS-style end-of-line (EOL) format, it 
displays a backslash "\" at the left edge of the mode line.  (Versions of 
Emacs after 20.3 display a more prominent "(DOS)" indicator, when Emacs 
runs on a Unix system.)  That is a sign that the file has CRLF pair of 
characters at the end of each line.

You can disable the automatic conversion of the EOL format by setting the 
variable inhibit-eol-conversion to t, but I think this variable didn't 
exist in v20.3 (you might as well upgrade).

> 2) how to get rid of these control-M characters?

How did you do that with Emacs 19?  The same methods will work in
Emacs 20, if you disable EOL conversion.

You can also type "C-x RET f undecided-unix RET" and then save the file; 
this will save it in Unix EOL format.

> I have tried to work around this by myself. The GNU Emacs Manual
> ( gives
> the following possible addition to a .emacs file:
>   (add-hook 'comint-output-filter-functions
>             'comint-strip-ctrl-m)
> The Emacs FAQ for the Microsoft Windows port
> ( gives
> the following possible addition to a .emacs file:
>   (add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)
> (In both cases is this connected with "ctrl-m's printed in the shell
> buffer")

These solutions have nothing to do with your problem.  They don't affect 
the EOL format used to save files in any way.

Please also note that a special feature, called untranslated filesystems, 
exists in the Windows port of Emnacs, whereby you can force Emacs to save 
all files on a certain drive or directory in Unix format.  If some of the 
DOS-style files were created by Emacs running on a Windows machine, this 
might be a better solution.  For details, please read the section "Text 
and Binary" in the Emacs manual.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]