* On 05 Jul 2011, William Yardley wrote: 
> I did some basic web searches, and I can't figure out why this isn't
> working.
> 
> If I have this line:
> text/html; /usr/bin/open %s
> 
> in my .mailcap, I get the error:
> "mailcap entry for type text/html not found"
> when trying to open a file with content-type text/html (same with a
> trailing semi-colon).
> 
> I know it's actually seeing that entry, because if I add:
> ; copiousoutput
> (which shouldn't be needed if I understand it correctly)

TFM says:
> This flag tells Mutt that the command passes possibly large amounts of
> text on stdout. This causes Mutt to invoke a pager (either the internal
> pager or the external pager defined by the pager variable) on the output
> of the view command. Without this flag, Mutt assumes that the command is
> interactive.

Note that last bit.


Gary Johnson's web page on this further clarifies:
> Mutt uses the copiousoutput field to indicate that the viewer is
> non-interactive and can be used to automatically view attachments
> within the pager as well as from the attachment menu. Conversely,
> mutt uses the absence of the copiousoutput field to indicate that
> the viewer is interactive and can be used only from the attachment
> menu. Therefore, any lines with the copiousoutput field should be last
> among those of a given content-type. This usage is an extension of
> that specified in RFC 1524.

So that's why you need copiousoutput for viewing automatically when
reading a message (vs. from the attachment menu).  You didn't say that's
what you're doing, but I imagine it is.


You also wrote:
> mutt does try to open the file in Firefox on my Mac, but the file it
> passes in doesn't actually exist)

That's a standard issue with OSX "open".  It launches applications
asynchronously and exits, whereupon mutt removes the temporary file.
Then the app finishes launching/receiving remote instruction and looks
for the file, and it's not there.  So basically, yes you need a wrapper
script (or an alternate implementation of "open").

My favorite approach to the open wrapper is to hardlink it to another
file with some, prefix, then open that instead, and remove it after a
sleep.  E.g.

#!/bin/sh

ln "$1" "open-$1"
(sleep 60; rm -f "open-$1") &
open "open-$1"

By hardlinking you don't need to worry so much about file size, free
space, etc.

-- 
David Champion • d...@uchicago.edu • IT Services • University of Chicago

Reply via email to