[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should `auto-coding-functions' be mode-specific?

From: Lennart Borgman (gmail)
Subject: Re: Should `auto-coding-functions' be mode-specific?
Date: Tue, 02 Jan 2007 23:14:42 +0100
User-agent: Thunderbird (Windows/20061207)

Romain Francoise wrote:
I received a bug report from a Debian user (CC'd) who was surprised
to see that Emacs 22 opens one of his utf-8-encoded files as ASCII,
because it contains the following HTML snippet near the top:

| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
| <META http-equiv=Content-Type content="text/html; charset=us-ascii">
| </HEAD>
| <BODY>
| </BODY></HTML>

The file itself is not an HTML file, but Emacs still uses the
encoding specified in the HTML code to set the encoding.  (This is
caused by `sgml-html-meta-auto-coding-function', which is present by
default in the list of `auto-coding-functions' -- the functions are
tried in the first 1K or last 3K bytes of the buffer.)

I replied that the encoding can be forced using a -*- coding: .. -*-
cookie, but the submitter argues that the functions to get the
encoding from the file's contents should only be enabled in modes
where the content of the buffer is supposed to match -- i.e. don't
use the META header function in buffers that aren't in html-mode (or

What do people think?

(See http://bugs.debian.org/404236 for the discussion.)

IIt seems clear to me that this must be mode specific. Just a silly example: Suppose someone saves something like the html-snippet above in a customization.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]