Subject: Re: bug#21574: po-mode mishandles ASCII files

From: Eli Zaretskii <[email-masked]>
Date: Mon, 28 Sep 2015 13:18:49 +0300

> From: Paul Eggert <[email-masked]>
> Date: Sun, 27 Sep 2015 13:01:22 -0700
> 
> Emacs's po-mode mishandles .po files that specify charset=us-ascii.  To 
> reproduce the problem on Fedora, run 'LC_ALL=cs_CZ.iso88592 emacs -Q fr.po' with 
> fr.po being the attached file (taken from Texinfo 6.0), and type '# C-x 8 RET 
> 161 RET RET C-x C-s'.  The file will be saved with the line '#š' prepended, in 
> Latin-2 encoding, even though the file declares its encoding to be 
> charset=us-ascii.

I think what you see is a side effect of a feature: when a character
is added that can be safely encoded by the default value of
buffer-file-coding-system, Emacs silently saves the file in that
encoding.  This feature was added in response to user requests not to
bother them with annoying requests to select an encoding when all they
did was add some non-ASCII text native to their locale to a file that
was previously ASCII-only.

What we need in this particular case, I think, is some code in po.el
that would function similarly to what we already do when the file has
a coding cookie, and the user adds characters that cannot be saved
with the encoding stated by the cookie.

Btw, do we have a similar problem in other files that have entries in
file-coding-system-alist, like XML files or LaTeX files?