forked from mirrors/nixpkgs
47c92a87c8
This change uses a different patchset for mutt-with-sidebar.
199 lines
5.9 KiB
Diff
199 lines
5.9 KiB
Diff
From: Steve Kemp <steve@steve.org.uk>
|
|
Date: Tue, 4 Mar 2014 22:07:06 +0100
|
|
Subject: sidebar-newonly
|
|
|
|
patches written by Steve Kemp, it adds two new functionalities to the sidebar,
|
|
so only the mailbox with new messages will be shown (and/or) selected
|
|
See Debian bug http://bugs.debian.org/532510
|
|
|
|
Gbp-Pq: Topic mutt-patched
|
|
---
|
|
OPS | 2 ++
|
|
curs_main.c | 2 ++
|
|
functions.h | 4 ++++
|
|
init.h | 5 +++++
|
|
mutt.h | 2 ++
|
|
pager.c | 2 ++
|
|
sidebar.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
7 files changed, 70 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/OPS b/OPS
|
|
index b036db9..1ed9c96 100644
|
|
--- a/OPS
|
|
+++ b/OPS
|
|
@@ -185,3 +185,5 @@ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
|
|
OP_SIDEBAR_NEXT "go down to next mailbox"
|
|
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"
|
|
diff --git a/curs_main.c b/curs_main.c
|
|
index ea530a6..acb106d 100644
|
|
--- a/curs_main.c
|
|
+++ b/curs_main.c
|
|
@@ -2326,6 +2326,8 @@ int mutt_index_menu (void)
|
|
case OP_SIDEBAR_SCROLL_DOWN:
|
|
case OP_SIDEBAR_NEXT:
|
|
case OP_SIDEBAR_PREV:
|
|
+ case OP_SIDEBAR_NEXT_NEW:
|
|
+ case OP_SIDEBAR_PREV_NEW:
|
|
scroll_sidebar(op, menu->menu);
|
|
break;
|
|
default:
|
|
diff --git a/functions.h b/functions.h
|
|
index ef8937a..363b4d5 100644
|
|
--- a/functions.h
|
|
+++ b/functions.h
|
|
@@ -174,6 +174,8 @@ const struct binding_t OpMain[] = { /* map: index */
|
|
{ "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
|
|
{ "sidebar-next", OP_SIDEBAR_NEXT, NULL },
|
|
{ "sidebar-prev", OP_SIDEBAR_PREV, NULL },
|
|
+ { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
|
|
+ { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
|
|
{ "sidebar-open", OP_SIDEBAR_OPEN, NULL },
|
|
{ NULL, 0, NULL }
|
|
};
|
|
@@ -283,6 +285,8 @@ const struct binding_t OpPager[] = { /* map: pager */
|
|
{ "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
|
|
{ "sidebar-next", OP_SIDEBAR_NEXT, NULL },
|
|
{ "sidebar-prev", OP_SIDEBAR_PREV, NULL },
|
|
+ { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
|
|
+ { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
|
|
{ "sidebar-open", OP_SIDEBAR_OPEN, NULL },
|
|
{ NULL, 0, NULL }
|
|
};
|
|
diff --git a/init.h b/init.h
|
|
index 166671b..a5d4238 100644
|
|
--- a/init.h
|
|
+++ b/init.h
|
|
@@ -2059,6 +2059,11 @@ struct option_t MuttVars[] = {
|
|
** you're not using IMAP folders, you probably prefer setting this to "/"
|
|
** alone.
|
|
*/
|
|
+ {"sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0 },
|
|
+ /*
|
|
+ ** .pp
|
|
+ ** Show only new mail in the sidebar.
|
|
+ */
|
|
{ "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
|
|
/*
|
|
** .pp
|
|
diff --git a/mutt.h b/mutt.h
|
|
index 5f25406..d73e514 100644
|
|
--- a/mutt.h
|
|
+++ b/mutt.h
|
|
@@ -529,6 +529,8 @@ enum
|
|
OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
|
|
OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
|
|
|
|
+ OPTSIDEBARNEWMAILONLY,
|
|
+
|
|
OPTMAX
|
|
};
|
|
|
|
diff --git a/pager.c b/pager.c
|
|
index 5cfcb75..8d64fe1 100644
|
|
--- a/pager.c
|
|
+++ b/pager.c
|
|
@@ -2789,6 +2789,8 @@ search_next:
|
|
case OP_SIDEBAR_SCROLL_DOWN:
|
|
case OP_SIDEBAR_NEXT:
|
|
case OP_SIDEBAR_PREV:
|
|
+ case OP_SIDEBAR_NEXT_NEW:
|
|
+ case OP_SIDEBAR_PREV_NEW:
|
|
scroll_sidebar(ch, MENU_PAGER);
|
|
break;
|
|
|
|
diff --git a/sidebar.c b/sidebar.c
|
|
index 8f58f85..51a25ca 100644
|
|
--- a/sidebar.c
|
|
+++ b/sidebar.c
|
|
@@ -269,8 +269,21 @@ int draw_sidebar(int menu) {
|
|
SETCOLOR(MT_COLOR_NEW);
|
|
else if ( tmp->msg_flagged > 0 )
|
|
SETCOLOR(MT_COLOR_FLAGGED);
|
|
- else
|
|
- SETCOLOR(MT_COLOR_NORMAL);
|
|
+ else {
|
|
+ /* make sure the path is either:
|
|
+ 1. Containing new mail.
|
|
+ 2. The inbox.
|
|
+ 3. The current box.
|
|
+ */
|
|
+ if ((option (OPTSIDEBARNEWMAILONLY)) &&
|
|
+ ( (tmp->msg_unread <= 0) &&
|
|
+ ( tmp != Incoming ) &&
|
|
+ Context &&
|
|
+ ( strcmp( tmp->path, Context->path ) != 0 ) ) )
|
|
+ continue;
|
|
+ else
|
|
+ SETCOLOR(MT_COLOR_NORMAL);
|
|
+ }
|
|
|
|
move( lines, 0 );
|
|
if ( Context && !strcmp( tmp->path, Context->path ) ) {
|
|
@@ -336,6 +349,29 @@ int draw_sidebar(int menu) {
|
|
return 0;
|
|
}
|
|
|
|
+BUFFY * exist_next_new()
|
|
+{
|
|
+ BUFFY *tmp = CurBuffy;
|
|
+ if(tmp == NULL) return NULL;
|
|
+ while (tmp->next != NULL)
|
|
+ {
|
|
+ tmp = tmp->next;
|
|
+ if(tmp->msg_unread) return tmp;
|
|
+ }
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
+BUFFY * exist_prev_new()
|
|
+{
|
|
+ BUFFY *tmp = CurBuffy;
|
|
+ if(tmp == NULL) return NULL;
|
|
+ while (tmp->prev != NULL)
|
|
+ {
|
|
+ tmp = tmp->prev;
|
|
+ if(tmp->msg_unread) return tmp;
|
|
+ }
|
|
+ return NULL;
|
|
+}
|
|
|
|
void set_buffystats(CONTEXT* Context)
|
|
{
|
|
@@ -352,18 +388,33 @@ void set_buffystats(CONTEXT* Context)
|
|
|
|
void scroll_sidebar(int op, int menu)
|
|
{
|
|
+ BUFFY *tmp;
|
|
if(!SidebarWidth) return;
|
|
if(!CurBuffy) return;
|
|
|
|
switch (op) {
|
|
case OP_SIDEBAR_NEXT:
|
|
+ if (!option (OPTSIDEBARNEWMAILONLY)) {
|
|
if ( CurBuffy->next == NULL ) return;
|
|
CurBuffy = CurBuffy->next;
|
|
break;
|
|
+ }
|
|
+ case OP_SIDEBAR_NEXT_NEW:
|
|
+ if ( (tmp = exist_next_new()) == NULL)
|
|
+ return;
|
|
+ else CurBuffy = tmp;
|
|
+ break;
|
|
case OP_SIDEBAR_PREV:
|
|
+ if (!option (OPTSIDEBARNEWMAILONLY)) {
|
|
if ( CurBuffy->prev == NULL ) return;
|
|
CurBuffy = CurBuffy->prev;
|
|
break;
|
|
+ }
|
|
+ case OP_SIDEBAR_PREV_NEW:
|
|
+ if ( (tmp = exist_prev_new()) == NULL)
|
|
+ return;
|
|
+ else CurBuffy = tmp;
|
|
+ break;
|
|
case OP_SIDEBAR_SCROLL_UP:
|
|
CurBuffy = TopBuffy;
|
|
if ( CurBuffy != Incoming ) {
|