A major update / rewrite of ffi-magic.el
This changeset brings a good deal of file(1)'s capabilities. The
file(1) options that are now supported in some fashion are:
--apple, -d, -E, -e, --extension, -i, --mime-type,
--mime-encoding, -k, -L, -p, -r, -s, -v, -z, -Z
Missing is: -P, but hopefully I'll nut that out soon.
The old #'magic:file-type has been made obsolete and has been replaced
with #'magic:file. See its doc for option flags that can be set and
example usage.
A form of error checking is on by default which comes in two waves:
1) Option flags given are parsed through a sanitiser to help prevent
causing unknown or unwanted results. See
`ffi-magic-sanitise-flags' and `ffi-magic-no-safety' to turn it
off.
2) Errors from libmagic and the shell are captured and reported as
actual errors in SXEmacs. This can be turned off if required.
See `ffi-magic-persistent-flags'.
A few convenience functions have also been added:
o #'magic:file-audio-p
o #'magic:file-video-p
o #'magic:file-image-p
o #'magic:file-text-p
They all do what you'd imagine they would.
There is also the availability of using ffi-magic with
`find-file-magic-files-alist' to auto-detect coding system. Use it at
your own risk, YMMV, don't blame me if it kicks your dog and eats your
children. It is not enabled by default because of the mixed results
that I've gotten. For example, see what file(1) says about any .info
file you have, or indeed even etags.el or info.el. A single #o177
character in a file will cause it to be reported as binary.
* lisp/ffi/ffi-magic.el (ffi-magic-persistent-flags): New.
(magic-options, ffi-magic-options-list, magic-list): New.
(magic-errno, magic-getflags, magic-setflags): New.
(magic-version, magic:version, magic-descriptor): New.
(magic:getflags, ffi-magic-no-safety): New.
(ffi-magic-sanitise-flags, ffi-magic-flag-value): New.
(magic:setflags, magic:cleanup, magic:error): New.
(magic:file-audio-p, magic:file-video-p): New.
(magic:file-image-p, magic:file-text-p): New.
(magic:file-coding-system-p, magic:find-file-noselect): New.
(magic:find-file-magic-alist-enable): New.
(magic:file-type): Made obsolete, alias to #'magic:file.
(magic:file): Now accepts a 2nd FLAGS arg for setting libmagic
flags. It is interactively accessible via prefix arg, with
completion.
Output can optionally be inserted into the current buffer with a
2nd prefix arg.
* lisp/cl-macs.el (load-time-value): Synced up with XE 21.5's
version as their's doesn't cause byte-compiler warnings.
Signed-off-by: Steve Youngs <steve@sxemacs.org>