From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs 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) Date: Sun, 06 Oct 2013 19:51:34 +0300 Message-ID: <83vc1a5omh.fsf@gnu.org> References: <871u3z49ty.fsf@yandex.ru> <52509C0D.1000600@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Trace: ger.gmane.org 1381078338 6751 80.91.229.3 (6 Oct 2013 16:52:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Oct 2013 16:52:18 +0000 (UTC) Cc: 15535@debbugs.gnu.org To: Dmitry Gutov , Kenichi Handa Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 06 18:52:20 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VSrZ6-0001uw-9G for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Oct 2013 18:52:20 +0200 Original-Received: from localhost ([::1]:55848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSrZ5-00085s-Vb for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Oct 2013 12:52:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSrYv-0007xu-1m for bug-gnu-emacs@gnu.org; Sun, 06 Oct 2013 12:52:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSrYo-0006KS-Re for bug-gnu-emacs@gnu.org; Sun, 06 Oct 2013 12:52:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSrYo-0006KO-OC for bug-gnu-emacs@gnu.org; Sun, 06 Oct 2013 12:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VSrYo-0001dk-9X for bug-gnu-emacs@gnu.org; Sun, 06 Oct 2013 12:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Oct 2013 16:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15535 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15535-submit@debbugs.gnu.org id=B15535.13810783076278 (code B ref 15535); Sun, 06 Oct 2013 16:52:02 +0000 Original-Received: (at 15535) by debbugs.gnu.org; 6 Oct 2013 16:51:47 +0000 Original-Received: from localhost ([127.0.0.1]:57859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSrYZ-0001dB-3r for submit@debbugs.gnu.org; Sun, 06 Oct 2013 12:51:47 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:62012) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VSrYV-0001d1-A6 for 15535@debbugs.gnu.org; Sun, 06 Oct 2013 12:51:44 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MU900G00AM71Z00@a-mtaout23.012.net.il> for 15535@debbugs.gnu.org; Sun, 06 Oct 2013 19:51:41 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MU900FH8AU4XK60@a-mtaout23.012.net.il>; Sun, 06 Oct 2013 19:51:41 +0300 (IDT) In-reply-to: <52509C0D.1000600@yandex.ru> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:78955 Archived-At: (I've added Handa-san to this discussion, as I'm not sure I didn't miss anything in looking into this.) > Date: Sun, 06 Oct 2013 02:09:01 +0300 > From: Dmitry Gutov > > Sorry, here's a better test: > > (ert-deftest save-buffer-updates-buffer-file-coding-system () > (let ((file (expand-file-name "foo" temporary-file-directory)) > (default-buffer-file-coding-system 'utf-8-unix)) > (find-file file) > (insert "abcdef\n") > (save-buffer) > (kill-buffer) > (unwind-protect > (with-current-buffer (find-file-noselect file) > (should (eq 'undecided (coding-system-change-eol-conversion > buffer-file-coding-system nil))) > (insert "водка матрёшка селёдка") > (save-buffer) > (let ((coding-system buffer-file-coding-system)) > (kill-buffer) > (should (eq 'utf-8-unix coding-system)))) > (delete-file file)))) > > Likewise, succeeds on 24.3, fails on trunk. Thanks. For the record, a simpler test case is this: emacs -Q C-x C-f foo RET Insert some ASCII text, then save the buffer, kill it, and visit the file again: C-x C-s C-x k RET C-x C-f foo RET You now have foo with `undecided' as its buffer-file-coding-system. Then: C-u C-\ cyrillic-translit RET abvgde C-\ C-x C-s The file is saved (as UTF-8, as can be seen by examining it on disk), but without asking for encoding, and without changing buffer-file-coding-system to reflect the actual encoding. What happens is that `undecided' silently encodes the buffer in UTF-8, but never communicates that fact back to its callers. So write-region thinks it used `undecided', as does select-safe-coding-system. The latter is actually equipped to DTRT when the `prefer-utf-8' variant of `undecided' is used, but that is not the case here. Is this what was supposed to happen, or is something misbehaving here? 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. Does this make sense?