What I do in similar situations is pipe the attachment to a helper (I
call it muttfilter) that accepts as first argument a file name, as
second argument a command name and as further arguments any options to
that command. The helper copies the attachment to the filename, runs
the command with all its arguments and with the file name as the last
argument. Thus, to open a password protected pdf from the attachments
menu I would type
   |muttfilter mydocument.pdf xpdf -upw mysecretpassword
and to edit a picture with gimp I would type
   |muttfilter mypicture.jpg gimp
For temporal filenames I always use the same name (rem.pdf or
rem.jpg), so new files replace old ones.

The muttfilter script is

  #!/bin/bash
  cat - > $1
  $2 ${@:3} $1

Hope it's helpful.
Best regards,
Luis


On Tue, Apr 28, 2015 at 12:17:46PM +1000, Cameron Simpson wrote:
> On 27Apr2015 09:23, martin f krafft <[email protected]> wrote:
> >also sprach Cameron Simpson <[email protected]> [2015-04-26 22:54 +0200]:
> >> Apphelper first asks whether to view the file, offering the
> >> supplied view command in [square brackets] as the default.  Pressing
> >> return or entering "y" or "yes' accepts this default and runs the
> >> viewer.  Entering "n" or "no" skips running the viewer.  Other
> >> answers are taken to be the name (and optional arguments) of a
> >> viewing program.
> >>
> >>Superficially that sounds like exactly what you're asking for.
> >
> >Yes, it does and thanks for being so persistent. I am sorry for
> >being finicky about this, but I know how things go and I don't want
> >to have to press <enter> 99% of the time just to accept a default so
> >that I can select a different viewer in 1% of the cases.
> 
> That is why my "ah" wraper (specific to my own preferences) passes the "-y"
> option to apphelper. Note also that apphelper honours a $APPHELPER_OPTS
> environment variable so you can tune your default options.
> 
> >What I really want is <view-attach> to grow a sibling:
> ><edit-attach>, which would spawn run-mailcap --action=edit instead
> >of the default --action=view. And then I could view or edit at the
> >press of one of two button without having to engage in an
> >interactive session requiring me to react to prompts.
> 
> Sounds like a job for a mutt macro. A first cut would be to write a macro
> which pointed $mailcap_path at a different mailcap file, then ran
> view-attach, then restored the old value.
> 
> Keeping two mailcaps can be tedious unless you autogenerate one from the
> other, eg by making the "ask" version prepend apphelper or similar to the
> front of end mailcap command.
> 
> Another approach would be a macro that pipes the attachment into a script
> that saves its input (making your temp file) and prompts for a command to
> issue with that file.
> 
> If mutt had a "setenv" command you could also write a macro to set an
> environment variable (eg $APPHELPER_OPTS for apphelper) before invoking
> <view-attach>, causing different behaviour from the same mailcap command. Eg
> to make apphelper ask or not ask about the viewer.
> 
> But it doesn't, AFAIK.
> 
> yet anothe possibility: let me direct your attention to mutt's
> <view-mailcap> command, bound to "m" in the attachments menu.  (<return>
> runs "view-attach".) view-mailcap is described in section 3.2.2 "Search
> Order" in the mutt manual.  I have just read it 3 or 4 times and believe I
> now have a slight handle on what it does. It might be possible to adapt it
> to get you a "view with default" (<return>) and a view with question for
> command (<view-mailcap>/"m"). I am not yet convinced though.
> 
> I do not properly understand <view-mailcap> versus <view-attach>. I would
> appreciate someone else chiming in here.
> 
> >Alternatively, this could probably be solved even more generically
> >e.g. by allowing a sequence like '%' to appear in the <shell-escape>
> >command line, which, if present, causes a temporary file to be
> >written and injected into the command line. I bet there could be
> >plenty of use-cases for this. The advantage of letting mutt write
> >the temporary file is that mutt knows more about the file than
> >children commands. mutt could even substitute %n for the filename
> >and %t for the mime-type.
> 
> Yes, that would help.
> 
> Cheers,
> Cameron Simpson <[email protected]>
> 
> Yes, [congress is] petty and venal and selfish.  That's why they're called
> _representatives_.      - Will Durst
> 

-- 

                                                                  o
W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
Apdo. Postal 48-3, 62251             |                           (*)/\/  \
Cuernavaca, Morelos, México          | [email protected]   /\_/\__/
Consider using GnuPrivacyGuard https://www.gnupg.org/
My key: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB, yours?



Reply via email to