[comp.mail.mush] RMAIL to MUSH conversion

browning@math.ucla.edu (08/17/89)

I'm in the process of converting to mush, after years of rmail
within Gnu emacs.  I have many rmail files that I would like
to convert to mush format.  Has anyone done this before?
I'd hate to have to write C program to do it!

On the other hand, is it possible (or even desirable) to have
mush maintain the rmail files, that is, for mush to use an rmail
format on its folders?  My system mailbox, /usr/spool/mail/yours-truly,
and ~/mbox, should stay in ucb-mail format.  It's a 4.2bsd system.

BTW, I have to change because my system administrator is not
supporting Gnu emacs, and I feel that I can support mush on my
own.

Thanks for any advice.

-- David


UUCP:...!{rutgers,ucbvax,sdcrdcf,{hao!cepu}}!ucla-se!math.ucla.edu!browning
ARPA: browning@math.ucla.edu        BITNET: browning%math.ucla.edu@INTERBIT

swb@DAINICHI.TN.CORNELL.EDU (Scott Brim) (08/18/89)

Here's a sed script I ran my RMAIL files through to convert them back
to reg'lar old Berkeley format.  I didn't attempt to convert the dates,
and your mail may display funny dates, depending on what's in the
headers in the actual mail files themselves.  I just lived with it.

#
# at the top, get rid of the first BABYL header totally
#
/^BABYL/,/^\*\*\* EOOH \*\*\*$/c\
>From nobody@nowhere.tn.cornell.edu Fri Jan 1 12:00:00 1988
#
# for every other header, replace with two blank lines and a From line
#
/^/,/^\*\*\* EOOH \*\*\*$/c\
\
\
>From nobody@nowhere.tn.cornell.edu Fri Jan 1 12:00:00 1988
#
# Finally, get rid of trailing  (that's control-underscore)
#
/^$/d

schaefer@CSE.OGC.EDU (Barton E. Schaefer) (08/18/89)

On Aug 17,  2:46pm, Scott Brim wrote:
} Subject: Re: RMAIL to MUSH conversion
} 
} Here's a sed script I ran my RMAIL files through to convert them
} 
} #
} # at the top, get rid of the first BABYL header totally
} #
} /^BABYL/,/^\*\*\* EOOH \*\*\*$/c\
} >From nobody@nowhere.tn.cornell.edu Fri Jan 1 12:00:00 1988

  ^ Note that the > there was inserted by the mail software and,
    if it reached you in that form as it did me, the > should be
    removed before using the script.

[ Some lines of script omitted ]
} >From nobody@nowhere.tn.cornell.edu Fri Jan 1 12:00:00 1988

  ^ Same applies here, remove the >.

Just a friendly warning ....

-- 
Bart Schaefer           "And if you believe that, you'll believe anything."
                                                            -- DangerMouse
CSNET / Internet                schaefer@cse.ogc.edu
UUCP                            ...{sequent,tektronix,verdix}!ogccse!schaefer

henry@GARP.MIT.EDU (Henry Mensch) (08/18/89)

this bit of e-lisp, which i got from robert krawitz <rlk@think.com>
should do the trick.  it could be just a tad cleverer, tho.

--- cut here ---

(defun rmail-convert-buffer-to-mail-file (file)
  "Convert current buffer to Mail format into a given filename"
  (interactive
   (list
    (read-file-name
     (concat "Output buffer to Unix mail file: (default "
	     (concat (file-name-nondirectory (buffer-file-name)) ".MAIL")
	     ") ")
     (file-name-directory (buffer-file-name))
     (concat (buffer-file-name) ".MAIL"))))
  (setq file (expand-file-name file))
  (let ((rmailbuf (current-buffer))
	(tembuf (get-buffer-create " rmail-output"))
	(case-fold-search t)
	(total rmail-total-messages)
	(msg rmail-current-message)
	(count 0)
	(str (concat "From " (user-real-login-name) "@" (system-name) "  "
		     (current-time-string) "\n")))
    (set-buffer tembuf)
    (delete-region (point-min) (point-max))
    (insert (concat "From " (user-real-login-name) "@" (system-name)))
    (set-buffer rmailbuf)
    (save-excursion
      (save-restriction
	(widen)
	(while (< count total)
	  (setq count (1+ count))
	  (let ((beg (rmail-msgbeg count))
		(end (rmail-msgend count)))
	    (goto-char beg)
	    (forward-line 2)
	    (search-forward "\n*** EOOH ***\n" end t)
	    (setq beg (point))
	    (goto-char end)
	    (forward-line 0)
	    (setq end (point))
	    (princ str tembuf)
	    (princ (buffer-substring beg end) tembuf)
	    (princ "\n" tembuf)))))
    (set-buffer tembuf)
    (append-to-file (point-min) (point-max) file)
    (kill-buffer tembuf)))

pwolfe@kailand.kai.COM (Patrick Wolfe) (08/18/89)

> I'm in the process of converting to mush, after years of rmail
> within Gnu emacs.  I have many rmail files that I would like
> to convert to mush format.  Has anyone done this before?

I had to write the enclosed Perl script to do exactly that when I simply
decided to *try* rmail once.  The damn thing went and sucked up my existing
mbox file, converting it to rmail format, but didn't provide a way to put
it back when I decided to stick with mush!

        Patrick Wolfe   (pat@kai.com, kailand!pat)
        System Manager, Kuck & Associates, Inc.


	#!/usr/local/bin/perl
	#	unrmailit
	$TRUE = 1;
	$FALSE = 0;
	$copy = $FALSE;
	$begin_string = "*** EOOH ***";
	$end_string = sprintf ("%c%c", 31, 12);

	while (<>)
		{
		if ($copy)
			{
			print $_;
			}
		chop;
		if ($_ eq $begin_string)
			{
			if (! $copy)
				{
				print "From unknown@unknown Sat Dec 31 00:01:00 1988\n";
				}
			$copy = $TRUE;
			}
		elsif ($_ eq $end_string)
			{
			$copy = $FALSE;
			}
		}
	exit (0);



-- 

        Patrick Wolfe   (pat@kai.com, kailand!pat)
        System Manager, Kuck & Associates, Inc.

khaw@pplace.COM (Mike Khaw) (08/19/89)

browning@math.ucla.edu writes:

>I'm in the process of converting to mush, after years of rmail
>within Gnu emacs.  I have many rmail files that I would like
>to convert to mush format.  Has anyone done this before?

It's been a while since I've touched GNU Emacs or RMAIL, but RMAIL
has a function that will write out your mail file in normal Unix mail
format, which is what MUSH understands.  Use the Emacs Info browser
on RMAIL to find the command.

Mike Khaw
-- 
ParcPlace Systems, 1550 Plymouth St., Mountain View, CA 94043	415/691-6749
Domain=khaw@parcplace.com, UUCP={uunet,sun,decwrl}!parcplace!khaw