On Wed, Oct 20, 2010 at 10:23 PM, Stephen J. Turnbull
<stephen(a)xemacs.org> wrote:
Samuel Bronson writes:
> However, I'm not certain that there is something to append
> "-literally" *to*; maybe you would add something to
> `file-coding-system-alist',
Since .tar, .gz, and .tgz are all there already, I don't have much
hope that it will help. ;-)
> and whatever the corresponding place is for content (magic number)
> based coding-system detection (Does XEmacs have that yet?).
IMO that's a broken idea. Coding-system detection applies only to
text/* media. Files where magic number can be used to determine the
coding are by definition binary.
Er, that's basically what the facility I'm thinking of is used for.
(It could perhaps also be used to prevent Emacs from getting confused
by local variable specs in formats that, like email, can embed other
files more-or-less textually.)
Sorry I wasn't more clear!
Eg, consider XML. I don't think it
is useful to try to match "\000u\000t\000f\000-\0001\0006" and its
swabbed version, when reading it as text will win nearly 100% of the
time. Consider an RFC 822 message, where the header is in ASCII and
the body can be in an arbitrary encoding (including non-ASCII
compatible encoding) via Content-Transfer-Encoding and Content-Type.
This is a binary format, no matter how much the mail you see in Kansas
looks like text/*. For sure, it would be a bad idea to apply the MIME
charset detected by matching "^Content-Type:\(.\|\n\s-+)*charset" in
an mbox file containing multiple messages! And the same thing is true
of tar files.
There is a facility called `format-alist' which matches regexps
against a prefix of the file, but I'm not sure at what stage this
happens. It might be useful here, but it depends on what decides to
do autodetection of coding systems. It might be jka-compr; it might
be the process code; it might be a find-file format handler. In the
first two cases, it won't work, format-alist is only used for files, I
think. In the latter, you have to be very careful or you'll end up
giving somebody else the same problem you are experiencing. That's
why I say this is hard.
Yeah, care is definitely needed, and that sounds like the facility I
was thinking of. I remember it being used to detect (some) zip files
by content when they didn't have names ending in .zip; I also remember
having to hack it in my init file to get it to catch certain
(Squeak-related?) zip archives.
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta