[Top][All Lists]

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

Re: using libmagic in Emacs?

From: Stephen J. Turnbull
Subject: Re: using libmagic in Emacs?
Date: Thu, 20 Aug 2009 13:50:13 +0900

Eli Zaretskii writes:

 > > I think the main interface should be just "file-magic", even if it's
 > > not in file.el.  It's analogous to "file-attributes", etc.
 > Actually, I think the interface should be `file-type' or some such.

Seriously, "file-type" is a terrible, ambiguous name.  DOS vs. Unix,
the extension of the file's name (!!), what program uses it, text
vs. binary, MIME type, endianness of the platform, Unicode vs. legacy
coding, copyleft vs. permissive vs. proprietary vs. public domain, I
could go on.  Sure, it's about "files", but the "type" is what file(1)
infers from magic numbers in the file, no more and no less ... and
exactly the people you expect to say "huh?" will proceed to guess
anything but the truth about the semantics of `file-type'.

 > Like `file-attributes' that is a wrapper for `stat', the API name
 > should have a good semantic value, instead of just inheriting the name
 > of the low-level C functions it uses to do the job.

`file-magic' does have a good semantic value.  It means "look at the
first few bytes of a file and infer various metadata about it, based
on a published database of 'magic numbers'."  It tells not only the
purpose but the exact semantics.

I suppose the more explicit `file-type-by-magic' might be better.

reply via email to

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