[comp.mail.mh] turning news articles into MH messages

benson@ksr.UUCP (Benson Margulies) (12/29/87)

has anyone got a quick way to turn a news posting read in rn into a
mail message in MH?
-- 
Benson I. Margulies                         Kendall Square Research Corp.
harvard!ksr!benson			    ksr!benson@harvard.harvard.edu

spock@falcon.mtl.u-tokyo.JUNET (Scientific Officer Vulcan,380E,6763,9574302) (12/29/87)

In article <207@ksr.UUCP> benson@ksr.UUCP () writes:
>has anyone got a quick way to turn a news posting read in rn into a
>mail message in MH?

I use simple rn macro. In ~/.rnmac file,

sm       |mhmail -subject "%s" -from "%t" kono@mtl.u-tokyo.junet 




------------------------
$@2OLn??<#(J $@ElBgBg3X1!>pJs9)3X@lLg2]Dx(J $@EDCf1QI'8&5f<<(J ($@EE5$9)3X2J(J)
Shinji Kono @ Tanaka Lab. Electorical Engineering, University of Tokyo
kono%mtl.u-tokyo.junet.CSNET@RELAY.CS.NET

smarks%trantor@Sun.COM (Stuart Marks) (12/30/87)

In article <207@ksr.UUCP> benson@ksr.UUCP (Benson I. Margulies) writes:
>has anyone got a quick way to turn a news posting read in rn into a
>mail message in MH?

Yes!  I have a very simple shell script "mhcp" that copies stdin to a new
message at the end of the specified folder.  It requires that you have the
"mhpath" command, which is present in MH 6.5.  (I don't know if it's present
in earlier versions.)

I also have a couple of rn macros that invoke mhcp from within rn.  The '!'
macro causes the current article to be appended to the folder "+news", while
the '@' macro lets you specify the folder to which the article will be
appended.  (Note that these macros don't check to see whether you're in the
proper one of rn's zillion modes.  I didn't feel like adding all the
conditional garbage.)

So, if I'm running rn and I run across an article I want to save, I
merely hit ! and it's saved in a jiffy!

Here's a shell archive with the mhcp script and the rn macros.

Stuart

================================ cut here ==================================
#! /bin/sh
# This is a shell archive.  To extract, cut everything above
# the "#! /bin/sh" line and run the rest through sh.
## mhcp
echo '=>' mhcp
cat > mhcp << '1930!Funky!Stuff!'
#! /bin/sh
# mhcp - copy stdin to a new mh article
# Usage:  mhcp [+folder]

if [ $# -eq 0 ]; then
    set +news
fi

outfile=`mhpath $* new`
echo "==> $outfile"
cat - > $outfile
1930!Funky!Stuff!
chmod +x mhcp
## rnmac
echo '=>' rnmac
cat > rnmac << '1930!Funky!Stuff!'
!	| mhcp +news\nn
@	| mhcp +
1930!Funky!Stuff!
exit
# End of shell archive.
================================ cut here ==================================
Stuart Marks			ARPA: smarks@sun.com
Window Systems Group		UUCP: {decwrl,ucbvax}!sun!smarks
Sun Microsystems, Inc.

mujica@CS.UCLA.EDU (12/30/87)

In article <279@fig.bbn.com> rsalz@bbn.com (Rich Salz) writes:
>
> >has anyone got a quick way to turn a news posting read in rn into a
> >mail message in MH?
>
>	!inc -file %A
>-- 
>For comp.sources.unix stuff, mail to sources@uunet.uu.net.

the simplest way may be to pipe the message through rcvstore
(look into the man page for rcvstore) or slocal, that in
addition will consult your ~/.maildelivery file (look at the
man page for mhook)

this will also work if the public news spool directory is not
in the local machine.



--------------
Sergio Mujica,       
mujica@cs.ucla.edu     (213) 825-7276
3804 Boelter Hall, Computer Science Department,
University of California, Los Angeles CA 90024

indra@amdcad.AMD.COM (Indra Singhal) (12/30/87)

In article <207@ksr.UUCP> benson@ksr.UUCP () writes:
>
>has anyone got a quick way to turn a news posting read in rn into a
>mail message in MH?
>-- 

I recall seeing some code that did that in the /miscellany directory
that came with the MH distribution.  

-- 
(-:-)                                                        (-:-)
-I said so... & said it for myself.             Indra K. Singhal
{ucbvax,decwrl,allegra}!amdcad!indra or amdcad!indra@decwrl.dec.com

cosell@cosell.bbn.com (Bernie Cosell) (12/30/87)

What I use is the following little shell script.  What I do is
tell rn to "|savemsg".

#!/bin/sh

case $# in
    0) sed -e '1d' >$H/1
        ;;
    1)  cat $1 >$H/1
        ;;
    *)  for file
            do savemsg $file ; done
        exit
        ;;
esac
refile 1 -src $H +saved </dev/null

   __
  /  )                              Bernie Cosell
 /--<  _  __  __   o _              BBN Labs, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com

rsalz@bbn.com (Rich Salz) (12/30/87)

 >has anyone got a quick way to turn a news posting read in rn into a
 >mail message in MH?

	!inc -file %A
-- 
For comp.sources.unix stuff, mail to sources@uunet.uu.net.

ken@cwi.nl (Ken Yap) (12/30/87)

Sorry guys, you missed the obvious:

	| rcvstore +junk

Rcvstore is in /usr/new/lib/mh or something like that so most people
don't know about it.

	Ken

leres@ucbarpa.Berkeley.EDU (Craig Leres) (12/30/87)

I use the appended script in conjunction with this .rnmac entry:

	s s|rntomh %C %a^J

I used to use inc but this is much faster.

		Craig
------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	rntomh
# This archive created: Tue Dec 29 21:09:38 1987
export PATH; PATH=/bin:$PATH
echo shar: extracting "'rntomh'" '(260 characters)'
if test -f 'rntomh'
then
	echo shar: will not over-write existing file "'rntomh'"
else
sed 's/^X//' << \SHAR_EOF > 'rntomh'
X#!/bin/csh -f
X#
X# rntomh
X#
X# Arguments:
X#   %C  newsgroup name, dot form
X#   %a  article number
X#
X# Stdin:
X#   the article to save
X
Xset folder=+news
X( echo "Article: $2 of $1" ; cat ) | /usr/new/lib/mh/rcvstore $folder
X
Xecho Saved article $2 of $1 to $folder.
SHAR_EOF
if test 260 -ne "`wc -c < 'rntomh'`"
then
	echo shar: error transmitting "'rntomh'" '(should have been 260 characters)'
fi
chmod +x 'rntomh'
fi # end of overwriting check
#	End of shell archive
exit 0

mob@mit-amt.MEDIA.MIT.EDU (Mario O Bourgoin) (12/30/87)

I think I take the cake for the most complex solution.  I use rn's
facilities for saving messages and give a shell script as my saver.

ENVIRONMENT:

setenv RNINIT ~/.rnrc


FILE .rnrc:

-EMAILHEADER="To: %T
Subject: %(%i=^$?:Re: %S
Newsgroups: %n
In-Reply-To: %i)
Fcc: outbox
--------
"
-EMAILPOSTER="~/.rn_mailer %h"
-EMBOXSAVER="~/.rn_saver %b %A"
-ESAVEDIR="~/Mail"
-ESAVENAME="article"


FILE .rn_saver

#! /bin/csh -f
# Rn-Mh Mailmode article saver.
#
# Arguments:
#	If the folder exists
#		$1	<Mail Directory>/<folder>/article
#	Else
#		$1	<Mail Directory>/<folder>
#	Then
#		$2	Source article.

set folder=$1
if ("$1:t" == "article") set folder=$folder:h
inc -silent +$folder:t -file $2


FILE .rn_mailer

#! /bin/csh -f
# Rn-Mh Mailer.
#
# Arguments:
#		$1	The mail header file.

# Include a copy of the message in the drafts folder.
inc -silent +drafts -file $1

# Edit the message.
comp -use

wohler@spam.istc.sri.com (Bill Wohler) (01/05/88)

In article <207@ksr.UUCP> benson@ksr.UUCP () writes:
>
>has anyone got a quick way to turn a news posting read in rn into a
>mail message in MH?

  i've got the quickest:  just type 's' to save an article.  
  
  you have to invoke rn with "-d~/usr/spool/mail/news -/" in order for the
  article to be deposited as a mh file in a mh folder (in this case "news"). 
  also note that my mh directory is usr/spool/mail.  the above two arguments
  can placed in an RNINIT environment variable or file in order to avoid
  typing them every time.

						--bw

mayer@hplabsz.HPL.HP.COM (Niels Mayer) (01/05/88)

Stuart Marks (hi Stuart!) mentioned one way that he moves messages between
rn and mh.... I've found that our version of mh 6.5 running under HPUX on
the HP9000s3xx and HP9000s8xx will allow the use of the following rn
macro in ~/.rnmac:

mv	!refile -src +"%d" "%a" +inbox

mh's refile now treats an rn spool directory (%d) as an mh mail folder and
treats the mh article number (%a) as the mh article number. I can then just
type "mv<cr>" to get mh to copy an article to inbox, or I can use backspace
to edit over the "+inbox" to specify any destination folder I want. 

Infact, I often use mh's scan/show/repl/forw (in conjunction with my own
mh-based mail browser) to process news articles. It seems that if you
specify a full path to a "folder", that folder doesn't have to
be in your mh mail directory. For example "scan +/usr/spool/news/comp/mail/mh"
will give me a scan listing of all the postings in this group.

Is this feature only available on our version of mh 6.5, or does it work on
yours as well??

-- Niels Mayer
   HP Laboratories.

mayer@hplabsz.HPL.HP.COM (Niels Mayer) (01/05/88)

Ooops. Upon reading on, I noticed that you can get an even cleaner solution
with rcvstore. That also eliminates that pesky message from "refile" saying
that it cannot move the message and is therefore linking instead.

However the point still remains that you can access folders outside of your
mail directory by specyfying a full path after the "+". I still find that
feature useful. But here's a problem:

I've also noticed that after I do something like 
	"scan +/usr/spool/news/comp/mail/mh" 
I will also get an entry in my
	~/Mail/context 
that looks like this:
	atr-pseq-/usr/spool/news/comp/mail/mh: 33-63

This would normally not be a problem, except that when I issue the
"folders" command, it goes ahead and lists all the "external" folders that
I have referenced:
		Folder      # of messages (  range  ); cur  msg  (other files)
/usr/spool/news/news/announce/conferences  has   44 messages (  65- 138); cur= 125.
/usr/spool/news/comp/emacs  has  367 messages (1219-1587); cur=1531.
/usr/spool/news/comp/windows/x  has  370 messages (1094-1465); cur=1392.
/usr/spool/news/comp/mail/mh  has   31 messages (  33-  63); cur=  55.
	.
	.
	.

This makes the "folders" command take much longer than if it only scanned
the local folders.

Is there a way of disabling the generation of atr-pseq-<non-local-folder>
in ~/Mail/context, preferably, something other than prefacing all accesses
to nonlocal folders with "env MHCONTEXT=~/Mail/rncontext <mhcommand>"??

-- Niels.

lamy@ai.toronto.edu (Jean-Francois Lamy) (01/11/88)

In your .rnrc, add
	-ESAVEDIR='%~/Mail/%C'
	-ESAVENAME='%a'
Hitting 's' will save (e.g.) article 779 of comp.ai.digest in
~/Mail/comp.ai.digest/779

I sometimes prefer saving articles in my inbox (especially digests that I want
to burst - nice when MH is running under GNU Emacs in another window).  The
simplest way I've found to do this is to use 'S' after adding

S      s /`mhpath +inbox new`

to my .rnmac file.  Omitting the / does not get you what you want.  Leaving it
in generates //u0/lamy/Mail/inbox/... which works on BSD and friends. (Apollo
users should use something like ~/../../`mhpath `.  rn does not care.

Jean-Francois Lamy	               			lamy@ai.toronto.edu
AI Group, Department of Computer Science     		(416) 978-8700
University of Toronto, Toronto, Canada M5S 1A4