diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2002-12-14 23:43:01 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2002-12-14 23:43:01 +0000 |
commit | 791c8d0417524031acd17ab3a842c8a78d1895df (patch) | |
tree | b798c1fff340974d50adf97a475236b1696fbf5e | |
parent | 940f5f8b8e8f9baf641b98c729dd0cf5c56d2c98 (diff) | |
download | mailutils-791c8d0417524031acd17ab3a842c8a78d1895df.tar.gz mailutils-791c8d0417524031acd17ab3a842c8a78d1895df.tar.bz2 |
Skip deleted messages
-rw-r--r-- | mail/next.c | 23 | ||||
-rw-r--r-- | mail/previous.c | 27 |
2 files changed, 39 insertions, 11 deletions
diff --git a/mail/next.c b/mail/next.c index 42ea7167d..46c569b76 100644 --- a/mail/next.c +++ b/mail/next.c @@ -25,22 +25,35 @@ int mail_next (int argc, char **argv) { + size_t n; + message_t msg; + if (argc < 2) { - if (cursor < total) + int rc = 1; + for (n = cursor + 1; n <= total; n++) + { + rc = util_get_message (mbox, n, &msg, MSG_NODELETED|MSG_SILENT); + if (rc == 0) + break; + } + + if (rc) { - cursor++; - realcursor++; + util_error ("No applicable message"); + return 1; } } else { msgset_t *list = NULL; msgset_parse (argc, argv, &list); - cursor = list->msg_part[0]; - realcursor = cursor; + n = list->msg_part[0]; msgset_free (list); + if (util_get_message (mbox, n, &msg, MSG_NODELETED|MSG_SILENT)) + return 1; } + cursor = realcursor = n; util_do_command("print"); return 0; } diff --git a/mail/previous.c b/mail/previous.c index 838f08fa6..0ab517731 100644 --- a/mail/previous.c +++ b/mail/previous.c @@ -25,20 +25,35 @@ int mail_previous (int argc, char **argv) { + size_t n; + message_t msg; + if (argc < 2) { - cursor--; - realcursor--; + int rc = 1; + for (n = cursor - 1; n > 0; n--) + { + rc = util_get_message (mbox, n, &msg, MSG_NODELETED|MSG_SILENT); + if (rc == 0) + break; + } + + if (rc) + { + util_error ("No applicable message"); + return 1; + } } else { msgset_t *list = NULL; - if (msgset_parse (argc, argv, &list)) - return 1; - cursor = list->msg_part[0]; - realcursor = cursor; + msgset_parse (argc, argv, &list); + n = list->msg_part[0]; msgset_free (list); + if (util_get_message (mbox, n, &msg, MSG_NODELETED|MSG_SILENT)) + return 1; } + cursor = realcursor = n; util_do_command ("print"); return 0; } |