Re: mailcap for text/html on OS X

2011-07-06 Thread William Yardley
On Tue, Jul 05, 2011 at 10:24:18PM -0500, David Champion wrote:
 
 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.

I don't want it to open automatically in my browser whenever a message
has an HTML part - I want to hit enter on the message in the attachment
list and *then* select it.

My point is that mutt's error message mailcap entry for type text/html
not found (when copiousoutput is not set) is confusing -- I do in fact
have an entry for text/html, though it's possible that mutt doesn't like
it. I did read the bit in TFM about this, and based on what I was
reading, I would have thought that I wanted the *absence* of
copiousoutput, since I only want to view the message in the external
program when I specifically select it from the attachments menu.

Once copiousoutput is set, without any other changes, mutt will attempt
to open a file when I select it from the attachment menu (though with
the problem mentioned below, i.e., it exits and mutt removes the
temporary file), but also seems to try to open all of the attached html
files at once when I *reply* to a message.

 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).

I figured it was something like this. What's odd, though, is that
opening an attached PDF using /usr/bin/open %s works just fine.

w



Re: mailcap for text/html on OS X

2011-07-06 Thread Christian Ebert
* William Yardley on Wednesday, July 06, 2011 at 02:02:39 -0700
 On Tue, Jul 05, 2011 at 10:24:18PM -0500, David Champion wrote:
 
 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.
 
 I don't want it to open automatically in my browser whenever a message
 has an HTML part - I want to hit enter on the message in the attachment
 list and *then* select it.

With newer versions of Mutt you have to hit (by default) m for
view-mailcap. text/html is considered as text/*. By default
enter is bound to view-attach which tries to display in the
pager. Could that be the problem?

c
-- 
theatre - books - texts - movies
Black Trash Productions at home: http://www.blacktrash.org
Black Trash Productions on Facebook:
http://www.facebook.com/blacktrashproductions


Re: mailcap for text/html on OS X

2011-07-06 Thread William Yardley
On Wed, Jul 06, 2011 at 11:00:46AM +0100, Christian Ebert wrote:
 * William Yardley on Wednesday, July 06, 2011 at 02:02:39 -0700
  On Tue, Jul 05, 2011 at 10:24:18PM -0500, David Champion wrote:
  
  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.
  
  I don't want it to open automatically in my browser whenever a message
  has an HTML part - I want to hit enter on the message in the attachment
  list and *then* select it.
 
 With newer versions of Mutt you have to hit (by default) m for
 view-mailcap. text/html is considered as text/*. By default
 enter is bound to view-attach which tries to display in the
 pager. Could that be the problem?

Maybe, but then, why does it not display the html attachment in the
pager, and why does it give the error mailcap entry for type text/html
not found?

w



mailcap for text/html on OS X

2011-07-05 Thread William Yardley
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)
mutt does try to open the file in Firefox on my Mac, but the file it
passes in doesn't actually exist)

adding nametemplate=%s.html (which I don't think should be needed, since
the files already have .html in their name) doesn't change anything.
Neither does leaving OSX's default temporary dir rather than setting
$tmpdir to /tmp in the mutt config.

Is there a way to make this work without using a wrapper script?

w



Re: mailcap for text/html on OS X

2011-07-05 Thread David Champion
* 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