[comp.mail.mush] Mush in rn or nn

rock@warp.Eng.Sun.COM (Bill Petro) (11/14/90)

eddy@jafus.mi.org (Eddy J. Gurney) writes:

>In article <8863@darkstar.ucsc.edu> hermit@ucscf.UCSC.EDU (William R. Ward) writes:
>>
>>I have a feature suggestion for MUSH.
>>
>>When using rn to read news, I would like to be able to shell out to mush
>>to send mail and to post news.

>I agree with this suggestion completely!  I'd like to be able to use the
>features of mush, like it's nifty 'indent-string' capabilities, when
>replying to articles, followups, etc.  Anyone have time (I don't!) to look
>into this?

Or more generically, I use nn, and would like to use mush as my mailer,
but mush expects an argument.

I have tried in nn:
set mailer /home/speedway/rock/bin/mush
unset mailer-pipe-input

and even:
set mailer /home/speedway/rock/bin/mush_script
unset mailer-pipe-input

...where the mush_script is:
#!/bin/csh -f
recipient=`grep "To:" $1`
/home/speedway/rock/bin/mush $recipient < $!

Any ideas?

For those using rn, you might find some help from the script Rnmush:

#! /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
mailrecord=${MAILRECORD+record="${MAILRECORD}"}

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

headerfile=""
case $# in
0) ;;
*)  case $1 in
    -h)
	headerfile="$2"
	case $# in
	3) oldart=$3 ;;
	1) shift ;;
	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
    ;;
*)
    # Handle wrapped To: lines
    to=`$sed -n -e '1,/^$/ {
			/^To:/,/^[A-Za-z]/ {
				s/^To: \(.*\)/\1/p
				/^[^A-Za-z]/p
			}
		}' < $headerfile | tr '\012' ' '`
# 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
#
# The code below relies on mush's placement of the To: and Subject:
# headers.  If Subject: does not immediately follow To:, this removes
# too many headers.   Alternate sed command if you have this problem:
#   $sed -e '/^To:/d' -e '/^Subject:/d' -e '/^\$/d' < \$1 > /tmp/$$
# (the alternate does not handle wrapped To: lines properly).
#
    $cat <<EOStrip > $preedit
if $test ! -f $locked ; then
$sed -e '/^To:/,/^Subject:/d' -e '/^\$/d' < \$1 > /tmp/$$
$cat /tmp/$$ $headerfile $tmpart > \$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



--
     Bill Petro  {decwrl,hplabs,ucbvax}!sun!Eng!rock
"UNIX for the sake of the kingdom of heaven"  Matthew 19:12

schaefer@ogicse.ogi.edu (Barton E. Schaefer) (11/16/90)

In article <2708@exodus.Eng.Sun.COM> rock@warp.Eng.Sun.COM (Bill Petro) writes:
} eddy@jafus.mi.org (Eddy J. Gurney) writes:
} 
} >In article <8863@darkstar.ucsc.edu> hermit@ucscf.UCSC.EDU (William R. Ward) writes:
} >>
} >>When using rn to read news, I would like to be able to shell out to mush
} >>to send mail and to post news.

To get mush to post news, play around with

	set sendmail = "inews -h"

plus some my_hdr commands to create the appropriate Newsgroups: header
and so on.  The Rnmush script Bill was nice enough to repost is a place
to start looking for how to do this.  Note that this won't work on all
news systems, and that getting mush to post is only a small step toward
getting it to work for followups.

To use the Rnmush script for sending replies, set the environment variable
MAILPOSTER to "Rnmush -h".  Bill neglected to mention that detail.

} Or more generically, I use nn, and would like to use mush as my mailer,
} but mush expects an argument.
} 
} I have tried in nn:
[... various things that didn't work...] 
} Any ideas?

Well, I don't use or even have access to nn, but based on what your
attempts look like, you might try

set mailer "/home/speedway/rock/bin/mush -send -draft -"

(the double quotes may not be necessary).  Leave mailer-pipe-input alone,
the "-draft -" means to expect a complete message with headers on stdin.
-- 
Bart Schaefer						schaefer@cse.ogi.edu
ZipCode Software Corporation				schaefer@zipcode.com