Path: utzoo!attcan!uunet!husc6!bbn!bbn.com!mesard
From: mesard@bbn.com (Wayne Mesard)
Newsgroups: comp.mail.mh
Subject: Re: unrmm command
Message-ID: <26238@bbn.COM>
Date: 24 Jun 88 18:46:14 GMT
References: <8806241416.AA04206@oddjob.uchicago.edu>
Sender: news@bbn.COM
Lines: 118

From article <8806241416.AA04206@oddjob.uchicago.edu>, by matt@ODDJOB.UCHICAGO.EDU (Matt Crawford):
> And here's a little off-the-cuff mod of Craig's unrmm, using a csh
> feature and adding the possibility of multiple messages:
[script deleted]

Not to be outdone, here's my unrmm.  I guess this is the Cadillac
version.  It handles multiple messages, folder context changes and
relative message number specification.  So if the current message in
folder +foo is 28, the following command will undelete the 28, 26 and
29:

unrmm +foo cur -2 -+1

It tries to use the same message number, but if a new message has
already been put in it's place, it refiles it as the last message in the
folder.

(It ain't pretty on the outside, but you should see all the dials on the
dashboard, and oh! that plush interior :-)

-- 
unsigned *Wayne_Mesard();        MESARD@BBN.COM        BBN Labs, Cambridge, MA

Is it because of the people you hang around with that you say you do not
need dan rather?
			M-x psychoanalyze-pinhead
(Gee, whataneditor!!)

=============================snip===============================
#!/bin/csh -fe

set msgs
while ( X$1 != X )
	switch ($1)
		case -help:
			echo "syntax: `basename $0` [+folder] [special-msgs] [switches]"
			echo "  switches are:"
			echo "  -[no]changecur"
			echo "  -(help)"
			echo ""
			exit 0
		case -nochangecur:
			echo match
			set newcur
			breaksw
		case -changecur:
			unset newcur
			breaksw
		case +*:
			set mfolder = $1
			breaksw
		default:
			set msgs = "$msgs $1"
			breaksw
		endsw
	shift
end
exit
if ($?mfolder == '0') then
	set mfolder = +`folder -fast`
endif

cd `mhpath $mfolder`

set temp = `mhpath cur`
set curnum = $temp:t

if ("$msgs" == "") set msgs = $curnum

foreach msgnum ( $msgs )
	switch ($msgnum)
		case cur:
			set msgnum = $curnum
			breaksw
		case -+*:
			@ msgnum = $curnum + `expr $msgnum : '.\(.*\)'`
			breaksw
		case -*:
			@ msgnum = $curnum + $msgnum
			breaksw
		case [0-9]*:
			breaksw
		default:
			set msgnum = `pick $msgnum`
			breaksw
		endsw

	if (-e ",$msgnum") then
		if (-e "$msgnum") then
			echo Refiling ",$msgnum" as last message.
			echo refile $mfolder -file ",$msgnum"
			refile $mfolder -file ",$msgnum"
			if ( $?newcur == 0 )
				set newcur = `pick last`
		else
			echo Undeleting $msgnum.
			echo mv ",$msgnum" "$msgnum"
			mv ",$msgnum" "$msgnum"
			if ( $?newcur == 0 )
				set newcur = "$msgnum"
		endif
	else
		echo \"$mfolder/,$msgnum\": no such deleted message file.
	endif
end

## Change context to first message restored. ##
if ( $?newcur == 0)
	set newcur
folder $mfolder $newcur >/dev/null

-- 
unsigned *Wayne_Mesard();        MESARD@BBN.COM        BBN Labs, Cambridge, MA

Is it because of the people you hang around with that you say you do not
need dan rather?
			M-x psychoanalyze-pinhead
(Gee, whataneditor!!)