- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder))) {
+ adios(NULL, "unable to read folder %s", folder);
+ }
+ if (mp->nummsg == 0) {
+ adios(NULL, "no messages in %s", folder);
+ }
+ /*
+ ** parse all the message ranges/sequences and set SELECTED
+ ** (We do this for the refiling case as well, to complain
+ ** about invalid msg arguments in rmm, before we call refile.)
+ */
+ for (msgnum = 0; msgnum < msgs.size; msgnum++) {
+ if (!m_convert(mp, msgs.msgs[msgnum])) {
+ done(1);
+ }
+ }
+
+ context_replace(curfolder, folder);
+ context_save();
+
+ if (unlink_msgs) {
+ /* "remove" the SELECTED messages */
+ folder_delmsgs(mp, 1);
+ seq_setprev(mp);
+ seq_save(mp);
+ folder_free(mp);
+ done(0);
+ return 1;
+ }