emacs-devel
[Top][All Lists]
Advanced

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

Re: auto-detecting encoding for XML


From: Stefan Monnier
Subject: Re: auto-detecting encoding for XML
Date: Mon, 20 May 2002 10:23:11 -0400

> On Sun, 2002-05-19 at 19:13, Stefan Monnier wrote:
> > >   * international/mule.el (auto-coding-functions): New variable.
> > 
> > Why not extend auto-coding-regexp-alist so it can associate a regexp
> > to a function (rather than a coding-system) ?
> 
> Hm.  It seems cleaner to just have the function do the searching in the
> first place, instead of in this case matching against a regexp, then
> callling a function which will probably have to do the same searching...

No, it could just use the match-data directly.
I was thinking of it the other way: the function will most likely need
to do a regexp search anyway, so why not include it with
the auto-coding-regexp-alist.  Also the "specify a coding-system
or a function returning a coding-system" thing is already used in
file-coding-system-alist so it seemed natural enough.

> > Or why not do what po.el does (i.e. use file-coding-system-alist) ?
> > Admittedly, the file-coding-system-alist approach is pretty
> > hairy/heavy-weight.
> 
> Well, it also has the disadvantage in this case that it depends on file
> extensions; XML tends to be used as an encoding for other types of
> files, which use their own extension.  So using file names as a way to
> detect XML is probably a bad approach.

That's why it would be better to link it to major-modes.

> > Note that these are always associated with a mode, so
> > it would be good if the implementation also was mode-specific so
> > that it automatically works if you open an xml file called
> > foo.myxmlextension (as long as "\\.myxmlextension\\'" is in the
> > auto-mode-alist).
> Yes.  It's very tricky though.

Yes, I know it's tricky.  But maybe we can come up with something clever.
In the mean time, I agree that extending auto-coding-regexp-alist is maybe
the best approach.


        Stefan




reply via email to

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