Skip to content

Instantly share code, notes, and snippets.

@juliusknorr
Created February 13, 2015 00:37
Show Gist options
  • Save juliusknorr/68487e0d545b17509c0c to your computer and use it in GitHub Desktop.
Save juliusknorr/68487e0d545b17509c0c to your computer and use it in GitHub Desktop.
From ed547aeb2c6f10da3639e5212b47f4e3aea450d6 Mon Sep 17 00:00:00 2001
From: Julius Haertl <[email protected]>
Date: Tue, 9 Sep 2014 22:31:49 +0200
Subject: [PATCH] Patch for sidebar iteration functionality
sidebar-new will move the selected folder to the next with new messages.
If the end is reached, it will start at the top.
Useful macros would be:
macro index <esc>a "<sidebar-new><sidebar-open>"
macro pager <esc>a "<exit><sidebar-new><sidebar-open>"
---
OPS | 1 +
curs_main.c | 1 +
functions.h | 2 ++
pager.c | 1 +
sidebar.c | 10 ++++++++++
5 files changed, 15 insertions(+)
diff --git a/OPS b/OPS
index b900373..62db4b4 100644
--- a/OPS
+++ b/OPS
@@ -206,3 +206,4 @@ OP_SIDEBAR_PREV "go to previous mailbox"
OP_SIDEBAR_OPEN "open hilighted mailbox"
OP_SIDEBAR_NEXT_NEW "go down to next mailbox with new mail"
OP_SIDEBAR_PREV_NEW "go to previous mailbox with new mail"
+OP_SIDEBAR_NEW "iterate though mailboxes with new mail"
diff --git a/curs_main.c b/curs_main.c
index 8cec507..fb0a74f 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -2550,6 +2550,7 @@ int mutt_index_menu (void)
case OP_SIDEBAR_PREV:
case OP_SIDEBAR_NEXT_NEW:
case OP_SIDEBAR_PREV_NEW:
+ case OP_SIDEBAR_NEW:
scroll_sidebar(op, menu->menu);
break;
default:
diff --git a/functions.h b/functions.h
index 66f3345..8ca5411 100644
--- a/functions.h
+++ b/functions.h
@@ -195,6 +195,7 @@ const struct binding_t OpMain[] = { /* map: index */
{ "sidebar-prev", OP_SIDEBAR_PREV, NULL },
{ "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
{ "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
+ { "sidebar-new", OP_SIDEBAR_NEW, NULL },
{ "sidebar-open", OP_SIDEBAR_OPEN, NULL },
{ NULL, 0, NULL }
};
@@ -317,6 +318,7 @@ const struct binding_t OpPager[] = { /* map: pager */
{ "sidebar-prev", OP_SIDEBAR_PREV, NULL },
{ "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
{ "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
+ { "sidebar-new", OP_SIDEBAR_NEW, NULL },
{ "sidebar-open", OP_SIDEBAR_OPEN, NULL },
{ NULL, 0, NULL }
};
diff --git a/pager.c b/pager.c
index e888452..9a7d076 100644
--- a/pager.c
+++ b/pager.c
@@ -2868,6 +2868,7 @@ search_next:
case OP_SIDEBAR_PREV:
case OP_SIDEBAR_NEXT_NEW:
case OP_SIDEBAR_PREV_NEW:
+ case OP_SIDEBAR_NEW:
scroll_sidebar(ch, MENU_PAGER);
break;
diff --git a/sidebar.c b/sidebar.c
index c3ea338..eb8ecd2 100644
--- a/sidebar.c
+++ b/sidebar.c
@@ -429,6 +429,16 @@ void scroll_sidebar(int op, int menu)
CurBuffy = CurBuffy->next;
}
break;
+ case OP_SIDEBAR_NEW:
+ if ( (tmp = exist_next_new()) == NULL)
+ tmp = TopBuffy;
+ if ( tmp->msg_unread == 0 ) {
+ CurBuffy = tmp;
+ tmp = exist_next_new();
+ }
+ if ( tmp != NULL )
+ CurBuffy = tmp;
+ break;
default:
return;
}
--
2.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment