[comp.mail.mush] mush as Rnmail -h anyone?

schaefer@ogccse.ogc.edu (Barton E. Schaefer) (07/22/89)

In article <10930@ibmpcug.UUCP> ronald@ibmpcug.CO.UK (Ronald Khoo) writes:
} In recent replies to my postings, Barton E. Schaefer <schaefer@ogccse.UUCP>
} had me a little confused at first: mail messages with BOTH the correct
} news-style Newsgroups, References, etc. headers AND X-Mailer: MUSH !
} (Together with Bart's favourite X-Presidents :-)
} 
} At first, I thought I'd missed something, but after a quick RTFM, realised
} that Bart must have saved the news message into a mailbox and replied from
} there,

That does it.  I've got to re-post this silly thing.  Do you really think
that *I* would go to that much work just to reply to a news article? :-)

} but that got me thinking, why not implement the -h option in mush,
} to startup in mail originate mode (a la mail -iE) taking the filename arg
} as the edit text, (if you must - fix your paranoid From: 's first) ?

It's in the future plans.  It isn't as easy as it might at first appear,
given the way the initialization and command parsing is presently handled.

} Then I can have my replies from within rn look every bit as impressive as
} Bart's :-)

You can do that right now, with the Rnmush script which follows, assuming
that you use RN.  Just

    setenv MAILPOSTER "Rnmush -h %h"

and away you go.

} I'd volunteer to do it, but I still can't figure if my modification of
} 	long copy_flgs = 0;
} to
} 	long copy_flgs = flags;
} in line 739 of mail.c (to fix my earlier grumble about ! $alwaysignore
} being ignored...) breaks anything - i.e. not yet qualified to hack

Yes, it breaks something.  The flag bits for mail editing etc. overlap
with the bits for copy_msg.  In particular, EDIT_HDRS is the same as
NO_HEADERS, which means if you have $edit_hdrs set and you make the
change above, you will NEVER get any headers on your included messages.

Here's Rnmush.  You'll need to change some things in the
"system configuration" part -- it's presently set up for mush 6.5 on
a BSD-ish unix.  Enjoy.

#! /bin/sh -
# Rnmush -- script to use mush for Rnmail
#
# Based on Larry Wall's Rnmail
#
# syntax: Rnmush -h headerfile [oldart]		or
#         Rnmush destination-list 		or just
#         Rnmush
#
# This script creates two other scripts:
#  1) sh script, which takes care of merging the rn header file with
#	mush's editor temp file and then calls the regular visual editor;
#  2) mush script, fed via "mush -source", which sets up some environment
#	and arranges for the first script to be used as the visual editor.

# system configuration

# your organization name
orgname="/usr/lib/news/organization"

mush=mush
defeditor=/usr/ucb/vi
test=/bin/test
sed=sed
echo=echo
cat=cat
rm=/bin/rm
chmod=chmod

# how to echo without a newline
n="-n"
c=""

dotdir=${DOTDIR-${HOME-$LOGDIR}}
tmpart=$dotdir/.letter
start=$dotdir/.rnmush$$
preedit=$dotdir/.rnvis$$
locked=$dotdir/.rnvlk$$

trap "$rm -f $start $preedit $locked; exit 1" 1 2 3 13 15 21 22 23

# some initialization for the mush script
visual=${VISUAL-${EDITOR-$defeditor}}
orgname=${ORGANIZATION-$orgname}
case $orgname in
/*) orgname=`$cat $orgname` ;;
esac

# Use this line for mush 6.4
#$echo set verify autoedit\; unset edit_hdrs > $start
# Change to this line for mush 6.5
$echo set edit_hdrs verify autoedit > $start

headerfile=""
case $# in
0) ;;
*)  case $1 in
    -h)
	headerfile="$2"
	case $# in
	3) oldart=$3 ;;
	esac
	;;
    esac
    ;;
esac

subject=""
case $headerfile in
'')
    case $# in
    0)
	$echo $n "To: $c"
	read to
	;;
    *)
	to="$*"
	;;
    esac
    $echo $n "Subject: $c"
    subject="-s `read subject; echo '\"'$subject'\"'`"
    $echo $n "$c" > $tmpart
    $echo my_hdr Organization: "$orgname" >> $start
    $cat <<EOStrip > $preedit
if $test ! -f $locked ; then
$cat $tmpart >> \$1
$echo "" > $locked
fi
$visual \$1
EOStrip
    ;;
*)
    to=`$sed -e '/^To:/p' -e '/.*/d' < $headerfile | $sed 's/^To: //'`
# Use this section for mush 6.4
#    $echo unset ask asksub askcc >> $start
#    $sed '1,/^$/d' < $headerfile > $tmpart
#    subject="-s \"`$sed -e '/^Subject:/p' -e '/.*/d' < $headerfile \
#	| $sed 's/^Subject: //'`\""
#    $sed -e '1,/^$/p' -e '/.*/d' < $headerfile \
#	| $sed -e '/^To:/d' -e '/^Subject:/d' -e '/^$/d' -e 's/^/my_hdr /' \
#	>> $start
#    $cat <<EOStrip > $preedit
#if $test ! -f $locked ; then
#$cat < $tmpart > \$1
#$echo "" > $locked
#fi
#$visual \$1
#EOStrip
#
# Change to this new section for mush 6.5
#
    $cat <<'EOStart' >> $start
if $?ask
    unset ask
endif
if $?asksub
    unset asksub
endif
if $?askcc
    unset askcc
endif
EOStart
    $cat <<EOStrip > $preedit
if $test ! -f $locked ; then
$sed -e '/^To:/d' -e '/^Subject:/d' -e '/^\$/d' < \$1 > /tmp/$$
$cat /tmp/$$ $headerfile > \$1
$rm -f /tmp/$$
$echo "" > $locked
fi
$visual \$1
EOStrip
# End of 6.5 section
    ;;
esac

$cat <<EOStart >> $start
set visual=$preedit
mail $subject $to
quit
EOStart

$chmod +x $preedit

file=h
while $test "$file" = h ; do
    $echo ""
    $echo $n "Prepared file to include [none]: $c"
    read file
    case $file in
    h)
	;;
    '')
	$echo "" >> $tmpart
	;;
    *)
	$cat $file >> $tmpart
	;;
    esac
done

$echo ""
$mush -shell -noheaders -readonly -source $start -folder /dev/null
$rm -f $preedit $start $locked
exit 0
-- 
Bart Schaefer           "And if you believe that, you'll believe anything."
                                                            -- DangerMouse
CSNET / Internet                schaefer@cse.ogc.edu
UUCP                            ...{sequent,tektronix,verdix}!ogccse!schaefer

tneff@bfmny0.UUCP (Tom Neff) (07/22/89)

Excuse me for asking this, but why exactly would one want to
use Mush as the mailer for rn?  Rn is already building a nice
header for you, giving you complete control over the contents;
Rnmail as a personally customizable script lets you skip silly
questions or other stuff you don't like in the standard distribution;
and even Mush still needs a good underlying MTA to get the work
done.  Other than the empty pleasure of seeing the X-Mailer line,
I don't see what mush brings to the party.  (And I speak as a
die hard mush user, btw.)

For maximum comfort replying to articles, I simply built and
installed smail 2.5 and changed Rnmail to use it instead of
'recmail'.  As far as I can see, even if I stuck Mush up front
I would still have to route to smail from there.  Why not
just eliminate the middleman?
-- 
You may not redistribute this article for profit without written permission.
--
Tom Neff				UUCP:     ...!uunet!bfmny0!tneff
    "Truisms aren't everything."	Internet: tneff@bfmny0.UU.NET

ronald@ibmpcug.UUCP (Ronald Khoo) (07/22/89)

In recent replies to my postings, Barton E. Schaefer <schaefer@ogccse.UUCP>
had me a little confused at first: mail messages with BOTH the correct
news-style Newsgroups, References, etc. headers AND X-Mailer: MUSH !
(Together with Bart's favourite X-Presidents :-)

At first, I thought I'd missed something, but after a quick RTFM, realised
that Bart must have saved the news message into a mailbox and replied from
there, but that got me thinking, why not implement the -h option in mush,
to startup in mail originate mode (a la mail -iE) taking the filename arg
as the edit text, (if you must - fix your paranoid From: 's first) ?

Then I can have my replies from within rn look every bit as impressive as
Bart's :-)

I'd volunteer to do it, but I still can't figure if my modification of
	long copy_flgs = 0;
to
	long copy_flgs = flags;
in line 739 of mail.c (to fix my earlier grumble about ! $alwaysignore
being ignored...) breaks anything - i.e. not yet qualified to hack
mush until I have a spare week to read the source...

How 'bout it Bart, Dan? Mush 7.0 maybe? :-)

-- 
Ronald Khoo @ The IBM PC User Group, PO Box 360, Harrow HA1 4LQ
Phone:	+44 -1- 863 1191			Domain:	ronald@ibmpcug.CO.UK
Path:	...!ukc!slxsys!ibmpcug!ronald    	Fax:    +44 -1- 863 6095
              My Opinions? Sell 'em if you can. See if I care!