From: Thomas Roessler Date: Sat, 21 Dec 2002 20:30:36 +0000 (+0000) Subject: OK, Michael is right: Gotos suck. ;-) X-Git-Tag: mutt-1-5-4-rel~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bcea49ee8c7c6f15b150f53edfe10d7495a5685;p=mutt OK, Michael is right: Gotos suck. ;-) --- diff --git a/curs_main.c b/curs_main.c index 15f79558..00de1924 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1270,9 +1270,13 @@ int mutt_index_menu (void) case OP_MAIN_NEXT_NEW_THEN_UNREAD: case OP_MAIN_PREV_NEW_THEN_UNREAD: + { + int first_unread = -1; + int first_new = -1; + CHECK_MSGCOUNT; CHECK_VISIBLE; - next_unread_again: + i = menu->current; menu->current = -1; for (j = 0; j != Context->vcount; j++) @@ -1299,43 +1303,40 @@ int mutt_index_menu (void) if (CURHDRi->collapsed && (Sort & SORT_MASK) == SORT_THREADS) { - if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) && - UNREAD (CURHDRi)) - { - menu->current = i; - break; - } - if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW || - op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD) && - UNREAD (CURHDRi) == 1) - { - menu->current = i; - break; - } + if (UNREAD (CURHDRi) && first_unread == -1) + first_unread = i; + if (UNREAD (CURHDRi) == 1 && first_new == -1) + first_new = i; } else if ((!CURHDRi->deleted && !CURHDRi->read)) { - if (op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD || !CURHDRi->old) - { - menu->current = i; - break; - } + if (first_unread == -1) + first_unread = i; + if ((!CURHDRi->old) && first_new == -1) + first_new = i; } + + if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD) && + first_unread != -1) + break; + if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW || + op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD) + && first_new != -1) + break; } #undef CURHDRi + if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW || + op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD) + && first_new != -1) + menu->current = first_new; + else if ((op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD || + op == OP_MAIN_NEXT_NEW_THEN_UNREAD || op == OP_MAIN_PREV_NEW_THEN_UNREAD) + && first_unread != -1) + menu->current = first_unread; + if (menu->current == -1) { menu->current = menu->oldcurrent; - if (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) - { - op = OP_MAIN_NEXT_UNREAD; - goto next_unread_again; - } - if (op == OP_MAIN_PREV_NEW_THEN_UNREAD) - { - op = OP_MAIN_PREV_UNREAD; - goto next_unread_again; - } mutt_error ("%s%s.", (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) ? _("No new messages") : _("No unread messages"), Context->pattern ? _(" in this limited view") : ""); } @@ -1347,7 +1348,7 @@ int mutt_index_menu (void) else menu->redraw = REDRAW_MOTION; break; - + } case OP_FLAG_MESSAGE: CHECK_MSGCOUNT;