[comp.mail.mush] MUSH Question

schaefer@CSE.OGI.EDU (Barton E. Schaefer) (07/28/90)

On Jul 27,  9:33am, Murray S. Kucherawy wrote:
} Subject: MUSH Question

I hope you don't mind if I carbon my answer to the whole wide world. :-)

} I have a procedure that runs with the -F option on the UNIX command line.
} This procedure has some "pick" and "update" commands in it.  This works
} fine, but the only quirk is that new mail appears as "unread" mail when
} the procedure finishes and I display headers.
} 
} Can mush be set to mark messages as "new" that are actually new, leaving
} the status of other messages left in the mailbox from a previous session
} alone?

Check out the "flags" command.  You can make use of the fact that all
new messages are clumped together at the end of the file.  When the
script procedure begins, capture the numbers of the new and old messages,
thusly:

    headers -H:n | set new	# Can abbreviate as ":n | set new"
    * { $new } | set old

Now do all of your "pick" operations.  If you do any sorting, restrict
the range of the sort to the new messages:

    $new | sort -s	# or whatever sort options you want

This way, the value of $old will remain correct even if you update
the folder.  After each update, reset $new:

    update
    * { $old } | set new

As the final operations in your script, restore the "New" status by
using the "flags" command:

    $new | flags -O	# remove Old flag, leave others alone

Now you can safely sort the entire folder by whatever criteria you
want.  Just don't update it again or the new messages will change back
to unread.

-- 
Bart Schaefer						schaefer@cse.ogi.edu