On Sat, Jan 10, 2009 at 11:48:04PM -0800, George Davidovich wrote:
On Sat, Jan 10, 2009 at 03:27:56PM -0500, Ed Blackman wrote: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?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.).
cups-pdf handles this, replacing problematic characters with underscores.If the title of the document is "attributes in print_command?", the PDF will be named "attributes_in_print_command_.pdf".
If the concern is simply generating unique file names, then mktemp(1) might be the better approach.
I know that the (Subject, Date) tuple isn't guaranteed to be unique the way that Message-ID should be, much less the output of mktemp. But I want a title that has fewer collisions (the default always collides), but is also human-readable.
Most of the time I just want to save the file some place else with another name, or batch them for printing in a certain order. With a fixed title giving a fixed filename, I had to use a "select message, print message, switch to another shell to move/print, switch back" loop. Having a better title will allow me to "select, select, select, print, switch, move, move, move".
That said, the following will work. Modify accordingly for use withenscript.
Thanks for the concept! Here's what I ended up with: macro index,pager p '<enter-command>set pipe_decode<enter><pipe-message>muttPrint --highlight=mail -P ToPDF<enter>' #!/bin/sh # # muttPrint # # macro index,pager p \ # '<enter-command>set pipe_decode<enter><pipe-message>muttPrint [enscript args]<enter>' # Save message contents MSG="$(cat -)" # get Subject, striping all occurrances of 'Re: ?' and any initial spaces SUBJ="$(echo "$MSG" | formail -cx Subject | sed -e 's/Re: \?//g' -e 's/^\s\+//')" # get Date, and parse into a more regular, but still human-readable format DATE="$(date -d "$(echo "$MSG" | formail -cx Date)" +%Y-%m-%d-%H:%M:%S)" # send message to print with appropriate title and all passed enscript args echo "$MSG" | enscript --title "$SUBJ $DATE" "$@" Ed
Attachment:
signature.txt
Description: Digital signature