Subject: bug#15535: Acknowledgement (24.3.50; basic-save-buffer should update buffer-file-coding-system value if the contents were written using different coding system)

From: Eli Zaretskii <[email-masked]>
Date: Mon, 07 Oct 2013 05:52:38 +0300

> Date: Sun, 06 Oct 2013 23:58:57 +0300
> From: Dmitry Gutov <[email-masked]>
> CC: [email-masked]
> 
> On 06.10.2013 19:51, Eli Zaretskii wrote:
> > If the former, we could perhaps add some flag to struct undecided_spec
> > and set it whenever the encoder used by `undecided' sees a non-ASCII
> > character, and then use that flag to set last-coding-system-used to
> > UTF-8.
> 
> That already happens (last-coding-system-used has the right value right 
> after the file is written)

Not here, it doesn't.  I see 'undecided'.  And that is part of the
problem.

> but I don't think I can use it: even if 
> `ruby-mode-set-encoding' is moved to after-save-hook, as long as it's 
> not the first function in this hook (and I can't ensure that it is), the 
> previous functions can also do some I/O and thus change 
> last-coding-system-used's value.

You can always take the value of last-coding-system-used as the first
thing you do.  The problem is that the value is wrong, at least in the
scenario I used to reproduce the problem.