Re: hook on entering Attachment-View ?
On 2005-04-03, Michelle Konzack <linux4michelle@xxxxxxxxxx> wrote:
> Am 2005-04-02 13:26:10, schrieb Gary Johnson:
>
> > If I understand the problem correctly, the solution is to use the
> > copiousoutput field to distinguish the rules you want applied to
> > in-line autoviewing of attachments from those rules you want applied
> > in the attachment view/menu. This is discussed in the mutt manual.
> > I know this can be done with all the rules in one mailcap file; it
> > seems to me that it could also be done by putting a mailcap file
> > with all the copiousoutput rules last in the mailcap_path.
>
> ???
I guess I wasn't very clear. Let me try again, using an example
from your files.
>
> It is not right, because I have a standard-mailcap file, which poit to
>
> __( '/home/michelle.konzack/.tdfileview/mailcap' )____________________
> /
> | application/gzip; tdfileview --color %s; copiousoutput
> | application/ms-tnef; tdfileview %s; copiousoutput
> | application/octet-stream; tdfileview --color %s; copiousoutput
> | application/x-bzip2; tdfileview --color %s; copiousoutput
> | application/x-deb; tdfileview --color %s; copiousoutput
> | application/x-compressed-tar; tdfileview --color %s; copiousoutput
> | application/x-debian-package; tdfileview --color %s; copiousoutput
> | application/x-gettext; tdfileview --color %s; copiousoutput
> | application/x-httpd-php; tdfileview --color %s; copiousoutput
> | application/x-lha; tdfileview --color %s; copiousoutput
> | application/x-lzh; tdfileview --color %s; copiousoutput
> | application/x-man; tdfileview %s; copiousoutput
> | application/x-object; tdfileview %s; copiousoutput
> | application/x-patch; tdfileview --color %s; copiousoutput
> | application/x-php; tdfileview --color %s; copiousoutput
> | application/x-shellscript; tdfileview %s; copiousoutput
> | audio/mpeg; tdfileview --color %s; copiousoutput
> | image/gif; tdfileview --color %s; copiousoutput
> | image/jpeg; tdfileview --color %s; copiousoutput
> | text/x-csrc; tdfileview --color %s; copiousoutput
> | text/x-diff; tdfileview --color %s; copiousoutput
> | text/x-po; tdfileview --color %s; copiousoutput
> \______________________________________________________________________
>
> and generate mutt-inline-view for GIF, JPEG, PNG, MP3,... blahblah.
>
> Even in the "attachment-view"...
>
> If you select a mp3 vor example, 'mutt' will look into the mailcap
> and execute tdfileview, which show me the ID3 Tags and other infos.
> I want to see this only in the "pager".
>
> But if I am in the "attachment-view" I like to change the "mailcap_path"
> to "~/.mailcap:/etc/mailcap"
>
> __( '/home/michelle.konzack/.mailcap' )_______________________________
> /
> | audio/x-wav; rplay %s; description=;
> nametemplate=%s.wav
> | audio/mp3; mplayer %s; description=;
> nametemplate=%s.mp3
> | audio/mpeg; mplayer %s; description=;
> nametemplate=%s.mpg
> | audio/x-mp3; mplayer %s; description=;
> nametemplate=%s.mp3
> | audio/x-mpeg; mplayer %s; description=;
> nametemplate=%s.mpg
> | image/jpeg; zgv %s; test=test
> "$TERM" == ""; description="JPEG Image"; nametemplate=%s.jpg
> | text/plain; less '%s'; needsterminal
> | application/pdf; /usr/bin/xpdf '%s'; test=test
> "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf
> | application/x-pdf; /usr/bin/xpdf '%s'; test=test
> "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf
> | text/plain; cat '%s';
> print=/usr/bin/a2ps '%s'; copiousoutput
> | application/x-troff-man; /usr/bin/nroff -mandoc -Tlatin1;
> copiousoutput; print=/usr/bin/nroff -mandoc -Tlatin1 | print text/plain:-
> | text/html; /usr/bin/mozilla '%s';
> description=HTML Text; test=test -n "$DISPLAY"; nametemplate=%s.html
>
> <snip>
>
> | application/*; less '%s'; needsterminal
> \______________________________________________________________________
>
> that I can hear mp3, and see the PICs with zgv
What I'm trying to explain is that you don't need two mailcap files
to achieve this result. Let's consider your entries for audio/mpeg.
>From /home/michelle.konzack/.tdfileview/mailcap:
audio/mpeg; tdfileview --color %s; copiousoutput
>From /home/michelle.konzack/.mailcap:
audio/mpeg; mplayer %s; description=; nametemplate=%s.mpg
You can put these two entries in one mailcap file as long as you put
the entry with the copiousoutput field last, e.g.,
audio/mpeg; mplayer %s; description=; nametemplate=%s.mpg
audio/mpeg; tdfileview --color %s; copiousoutput
Mutt will use the absence of the copiousoutput field to select the
first entry as the one to use for viewing attachments from the
attachment menu ("attachment-view"). Mutt will use the presence of
the copiousoutput field to select the second entry as the one to use
for automatically viewing attachments within the pager.
If the mailcap file contained only the first entry, the pager would
say that it didn't know how to display the attachment and that you
should type 'v' to view it from the attachment menu. If the mailcap
contained only the second entry, the one entry would be used for
both the pager and the attachment menu.
> > You might also take a look at this web page which discusses using
> > different display programs for in-line viewing vs. attachment-menu
> > viewing of attachments.
>
> Oh, I am very satisfait with my BASH script "tdfileview" :-)
> And it is fun to do it and curently I do code a Super-Release
> which support syntax highliteing.
I wasn't suggesting that you should use any of those scripts instead
of yours; I was suggesting that you read that page in order to
understand how mutt selects different attachment viewers for the
pager and for the attachment menu. Much of what I explained above
is explained on that page.
> It make it easier to read po files, diffs/patches, XF86Config-4,
> XFree86.0.log or Debian/RPM Packages and much more...
>
> > http://www.spocom.com/users/gjohnson/mutt/
>
> I do not know whether this viewers support this :-/
As I said, the point was not to use those viewers but to see how
mutt selects among viewers in general.
>
> For NOW I need to know how to force an "attachment-view" macro which
>
> macro attachment-view 'set mailcap_path="~/.mailcap:/etc/mailcap"\n'
>
> and if I leafe it,
>
> macro ! attachment-view 'set mailcap_path="~/.tdfileview/mailcap"\n'
So the solution I would suggest is to put all your mailcap entries
into one mailcap file and order them so that for each content-type,
the entry with the copiousoutput field comes last.
Since all the entries in ~/.tdfileview/mailcap contain the
copiousoutput field, the solution may be as simple as putting that
file last in your mailcap_path:
set mailcap_path=~/.mailcap:/etc/mailcap:~/.tdfileview/mailcap
Whether that will actually work depends on how mutt processes the
entries in the files it finds in mailcap_path. It seems worth a
try, though.
Would you mind posting your tdfileview script here or to a web site?
I would be interested in seeing how you handle certain types of
attachments, such as application/ms-tnef.
Gary
--
Gary Johnson | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA