From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Bug in mule.el/sgml-xml-auto-coding-function
Date: Thu, 28 Apr 2005 12:29:18 -0600 [thread overview]
Message-ID: <d4r9nh$h7o$1@sea.gmane.org> (raw)
In-Reply-To: <4270CD7F.1090001@kosek.cz>
Jirka Kosek wrote:
> function sgml-xml-auto-coding-function tries to detect encoding of XML
> file.
What version of Emacs are you using? That function isn't distributed
with 21.3.
> XML specification allows encoding name to be surrounded by quotes
> or apostrophes. Current code expect only quotes so it won't detect
> encoding if specified as:
>
> <?xml version="1.0" encoding='windows-1250'?>
>
> The following function has corrected RE in order to deal with both
> delimiters.
>
> (defun sgml-xml-auto-coding-function (size)
> "Determine whether the buffer is XML, and if so, its encoding.
> This function is intended to be added to `auto-coding-functions'."
> (setq size (+ (point) size))
> (when (re-search-forward "\\`[[:space:]\n]*<\\?xml" size t)
> (let ((end (save-excursion
> ;; This is a hack.
> (re-search-forward "[\"']\\s-*\\?>" size t))))
> (when end
> (if (re-search-forward "encoding=[\"']\\(.+?\\)[\"']" end t)
> (let* ((match (match-string 1))
> (sym (intern (downcase match))))
> (if (coding-system-p sym)
> sym
> (message "Warning: unknown coding system \"%s\"" match)
> nil))
> 'utf-8)))))
The delimiters must match:
(if (re-search-forward "encoding=\\([\"']\\)\\(.+?\\)\\1" end t)
(let* ((match (match-string 2))
--
Kevin Rodgers
prev parent reply other threads:[~2005-04-28 18:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-28 11:48 Bug in mule.el/sgml-xml-auto-coding-function Jirka Kosek
2005-04-28 18:29 ` Kevin Rodgers [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='d4r9nh$h7o$1@sea.gmane.org' \
--to=ihs_4664@yahoo.com \
/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.