#! /bin/sh
#
# $Id: metamutt,v 1.4 1998/01/20 11:04:25 roland Exp $
#
# This should become a replacement of metamail, using the mail reader
# mutt. The options of metamail are not yet implemented, but it should
# work as a filter without any problems.
#
# (c) 1997,98 Roland Rosenfeld <roland@spinnaker.rhein.de>
#
# Most recent version can be found at http://www.rhein.de/~roland/mutt/metamutt
#

TMP=/tmp/metamutt.$$
trap "rm -f $TMP*; exit" 0 1 2 15

# ignore options:
for parameter 
do
    case $1 in 
        -- ) shift; break;;
        -e|-p ) shift;;
        -m ) shift 2;;
        * )  break;;
    esac
done

# create special muttrc for metamutt:
cat > $TMP-rc<<EOF
source ~/.muttrc
set pager_index_lines=0
bind pager i quit
bind pager q quit
bind pager x quit
bind index q quit
push "\n"
EOF

# create a mbox message:
echo "From PIPE `date`" > $TMP-mbox
cat $* - | sed 's/^From />From /' >> $TMP-mbox

# run mutt on mbox message with special muttrc:
mutt -F $TMP-rc -R -f $TMP-mbox </dev/tty >/dev/tty
