[comp.sources.d] Quick hack to use the normal mail program for replies in rn

liz@grian.UUCP (Liz Allen-Mitchell) (06/11/88)

In article <19305@watmath.waterloo.edu> sahayman@watmath.waterloo.edu
	(Steve Hayman) writes:
>Want to use the regular Unix "mail" program to compose
>replies to news articles from within "rn", rather than
>the "Rnmail" shell script?  Well, I do.  I do it like this:
>
>i) arrange to have rn take its options from a file, by something like 
>   setenv RNINIT ~/.rninit
>
>ii) in my .rninit file, add these three lines:
>
>-EMAILHEADER='From %t %`date`
>'
>-EMAILPOSTER='cat %A >>%h; mail -f %h'

I've been using something similar to use mh's comp to reply to mail:

	-EMAILPOSTER='/usr/local/bin/comp -form %h'
	-EMAILHEADER='To: %T\\n\
	Cc: liz\\n\
	Subject: Re: %S\\n\
	Newsgroups: %n\\n\
	In-Reply-To: %i\\n'

If you want to use it, you should change the "liz" up there to your
login!
-- 
		- Liz Allen-Mitchell	liz@grian.cps.com
					elroy!grian!liz@csvax.caltech.edu
					{cit-vax,ames}!elroy!grian!liz
"God is light; in him there is no darkness at all." -- 1 John 1:5b

ken@cs.rochester.edu (Ken Yap) (06/11/88)

|I've been using something similar to use mh's comp to reply to mail:
|
|	-EMAILPOSTER='/usr/local/bin/comp -form %h'
|	-EMAILHEADER='To: %T\\n\
|	Cc: liz\\n\
|	Subject: Re: %S\\n\
|	Newsgroups: %n\\n\
|	In-Reply-To: %i\\n'

Here is the bells and whistles one I've been using:

-EMAILPOSTER="MHCONTEXT=/tmp/mhc.%L comp -form %h -editor ${VISUAL-${EDITOR-vi}}"
-EMAILHEADER=\
'To: %t\\n\
Fcc: +CC\\n\
Subject: %(%i=^$?:Re: %S\\n\
X-Newsgroups: %n\\n\
In-Reply-To: %i)\\n\
X-Original-Path: %T\\n\
X-Organization: %o\\n\
X-UUCP: ..!rochester!ken Internet: ken@cs.rochester.edu\\n\
X-Snail: CS Dept., U. of Roch., NY 14627. Voice: Ken!\\n\
--\\n\
'

In particular, %t works better than %T, because it uses Reply-To or
From.  For an Internet site, at least.  Maybe %T is better for uucp
sites.  But I drag in %T also, in case I can't work out the return
address.

I used to use this for MAILPOSTER:

-EMAILPOSTER="MHCONTEXT=/tmp/mhc.%L repl -form %h -editor ${VISUAL-${EDITOR-vi}} +%d %a"

It had the advantage of allowing you to read in the original article with
:r @. But they broke repl -from in MH 6.5, sigh...

	Ken

jos@philapd.UUCP (Jos Vos) (06/15/88)

In article <19305@watmath.waterloo.edu> sahayman@watmath.waterloo.edu (Steve Hayman) writes:
>Want to use the regular Unix "mail" program to compose
>replies to news articles from within "rn", rather than
>the "Rnmail" shell script?  Well, I do.  I do it like this:
>i) arrange to have rn take its options from a file, by something like 
>   setenv RNINIT ~/.rninit
>ii) in my .rninit file, add these three lines:
>
>-EMAILHEADER='From %t %`date`
>'
>-EMAILPOSTER='cat %A >>%h; mail -f %h'
>
>Now, when I type 'r', rn dumps the current article into a
>file that looks like a mailbox, and then starts mail looking
>at that file;  type "r" within mail to reply.  I like this
>a lot better than "Rnmail" even though I have to type "r" twice,
>and don't get any of that "In article such-and-such you write" stuff.

What's really needed, I think, is the functionality of readnews' followup,
substituting the address in the 'internet' address of 'LIB/mailpaths'.
For that reason I adapted Rnmail.SH (and so Rnmail changes in the same way).
Here's the extra piece of text to be put after line 145 (just after the
first part  of file $tmpart is made):

--- START OF INSERTED TEXT ---
# START OF DESTINATION ADDRESS CONVERSION
# Equivalent to function 'replyname' (netnews/src/funcs2.c)
# search for 'internet' entry in file /usr/lib/mailpaths
iformat=`expr "\`$grep '^internet' /usr/lib/news/mailpaths\`" : \
		'internet[	 ][	 ]*\([^	 ]*\)'`
# if no entry is found, just assume we can handle internet addresses
if test -n "$iformat"
then
    # extract (internet) destination address from temporary file
    to=`expr "\`$grep '^To:' $tmpart\`" : 'To:[	 ]*\([^	 ]*\)'`
    # if format string contains no '!' or '@' we may just substitute
    if $test `expr "$iformat" : '[^!@]*$'` -eq 0
    then
	# format string contains '!' and/or '@'
	if $test `expr "$iformat" : '[^@]*$'` -gt 0
	then
	    # format string contains no '@'
	    # if to string contains no '@', nothing will change
	    to=`$echo "$to" | sed 's/^\([^@]*\)@\(.*\)$/\2!\1/'`
	else
	    # format string contains '@'
	    # if to string contains no '@', nothing will change
	    to=`$echo "$to" | sed 's/@/%/'`
	fi
    fi
    # now we can substitute the bang address into the format string
    to=`awk "END { printf \"$iformat\", \"$to\" }" < /dev/null`
    # finally, we have to replace the address in the temporary file
    $echo "/^To:/c\nTo: $to\n.\nw\nq" | ed - -s $tmpart
fi
# END OF DESTINATION ADDRESS CONVERSION
--- END OF INSERTED TEXT ---

I'm not sure it solves *all* problems, but I'm quite sure it solves
*the same* problems as the routine in funcs2.c (readnews) does.
For me that's enough.

-- 
#  Jos Vos                             #  Internet  jos@philapd.UUCP  #
#  Philips TDS, Dept SSP               #                              #
#  P.O. Box 245                        #  UUCP  ..!mcvax!philapd!jos  #
#  7300 AE Apeldoorn, The Netherlands  #  Phone        +31 55 433181  #