]> git.llucax.com Git - software/mutt-debian.git/blob - debian/patches/mutt-patched/sidebar-newonly
upstream/557395-muttrc-crypto.patch: small fix to the muttrc man (Closes: 557395)
[software/mutt-debian.git] / debian / patches / mutt-patched / sidebar-newonly
1 patches written by Steve Kemp, it adds two new functionalities to the sidebar,
2 so only the mailbox with new messages will be shown (and/or) selected
3 See Debian bug http://bugs.debian.org/532510
4
5 --- a/OPS
6 +++ b/OPS
7 @@ -184,3 +184,5 @@
8  OP_SIDEBAR_NEXT "go down to next mailbox"
9  OP_SIDEBAR_PREV "go to previous mailbox"
10  OP_SIDEBAR_OPEN "open hilighted mailbox"
11 +OP_SIDEBAR_NEXT_NEW "go down to next mailbox with new mail"
12 +OP_SIDEBAR_PREV_NEW "go to previous mailbox with new mail"
13 --- a/curs_main.c
14 +++ b/curs_main.c
15 @@ -2236,6 +2236,8 @@
16        case OP_SIDEBAR_SCROLL_DOWN:
17        case OP_SIDEBAR_NEXT:
18        case OP_SIDEBAR_PREV:
19 +      case OP_SIDEBAR_NEXT_NEW:
20 +      case OP_SIDEBAR_PREV_NEW:
21          scroll_sidebar(op, menu->menu);
22          break;
23        default:
24 --- a/functions.h
25 +++ b/functions.h
26 @@ -173,6 +173,10 @@
27   { "sidebar-scroll-down",      OP_SIDEBAR_SCROLL_DOWN, NULL },
28   { "sidebar-next",             OP_SIDEBAR_NEXT, NULL },
29   { "sidebar-prev",             OP_SIDEBAR_PREV, NULL },
30 + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
31 + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
32 + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL},
33 + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL},
34   { "sidebar-open",             OP_SIDEBAR_OPEN, NULL },
35    { NULL,                      0,                              NULL }
36  };
37 --- a/init.h
38 +++ b/init.h
39 @@ -1956,6 +1956,11 @@
40    {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
41    /*
42    ** .pp
43 +  ** Show only new mail in the sidebar.
44 +  */
45 +  {"sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, "no" },
46 +  /*
47 +  ** .pp
48    ** This specifies the delimiter between the sidebar (if visible) and
49    ** other screens.
50    */
51 --- a/mutt.h
52 +++ b/mutt.h
53 @@ -518,6 +518,8 @@
54    OPTDONTHANDLEPGPKEYS,        /* (pseudo) used to extract PGP keys */
55    OPTUNBUFFEREDINPUT,   /* (pseudo) don't use key buffer */
56  
57 +  OPTSIDEBARNEWMAILONLY,
58 +
59    OPTMAX
60  };
61  
62 --- a/pager.c
63 +++ b/pager.c
64 @@ -2756,6 +2756,8 @@
65        case OP_SIDEBAR_SCROLL_DOWN:
66        case OP_SIDEBAR_NEXT:
67        case OP_SIDEBAR_PREV:
68 +      case OP_SIDEBAR_NEXT_NEW:
69 +      case OP_SIDEBAR_PREV_NEW:
70         scroll_sidebar(ch, MENU_PAGER);
71         break;
72  
73 --- a/sidebar.c
74 +++ b/sidebar.c
75 @@ -261,8 +261,20 @@
76                         SETCOLOR(MT_COLOR_NEW);
77                 else if ( tmp->msg_flagged > 0 )
78                         SETCOLOR(MT_COLOR_FLAGGED);
79 -               else
80 -                       SETCOLOR(MT_COLOR_NORMAL);
81 +               else {
82 +                  /* make sure the path is either:
83 +                     1.  Containing new mail.
84 +                     2.  The inbox.
85 +                     3.  The current box.
86 +                   */
87 +                  if ((option (OPTSIDEBARNEWMAILONLY)) &&
88 +                      ( (tmp->msg_unread <= 0)  &&
89 +                        ( tmp != Incoming ) &&
90 +                        ( strcmp( tmp->path, Context->path ) != 0 ) ) )
91 +                    continue;
92 +                  else
93 +                    SETCOLOR(MT_COLOR_NORMAL);
94 +                }
95  
96                 move( lines, 0 );
97                 if ( Context && !strcmp( tmp->path, Context->path ) ) {
98 @@ -320,6 +332,29 @@
99         return 0;
100  }
101  
102 +BUFFY * exist_next_new()
103 +{
104 +       BUFFY *tmp = CurBuffy;
105 +       if(tmp == NULL) return NULL;
106 +       while (tmp->next != NULL)
107 +       {
108 +              tmp = tmp->next;
109 +               if(tmp->msg_unread) return tmp;
110 +       }
111 +       return NULL;
112 +}
113 +
114 +BUFFY * exist_prev_new()
115 +{
116 +       BUFFY *tmp = CurBuffy;
117 +       if(tmp == NULL) return NULL;
118 +       while (tmp->prev != NULL)
119 +       {
120 +               tmp = tmp->prev;
121 +               if(tmp->msg_unread) return tmp;
122 +       }
123 +       return NULL;
124 +}
125  
126  void set_buffystats(CONTEXT* Context)
127  {
128 @@ -336,18 +371,33 @@
129  
130  void scroll_sidebar(int op, int menu)
131  {
132 +        BUFFY *tmp;
133          if(!SidebarWidth) return;
134          if(!CurBuffy) return;
135  
136         switch (op) {
137                 case OP_SIDEBAR_NEXT:
138 +                if (!option (OPTSIDEBARNEWMAILONLY)) {
139                         if ( CurBuffy->next == NULL ) return;
140                         CurBuffy = CurBuffy->next;
141                         break;
142 +                }
143 +                case OP_SIDEBAR_NEXT_NEW:
144 +                        if ( (tmp = exist_next_new()) == NULL)
145 +                                return;
146 +                        else CurBuffy = tmp;
147 +                        break;
148                 case OP_SIDEBAR_PREV:
149 +                 if (!option (OPTSIDEBARNEWMAILONLY)) {
150                         if ( CurBuffy->prev == NULL ) return;
151                         CurBuffy = CurBuffy->prev;
152                         break;
153 +                }
154 +                case OP_SIDEBAR_PREV_NEW:
155 +                       if ( (tmp = exist_prev_new()) == NULL)
156 +                               return;
157 +                       else CurBuffy = tmp;
158 +                       break;
159                 case OP_SIDEBAR_SCROLL_UP:
160                         CurBuffy = TopBuffy;
161                         if ( CurBuffy != Incoming ) {