Re: Include message attributes in print_command?
On Sat, Jan 10, 2009 at 03:27:56PM -0500, Ed Blackman wrote:
> I use Mutt on Linux, and use enscript to print to my cups-pdf printer:
> set print_command="enscript --highlight=mail -P ToPDF"
>
> This produces a PDF named Enscript_Output.pdf in ~/PDF when I print.
>
> However, "Enscript_Output" isn't very descriptive, and if I print one
> message, then print another, the file gets overwritten. I'd like to be
> able to put the subject line and date in the filename.
>
> cups-pdf uses the document title to create the filename, so if I do:
> set print_command="enscript --highlight=mail -P ToPDF --title Foo"
> I get Foo.pdf instead.
>
> So all I need to do is to get Mutt to pass the message subject and date
> to enscript, but can't find any way to do this.
>
> Is there a way to do that short of patching mutt?
>
> If not, could someone who has worked on mutt's source give an opinion on
> how hard it would be to support the index format expandos in
> print_command? Then I could add "--title '%s %D'" to my print_command.
You may want to consider using the Message-ID (and possibly a
re-formatted date) instead of the Subject given that most all Subject
lines are problematic (length, use of spaces and extraneous characters,
etc.). If the concern is simply generating unique file names, then
mktemp(1) might be the better approach.
That said, the following will work. Modify accordingly for use with
enscript.
#!/bin/sh
#
# muttprint
#
# macro pager p \
# '<enter-command>set pipe_decode<enter><pipe-message>muttprint<enter>'
#
message="$(cat -)"
myheader="$(echo "$message" | formail -X Subject -X Date)"
echo "-----------------------------------------------------------------"
echo "$myheader"
echo "-----------------------------------------------------------------"
echo
echo "$message"
--
George