You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sidebar-newonly.patch 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. From: Steve Kemp <steve@steve.org.uk>
  2. Date: Tue, 4 Mar 2014 22:07:06 +0100
  3. Subject: sidebar-newonly
  4. patches written by Steve Kemp, it adds two new functionalities to the sidebar,
  5. so only the mailbox with new messages will be shown (and/or) selected
  6. See Debian bug http://bugs.debian.org/532510
  7. Gbp-Pq: Topic mutt-patched
  8. ---
  9. OPS | 2 ++
  10. curs_main.c | 2 ++
  11. functions.h | 4 ++++
  12. init.h | 5 +++++
  13. mutt.h | 2 ++
  14. pager.c | 2 ++
  15. sidebar.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
  16. 7 files changed, 70 insertions(+), 2 deletions(-)
  17. diff --git a/OPS b/OPS
  18. index b036db9..1ed9c96 100644
  19. --- a/OPS
  20. +++ b/OPS
  21. @@ -185,3 +185,5 @@ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
  22. OP_SIDEBAR_NEXT "go down to next mailbox"
  23. OP_SIDEBAR_PREV "go to previous mailbox"
  24. OP_SIDEBAR_OPEN "open hilighted mailbox"
  25. +OP_SIDEBAR_NEXT_NEW "go down to next mailbox with new mail"
  26. +OP_SIDEBAR_PREV_NEW "go to previous mailbox with new mail"
  27. diff --git a/curs_main.c b/curs_main.c
  28. index 7b81798..5c58f1c 100644
  29. --- a/curs_main.c
  30. +++ b/curs_main.c
  31. @@ -2262,6 +2262,8 @@ int mutt_index_menu (void)
  32. case OP_SIDEBAR_SCROLL_DOWN:
  33. case OP_SIDEBAR_NEXT:
  34. case OP_SIDEBAR_PREV:
  35. + case OP_SIDEBAR_NEXT_NEW:
  36. + case OP_SIDEBAR_PREV_NEW:
  37. scroll_sidebar(op, menu->menu);
  38. break;
  39. default:
  40. diff --git a/functions.h b/functions.h
  41. index ef8937a..363b4d5 100644
  42. --- a/functions.h
  43. +++ b/functions.h
  44. @@ -174,6 +174,8 @@ const struct binding_t OpMain[] = { /* map: index */
  45. { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
  46. { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
  47. { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
  48. + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
  49. + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
  50. { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
  51. { NULL, 0, NULL }
  52. };
  53. @@ -283,6 +285,8 @@ const struct binding_t OpPager[] = { /* map: pager */
  54. { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL },
  55. { "sidebar-next", OP_SIDEBAR_NEXT, NULL },
  56. { "sidebar-prev", OP_SIDEBAR_PREV, NULL },
  57. + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
  58. + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
  59. { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
  60. { NULL, 0, NULL }
  61. };
  62. diff --git a/init.h b/init.h
  63. index b0784d8..e20a24e 100644
  64. --- a/init.h
  65. +++ b/init.h
  66. @@ -2009,6 +2009,11 @@ struct option_t MuttVars[] = {
  67. ** you're not using IMAP folders, you probably prefer setting this to "/"
  68. ** alone.
  69. */
  70. + {"sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0 },
  71. + /*
  72. + ** .pp
  73. + ** Show only new mail in the sidebar.
  74. + */
  75. { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
  76. /*
  77. ** .pp
  78. diff --git a/mutt.h b/mutt.h
  79. index 61a9612..932ef10 100644
  80. --- a/mutt.h
  81. +++ b/mutt.h
  82. @@ -525,6 +525,8 @@ enum
  83. OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
  84. OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */
  85. + OPTSIDEBARNEWMAILONLY,
  86. +
  87. OPTMAX
  88. };
  89. diff --git a/pager.c b/pager.c
  90. index 469efe4..d372fc0 100644
  91. --- a/pager.c
  92. +++ b/pager.c
  93. @@ -2789,6 +2789,8 @@ search_next:
  94. case OP_SIDEBAR_SCROLL_DOWN:
  95. case OP_SIDEBAR_NEXT:
  96. case OP_SIDEBAR_PREV:
  97. + case OP_SIDEBAR_NEXT_NEW:
  98. + case OP_SIDEBAR_PREV_NEW:
  99. scroll_sidebar(ch, MENU_PAGER);
  100. break;
  101. diff --git a/sidebar.c b/sidebar.c
  102. index 8f58f85..51a25ca 100644
  103. --- a/sidebar.c
  104. +++ b/sidebar.c
  105. @@ -269,8 +269,21 @@ int draw_sidebar(int menu) {
  106. SETCOLOR(MT_COLOR_NEW);
  107. else if ( tmp->msg_flagged > 0 )
  108. SETCOLOR(MT_COLOR_FLAGGED);
  109. - else
  110. - SETCOLOR(MT_COLOR_NORMAL);
  111. + else {
  112. + /* make sure the path is either:
  113. + 1. Containing new mail.
  114. + 2. The inbox.
  115. + 3. The current box.
  116. + */
  117. + if ((option (OPTSIDEBARNEWMAILONLY)) &&
  118. + ( (tmp->msg_unread <= 0) &&
  119. + ( tmp != Incoming ) &&
  120. + Context &&
  121. + ( strcmp( tmp->path, Context->path ) != 0 ) ) )
  122. + continue;
  123. + else
  124. + SETCOLOR(MT_COLOR_NORMAL);
  125. + }
  126. move( lines, 0 );
  127. if ( Context && !strcmp( tmp->path, Context->path ) ) {
  128. @@ -336,6 +349,29 @@ int draw_sidebar(int menu) {
  129. return 0;
  130. }
  131. +BUFFY * exist_next_new()
  132. +{
  133. + BUFFY *tmp = CurBuffy;
  134. + if(tmp == NULL) return NULL;
  135. + while (tmp->next != NULL)
  136. + {
  137. + tmp = tmp->next;
  138. + if(tmp->msg_unread) return tmp;
  139. + }
  140. + return NULL;
  141. +}
  142. +
  143. +BUFFY * exist_prev_new()
  144. +{
  145. + BUFFY *tmp = CurBuffy;
  146. + if(tmp == NULL) return NULL;
  147. + while (tmp->prev != NULL)
  148. + {
  149. + tmp = tmp->prev;
  150. + if(tmp->msg_unread) return tmp;
  151. + }
  152. + return NULL;
  153. +}
  154. void set_buffystats(CONTEXT* Context)
  155. {
  156. @@ -352,18 +388,33 @@ void set_buffystats(CONTEXT* Context)
  157. void scroll_sidebar(int op, int menu)
  158. {
  159. + BUFFY *tmp;
  160. if(!SidebarWidth) return;
  161. if(!CurBuffy) return;
  162. switch (op) {
  163. case OP_SIDEBAR_NEXT:
  164. + if (!option (OPTSIDEBARNEWMAILONLY)) {
  165. if ( CurBuffy->next == NULL ) return;
  166. CurBuffy = CurBuffy->next;
  167. break;
  168. + }
  169. + case OP_SIDEBAR_NEXT_NEW:
  170. + if ( (tmp = exist_next_new()) == NULL)
  171. + return;
  172. + else CurBuffy = tmp;
  173. + break;
  174. case OP_SIDEBAR_PREV:
  175. + if (!option (OPTSIDEBARNEWMAILONLY)) {
  176. if ( CurBuffy->prev == NULL ) return;
  177. CurBuffy = CurBuffy->prev;
  178. break;
  179. + }
  180. + case OP_SIDEBAR_PREV_NEW:
  181. + if ( (tmp = exist_prev_new()) == NULL)
  182. + return;
  183. + else CurBuffy = tmp;
  184. + break;
  185. case OP_SIDEBAR_SCROLL_UP:
  186. CurBuffy = TopBuffy;
  187. if ( CurBuffy != Incoming ) {