Subject: 23.2; line-encoding not recognized in short files

From: David Reitter <[email-masked]>
Date: Wed, 2 Jun 2010 22:17:49 -0400

X-Debbugs-CC: [email-masked]
X-Debbugs-CC: [email-masked]

Emacs fails to recognize the encoding of a relatively short file with Mac-like line endings (attached).   I think that this is the main problem.  This I have reproduced in a 23-based Emacs.  If the file is made longer (with more LaTeX code), line-endings seem to be recognized correctly.

The user's report is below; you can see that he is surprised by Emacs trying to be smart and guessing the encoding from \usepackage[mac]{inputenv} in his LaTeX file.  Note that it only guesses this when the file is re-loaded - not upon the first save.  That is part of why this is surprising "by design".  (Then, the LaTeX-aware encoding guesser seems to ignore the actual line-endings of the file being loaded and goes for "Mac".)

Begin forwarded message:

> From: Francesco Della Pietra <[email-masked]>
> Date: June 2, 2010 9:41:38 AM EDT
> To: Bug reports for Aquamacs Emacs <[email-masked]>
> Subject: Re: [Aquamacs-bugs] 23.2; files saved in wrong line end format
> Reply-To: Bug reports for Aquamacs Emacs <[email-masked]>
> 
> Yes,
> but this does not happen with your file. After some tests, the minimal text where i find this problem is the following, with these (minimal) instructions:
> 
> - start without customizations
> -command-N
> -enter exactly these lines:
> 
> \documentclass[a4paper,10pt]{article}
> 
> \usepackage[mac]{inputenc}
> \usepackage[italian]{babel}
> \usepackage[intlimits]{amsmath} 
> \usepackage{amsthm,booktabs} 
> \reversemarginpar
> \usepackage{amsfonts}     
> \usepackage{amssymb,color,comment}
> \usepackage[top=2cm, bottom=1cm, left=1cm, right=1cm]  {geometry}
> \begin{document}
> \pagestyle{empty}
> \twocolumn
> \begin{center}
> \textbf{\Large \sc Analisi Matematica}
> \end{center}
> 
> -C-x C-s foo.tex
> -Command-W
> -C-x C-f foo.tex
> 
> (it appears OK)
> 
> - Now modify something, for example give an empty space between lines:
> 
> \documentclass[a4paper,10pt]{article}
> 
> \usepackage[mac]{inputenc}
> \usepackage[italian]{babel}
> 
> \usepackage[intlimits]{amsmath} 
> \usepackage{amsthm,booktabs} 
> \reversemarginpar
> \usepackage{amsfonts}     
> \usepackage{amssymb,color,comment}
> \usepackage[top=2cm, bottom=1cm, left=1cm, right=1cm]  {geometry}
> \begin{document}
> \pagestyle{empty}
> \twocolumn
> \begin{center}
> \textbf{\Large \sc Analisi Matematica}
> \end{center}
> 
> -C-x C-s
> -Command-W
> -C-x C-f foo.tex
> 
> Now appears
> 
> \documentclass[a4paper,10pt]{article}^M^M\usepackage[mac]{inputenc}^M\usepackage[italian]{babel}^M^M\usepackage[intlimits]{amsmath} 
> ^M\usepackage{amsthm,booktabs}^M\reversemarginpar^M\usepackage{amsfonts} ...
> and so on.
> 
> 
> 
> Thanks for the time you spent on my problem.
>