From: LIN Sumang <linsumang@gmail.com>
To: 8283@debbugs.gnu.org
Subject: bug#8283: sgml-xml-auto-coding-function() should respect the *-with-signature-* coding
Date: Fri, 18 Mar 2011 15:10:18 +0800 [thread overview]
Message-ID: <AANLkTi=SfK5SDH03wDthnnqMowwDhucsmuYd=RSLH7tC@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikAgc+XbB9PN-j8H2Vj7E8RDRs8yhjA34gdO46h@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1749 bytes --]
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@gmail.com> 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.
>
>
>
[-- Attachment #2: Type: text/html, Size: 4421 bytes --]
prev parent reply other threads:[~2011-03-18 7:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-18 5:56 bug#8282: sgml-xml-auto-coding-function() should respect the *-with-signature-* coding LIN Sumang
2011-03-18 7:10 ` LIN Sumang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTi=SfK5SDH03wDthnnqMowwDhucsmuYd=RSLH7tC@mail.gmail.com' \
--to=linsumang@gmail.com \
--cc=8283@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.