]> granicus.if.org Git - mutt/commitdiff
Experimental: Introduce {next,previous}-new-then-unread. These
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 17 Dec 2002 09:50:26 +0000 (09:50 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 17 Dec 2002 09:50:26 +0000 (09:50 +0000)
functions behave like {next,previous}-new as long as new messages
are visible.  When no new messages are visibuel any more, there's a
fall-back to {next,prev}-unread.

Memo to self: Impose a weekly quota on the use of goto statements.

OPS
curs_main.c
functions.h

diff --git a/OPS b/OPS
index f8abbfb7657f9d2ce1403b5a3d5e0ae1d594c037..ddb2022da53772fa713b7d0e470dc94b01f3f9ca 100644 (file)
--- a/OPS
+++ b/OPS
@@ -105,6 +105,7 @@ OP_MAIN_FIRST_MESSAGE "move to the first message"
 OP_MAIN_LAST_MESSAGE "move to the last message"
 OP_MAIN_LIMIT "show only messages matching a pattern"
 OP_MAIN_NEXT_NEW "jump to the next new message"
+OP_MAIN_NEXT_NEW_THEN_UNREAD "jump to the next new or unread message"
 OP_MAIN_NEXT_SUBTHREAD "jump to the next subthread"
 OP_MAIN_NEXT_THREAD "jump to the next thread"
 OP_MAIN_NEXT_UNDELETED "move to the next undeleted message"
@@ -114,6 +115,7 @@ OP_MAIN_PREV_THREAD "jump to previous thread"
 OP_MAIN_PREV_SUBTHREAD "jump to previous subthread"
 OP_MAIN_PREV_UNDELETED "move to the previous undeleted message"
 OP_MAIN_PREV_NEW "jump to the previous new message"
+OP_MAIN_PREV_NEW_THEN_UNREAD "jump to the previous new or unread message"
 OP_MAIN_PREV_UNREAD "jump to the previous unread message"
 OP_MAIN_READ_THREAD "mark the current thread as read"
 OP_MAIN_READ_SUBTHREAD "mark the current subthread as read"
index 2f6198dab47979a49e5cbed038bf91a4f0f7f303..15f79558c21ef9e4a85b78042f0aa187bc144f7f 100644 (file)
@@ -1267,15 +1267,18 @@ int mutt_index_menu (void)
       case OP_MAIN_NEXT_UNREAD:
       case OP_MAIN_PREV_NEW:
       case OP_MAIN_PREV_UNREAD:
+      case OP_MAIN_NEXT_NEW_THEN_UNREAD:
+      case OP_MAIN_PREV_NEW_THEN_UNREAD:
 
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
+      next_unread_again:
        i = menu->current;
        menu->current = -1;
        for (j = 0; j != Context->vcount; j++)
        {
 #define CURHDRi Context->hdrs[Context->v2r[i]] 
-         if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD)
+         if (op == OP_MAIN_NEXT_NEW || op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_NEXT_NEW_THEN_UNREAD)
          {
            i++;
            if (i > Context->vcount - 1)
@@ -1302,7 +1305,8 @@ int mutt_index_menu (void)
              menu->current = i;
              break;
            }
-           if ((op == OP_MAIN_NEXT_NEW || op == OP_MAIN_PREV_NEW) &&
+           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;
@@ -1322,6 +1326,16 @@ int mutt_index_menu (void)
        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") : "");
        }
index 9e80de3adbd75eb6801b2fd11020227447eaaa2c..accb9448acbd30746d76ab8703e46660b6d8250e 100644 (file)
@@ -130,8 +130,10 @@ struct binding_t OpMain[] = {
   { "sync-mailbox",            OP_MAIN_SYNC_FOLDER,            "$" },
   { "display-address",         OP_DISPLAY_ADDRESS,             "@" },
   { "pipe-message",            OP_PIPE,                        "|" },
-  { "next-new",                        OP_MAIN_NEXT_NEW,               "\t" },
-  { "previous-new",            OP_MAIN_PREV_NEW,               "\033\t" },
+  { "next-new",                        OP_MAIN_NEXT_NEW,               NULL },
+  { "next-new-then-unread",    OP_MAIN_NEXT_NEW_THEN_UNREAD,   "\t" },
+  { "previous-new",            OP_MAIN_PREV_NEW,               NULL },
+  { "previous-new-then-unread",        OP_MAIN_PREV_NEW_THEN_UNREAD,   "\033\t" },
   { "next-unread",             OP_MAIN_NEXT_UNREAD,            NULL },
   { "previous-unread",         OP_MAIN_PREV_UNREAD,            NULL },
   { "parent-message",          OP_MAIN_PARENT_MESSAGE,         "P" },
@@ -205,7 +207,9 @@ struct binding_t OpPager[] = {
   { "show-version",    OP_VERSION,                     "V" },
   { "search-toggle",   OP_SEARCH_TOGGLE,               "\\" },
   { "display-address", OP_DISPLAY_ADDRESS,             "@" },
-  { "next-new",                OP_MAIN_NEXT_NEW,               "\t" },
+  { "next-new",                OP_MAIN_NEXT_NEW,               NULL },
+  { "next-new-then-unread", 
+                        OP_MAIN_NEXT_NEW_THEN_UNREAD,   "\t" },
   { "pipe-message",    OP_PIPE,                        "|" },
   { "help",            OP_HELP,                        "?" },
   { "next-page",       OP_NEXT_PAGE,                   " " },
@@ -222,6 +226,8 @@ struct binding_t OpPager[] = {
   { "jump",            OP_JUMP,                        NULL },
   { "next-unread",     OP_MAIN_NEXT_UNREAD,            NULL },
   { "previous-new",    OP_MAIN_PREV_NEW,               NULL },
+  { "previous-new-then-unread",
+                       OP_MAIN_PREV_NEW_THEN_UNREAD,   NULL },
   { "previous-unread", OP_MAIN_PREV_UNREAD,            NULL },
   { "half-up",         OP_HALF_UP,                     NULL },
   { "half-down",       OP_HALF_DOWN,                   NULL },