GNU bug report logs - #8283
sgml-xml-auto-coding-function() should respect the *-with-signature-* coding

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: LIN Sumang <linsumang@HIDDEN>; merged with #8282; dated Fri, 18 Mar 2011 13:34:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Merged 8282 8283. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Mar 2011 13:33:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Mar 18 09:33:31 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Q0Zo2-0007pl-D0
	for submit <at> debbugs.gnu.org; Fri, 18 Mar 2011 09:33:31 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <linsumang@HIDDEN>) id 1Q0TpT-00075w-VB
	for submit <at> debbugs.gnu.org; Fri, 18 Mar 2011 03:10:36 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <linsumang@HIDDEN>) id 1Q0TpN-0002DR-O0
	for submit <at> debbugs.gnu.org; Fri, 18 Mar 2011 03:10:30 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	HTML_MESSAGE,RCVD_IN_DNSWL_LOW,T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL
	autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:34686)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <linsumang@HIDDEN>) id 1Q0TpM-0002D9-He
	for submit <at> debbugs.gnu.org; Fri, 18 Mar 2011 03:10:29 -0400
Received: from [140.186.70.92] (port=55343 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Q0TpF-00088C-PC
	for bug-gnu-emacs@HIDDEN; Fri, 18 Mar 2011 03:10:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <linsumang@HIDDEN>) id 1Q0TpD-0002Ak-Mg
	for bug-gnu-emacs@HIDDEN; Fri, 18 Mar 2011 03:10:20 -0400
Received: from mail-iy0-f169.google.com ([209.85.210.169]:60851)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <linsumang@HIDDEN>) id 1Q0TpD-0002Af-Ge
	for bug-gnu-emacs@HIDDEN; Fri, 18 Mar 2011 03:10:19 -0400
Received: by iyf13 with SMTP id 13so4566630iyf.0
	for <bug-gnu-emacs@HIDDEN>; Fri, 18 Mar 2011 00:10:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:content-type;
	bh=SNd9OQ3VhZOI4rmkdeHGxPJ97SOGnVHdxZ7sQlNQ0eE=;
	b=IUzbBILnQ1+uNaQ7DhaaBJGLUAyU3XXfTL7YQKlxMmNZwcKQI94JuKvupje56IEvU5
	LLIR+FNUFEEHWg6h0cZsLp9bgQtALjjPLOnCB4PvuWURXntsoEQPlZA3WC7GIVdBWc+H
	7R72R54vj85U5TMeGTaLX3eDhKTy6vjJNgve0=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type;
	b=R+NwDlpmPC/s/aQY1I3sGt7MxK7LS9kqxbAqRvT6f/+dZBOwMoz6/tV7gti8o8RYC6
	eCsqzXgcUS5YUfeqkCYNPdBuaqep9DKUmNwiA8LmykCJ/6fr/N4J6An0e5hyV9eMBxKS
	Jn2ccomOuo7s1qgws4bv5+zTFvKu4qp6WPR84=
MIME-Version: 1.0
Received: by 10.43.65.72 with SMTP id xl8mr1048195icb.211.1300432218641; Fri,
	18 Mar 2011 00:10:18 -0700 (PDT)
Received: by 10.42.195.77 with HTTP; Fri, 18 Mar 2011 00:10:18 -0700 (PDT)
In-Reply-To: <AANLkTikAgc+XbB9PN-j8H2Vj7E8RDRs8yhjA34gdO46h@HIDDEN>
References: <AANLkTikAgc+XbB9PN-j8H2Vj7E8RDRs8yhjA34gdO46h@HIDDEN>
Date: Fri, 18 Mar 2011 15:10:18 +0800
Message-ID: <AANLkTi=SfK5SDH03wDthnnqMowwDhucsmuYd=RSLH7tC@HIDDEN>
Subject: Re: sgml-xml-auto-coding-function() should respect the
	*-with-signature-* coding
From: LIN Sumang <linsumang@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary=bcaec51ddcb77254f9049ebc7886
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-Received-From: 199.232.76.165
X-Spam-Score: -5.9 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 18 Mar 2011 09:33:28 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.9 (-----)

--bcaec51ddcb77254f9049ebc7886
Content-Type: text/plain; charset=ISO-8859-1

I wrote a simple function for *workaround*. Hope it helps.

(defun sgml-xml-auto-coding-function-utf (size)
  (let* ((selected-coding (sgml-xml-auto-coding-function size))
         (selected (symbol-name selected-coding))
         (current-coding buffer-file-coding-system)
         (current (symbol-name current-coding))
         )
    (if (and (string-match "^utf-" selected)
             (string-match "^utf-.+\\(-with-signature.*\\)" current))
        (if (string= selected (substring current 0 (length selected)))
            current-coding
          ;; current=utf-cc-xxxx; selected=utf-ss; new -> utf-ss-xxxx
          (let ((sig (match-string 1 current))
                new)
            (string-match "^utf-\\(.+\\)" selected)
            (setq new (match-string 1 selected))
            (setq new (intern (concat "utf-" new sig)))
            (if (coding-system-p new)
                new
              selected-coding
              )))
      selected-coding))
    )

On Fri, Mar 18, 2011 at 1:56 PM, LIN Sumang <linsumang@HIDDEN> wrote:

> Hi,
>
> I am using Emacs 23.2.1. I think sgml-xml-auto-coding-function() should
> respect the *-with-signature-* coding.
>
> Consider the scenario below:
> 1. xml file with the signature \376\377 at beginning of the file and the
> first line is
> <?xml version="1.0" encoding="utf-16be"?>
> 2. edit this file and save it. sgml-xml-auto-coding-function will use the
> utf-16be to save the file.
> 3. open the file again, get messed.
>
> In this case sgml-xml-auto-coding-function() shouldn't change the coding
> and if it really need to change the coding, it should append the
> *-with-signature-* to the selected coding.
>
> sgml-html-meta-auto-coding-function() should have same problem.
>
>
>

--bcaec51ddcb77254f9049ebc7886
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I wrote a simple function for <em>workaround</em>. Hope it helps.<br><br><s=
pan style=3D"font-family: courier new,monospace;">(defun sgml-xml-auto-codi=
ng-function-utf (size)</span><br style=3D"font-family: courier new,monospac=
e;">
<span style=3D"font-family: courier new,monospace;">=A0 (let* ((selected-co=
ding (sgml-xml-auto-coding-function size))</span><br style=3D"font-family: =
courier new,monospace;"><span style=3D"font-family: courier new,monospace;"=
>=A0=A0=A0=A0=A0=A0=A0=A0 (selected (symbol-name selected-coding))</span><b=
r style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0 (current-coding buffer-file-coding-system)</span><br style=3D"font-fami=
ly: courier new,monospace;"><span style=3D"font-family: courier new,monospa=
ce;">=A0=A0=A0=A0=A0=A0=A0=A0 (current (symbol-name current-coding))</span>=
<br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0 )</span><br style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: courier new,monospace;">=A0=A0=A0 (if (and (string-match &=
quot;^utf-&quot; selected)</span><br style=3D"font-family: courier new,mono=
space;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0 (string-match &quot;^utf-.+\\(-with-signature.*\\)&quot; cu=
rrent))</span><br style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0 (if (string=
=3D selected (substring current 0 (length selected)))</span><br style=3D"fo=
nt-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 current-coding</span><br style=3D"font-family: courier new,mon=
ospace;"><span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=
=A0=A0=A0=A0=A0 ;; current=3Dutf-cc-xxxx; selected=3Dutf-ss; new -&gt; utf-=
ss-xxxx</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 (let ((sig (match-string 1 current))</span><br style=3D"font-family:=
 courier new,monospace;"><span style=3D"font-family: courier new,monospace;=
">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 new)</span><br style=3D"fon=
t-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 (string-match &quot;^utf-\\(.+\\)&quot; selected)</span><br st=
yle=3D"font-family: courier new,monospace;"><span style=3D"font-family: cou=
rier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (setq new (match-str=
ing 1 selected))</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 (setq new (intern (concat &quot;utf-&quot; new sig)))</span><b=
r style=3D"font-family: courier new,monospace;"><span style=3D"font-family:=
 courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (if (coding-syst=
em-p new)</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 new</span><br style=3D"font-family: courier new,mo=
nospace;"><span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0 selected-coding</span><br style=3D"font-family:=
 courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 )))</span><br style=3D"font-family: courier new,monospac=
e;"><span style=3D"font-family: courier new,monospace;">=A0=A0=A0=A0=A0 sel=
ected-coding))</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=A0=A0=A0 )</span><br s=
tyle=3D"font-family: courier new,monospace;"><br><div class=3D"gmail_quote"=
>On Fri, Mar 18, 2011 at 1:56 PM, LIN Sumang <span dir=3D"ltr">&lt;<a href=
=3D"mailto:linsumang@HIDDEN">linsumang@HIDDEN</a>&gt;</span> wrote:<b=
r>
<blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br><br>I am u=
sing Emacs 23.2.1. I think sgml-xml-auto-coding-function() should respect t=
he *-with-signature-* coding.<br>
<br>Consider the scenario below:<br>1. xml file with the signature \376\377=
 at beginning of the file and the first line is <br>
&lt;?xml version=3D&quot;1.0&quot; encoding=3D&quot;utf-16be&quot;?&gt;<br>=
2. edit this file and save it. sgml-xml-auto-coding-function will use the u=
tf-16be to save the file.<br>3. open the file again, get messed.<br><br>In =
this case sgml-xml-auto-coding-function() shouldn&#39;t change the coding a=
nd if it really need to change the coding, it should append the *-with-sign=
ature-* to the selected coding.<br>

<br>sgml-html-meta-auto-coding-function() should have same problem.<br><br>=
<br>
</blockquote></div><br>

--bcaec51ddcb77254f9049ebc7886--




Acknowledgement sent to LIN Sumang <linsumang@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8283; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.