+ /*
+ ** Either unlink or rename the SELECTED messages
+ */
+ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
+ if (is_selected(mp, msgnum)) {
+ /* unselect message */
+ unset_selected(mp, msgnum);
+ mp->numsel--;
+
+ /*
+ ** Run the external hook on the message if one
+ ** was specified in the context. All we have
+ ** is the message number; we have changed to
+ ** the directory containing the message. So,
+ ** we need to extract that directory to form the
+ ** complete path. Note that the caller knows the
+ ** directory, but has no way of passing that to us.
+ */
+
+ if (!nohook) {
+ snprintf(msgpath, sizeof (msgpath), "%s/%d",
+ mp->foldpath, msgnum);
+ ext_hook("del-hook", msgpath, NULL);
+ }
+
+ dp = m_name(msgnum);
+
+ if (unlink_msgs) {
+ /* just unlink the messages */
+ if (unlink(dp) == -1) {
+ admonish(dp, "unable to unlink");
+ retval = -1;
+ continue;
+ }
+ } else {
+ /* or rename messages with standard prefix */
+ strncpy(buf, m_backup(dp), sizeof(buf));
+ if (rename(dp, buf) == -1) {
+ admonish(buf, "unable to rename %s to", dp);
+ retval = -1;
+ continue;
+ }
+ }
+
+ /* If removal was successful, decrement message count */
+ unset_exists(mp, msgnum);
+ mp->nummsg--;
+ }