<<< Date Index >>>     <<< Thread Index >>>

Re: autoview/mailcap/elinks question



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday, May  1 at 12:04 PM, quoth Chris G:
> I have moved from using lynx as my HTML mail viewer to using elinks 
> which, for some types of HTML in particular, works much better.

Personally, I prefer w3m, because it uses line-drawing characters for 
tables.

> However it's still not as good as it could be.  I have "auto_view 
> text/html" in my muttrc file.  I have "text/html; elinks -force-html 
> %s; copiousoutput" in my .mailcap.  HTML E-Mail is displayed 80 
> columns wide even when I have a much wider window and colours (i.e. 
> background etc.) are not set properly.
>
> If I hit 'v' in the index and save the HTML part of the message to a 
> file and then view that file using elinks I get a much better version, 
> it uses the available width of the window and sets background colours 
> etc.

The important thing to realize here is that you're using elinks two 
different ways here. When you trigger elinks from the view menu ('v'), 
mutt is calling elinks and allowing it to control the terminal and do 
things like control it's own scrolling and take input from the user 
and such. When mutt calls elinks for doing auto_view, mutt connects 
elinks' output to a pipe so that mutt can capture that output and 
display it. The big difference as far as elinks is concerned is that 
in the first case it has a connection to the terminal. It can find out 
how big the terminal is, and so can adjust itself. In the auto_view 
case, however, elinks doesn't have any way to ask the terminal how big 
it is, so it has to rely on it's configuration. Specifically, when it 
can't find out the width of the terminal, elinks defaults to assuming 
standard 80-column output. You can alter that with the -dump-width 
flag.

So, the way to get elinks to fill the width is to tell it the width of 
the terminal. Now, how you do that is up to you; I would try a 
two-pronged approach: first, before you load up mutt, run `export 
COLUMNS`, which puts the current terminal size into the environment. 
Then use a mailcap line like this:

     text/html; elinks -force-html -dump-width $COLUMNS %s;
     copiousoutput

Note that if you change terminal size while mutt is open, $COLUMNS 
will still be the original value, so it's not a perfect solution. But 
it's enough to get by.

The next task is to figure out how to get elinks' colors to be 
preserved. The key mutt configuration value here is $allow_ansi. 
Default is "no", but if you set it to "yes" then mutt will preserve 
the colors in elinks' output. If that doesn't work, it means that 
elinks isn't putting the colors into its dump output, so you have to 
tell elinks to use colors when printing formatted text to a pipe. The 
magic argument you need to pass to elinks is -dump-color-mode. 
Unfortunately, as you can see in this bugreport 
(http://bugzilla.elinks.cz/show_bug.cgi?id=622), they've only 
implemented that flag for the cutting edge 0.12.GIT version of elinks 
(it hasn't made it into a stable version of elinks yet). So, if you 
REALLY REALLY want color, you can get it, but it'll be a bit of a 
pain.

~Kyle
- -- 
In order to keep a true perspective of one's importance, everyone 
should have a dog that will worship him and a cat that will ignore 
him.
                                                        -- Dereke Bruce
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkgZ30MACgkQBkIOoMqOI14N9ACgidZoM4myE0MeeQAXQiV6d0vL
z0YAoJ/i3j6MivsjzoCoMyObTlN1cCWs
=Tw69
-----END PGP SIGNATURE-----