[comp.mail.mush] deleting last message

schaefer@ogicse.ogi.edu (Barton E. Schaefer) (05/29/90)

In article <1627@island.uu.net> duffy@island.uu.net (Ken Duffy) writes:
} I have a mush question which may have a simple answer.  (I just hope
} it isn't "No.")  Can you be on the last message and enter a command to
} delete the message, and automatically be moved to the previous message
} rather than to the first message?

Unfortunately, the simple answer is indeed, "No."

} I want to stay on the last existing message (the one
} previous to the one deleted).  How can I do this in one command?

It's pretty difficult at the moment because mush doesn't (yet) have an
"if" construct that works interactively (it only works in scripts).  You
can make a single command that *always* goes to the last not-deleted
message, but not one that goes to the last not-deleted message only when
the current message is past that one (which is what you want, I think).

The cmd to go to the last undeleted message is just

    cmd last "headers | pick -1 | from +"

where the "pick -1" says take the last one message from the piped-in
list.  The "from +" simply forces the current message to change to the
message selected by pick; you can replace "from +" with "p" or any
command that changes the current message.  This cmd is sensitive to the
setting of $show_deleted; if you want to find the last undeleted message
regardless of $show_deleted, use:

    cmd last "pick -1 -r * {`:d`} | from +"

If it helps you any, the "previous" command works like "next" in that it
will skip over deleted messages to find the nearest preceding undeleted
message, then display that one.  So you could

    cmd dp "delete;previous"

and then if you know you are on the last message, use "dp", and otherwise
use "dt".  But there isn't any easy way to get mush to figure out for you
which one you should use.
-- 
Bart Schaefer						schaefer@cse.ogi.edu