From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#8308: 23.3; Use utf-8 for writing abbrev file Date: Tue, 22 Mar 2011 11:47:21 +0800 Message-ID: References: <834o6w9usy.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1300766847 27710 80.91.229.12 (22 Mar 2011 04:07:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Mar 2011 04:07:27 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 22 05:07:15 2011 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.69) (envelope-from ) id 1Q1ssD-0005jv-Hd for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Mar 2011 05:07:13 +0100 Original-Received: from localhost ([127.0.0.1]:60772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1ssC-00086l-8z for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Mar 2011 00:07:12 -0400 Original-Received: from [140.186.70.92] (port=56973 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1ss6-00080U-5u for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2011 00:07:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1ss5-0004FH-3D for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2011 00:07:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1ss4-0004FD-UM for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2011 00:07:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Q1sZe-0003rL-Dg; Mon, 21 Mar 2011 23:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Mar 2011 03:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8308 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.130076566114791 (code B ref -1); Tue, 22 Mar 2011 03:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Mar 2011 03:47:41 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1sZI-0003qV-Kk for submit@debbugs.gnu.org; Mon, 21 Mar 2011 23:47:40 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1sZG-0003qB-O3 for submit@debbugs.gnu.org; Mon, 21 Mar 2011 23:47:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1sZA-0001xh-Mc for submit@debbugs.gnu.org; Mon, 21 Mar 2011 23:47:33 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:33596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1sZA-0001xa-KJ for submit@debbugs.gnu.org; Mon, 21 Mar 2011 23:47:32 -0400 Original-Received: from [140.186.70.92] (port=38260 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1sZ9-0001vS-KI for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2011 23:47:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1sZ8-0001xF-AJ for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2011 23:47:31 -0400 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:59339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1sZ8-0001x9-3J; Mon, 21 Mar 2011 23:47:30 -0400 Original-Received: by iyf13 with SMTP id 13so9005651iyf.0 for ; Mon, 21 Mar 2011 20:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=ip85oOhi07+JLnNfjsbcq1KNOg48UlxKXUF2EwvuEIc=; b=Vl8emCxdb+dXhMB1HFBe6i76JmWobYvZmsgA1nUugR9DFPPuejMBah3dHd21/eAkBw 2ccaXQze7t2QHIZ9O4ZMMM8PE6E3u+S+X5AUvCxjGjCJ3BxFASb+bOCg8Wy1Z4r6RV3z k7MdXdeanauqxKUeVh5RuBkbv1jl4m2cv3lso= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=vJmLW0mX+cijtbxFzalxVwAJtmpcb4pN2UNBobSBqN68hj36CW9PhmEAdQIYN5w02D Es86nUyqMVgSf/PfstYpj99fIhCquYGURcSp2scuglBo6l9iOa3Dlz7HyuBjRNT5yqJN mb67sVBVLzquzNzxG3JrW3d91SRaZft4xgEo8= Original-Received: by 10.42.73.195 with SMTP id t3mr6000968icj.106.1300765649359; Mon, 21 Mar 2011 20:47:29 -0700 (PDT) Original-Received: from localhost (th041092.ip.tsinghua.edu.cn [59.66.41.92]) by mx.google.com with ESMTPS id g16sm2453730ibb.3.2011.03.21.20.47.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 Mar 2011 20:47:27 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 21 Mar 2011 22:48:40 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (Mac OS X 10.6.6) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 21 Mar 2011 23:48:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , 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:45249 Archived-At: On 2011-03-22 10:48 +0800, Stefan Monnier wrote: > I think it might be OK to do it for Emacs-25, but since Emacs-22 can't > handle utf-8-emacs, I think it's a bit early to switch to it in > Emacs-24. If utf-8 is sufficient, OTOH it's the best choice. So maybe > we should check the buffer first to see if utf-8 is safe, and only fall > back to emacs-mule if utf-8 is not safe. I think default to utf-8 is good, which is sufficient for most people. Any comments on the following patch? I don't know how to introduce a char unencodable with utf-8 to the abbrevs. So it is only partially tested. === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-01-25 04:08:28 +0000 +++ lisp/abbrev.el 2011-03-22 03:30:52 +0000 @@ -225,21 +225,29 @@ abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) - (let ((coding-system-for-write 'emacs-mule)) - (with-temp-file file - (insert ";;-*-coding: emacs-mule;-*-\n") + (let ((coding-system-for-write 'utf-8)) + (with-temp-buffer (dolist (table - ;; We sort the table in order to ease the automatic - ;; merging of different versions of the user's abbrevs - ;; file. This is useful, for example, for when the - ;; user keeps their home directory in a revision - ;; control system, and is therefore keeping multiple - ;; slightly-differing copies loosely synchronized. - (sort (copy-sequence abbrev-table-name-list) - (lambda (s1 s2) - (string< (symbol-name s1) - (symbol-name s2))))) - (insert-abbrev-table-description table nil))))) + ;; We sort the table in order to ease the automatic + ;; merging of different versions of the user's abbrevs + ;; file. This is useful, for example, for when the + ;; user keeps their home directory in a revision + ;; control system, and is therefore keeping multiple + ;; slightly-differing copies loosely synchronized. + (sort (copy-sequence abbrev-table-name-list) + (lambda (s1 s2) + (string< (symbol-name s1) + (symbol-name s2))))) + (insert-abbrev-table-description table nil)) + (when (unencodable-char-position (point-min) (point-max) 'utf-8) + (setq coding-system-for-write + (if (> emacs-major-version 24) + 'utf-8-emacs + ;; For compatibility with Emacs 22 + 'emacs-mule))) + (goto-char (point-min)) + (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) + (write-region nil nil file nil 0)))) (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point.