Skip to content

Instantly share code, notes, and snippets.

@qmx
Created May 6, 2013 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qmx/5523277 to your computer and use it in GitHub Desktop.
Save qmx/5523277 to your computer and use it in GitHub Desktop.
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
--- a/OPS
+++ b/OPS
@@ -184,3 +184,5 @@
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"
--- a/curs_main.c
+++ b/curs_main.c
@@ -2236,6 +2236,8 @@
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:
--- a/functions.h
+++ b/functions.h
@@ -173,6 +173,10 @@
{ "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-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
+ { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
{ "sidebar-open", OP_SIDEBAR_OPEN, NULL },
{ NULL, 0, NULL }
};
--- a/init.h
+++ b/init.h
@@ -1956,6 +1956,11 @@
{"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
/*
** .pp
+ ** Show only new mail in the sidebar.
+ */
+ {"sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, "no" },
+ /*
+ ** .pp
** This specifies the delimiter between the sidebar (if visible) and
** other screens.
*/
--- a/mutt.h
+++ b/mutt.h
@@ -518,6 +518,8 @@
OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
+ OPTSIDEBARNEWMAILONLY,
+
OPTMAX
};
--- a/pager.c
+++ b/pager.c
@@ -2756,6 +2756,8 @@
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;
--- a/sidebar.c
+++ b/sidebar.c
@@ -261,8 +261,20 @@
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 ) &&
+ ( strcmp( tmp->path, Context->path ) != 0 ) ) )
+ continue;
+ else
+ SETCOLOR(MT_COLOR_NORMAL);
+ }
move( lines, 0 );
if ( Context && !strcmp( tmp->path, Context->path ) ) {
@@ -320,6 +332,29 @@
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)
{
@@ -336,18 +371,33 @@
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 ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment