[Top] [All Lists]

Re: [Nmh-workers] message/rfc822 C-T and whatnow's attach?

2013-12-22 15:41:37

On Dec 22, 2013, at 1:00 PM, David Levine <levinedl@acm.org> wrote:

Done.  If "file --mime" or "file -i" are supported, nmh will
configure to use them for all files that are attach'ed via whatnow.

I just took a peek at Mac OS; it uses 'file --mime-type' :-P  But it also 
supports a a '--mime-encoding' flag that adds a charset parameter to the output.

While having file output MIME info is potentially useful, it has always 
bothered me how the magic file authors like to make up arbitrary (and often, 
pointless) types for content.  E.g., a selection from Mac OS 10.9:

/usr/bin/2to3:                             text/x-python
/usr/bin/2to3-2.7:                         text/x-java
/usr/bin/aclocal:                          text/x-perl
/usr/bin/alias:                            text/x-shellscript
/usr/bin/bitesize.d:                       text/x-c
/usr/bin/dbicadmin5.12:                    text/plain
/usr/bin/gen_bridge_metadata:              text/x-ruby

/usr/bin/idle:                             text/x-python
/usr/bin/idle2.5:                          text/x-java
/usr/bin/idle2.6:                          text/x-java
/usr/bin/idle2.7:                          text/x-java

/usr/bin/rails:                            text/x-ruby
/usr/bin/rake:                             text/plain

These x-* types are pointless. Nobody in their right mind is going to 
automatically dispatch any of these to the corresponding interpreter, so it's 
just make work for the end user, having to configure viewers for each of these 
arbitrary types.  If you're lucky, your software will let you set up a viewer 
type hierarchy, e.g.:

  text/html     |htmlfmt
  text/*        |less

Even if you do decide to display, say, text/x-ruby in your favourite IDE, 
notice how 'rails' is a Ruby app, while 'rake' is just plain text?  But they 
both start with the same #! command string.  And apparently Python and Java are 
interchangeable languages.

And why don't we have application/x-solaris-i386 and 
application/freebsd-sparc64 ???  It's all madness :-)

Anyway, for a long while now I've thought about incorporating a built-in 
mimetype() function that does what 'file -i' does, but with a sane and 
conservative set of types.  And which includes things like charset= when 
appropriate.  Plan 9 has a nice simple implementation of this that would port 
across without too much effort, and is license compatible.  Maybe over 
Christmas I'll sit down for an afternoon and port the code into a 
Posix-buildable library that we could embed as a compilation option.

But once again this raises the spectre of cutting a new nmh release.  See my 
next message ... ;-)


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Nmh-workers mailing list
<Prev in Thread] Current Thread [Next in Thread>