emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: Recovered file has extra ^M


From: Kenichi Handa
Subject: Re: Recovered file has extra ^M
Date: Thu, 17 Aug 2006 09:45:09 +0900
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/22.0.50 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

In article <address@hidden>, Eli Zaretskii <address@hidden> writes:

> > From: Kenichi Handa <address@hidden>
> > CC: address@hidden
> > Date: Wed, 16 Aug 2006 14:18:29 +0900
> > 
> > (let (coding-system)
> >   (switch-to-buffer (find-file-noselect "temp"))
> >   (setq coding-system buffer-file-coding-system)
> >   (erase-buffer)
> >   (let ((coding-system-for-read 'auto-save-coding))
> >     (insert-file-contents "#temp#"))
> >   (set-buffer-file-coding-system coding-system))
> > 
> > So, if the correct encoding can be detected from "temp",
> > Emacs wins.

> I'm not sure I understand what did you mean by ``if the correct
> encoding can be detected from "temp"''.  Does it mean that only the
> file name and perhaps its contents before the editing are used in the
> usual way to determine or detect its EOL format?

And also default-buffer-file-coding-system.  In short, the
same coding system decided for a buffer which visits
"temp" in a normal way.

> If so, then the
> following scenario will lose:

>     C-x C-f temp RET
>     C-x RET f dos
>     ... edit the file's text ...
>     M-x do-auto-save RET
>     C-x C-c

> If after this, you recover-file, and the original file "temp" had EOL
> format other than -dos, then the recovered file will not have the -dos
> EOL format.  Am I missing something?

No.  But, there are several other cases that will lose some
coding information in a recovered buffer.

Ex: Provided that "temp" contains only ASCII chars.
C-x C-f temp RET
C-x RET f utf-8
... insert non-ASCII chars ...
M-x do-auto-save RET
C-x C-c

The buffer of the recovered file is not utf-8.

To fix this kind of problem, we must store the information
of buffer-file-coding-system in a saved file or in a
separate file (e.g. #temp#.coding).

Even in the EOL case, it's not enough to encode #temp# by
the current buffer-file-coding-system because, in editing,
you may delete all newlines in a buffer.

---
Kenichi Handa
address@hidden




reply via email to

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