From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#4816: change of coding system without inquiry Date: Fri, 30 Oct 2009 11:02:49 -0400 Message-ID: References: <4AE77C59.5060106@informatik.uni-muenchen.de> <4AEAE7F8.6010609@informatik.uni-muenchen.de> Reply-To: Stefan Monnier , 4816@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1256916894 22001 80.91.229.12 (30 Oct 2009 15:34:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Oct 2009 15:34:54 +0000 (UTC) Cc: 4816@emacsbugs.donarmstrong.com To: eisinger@informatik.uni-muenchen.de Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 30 16:34:47 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N3tUt-0004aS-5r for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Oct 2009 16:34:39 +0100 Original-Received: from localhost ([127.0.0.1]:37372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3tUs-0001ta-K0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Oct 2009 11:34:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N3tNr-00044T-7a for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2009 11:27:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N3tNm-0003y4-Dg for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2009 11:27:22 -0400 Original-Received: from [199.232.76.173] (port=40917 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3tNm-0003xu-9T for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2009 11:27:18 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:47582) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N3tNl-0003bY-Io for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2009 11:27:17 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n9UFREV0009194; Fri, 30 Oct 2009 08:27:14 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n9UFA5jM007589; Fri, 30 Oct 2009 08:10:05 -0700 Resent-Date: Fri, 30 Oct 2009 08:10:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Fri, 30 Oct 2009 15:10:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4816 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4816-submit@emacsbugs.donarmstrong.com id=B4816.12569149775755 (code B ref 4816); Fri, 30 Oct 2009 15:10:05 +0000 Original-Received: (at 4816) by emacsbugs.donarmstrong.com; 30 Oct 2009 15:02:57 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.183]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n9UF2tug005750 for <4816@emacsbugs.donarmstrong.com>; Fri, 30 Oct 2009 08:02:56 -0700 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhAFAASd6kpLd/xb/2dsb2JhbACBUOBNhD0EgWKHAQ X-IronPort-AV: E=Sophos;i="4.44,653,1249272000"; d="scan'208";a="48423740" Original-Received: from 75-119-252-91.dsl.teksavvy.com (HELO pastel.home) ([75.119.252.91]) by ironport2-out.pppoe.ca with ESMTP; 30 Oct 2009 11:02:49 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 05BAA80C9; Fri, 30 Oct 2009 11:02:49 -0400 (EDT) In-Reply-To: <4AEAE7F8.6010609@informatik.uni-muenchen.de> (Norbert Eisinger's message of "Fri, 30 Oct 2009 14:19:52 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Fri, 30 Oct 2009 11:27:22 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32292 Archived-At: > Our computer environment has for years been a SuSE distribution > of Linux with latin-1 locale. Recently it was replaced by a > Kubuntu distribution with utf-8 locale. Fairly common situation. > Over the years we have accumulated a large number of latin-1 files > that were created and edited by people who are no longer in the group > and who used whichever editors they liked. Some files may contain as > part of their text content information about the coding system: > "\usepackage[latin1]{inputenc}" in a LaTeX file, > "" in an XML file, > "" > in an HTML file. Probably there are similar examples for other formats. Those xml/latex statement should be understood by Emacs as coding cookies, so the files that contain those statements should be handled properly with Emacs-23.2. > Depending on the format the files may also contain some form of > include mechanism that refers to a different file whose text > content contains such coding information. Yes, this is a more problematic case, because fundamentally there is a coding-cookie, but Emacs doesn't know it because it's in another file. > I don't know how frequent our situation is, but I guess that > it is not uncommon in university environments in countries > whose language needed one of the ISO-latin extensions of ASCII. That was helpful, thank you. I think you're right that we should at least do a y-or-n-p prompt when changing the buffer-file-coding-system, unless the change is to a "superset coding system" (like from us-ascii to latin-1). Can you try the patch below to see if it gives you the behavior you want? Stefan === modified file 'lisp/international/mule-cmds.el' --- lisp/international/mule-cmds.el 2009-10-24 18:33:25 +0000 +++ lisp/international/mule-cmds.el 2009-10-30 15:01:02 +0000 @@ -979,6 +979,17 @@ (if safe (setq coding-system (car safe)))) + (unless (or (local-variable-p 'buffer-file-coding-system) + (eq coding-system buffer-file-coding-system) + ;; We'd rather only bother the user if the coding-system + ;; change would cause the file's content to change, so we'd + ;; want to check whether the new coding-system is a superset + ;; of the previous one. + (memq buffer-file-coding-system '(nil undecided us-ascii)) + (y-or-n-p (format "Change encoding from %s to %s? " + buffer-file-coding-system coding-system))) + (setq coding-system nil)) + ;; If all the defaults failed, ask a user. (when (not coding-system) (setq coding-system (select-safe-coding-system-interactively @@ -1024,6 +1035,7 @@ %s specified by file contents. Really save (else edit coding cookies \ and try again)? " coding-system auto-cs)) (error "Save aborted")))) + (when (and tick (/= tick (buffer-chars-modified-tick))) (error "Cancelled because the buffer was modified")) coding-system)))