View | Details | Raw Unified | Return to bug 199727
Collapse All | Expand All

(-)./Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	mutt
4
PORTNAME=	mutt
5
PORTVERSION=	1.5.23
5
PORTVERSION=	1.5.23
6
PORTREVISION?=	8
6
PORTREVISION?=	9
7
CATEGORIES+=	mail ipv6
7
CATEGORIES+=	mail ipv6
8
MASTER_SITES=	ftp://ftp.mutt.org/mutt/ \
8
MASTER_SITES=	ftp://ftp.mutt.org/mutt/ \
9
		ftp://ftp.mutt.org/mutt/devel/ \
9
		ftp://ftp.mutt.org/mutt/devel/ \
(-)./files/extra-patch-sidebar (-1397 / +2332 lines)
Lines 1-1416 Link Here
1
Based on Gentoo's updated version of the Mutt Sidebar patch,
1
Taken from http://lunar-linux.org/~tchan/mutt/patch-1.5.23.sidebar.20140412.txt
2
rebased to apply to pristine Mutt sources.
3
2
4
http://prefix.gentooexperimental.org:8000/mutt-patches/file/8117acc3edc0/sidebar.patch
5
6
diff -uNp -r mutt-1.5.22.orig/OPS mutt-1.5.22/OPS
7
--- mutt-1.5.22.orig/OPS	Tue Feb 23 06:57:28 2010
8
+++ mutt-1.5.22/OPS	Fri Oct 18 10:18:45 2013
9
@@ -179,3 +179,8 @@ OP_WHAT_KEY "display the keycode for a key press"
10
 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
11
 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
12
 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
13
+OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
14
+OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
15
+OP_SIDEBAR_NEXT "go down to next mailbox"
16
+OP_SIDEBAR_PREV "go to previous mailbox"
17
+OP_SIDEBAR_OPEN "open hilighted mailbox"
18
diff -uNp -r mutt-1.5.22.orig/PATCHES mutt-1.5.22/PATCHES
19
--- mutt-1.5.22.orig/PATCHES	Sun Feb 21 05:51:26 2010
20
+++ mutt-1.5.22/PATCHES	Fri Oct 18 10:19:14 2013
21
@@ -0,0 +1 @@
22
+patch-1.5.22.sidebar.gentoo-openbsd
23
diff -uNp -r mutt-1.5.22.orig/buffy.c mutt-1.5.22/buffy.c
3
diff -uNp -r mutt-1.5.22.orig/buffy.c mutt-1.5.22/buffy.c
24
--- mutt-1.5.22.orig/buffy.c	Mon Apr 22 07:14:53 2013
4
*** mutt-1.5.23-orig/buffy.c	2014-03-12 11:03:44.000000000 -0500
25
+++ mutt-1.5.22/buffy.c	Fri Oct 18 10:18:45 2013
5
--- mutt-1.5.23/buffy.c	2014-04-12 15:33:54.000000000 -0500
26
@@ -161,6 +161,49 @@ void mutt_buffy_cleanup (const char *buf, struct stat 
6
***************
27
   }
7
*** 161,166 ****
28
 }
8
--- 161,209 ----
29
 
9
    }
30
+static int buffy_compare_name(const void *a, const void *b) {
10
  }
31
+  const BUFFY *b1 = * (BUFFY * const *) a;
11
  
32
+  const BUFFY *b2 = * (BUFFY * const *) b;
12
+ static int buffy_compare_name(const void *a, const void *b) {
33
+
13
+   const BUFFY *b1 = * (BUFFY * const *) a;
34
+  return mutt_strcoll(b1->path, b2->path);
14
+   const BUFFY *b2 = * (BUFFY * const *) b;
35
+}
15
+ 
36
+
16
+   return mutt_strcoll(b1->path, b2->path);
37
+static BUFFY *buffy_sort(BUFFY *b)
17
+ }
38
+{
18
+ 
39
+  BUFFY *tmp = b;
19
+ static BUFFY *buffy_sort(BUFFY *b)
40
+  int buffycount = 0;
20
+ {
41
+  BUFFY **ary;
21
+   BUFFY *tmp = b;
42
+  int i;
22
+   int buffycount = 0;
43
+
23
+   BUFFY **ary;
44
+  if (!option(OPTSIDEBARSORT))
24
+   int i;
45
+    return b;
25
+ 
46
+
26
+   if (!option(OPTSIDEBARSORT))
47
+  for (; tmp != NULL; tmp = tmp->next)
27
+     return b;
48
+    buffycount++;
28
+ 
49
+
29
+   for (; tmp != NULL; tmp = tmp->next)
50
+  ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
30
+     buffycount++;
51
+
31
+ 
52
+  tmp = b;
32
+   ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
53
+  for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
33
+ 
54
+    ary[i] = tmp;
34
+   tmp = b;
55
+  }
35
+   for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
56
+
36
+     ary[i] = tmp;
57
+  qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
37
+   }
58
+
38
+ 
59
+  for (i = 0; i < buffycount - 1; i++) {
39
+   qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
60
+    ary[i]->next = ary[i+1];
40
+ 
61
+  }
41
+   for (i = 0; i < buffycount - 1; i++) {
62
+  ary[buffycount - 1]->next = NULL;
42
+     ary[i]->next = ary[i+1];
63
+  for (i = 1; i < buffycount; i++) {
43
+   }
64
+    ary[i]->prev = ary[i-1];
44
+   ary[buffycount - 1]->next = NULL;
65
+  }
45
+   for (i = 1; i < buffycount; i++) {
66
+  ary[0]->prev = NULL;
46
+     ary[i]->prev = ary[i-1];
67
+
47
+   }
68
+  tmp = ary[0];
48
+   ary[0]->prev = NULL;
69
+  free(ary);
49
+ 
70
+  return tmp;
50
+   tmp = ary[0];
71
+}
51
+   free(ary);
72
+
52
+   return tmp;
73
 BUFFY *mutt_find_mailbox (const char *path)
53
+ }
74
 {
54
+ 
75
   BUFFY *tmp = NULL;
55
  BUFFY *mutt_find_mailbox (const char *path)
76
@@ -282,6 +325,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, uns
56
  {
77
     else
57
    BUFFY *tmp = NULL;
78
       (*tmp)->size = 0;
58
***************
79
   }
59
*** 196,204 ****
80
+  Incoming = buffy_sort(Incoming);
60
--- 239,251 ----
81
   return 0;
61
  static BUFFY *buffy_new (const char *path)
82
 }
62
  {
83
 
63
    BUFFY* buffy;
84
@@ -340,6 +384,68 @@ static int buffy_maildir_hasnew (BUFFY* mailbox)
64
+   char rp[PATH_MAX];
85
   return rc;
65
+   char *r;
86
 }
66
  
87
 
67
    buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
88
+/* update message counts for the sidebar */
68
    strfcpy (buffy->path, path, sizeof (buffy->path));
89
+void buffy_maildir_update (BUFFY* mailbox)
69
+   r = realpath(path, rp);
90
+{
70
+   strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
91
+  char path[_POSIX_PATH_MAX];
71
    buffy->next = NULL;
92
+  DIR *dirp;
72
    buffy->magic = 0;
93
+  struct dirent *de;
73
  
94
+  char *p;
74
***************
95
+
75
*** 243,250 ****
96
+  mailbox->msgcount = 0;
76
      p = realpath (buf, f1);
97
+  mailbox->msg_unread = 0;
77
      for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
98
+  mailbox->msg_flagged = 0;
99
+
100
+  snprintf (path, sizeof (path), "%s/new", mailbox->path);
101
+        
102
+  if ((dirp = opendir (path)) == NULL)
103
+  {   
104
+    mailbox->magic = 0;
105
+    return;
106
+  } 
107
+      
108
+  while ((de = readdir (dirp)) != NULL)
109
+  {
110
+    if (*de->d_name == '.')
111
+      continue;
112
+
113
+    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
114
+      mailbox->new = 1;
115
+      mailbox->msgcount++;
116
+      mailbox->msg_unread++;
117
+    }
118
+  }
119
+
120
+  closedir (dirp);
121
+  snprintf (path, sizeof (path), "%s/cur", mailbox->path);
122
+        
123
+  if ((dirp = opendir (path)) == NULL)
124
+  {   
125
+    mailbox->magic = 0;
126
+    return;
127
+  } 
128
+      
129
+  while ((de = readdir (dirp)) != NULL)
130
+  {
131
+    if (*de->d_name == '.')
132
+      continue;
133
+
134
+    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
135
+      mailbox->msgcount++;
136
+      if ((p = strstr (de->d_name, ":2,"))) {
137
+        if (!strchr (p + 3, 'T')) {
138
+          if (!strchr (p + 3, 'S'))
139
+            mailbox->msg_unread++;
140
+          if (strchr(p + 3, 'F'))
141
+            mailbox->msg_flagged++;
142
+        }
143
+      }
144
+    }
145
+  }
146
+
147
+  closedir (dirp);
148
+}
149
+
150
 /* returns 1 if mailbox has new mail */ 
151
 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
152
 {
153
@@ -371,6 +477,20 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct s
154
   return rc;
155
 }
156
 
157
+/* update message counts for the sidebar */
158
+void buffy_mbox_update (BUFFY* mailbox)
159
+{
160
+  CONTEXT *ctx = NULL;
161
+
162
+  ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
163
+  if(ctx)
164
+  {
165
+    mailbox->msgcount = ctx->msgcount;
166
+    mailbox->msg_unread = ctx->unread;
167
+    mx_close_mailbox(ctx, 0);
168
+  }
169
+}
170
+
171
 int mutt_buffy_check (int force)
172
 {
173
   BUFFY *tmp;
174
@@ -444,16 +564,19 @@ int mutt_buffy_check (int force)
175
       {
176
       case M_MBOX:
177
       case M_MMDF:
178
+	buffy_mbox_update (tmp);
179
 	if (buffy_mbox_hasnew (tmp, &sb) > 0)
180
 	  BuffyCount++;
181
 	break;
182
 
183
       case M_MAILDIR:
184
+	buffy_maildir_update (tmp);
185
 	if (buffy_maildir_hasnew (tmp) > 0)
186
 	  BuffyCount++;
187
 	break;
188
 
189
       case M_MH:
190
+	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
191
 	mh_buffy(tmp);
192
 	if (tmp->new)
193
 	  BuffyCount++;
194
diff -uNp -r mutt-1.5.22.orig/buffy.h mutt-1.5.22/buffy.h
195
--- mutt-1.5.22.orig/buffy.h	Mon Apr 22 07:14:53 2013
196
+++ mutt-1.5.22/buffy.h	Fri Oct 18 10:18:45 2013
197
@@ -25,7 +25,11 @@ typedef struct buffy_t
198
   char path[_POSIX_PATH_MAX];
199
   off_t size;
200
   struct buffy_t *next;
201
+  struct buffy_t *prev;
202
   short new;			/* mailbox has new mail */
203
+  int msgcount;			/* total number of messages */
204
+  int msg_unread;		/* number of unread messages */
205
+  int msg_flagged;		/* number of flagged messages */
206
   short notified;		/* user has been notified */
207
   short magic;			/* mailbox type */
208
   short newly_created;		/* mbox or mmdf just popped into existence */
209
diff -uNp -r mutt-1.5.22.orig/color.c mutt-1.5.22/color.c
210
--- mutt-1.5.22.orig/color.c	Tue Jan 15 07:37:15 2013
211
+++ mutt-1.5.22/color.c	Fri Oct 18 10:19:53 2013
212
@@ -93,6 +93,8 @@ static const struct mapping_t Fields[] =
213
   { "bold",		MT_COLOR_BOLD },
214
   { "underline",	MT_COLOR_UNDERLINE },
215
   { "index",		MT_COLOR_INDEX },
216
+  { "sidebar_new",	MT_COLOR_NEW },
217
+  { "sidebar_flagged",	MT_COLOR_FLAGGED },
218
   { NULL,		0 }
219
 };
220
 
221
diff -uNp -r mutt-1.5.22.orig/compose.c mutt-1.5.22/compose.c
222
--- mutt-1.5.22.orig/compose.c	Fri Oct 18 05:48:24 2013
223
+++ mutt-1.5.22/compose.c	Fri Oct 18 10:22:12 2013
224
@@ -72,7 +72,7 @@ enum
225
 
226
 #define HDR_XOFFSET 10
227
 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
228
-#define W (COLS - HDR_XOFFSET)
229
+#define W (COLS - HDR_XOFFSET - SidebarWidth)
230
 
231
 static const char * const Prompts[] =
232
 {
233
@@ -110,7 +110,7 @@ static void snd_entry (char *b, size_t blen, MUTTMENU 
234
 
235
 static void redraw_crypt_lines (HEADER *msg)
236
 {
237
-  mvaddstr (HDR_CRYPT, 0, "Security: ");
238
+  mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
239
 
240
   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
241
   {
242
@@ -142,7 +142,7 @@ static void redraw_crypt_lines (HEADER *msg)
243
   }
244
 
245
   clrtoeol ();
246
-  move (HDR_CRYPTINFO, 0);
247
+  move (HDR_CRYPTINFO, SidebarWidth);
248
   clrtoeol ();
249
 
250
   if ((WithCrypto & APPLICATION_PGP)
251
@@ -159,7 +159,7 @@ static void redraw_crypt_lines (HEADER *msg)
252
       && (msg->security & ENCRYPT)
253
       && SmimeCryptAlg
254
       && *SmimeCryptAlg) {
255
-      mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
256
+      mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
257
 		NONULL(SmimeCryptAlg));
258
   }
259
 }
260
@@ -172,7 +172,7 @@ static void redraw_mix_line (LIST *chain)
261
   int c;
262
   char *t;
263
 
264
-  mvaddstr (HDR_MIX, 0,     "     Mix: ");
265
+  mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
266
 
267
   if (!chain)
268
   {
269
@@ -187,7 +187,7 @@ static void redraw_mix_line (LIST *chain)
270
     if (t && t[0] == '0' && t[1] == '\0')
271
       t = "<random>";
272
     
273
-    if (c + mutt_strlen (t) + 2 >= COLS)
274
+    if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
275
       break;
276
 
277
     addstr (NONULL(t));
278
@@ -239,7 +239,7 @@ static void draw_envelope_addr (int line, ADDRESS *add
279
 
280
   buf[0] = 0;
281
   rfc822_write_address (buf, sizeof (buf), addr, 1);
282
-  mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
283
+  mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
284
   mutt_paddstr (W, buf);
285
 }
286
 
287
@@ -249,10 +249,10 @@ static void draw_envelope (HEADER *msg, char *fcc)
288
   draw_envelope_addr (HDR_TO, msg->env->to);
289
   draw_envelope_addr (HDR_CC, msg->env->cc);
290
   draw_envelope_addr (HDR_BCC, msg->env->bcc);
291
-  mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
292
+  mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
293
   mutt_paddstr (W, NONULL (msg->env->subject));
294
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
295
-  mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
296
+  mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
297
   mutt_paddstr (W, fcc);
298
 
299
   if (WithCrypto)
300
@@ -263,7 +263,7 @@ static void draw_envelope (HEADER *msg, char *fcc)
301
 #endif
302
 
303
   SETCOLOR (MT_COLOR_STATUS);
304
-  mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
305
+  mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
306
   clrtoeol ();
307
 
308
   NORMAL_COLOR;
309
@@ -299,7 +299,7 @@ static int edit_address_list (int line, ADDRESS **addr
310
   /* redraw the expanded list so the user can see the result */
311
   buf[0] = 0;
312
   rfc822_write_address (buf, sizeof (buf), *addr, 1);
313
-  move (line, HDR_XOFFSET);
314
+  move (line, HDR_XOFFSET+SidebarWidth);
315
   mutt_paddstr (W, buf);
316
   
317
   return 0;
318
@@ -544,7 +544,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for
319
 	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
320
 	{
321
 	  mutt_str_replace (&msg->env->subject, buf);
322
-	  move (HDR_SUBJECT, HDR_XOFFSET);
323
+	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
324
 	  if (msg->env->subject)
325
 	    mutt_paddstr (W, msg->env->subject);
326
 	  else
327
@@ -562,7 +562,7 @@ int mutt_compose_menu (HEADER *msg,   /* structure for
328
 	{
329
 	  strfcpy (fcc, buf, fcclen);
330
 	  mutt_pretty_mailbox (fcc, fcclen);
331
-	  move (HDR_FCC, HDR_XOFFSET);
332
+	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
333
 	  mutt_paddstr (W, fcc);
334
 	  fccSet = 1;
335
 	}
336
diff -uNp -r mutt-1.5.22.orig/curs_main.c mutt-1.5.22/curs_main.c
337
--- mutt-1.5.22.orig/curs_main.c	Tue Jan 15 07:37:15 2013
338
+++ mutt-1.5.22/curs_main.c	Fri Oct 18 10:18:45 2013
339
@@ -26,7 +26,9 @@
340
 #include "mailbox.h"
341
 #include "mapping.h"
342
 #include "sort.h"
343
+#include "buffy.h"
344
 #include "mx.h"
345
+#include "sidebar.h"
346
 
347
 #ifdef USE_POP
348
 #include "pop.h"
349
@@ -519,8 +521,12 @@ int mutt_index_menu (void)
350
        menu->redraw |= REDRAW_STATUS;
351
      if (do_buffy_notify)
352
      {
78
      {
353
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
79
!       q = realpath ((*tmp)->path, f2);
354
- 	beep ();
80
!       if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
355
+       if (mutt_buffy_notify ())
81
        {
356
+       {
82
  	dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
357
+         menu->redraw |= REDRAW_FULL;
83
  	break;
358
+         if (option (OPTBEEPNEW))
84
--- 290,297 ----
359
+           beep ();
85
      p = realpath (buf, f1);
86
      for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
87
      {
88
!       q = (*tmp)->realpath;
89
!       if (mutt_strcmp (p ? p : buf, q) == 0)
90
        {
91
  	dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
92
  	break;
93
***************
94
*** 282,287 ****
95
--- 329,335 ----
96
      else
97
        (*tmp)->size = 0;
98
    }
99
+   Incoming = buffy_sort(Incoming);
100
    return 0;
101
  }
102
  
103
***************
104
*** 306,311 ****
105
--- 354,364 ----
106
        return 0;
107
    }
108
  
109
+   if (option(OPTSIDEBAR) && mailbox->msg_unread > 0) {
110
+       mailbox->new = 1;
111
+       return 1;
112
+   }
113
+ 
114
    if ((dirp = opendir (path)) == NULL)
115
    {
116
      mailbox->magic = 0;
117
***************
118
*** 340,345 ****
119
--- 393,464 ----
120
    return rc;
121
  }
122
  
123
+ /* update message counts for the sidebar */
124
+ void buffy_maildir_update (BUFFY* mailbox)
125
+ {
126
+   char path[_POSIX_PATH_MAX];
127
+   DIR *dirp;
128
+   struct dirent *de;
129
+   char *p;
130
+ 
131
+   if(!option(OPTSIDEBAR))
132
+       return;
133
+ 
134
+   mailbox->msgcount = 0;
135
+   mailbox->msg_unread = 0;
136
+   mailbox->msg_flagged = 0;
137
+ 
138
+   snprintf (path, sizeof (path), "%s/new", mailbox->path);
139
+         
140
+   if ((dirp = opendir (path)) == NULL)
141
+   {   
142
+     mailbox->magic = 0;
143
+     return;
144
+   } 
145
+       
146
+   while ((de = readdir (dirp)) != NULL)
147
+   {
148
+     if (*de->d_name == '.')
149
+       continue;
150
+ 
151
+     if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
152
+       mailbox->new = 1;
153
+       mailbox->msgcount++;
154
+       mailbox->msg_unread++;
155
+     }
156
+   }
157
+ 
158
+   closedir (dirp);
159
+   snprintf (path, sizeof (path), "%s/cur", mailbox->path);
160
+         
161
+   if ((dirp = opendir (path)) == NULL)
162
+   {   
163
+     mailbox->magic = 0;
164
+     return;
165
+   } 
166
+       
167
+   while ((de = readdir (dirp)) != NULL)
168
+   {
169
+     if (*de->d_name == '.')
170
+       continue;
171
+ 
172
+     if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
173
+       mailbox->msgcount++;
174
+       if ((p = strstr (de->d_name, ":2,"))) {
175
+         if (!strchr (p + 3, 'T')) {
176
+           if (!strchr (p + 3, 'S'))
177
+             mailbox->msg_unread++;
178
+           if (strchr(p + 3, 'F'))
179
+             mailbox->msg_flagged++;
180
+         }
360
+       }
181
+       }
182
+     }
183
+   }
184
+ 
185
+   mailbox->sb_last_checked = time(NULL);
186
+   closedir (dirp);
187
+ }
188
+ 
189
  /* returns 1 if mailbox has new mail */ 
190
  static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
191
  {
192
***************
193
*** 351,357 ****
194
    else
195
      statcheck = sb->st_mtime > sb->st_atime
196
        || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
197
!   if (statcheck)
198
    {
199
      if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
200
      {
201
--- 470,476 ----
202
    else
203
      statcheck = sb->st_mtime > sb->st_atime
204
        || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
205
!   if ((!option(OPTSIDEBAR) && statcheck) || (option(OPTSIDEBAR) && mailbox->msg_unread > 0))
206
    {
207
      if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
208
      {
209
***************
210
*** 371,376 ****
211
--- 490,516 ----
212
    return rc;
213
  }
214
  
215
+ /* update message counts for the sidebar */
216
+ void buffy_mbox_update (BUFFY* mailbox, struct stat *sb)
217
+ {
218
+   CONTEXT *ctx = NULL;
219
+ 
220
+   if(!option(OPTSIDEBAR))
221
+       return;
222
+   if(mailbox->sb_last_checked > sb->st_mtime && mailbox->msgcount != 0)
223
+       return; /* no check necessary */
224
+ 
225
+   ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
226
+   if(ctx)
227
+   {
228
+     mailbox->msgcount = ctx->msgcount;
229
+     mailbox->msg_unread = ctx->unread;
230
+     mailbox->msg_flagged = ctx->flagged;
231
+     mailbox->sb_last_checked = time(NULL);
232
+     mx_close_mailbox(ctx, 0);
233
+   }
234
+ }
235
+ 
236
  int mutt_buffy_check (int force)
237
  {
238
    BUFFY *tmp;
239
***************
240
*** 444,460 ****
241
        {
242
        case M_MBOX:
243
        case M_MMDF:
244
  	if (buffy_mbox_hasnew (tmp, &sb) > 0)
245
  	  BuffyCount++;
246
  	break;
247
  
248
        case M_MAILDIR:
249
  	if (buffy_maildir_hasnew (tmp) > 0)
250
  	  BuffyCount++;
251
  	break;
252
  
253
        case M_MH:
254
! 	mh_buffy(tmp);
255
  	if (tmp->new)
256
  	  BuffyCount++;
257
  	break;
258
--- 584,603 ----
259
        {
260
        case M_MBOX:
261
        case M_MMDF:
262
+ 	buffy_mbox_update (tmp, &sb);
263
  	if (buffy_mbox_hasnew (tmp, &sb) > 0)
264
  	  BuffyCount++;
265
  	break;
266
  
267
        case M_MAILDIR:
268
+ 	buffy_maildir_update (tmp);
269
  	if (buffy_maildir_hasnew (tmp) > 0)
270
  	  BuffyCount++;
271
  	break;
272
  
273
        case M_MH:
274
! 	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
275
!         mh_buffy(tmp);
276
  	if (tmp->new)
277
  	  BuffyCount++;
278
  	break;
279
*** mutt-1.5.23-orig/buffy.h	2014-03-12 11:03:44.000000000 -0500
280
--- mutt-1.5.23/buffy.h	2014-04-11 10:14:01.000000000 -0500
281
***************
282
*** 23,35 ****
283
--- 23,41 ----
284
  typedef struct buffy_t
285
  {
286
    char path[_POSIX_PATH_MAX];
287
+   char realpath[_POSIX_PATH_MAX];
288
    off_t size;
289
    struct buffy_t *next;
290
+   struct buffy_t *prev;
291
    short new;			/* mailbox has new mail */
292
+   int msgcount;			/* total number of messages */
293
+   int msg_unread;		/* number of unread messages */
294
+   int msg_flagged;		/* number of flagged messages */
295
    short notified;		/* user has been notified */
296
    short magic;			/* mailbox type */
297
    short newly_created;		/* mbox or mmdf just popped into existence */
298
    time_t last_visited;		/* time of last exit from this mailbox */
299
+   time_t sb_last_checked;      /* time of last buffy check from sidebar */
300
  }
301
  BUFFY;
302
  
303
*** mutt-1.5.23-orig/color.c	2014-03-12 11:03:45.000000000 -0500
304
--- mutt-1.5.23/color.c	2014-04-11 10:14:01.000000000 -0500
305
***************
306
*** 93,98 ****
307
--- 93,100 ----
308
    { "bold",		MT_COLOR_BOLD },
309
    { "underline",	MT_COLOR_UNDERLINE },
310
    { "index",		MT_COLOR_INDEX },
311
+   { "sidebar_new",	MT_COLOR_NEW },
312
+   { "sidebar_flagged",	MT_COLOR_FLAGGED },
313
    { NULL,		0 }
314
  };
315
  
316
*** mutt-1.5.23-orig/compose.c	2014-03-12 11:03:45.000000000 -0500
317
--- mutt-1.5.23/compose.c	2014-04-12 12:15:56.000000000 -0500
318
***************
319
*** 72,78 ****
320
  
321
  #define HDR_XOFFSET 10
322
  #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
323
! #define W (COLS - HDR_XOFFSET)
324
  
325
  static const char * const Prompts[] =
326
  {
327
--- 72,78 ----
328
  
329
  #define HDR_XOFFSET 10
330
  #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */
331
! #define W (COLS - HDR_XOFFSET - SidebarWidth)
332
  
333
  static const char * const Prompts[] =
334
  {
335
***************
336
*** 110,116 ****
337
  
338
  static void redraw_crypt_lines (HEADER *msg)
339
  {
340
!   mvaddstr (HDR_CRYPT, 0, "Security: ");
341
  
342
    if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
343
    {
344
--- 110,116 ----
345
  
346
  static void redraw_crypt_lines (HEADER *msg)
347
  {
348
!   mvaddstr (HDR_CRYPT, SidebarWidth, "Security: ");
349
  
350
    if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
351
    {
352
***************
353
*** 142,148 ****
354
    }
355
  
356
    clrtoeol ();
357
!   move (HDR_CRYPTINFO, 0);
358
    clrtoeol ();
359
  
360
    if ((WithCrypto & APPLICATION_PGP)
361
--- 142,148 ----
362
    }
363
  
364
    clrtoeol ();
365
!   move (HDR_CRYPTINFO, SidebarWidth);
366
    clrtoeol ();
367
  
368
    if ((WithCrypto & APPLICATION_PGP)
369
***************
370
*** 159,165 ****
371
        && (msg->security & ENCRYPT)
372
        && SmimeCryptAlg
373
        && *SmimeCryptAlg) {
374
!       mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
375
  		NONULL(SmimeCryptAlg));
376
    }
377
  }
378
--- 159,165 ----
379
        && (msg->security & ENCRYPT)
380
        && SmimeCryptAlg
381
        && *SmimeCryptAlg) {
382
!       mvprintw (HDR_CRYPTINFO, SidebarWidth + 40, "%s%s", _("Encrypt with: "),
383
  		NONULL(SmimeCryptAlg));
384
    }
385
  }
386
***************
387
*** 172,178 ****
388
    int c;
389
    char *t;
390
  
391
!   mvaddstr (HDR_MIX, 0,     "     Mix: ");
392
  
393
    if (!chain)
394
    {
395
--- 172,178 ----
396
    int c;
397
    char *t;
398
  
399
!   mvaddstr (HDR_MIX, SidebarWidth,     "     Mix: ");
400
  
401
    if (!chain)
402
    {
403
***************
404
*** 187,193 ****
405
      if (t && t[0] == '0' && t[1] == '\0')
406
        t = "<random>";
407
      
408
!     if (c + mutt_strlen (t) + 2 >= COLS)
409
        break;
410
  
411
      addstr (NONULL(t));
412
--- 187,193 ----
413
      if (t && t[0] == '0' && t[1] == '\0')
414
        t = "<random>";
415
      
416
!     if (c + mutt_strlen (t) + 2 >= COLS - SidebarWidth)
417
        break;
418
  
419
      addstr (NONULL(t));
420
***************
421
*** 239,245 ****
422
  
423
    buf[0] = 0;
424
    rfc822_write_address (buf, sizeof (buf), addr, 1);
425
!   mvprintw (line, 0, TITLE_FMT, Prompts[line - 1]);
426
    mutt_paddstr (W, buf);
427
  }
428
  
429
--- 239,245 ----
430
  
431
    buf[0] = 0;
432
    rfc822_write_address (buf, sizeof (buf), addr, 1);
433
!   mvprintw (line, SidebarWidth, TITLE_FMT, Prompts[line - 1]);
434
    mutt_paddstr (W, buf);
435
  }
436
  
437
***************
438
*** 249,258 ****
439
    draw_envelope_addr (HDR_TO, msg->env->to);
440
    draw_envelope_addr (HDR_CC, msg->env->cc);
441
    draw_envelope_addr (HDR_BCC, msg->env->bcc);
442
!   mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
443
    mutt_paddstr (W, NONULL (msg->env->subject));
444
    draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
445
!   mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
446
    mutt_paddstr (W, fcc);
447
  
448
    if (WithCrypto)
449
--- 249,258 ----
450
    draw_envelope_addr (HDR_TO, msg->env->to);
451
    draw_envelope_addr (HDR_CC, msg->env->cc);
452
    draw_envelope_addr (HDR_BCC, msg->env->bcc);
453
!   mvprintw (HDR_SUBJECT, SidebarWidth, TITLE_FMT, Prompts[HDR_SUBJECT - 1]);
454
    mutt_paddstr (W, NONULL (msg->env->subject));
455
    draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
456
!   mvprintw (HDR_FCC, SidebarWidth, TITLE_FMT, Prompts[HDR_FCC - 1]);
457
    mutt_paddstr (W, fcc);
458
  
459
    if (WithCrypto)
460
***************
461
*** 263,269 ****
462
  #endif
463
  
464
    SETCOLOR (MT_COLOR_STATUS);
465
!   mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments"));
466
    clrtoeol ();
467
  
468
    NORMAL_COLOR;
469
--- 263,269 ----
470
  #endif
471
  
472
    SETCOLOR (MT_COLOR_STATUS);
473
!   mvaddstr (HDR_ATTACH - 1, SidebarWidth, _("-- Attachments"));
474
    clrtoeol ();
475
  
476
    NORMAL_COLOR;
477
***************
478
*** 299,305 ****
479
    /* redraw the expanded list so the user can see the result */
480
    buf[0] = 0;
481
    rfc822_write_address (buf, sizeof (buf), *addr, 1);
482
!   move (line, HDR_XOFFSET);
483
    mutt_paddstr (W, buf);
484
    
485
    return 0;
486
--- 299,305 ----
487
    /* redraw the expanded list so the user can see the result */
488
    buf[0] = 0;
489
    rfc822_write_address (buf, sizeof (buf), *addr, 1);
490
!   move (line, HDR_XOFFSET+SidebarWidth);
491
    mutt_paddstr (W, buf);
492
    
493
    return 0;
494
***************
495
*** 544,550 ****
496
  	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
497
  	{
498
  	  mutt_str_replace (&msg->env->subject, buf);
499
! 	  move (HDR_SUBJECT, HDR_XOFFSET);
500
  	  if (msg->env->subject)
501
  	    mutt_paddstr (W, msg->env->subject);
502
  	  else
503
--- 544,550 ----
504
  	if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0)
505
  	{
506
  	  mutt_str_replace (&msg->env->subject, buf);
507
! 	  move (HDR_SUBJECT, HDR_XOFFSET + SidebarWidth);
508
  	  if (msg->env->subject)
509
  	    mutt_paddstr (W, msg->env->subject);
510
  	  else
511
***************
512
*** 562,568 ****
513
  	{
514
  	  strfcpy (fcc, buf, fcclen);
515
  	  mutt_pretty_mailbox (fcc, fcclen);
516
! 	  move (HDR_FCC, HDR_XOFFSET);
517
  	  mutt_paddstr (W, fcc);
518
  	  fccSet = 1;
519
  	}
520
--- 562,568 ----
521
  	{
522
  	  strfcpy (fcc, buf, fcclen);
523
  	  mutt_pretty_mailbox (fcc, fcclen);
524
! 	  move (HDR_FCC, HDR_XOFFSET + SidebarWidth);
525
  	  mutt_paddstr (W, fcc);
526
  	  fccSet = 1;
527
  	}
528
*** mutt-1.5.23-orig/configure.ac	2014-03-12 11:26:40.000000000 -0500
529
--- mutt-1.5.23/configure.ac	2014-04-11 10:14:01.000000000 -0500
530
***************
531
*** 1276,1281 ****
532
--- 1276,1283 ----
533
    AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
534
  fi
535
  
536
+ AC_CHECK_FUNCS(fmemopen open_memstream)
537
+ 
538
  dnl Documentation tools
539
  have_openjade="no"
540
  AC_PATH_PROG([OSPCAT], [ospcat], [none])
541
*** mutt-1.5.23-orig/curs_main.c	2014-03-12 11:06:17.000000000 -0500
542
--- mutt-1.5.23/curs_main.c	2014-04-12 21:45:21.000000000 -0500
543
***************
544
*** 26,32 ****
545
--- 26,34 ----
546
  #include "mailbox.h"
547
  #include "mapping.h"
548
  #include "sort.h"
549
+ #include "buffy.h"
550
  #include "mx.h"
551
+ #include "sidebar.h"
552
  
553
  #ifdef USE_POP
554
  #include "pop.h"
555
***************
556
*** 519,538 ****
557
         menu->redraw |= REDRAW_STATUS;
558
       if (do_buffy_notify)
559
       {
560
!        if (mutt_buffy_notify () && option (OPTBEEPNEW))
561
!  	beep ();
562
       }
563
       else
564
         do_buffy_notify = 1;
361
      }
565
      }
362
      else
566
  
363
        do_buffy_notify = 1;
567
      if (op != -1)
364
@@ -532,6 +538,7 @@ int mutt_index_menu (void)
568
        mutt_curs_set (0);
365
     if (menu->redraw & REDRAW_FULL)
569
  
366
     {
570
      if (menu->redraw & REDRAW_FULL)
367
       menu_redraw_full (menu);
571
      {
368
+      draw_sidebar(menu->menu);
572
        menu_redraw_full (menu);
369
       mutt_show_error ();
573
        mutt_show_error ();
370
     }
574
      }
371
 
575
  
372
@@ -554,9 +561,12 @@ int mutt_index_menu (void)
576
      if (menu->menu == MENU_MAIN)
373
 
577
--- 521,551 ----
374
       if (menu->redraw & REDRAW_STATUS)
578
         menu->redraw |= REDRAW_STATUS;
579
       if (do_buffy_notify)
375
       {
580
       {
376
+	DrawFullLine = 1;
581
!        if (mutt_buffy_notify ())
377
 	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
582
!        {
378
+	DrawFullLine = 0;
583
!          menu->redraw |= REDRAW_STATUS;
379
 	move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
584
!          if (option (OPTBEEPNEW))
380
 	SETCOLOR (MT_COLOR_STATUS);
585
!            beep ();
381
+	set_buffystats(Context);
586
!        }
382
 	mutt_paddstr (COLS, buf);
587
       }
383
 	NORMAL_COLOR;
384
 	menu->redraw &= ~REDRAW_STATUS;
385
@@ -569,7 +579,7 @@ int mutt_index_menu (void)
386
 	menu->oldcurrent = -1;
387
 
388
       if (option (OPTARROWCURSOR))
389
-	move (menu->current - menu->top + menu->offset, 2);
390
+	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
391
       else if (option (OPTBRAILLEFRIENDLY))
392
 	move (menu->current - menu->top + menu->offset, 0);
393
       else
588
       else
394
@@ -1070,6 +1080,7 @@ int mutt_index_menu (void)
589
         do_buffy_notify = 1;
395
 	  menu->redraw = REDRAW_FULL;
590
      }
396
 	break;
591
  
397
 
592
+     if(option(OPTSIDEBAR))
398
+      case OP_SIDEBAR_OPEN:
593
+         menu->redraw |= REDRAW_SIDEBAR;
399
       case OP_MAIN_CHANGE_FOLDER:
594
+ 
400
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
595
      if (op != -1)
401
 
596
        mutt_curs_set (0);
402
@@ -1101,7 +1112,11 @@ int mutt_index_menu (void)
597
  
403
 	{
598
      if (menu->redraw & REDRAW_FULL)
404
 	  mutt_buffy (buf, sizeof (buf));
599
      {
405
 
600
        menu_redraw_full (menu);
406
-	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
601
+       draw_sidebar(menu->menu);
407
+          if ( op == OP_SIDEBAR_OPEN ) {
602
        mutt_show_error ();
408
+              if(!CurBuffy)
603
+     } else if(menu->redraw & REDRAW_SIDEBAR) {
409
+                break;
604
+         draw_sidebar(menu->menu);
410
+            strncpy( buf, CurBuffy->path, sizeof(buf) );  
605
+         menu->redraw &= ~REDRAW_SIDEBAR;
411
+	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
606
      }
412
 	  {
607
  
413
 	    if (menu->menu == MENU_PAGER)
608
      if (menu->menu == MENU_MAIN)
414
 	    {
609
***************
415
@@ -1119,6 +1134,7 @@ int mutt_index_menu (void)
610
*** 554,562 ****
416
 	}
611
--- 567,578 ----
417
 
612
  
418
 	mutt_expand_path (buf, sizeof (buf));
613
        if (menu->redraw & REDRAW_STATUS)
419
+        set_curbuffy(buf);
614
        {
420
 	if (mx_get_magic (buf) <= 0)
615
+         DrawFullLine = 1;
421
 	{
616
  	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
422
 	  mutt_error (_("%s is not a mailbox."), buf);
617
+         DrawFullLine = 0;
423
@@ -2209,6 +2225,12 @@ int mutt_index_menu (void)
618
  	move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
424
 	mutt_what_key();
619
  	SETCOLOR (MT_COLOR_STATUS);
425
 	break;
620
+         set_buffystats(Context);
426
 
621
  	mutt_paddstr (COLS, buf);
427
+      case OP_SIDEBAR_SCROLL_UP:
622
  	NORMAL_COLOR;
428
+      case OP_SIDEBAR_SCROLL_DOWN:
623
  	menu->redraw &= ~REDRAW_STATUS;
429
+      case OP_SIDEBAR_NEXT:
624
***************
430
+      case OP_SIDEBAR_PREV:
625
*** 569,575 ****
431
+        scroll_sidebar(op, menu->menu);
626
  	menu->oldcurrent = -1;
432
+        break;
627
  
433
       default:
628
        if (option (OPTARROWCURSOR))
434
 	if (menu->menu == MENU_MAIN)
629
! 	move (menu->current - menu->top + menu->offset, 2);
435
 	  km_error_key (MENU_MAIN);
630
        else if (option (OPTBRAILLEFRIENDLY))
436
diff -uNp -r mutt-1.5.22.orig/flags.c mutt-1.5.22/flags.c
631
  	move (menu->current - menu->top + menu->offset, 0);
437
--- mutt-1.5.22.orig/flags.c	Sun Feb 21 22:10:41 2010
632
        else
438
+++ mutt-1.5.22/flags.c	Fri Oct 18 10:18:45 2013
633
--- 585,591 ----
439
@@ -22,8 +22,10 @@
634
  	menu->oldcurrent = -1;
440
 
635
  
441
 #include "mutt.h"
636
        if (option (OPTARROWCURSOR))
442
 #include "mutt_curses.h"
637
! 	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
443
+#include "mutt_menu.h"
638
        else if (option (OPTBRAILLEFRIENDLY))
444
 #include "sort.h"
639
  	move (menu->current - menu->top + menu->offset, 0);
445
 #include "mx.h"
640
        else
446
+#include "sidebar.h"
641
***************
447
 
642
*** 1011,1016 ****
448
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
643
--- 1027,1033 ----
449
 {
644
  	  break;
450
@@ -263,6 +265,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag
645
  
451
    */
646
  	CHECK_MSGCOUNT;
452
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
647
+         CHECK_VISIBLE;
453
     h->searched = 0;
648
  	CHECK_READONLY;
454
+	draw_sidebar(0);
649
  	{
455
 }
650
  	  int oldvcount = Context->vcount;
456
 
651
***************
457
 void mutt_tag_set_flag (int flag, int bf)
652
*** 1070,1075 ****
458
diff -uNp -r mutt-1.5.22.orig/functions.h mutt-1.5.22/functions.h
653
--- 1087,1093 ----
459
--- mutt-1.5.22.orig/functions.h	Sat Dec  3 19:10:04 2011
654
  	  menu->redraw = REDRAW_FULL;
460
+++ mutt-1.5.22/functions.h	Fri Oct 18 10:18:45 2013
655
  	break;
461
@@ -169,6 +169,11 @@ const struct binding_t OpMain[] = { /* map: index */
656
  
462
   { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
657
+       case OP_SIDEBAR_OPEN:
463
 
658
        case OP_MAIN_CHANGE_FOLDER:
464
 
659
        case OP_MAIN_NEXT_UNREAD_MAILBOX:
465
+ { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
660
  
466
+ { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
661
***************
467
+ { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
662
*** 1101,1107 ****
468
+ { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
663
  	{
469
+ { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
664
  	  mutt_buffy (buf, sizeof (buf));
470
   { NULL,			0,				NULL }
665
  
471
 };
666
! 	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
472
 
667
  	  {
473
@@ -272,6 +277,11 @@ const struct binding_t OpPager[] = { /* map: pager */
668
  	    if (menu->menu == MENU_PAGER)
474
 
669
  	    {
475
   { "what-key",		OP_WHAT_KEY,		NULL },
670
--- 1119,1129 ----
476
 
671
  	{
672
  	  mutt_buffy (buf, sizeof (buf));
673
  
674
!           if ( op == OP_SIDEBAR_OPEN ) {
675
!               if(!CurBuffy)
676
!                 break;
677
!             strncpy( buf, CurBuffy->path, sizeof(buf) );  
678
! 	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
679
  	  {
680
  	    if (menu->menu == MENU_PAGER)
681
  	    {
682
***************
683
*** 1119,1124 ****
684
--- 1141,1147 ----
685
  	}
686
  
687
  	mutt_expand_path (buf, sizeof (buf));
688
+         set_curbuffy(buf);
689
  	if (mx_get_magic (buf) <= 0)
690
  	{
691
  	  mutt_error (_("%s is not a mailbox."), buf);
692
***************
693
*** 2209,2214 ****
694
--- 2232,2243 ----
695
  	mutt_what_key();
696
  	break;
697
  
698
+       case OP_SIDEBAR_SCROLL_UP:
699
+       case OP_SIDEBAR_SCROLL_DOWN:
700
+       case OP_SIDEBAR_NEXT:
701
+       case OP_SIDEBAR_PREV:
702
+         scroll_sidebar(op, menu->menu);
703
+         break;
704
        default:
705
  	if (menu->menu == MENU_MAIN)
706
  	  km_error_key (MENU_MAIN);
707
*** mutt-1.5.23-orig/flags.c	2014-03-12 11:03:45.000000000 -0500
708
--- mutt-1.5.23/flags.c	2014-04-11 10:14:01.000000000 -0500
709
***************
710
*** 22,29 ****
711
--- 22,31 ----
712
  
713
  #include "mutt.h"
714
  #include "mutt_curses.h"
715
+ #include "mutt_menu.h"
716
  #include "sort.h"
717
  #include "mx.h"
718
+ #include "sidebar.h"
719
  
720
  void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
721
  {
722
***************
723
*** 263,268 ****
724
--- 265,271 ----
725
     */
726
    if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
727
      h->searched = 0;
728
+ 	draw_sidebar(0);
729
  }
730
  
731
  void mutt_tag_set_flag (int flag, int bf)
732
*** mutt-1.5.23-orig/functions.h	2014-03-12 11:03:45.000000000 -0500
733
--- mutt-1.5.23/functions.h	2014-04-11 10:14:01.000000000 -0500
734
***************
735
*** 169,174 ****
736
--- 169,179 ----
737
    { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
738
  
739
  
477
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
740
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
478
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
741
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
479
+  { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
742
+  { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
480
+  { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
743
+  { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
481
+  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
744
+  { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
482
   { NULL,		0,				NULL }
745
    { NULL,			0,				NULL }
483
 };
746
  };
484
 
747
  
485
diff -uNp -r mutt-1.5.22.orig/globals.h mutt-1.5.22/globals.h
748
***************
486
--- mutt-1.5.22.orig/globals.h	Sat Dec  3 19:10:04 2011
749
*** 272,277 ****
487
+++ mutt-1.5.22/globals.h	Fri Oct 18 10:18:45 2013
750
--- 277,287 ----
488
@@ -117,6 +117,7 @@ WHERE short SearchContext;
751
  
489
 WHERE char *SendCharset;
752
    { "what-key",		OP_WHAT_KEY,		NULL },
490
 WHERE char *Sendmail;
753
  
491
 WHERE char *Shell;
754
+   { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
492
+WHERE char *SidebarDelim;
755
+   { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
493
 WHERE char *Signature;
756
+   { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
494
 WHERE char *SimpleSearch;
757
+   { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
495
 #if USE_SMTP
758
+   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
496
@@ -208,6 +209,9 @@ WHERE short ScoreThresholdDelete;
759
    { NULL,		0,				NULL }
497
 WHERE short ScoreThresholdRead;
760
  };
498
 WHERE short ScoreThresholdFlag;
761
  
499
 
762
*** mutt-1.5.23-orig/globals.h	2014-03-12 11:06:17.000000000 -0500
500
+WHERE struct buffy_t *CurBuffy INITVAL(0);
763
--- mutt-1.5.23/globals.h	2014-04-11 10:14:01.000000000 -0500
501
+WHERE short DrawFullLine INITVAL(0);
764
***************
502
+WHERE short SidebarWidth;
765
*** 117,122 ****
503
 #ifdef USE_IMAP
766
--- 117,125 ----
504
 WHERE short ImapKeepalive;
767
  WHERE char *SendCharset;
505
 WHERE short ImapPipelineDepth;
768
  WHERE char *Sendmail;
506
diff -uNp -r mutt-1.5.22.orig/imap/command.c mutt-1.5.22/imap/command.c
769
  WHERE char *Shell;
507
--- mutt-1.5.22.orig/imap/command.c	Fri Oct 18 05:48:24 2013
770
+ WHERE char *SidebarDelim;
508
+++ mutt-1.5.22/imap/command.c	Fri Oct 18 10:18:45 2013
771
+ WHERE char *SidebarFormat;
509
@@ -1012,6 +1012,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* 
772
+ WHERE char *SidebarIndentStr;
510
 	     opened */
773
  WHERE char *Signature;
511
 	  status->uidnext = oldun;
774
  WHERE char *SimpleSearch;
512
 
775
  #if USE_SMTP
513
+        /* Added to make the sidebar show the correct numbers */
776
***************
514
+        if (status->messages)
777
*** 208,213 ****
515
+        {
778
--- 211,219 ----
516
+          inc->msgcount = status->messages;
779
  WHERE short ScoreThresholdRead;
517
+          inc->msg_unread = status->unseen;
780
  WHERE short ScoreThresholdFlag;
518
+        }
781
  
519
+
782
+ WHERE struct buffy_t *CurBuffy INITVAL(0);
520
         FREE (&value);
783
+ WHERE short DrawFullLine INITVAL(0);
521
         return;
784
+ WHERE short SidebarWidth;
522
       }
785
  #ifdef USE_IMAP
523
diff -uNp -r mutt-1.5.22.orig/imap/imap.c mutt-1.5.22/imap/imap.c
786
  WHERE short ImapKeepalive;
524
--- mutt-1.5.22.orig/imap/imap.c	Fri Oct 18 05:48:24 2013
787
  WHERE short ImapPipelineDepth;
525
+++ mutt-1.5.22/imap/imap.c	Fri Oct 18 10:18:45 2013
788
*** mutt-1.5.23-orig/handler.c	2014-03-12 11:03:45.000000000 -0500
526
@@ -1514,7 +1514,7 @@ int imap_buffy_check (int force)
789
--- mutt-1.5.23/handler.c	2014-04-11 10:14:01.000000000 -0500
527
 
790
***************
528
     imap_munge_mbox_name (munged, sizeof (munged), name);
791
*** 1599,1604 ****
529
     snprintf (command, sizeof (command),
792
--- 1599,1609 ----
530
-	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
793
    size_t tmplength = 0;
531
+	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
794
    int rc = 0;
532
 
795
  
533
     if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
796
+ #ifdef HAVE_FMEMOPEN
534
     {
797
+   char *temp;
535
diff -uNp -r mutt-1.5.22.orig/init.h mutt-1.5.22/init.h
798
+   size_t tempsize;
536
--- mutt-1.5.22.orig/init.h	Tue Jan 15 07:37:15 2013
799
+ #endif
537
+++ mutt-1.5.22/init.h	Fri Oct 18 10:18:45 2013
800
+ 
538
@@ -1966,6 +1966,27 @@ struct option_t MuttVars[] = {
801
    int oflags = s->flags;
539
   ** not used.
802
    
540
   ** (PGP only)
803
    /* first determine which handler to use to process this part */
804
***************
805
*** 1711,1716 ****
806
--- 1716,1729 ----
807
        {
808
  	/* decode to a tempfile, saving the original destination */
809
  	fp = s->fpout;
810
+ #ifdef HAVE_FMEMOPEN
811
+ 	if ((s->fpout = open_memstream(&temp, &tempsize)) == NULL)
812
+ 	{
813
+ 	  mutt_error _("Unable to open memory stream!");
814
+ 	  dprint (1, (debugfile, "Can't open memory stream.\n"));
815
+ 	  goto bail;
816
+ 	}
817
+ #else
818
  	mutt_mktemp (tempfile, sizeof (tempfile));
819
  	if ((s->fpout = safe_fopen (tempfile, "w")) == NULL)
820
  	{
821
***************
822
*** 1718,1723 ****
823
--- 1731,1737 ----
824
  	  dprint (1, (debugfile, "Can't open %s.\n", tempfile));
825
  	  goto bail;
826
  	}
827
+ #endif
828
  	/* decoding the attachment changes the size and offset, so save a copy
829
  	 * of the "real" values now, and restore them after processing
830
  	 */
831
***************
832
*** 1746,1753 ****
833
--- 1760,1778 ----
834
  	/* restore final destination and substitute the tempfile for input */
835
  	s->fpout = fp;
836
  	fp = s->fpin;
837
+ #ifdef HAVE_FMEMOPEN
838
+ 	if(tempsize)
839
+ 		s->fpin = fmemopen(temp, tempsize, "r");
840
+ 	else /* fmemopen cannot handle zero-length buffers */
841
+ 		s->fpin = safe_fopen ("/dev/null", "r");
842
+ 	if(s->fpin == NULL) {
843
+ 		mutt_perror("failed to re-open memstream!");
844
+ 		return (-1);
845
+ 	}
846
+ #else
847
  	s->fpin = fopen (tempfile, "r");
848
  	unlink (tempfile);
849
+ #endif
850
  
851
  	/* restore the prefix */
852
  	s->prefix = savePrefix;
853
***************
854
*** 1773,1778 ****
855
--- 1798,1807 ----
856
  
857
  	/* restore the original source stream */
858
  	safe_fclose (&s->fpin);
859
+ #ifdef HAVE_FMEMOPEN
860
+ 	if(tempsize)
861
+ 	    FREE(&temp);
862
+ #endif
863
  	s->fpin = fp;
864
        }
865
      }
866
*** mutt-1.5.23-orig/init.h	2014-03-12 11:06:17.000000000 -0500
867
--- mutt-1.5.23/init.h	2014-04-11 10:14:01.000000000 -0500
868
***************
869
*** 1966,1971 ****
870
--- 1966,2019 ----
871
    ** not used.
872
    ** (PGP only)
873
    */
874
+   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, UL "|"},
875
+   /*
876
+   ** .pp
877
+   ** This specifies the delimiter between the sidebar (if visible) and 
878
+   ** other screens.
879
+   */
880
+   {"sidebar_indentstr", DT_STR, R_BOTH, UL &SidebarIndentStr, UL " "},
881
+   /*
882
+   ** .pp
883
+   ** This specifies the string that is used to indent items
884
+   ** with sidebar_folderindent= yes
885
+   */
886
+   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
887
+   /*
888
+   ** .pp
889
+   ** This specifies whether or not to show sidebar (left-side list of folders).
890
+   */
891
+   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
892
+   /*
893
+   ** .pp
894
+   ** This specifies whether or not to sort the sidebar alphabetically.
895
+   */
896
+   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
897
+   /*
898
+   ** .pp
899
+   ** The width of the sidebar.
900
+   */
901
+   { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 1 },
902
+   /*
903
+   ** .pp
904
+   ** Should the sidebar shorten the path showed.
905
+   */
906
+   {"sidebar_format", DT_STR, R_NONE, UL &SidebarFormat, UL "%B%?F? [%F]?%* %?N?%N/?%4S"},
907
+   /*
908
+   ** .pp
909
+   ** Format string for the sidebar. The sequences `%N', `%F' and `%S'
910
+   ** will be replaced by the number of new or flagged messages or the total
911
+   ** size of them mailbox. `%B' will be replaced with the name of the mailbox.
912
+   ** The `%!' sequence will be expanded to `!' if there is one flagged message;
913
+   ** to `!!' if there are two flagged messages; and to `n!' for n flagged
914
+   ** messages, n>2.
915
+   */
916
+   { "sidebar_folderindent", DT_BOOL, R_BOTH, OPTSIDEBARFOLDERINDENT, 0 },
917
+   /*
918
+   ** .pp
919
+   ** Should folders be indented in the sidebar.
920
+   */
921
+ 
922
    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
923
    /*
924
    ** .pp
925
*** mutt-1.5.23-orig/mailbox.h	2014-03-12 11:03:45.000000000 -0500
926
--- mutt-1.5.23/mailbox.h	2014-04-11 10:14:01.000000000 -0500
927
***************
928
*** 27,32 ****
929
--- 27,33 ----
930
  #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
931
  				* safe_fopen() for mbox-style folders.
932
  				*/
933
+ #define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
934
  
935
  /* mx_open_new_message() */
936
  #define M_ADD_FROM	1	/* add a From_ line */
937
*** mutt-1.5.23-orig/main.c	2014-03-12 11:06:17.000000000 -0500
938
--- mutt-1.5.23/main.c	2014-04-11 10:14:01.000000000 -0500
939
***************
940
*** 50,55 ****
941
--- 50,56 ----
942
  #include <unistd.h>
943
  #include <errno.h>
944
  #include <sys/stat.h>
945
+ #include <limits.h>
946
  #include <sys/utsname.h>
947
  
948
  #ifdef HAVE_GETOPT_H
949
***************
950
*** 555,561 ****
951
  
952
  int main (int argc, char **argv)
953
  {
954
!   char folder[_POSIX_PATH_MAX] = "";
955
    char *subject = NULL;
956
    char *includeFile = NULL;
957
    char *draftFile = NULL;
958
--- 556,562 ----
959
  
960
  int main (int argc, char **argv)
961
  {
962
!   char folder[PATH_MAX] = "";
963
    char *subject = NULL;
964
    char *includeFile = NULL;
965
    char *draftFile = NULL;
966
***************
967
*** 1025,1030 ****
968
--- 1026,1038 ----
969
        strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
970
      mutt_expand_path (folder, sizeof (folder));
971
  
972
+     {
973
+       char tmpfolder[PATH_MAX];
974
+       strfcpy (tmpfolder, folder, sizeof (tmpfolder));
975
+       if(!realpath(tmpfolder, folder))
976
+           strfcpy (folder, tmpfolder, sizeof (tmpfolder));
977
+     }
978
+ 
979
      mutt_str_replace (&CurrentFolder, folder);
980
      mutt_str_replace (&LastFolder, folder);
981
  
982
***************
983
*** 1047,1052 ****
984
--- 1055,1061 ----
985
      if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
986
         || !explicit_folder)
987
      {
988
+       set_curbuffy(folder);
989
        mutt_index_menu ();
990
        if (Context)
991
  	FREE (&Context);
992
*** mutt-1.5.23-orig/Makefile.am	2014-03-12 11:03:44.000000000 -0500
993
--- mutt-1.5.23/Makefile.am	2014-04-11 10:14:01.000000000 -0500
994
***************
995
*** 32,37 ****
996
--- 32,38 ----
997
  	rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
998
  	score.c send.c sendlib.c signal.c sort.c \
999
  	status.c system.c thread.c charset.c history.c lib.c \
1000
+ 	sidebar.c \
1001
  	muttlib.c editmsg.c mbyte.c \
1002
  	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1003
  
1004
*** mutt-1.5.23-orig/Makefile.in	2014-03-12 11:26:44.000000000 -0500
1005
--- mutt-1.5.23/Makefile.in	2014-04-12 12:12:38.000000000 -0500
1006
***************
1007
*** 129,135 ****
1008
  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
1009
  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
1010
  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
1011
! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
1012
  am__objects_1 =
1013
  am__objects_2 = patchlist.$(OBJEXT) conststrings.$(OBJEXT) \
1014
  	$(am__objects_1)
1015
--- 129,136 ----
1016
  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
1017
  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
1018
  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
1019
! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) \
1020
! 	sidebar.$(OBJEXT)
1021
  am__objects_1 =
1022
  am__objects_2 = patchlist.$(OBJEXT) conststrings.$(OBJEXT) \
1023
  	$(am__objects_1)
1024
***************
1025
*** 468,474 ****
1026
  	score.c send.c sendlib.c signal.c sort.c \
1027
  	status.c system.c thread.c charset.c history.c lib.c \
1028
  	muttlib.c editmsg.c mbyte.c \
1029
! 	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1030
  
1031
  nodist_mutt_SOURCES = $(BUILT_SOURCES)
1032
  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
1033
--- 469,476 ----
1034
  	score.c send.c sendlib.c signal.c sort.c \
1035
  	status.c system.c thread.c charset.c history.c lib.c \
1036
  	muttlib.c editmsg.c mbyte.c \
1037
! 	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c \
1038
! 	sidebar.c
1039
  
1040
  nodist_mutt_SOURCES = $(BUILT_SOURCES)
1041
  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
1042
***************
1043
*** 500,506 ****
1044
  	README.SSL smime.h group.h \
1045
  	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
1046
  	ChangeLog mkchangelog.sh mutt_idna.h \
1047
! 	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \
1048
  	txt2c.c txt2c.sh version.sh check_sec.sh
1049
  
1050
  EXTRA_SCRIPTS = smime_keys
1051
--- 502,508 ----
1052
  	README.SSL smime.h group.h \
1053
  	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
1054
  	ChangeLog mkchangelog.sh mutt_idna.h \
1055
! 	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in \
1056
  	txt2c.c txt2c.sh version.sh check_sec.sh
1057
  
1058
  EXTRA_SCRIPTS = smime_keys
1059
*** mutt-1.5.23-orig/mbox.c	2014-03-12 11:03:45.000000000 -0500
1060
--- mutt-1.5.23/mbox.c	2014-04-11 10:14:01.000000000 -0500
1061
***************
1062
*** 100,105 ****
1063
--- 100,106 ----
1064
      mutt_perror (ctx->path);
1065
      return (-1);
1066
    }
1067
+   ctx->atime = sb.st_atime;
1068
    ctx->mtime = sb.st_mtime;
1069
    ctx->size = sb.st_size;
1070
  
1071
***************
1072
*** 251,256 ****
1073
--- 252,258 ----
1074
  
1075
    ctx->size = sb.st_size;
1076
    ctx->mtime = sb.st_mtime;
1077
+   ctx->atime = sb.st_atime;
1078
  
1079
  #ifdef NFS_ATTRIBUTE_HACK
1080
    if (sb.st_mtime > sb.st_atime)
1081
*** mutt-1.5.23-orig/menu.c	2014-03-12 11:03:45.000000000 -0500
1082
--- mutt-1.5.23/menu.c	2014-04-12 21:31:16.000000000 -0500
1083
***************
1084
*** 24,29 ****
1085
--- 24,30 ----
1086
  #include "mutt_curses.h"
1087
  #include "mutt_menu.h"
1088
  #include "mbyte.h"
1089
+ #include "sidebar.h"
1090
  
1091
  extern size_t UngetCount;
1092
  
1093
***************
1094
*** 186,192 ****
1095
  {
1096
    char *scratch = safe_strdup (s);
1097
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
1098
!   int cols = COLS - shift;
1099
  
1100
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1101
    s[n - 1] = 0;
1102
--- 187,193 ----
1103
  {
1104
    char *scratch = safe_strdup (s);
1105
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
1106
!   int cols = COLS - shift - SidebarWidth;
1107
  
1108
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1109
    s[n - 1] = 0;
1110
***************
1111
*** 239,244 ****
1112
--- 240,246 ----
1113
    int do_color;
1114
    int attr;
1115
  
1116
+   draw_sidebar(1);
1117
    for (i = menu->top; i < menu->top + menu->pagelen; i++)
1118
    {
1119
      if (i < menu->max)
1120
***************
1121
*** 249,255 ****
1122
        menu_pad_string (buf, sizeof (buf));
1123
  
1124
        ATTRSET(attr);
1125
!       move(i - menu->top + menu->offset, 0);
1126
        do_color = 1;
1127
  
1128
        if (i == menu->current)
1129
--- 251,257 ----
1130
        menu_pad_string (buf, sizeof (buf));
1131
  
1132
        ATTRSET(attr);
1133
!       move(i - menu->top + menu->offset, SidebarWidth);
1134
        do_color = 1;
1135
  
1136
        if (i == menu->current)
1137
***************
1138
*** 272,278 ****
1139
      else
1140
      {
1141
        NORMAL_COLOR;
1142
!       CLEARLINE(i - menu->top + menu->offset);
1143
      }
1144
    }
1145
    NORMAL_COLOR;
1146
--- 274,280 ----
1147
      else
1148
      {
1149
        NORMAL_COLOR;
1150
!       CLEARLINE_WIN (i - menu->top + menu->offset);
1151
      }
1152
    }
1153
    NORMAL_COLOR;
1154
***************
1155
*** 289,295 ****
1156
      return;
1157
    }
1158
    
1159
!   move (menu->oldcurrent + menu->offset - menu->top, 0);
1160
    ATTRSET(menu->color (menu->oldcurrent));
1161
  
1162
    if (option (OPTARROWCURSOR))
1163
--- 291,297 ----
1164
      return;
1165
    }
1166
    
1167
!   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
1168
    ATTRSET(menu->color (menu->oldcurrent));
1169
  
1170
    if (option (OPTARROWCURSOR))
1171
***************
1172
*** 301,313 ****
1173
      {
1174
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1175
        menu_pad_string (buf, sizeof (buf));
1176
!       move (menu->oldcurrent + menu->offset - menu->top, 3);
1177
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1178
      }
1179
  
1180
      /* now draw it in the new location */
1181
      SETCOLOR(MT_COLOR_INDICATOR);
1182
!     mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
1183
    }
1184
    else
1185
    {
1186
--- 303,315 ----
1187
      {
1188
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1189
        menu_pad_string (buf, sizeof (buf));
1190
!       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
1191
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1192
      }
1193
  
1194
      /* now draw it in the new location */
1195
      SETCOLOR(MT_COLOR_INDICATOR);
1196
!     mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
1197
    }
1198
    else
1199
    {
1200
***************
1201
*** 320,326 ****
1202
      menu_make_entry (buf, sizeof (buf), menu, menu->current);
1203
      menu_pad_string (buf, sizeof (buf));
1204
      SETCOLOR(MT_COLOR_INDICATOR);
1205
!     move(menu->current - menu->top + menu->offset, 0);
1206
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1207
    }
1208
    menu->redraw &= REDRAW_STATUS;
1209
--- 322,328 ----
1210
      menu_make_entry (buf, sizeof (buf), menu, menu->current);
1211
      menu_pad_string (buf, sizeof (buf));
1212
      SETCOLOR(MT_COLOR_INDICATOR);
1213
!     move(menu->current - menu->top + menu->offset, SidebarWidth);
1214
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1215
    }
1216
    menu->redraw &= REDRAW_STATUS;
1217
***************
1218
*** 332,338 ****
1219
    char buf[LONG_STRING];
1220
    int attr = menu->color (menu->current);
1221
    
1222
!   move (menu->current + menu->offset - menu->top, 0);
1223
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
1224
    menu_pad_string (buf, sizeof (buf));
1225
  
1226
--- 334,340 ----
1227
    char buf[LONG_STRING];
1228
    int attr = menu->color (menu->current);
1229
    
1230
!   move (menu->current + menu->offset - menu->top, SidebarWidth);
1231
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
1232
    menu_pad_string (buf, sizeof (buf));
1233
  
1234
***************
1235
*** 872,878 ****
1236
      
1237
      
1238
      if (option (OPTARROWCURSOR))
1239
!       move (menu->current - menu->top + menu->offset, 2);
1240
      else if (option (OPTBRAILLEFRIENDLY))
1241
        move (menu->current - menu->top + menu->offset, 0);
1242
      else
1243
--- 874,880 ----
1244
      
1245
      
1246
      if (option (OPTARROWCURSOR))
1247
!       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
1248
      else if (option (OPTBRAILLEFRIENDLY))
1249
        move (menu->current - menu->top + menu->offset, 0);
1250
      else
1251
*** mutt-1.5.23-orig/mh.c	2014-03-12 11:03:45.000000000 -0500
1252
--- mutt-1.5.23/mh.c	2014-04-11 11:04:59.000000000 -0500
1253
***************
1254
*** 295,300 ****
1255
--- 295,326 ----
1256
    mhs_free_sequences (&mhs);
1257
  }
1258
  
1259
+ void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged, time_t *sb_last_checked)
1260
+ {
1261
+   int i;
1262
+   struct mh_sequences mhs;
1263
+   memset (&mhs, 0, sizeof (mhs));
1264
+ 
1265
+   if(!option(OPTSIDEBAR))
1266
+       return;
1267
+ 
1268
+   if (mh_read_sequences (&mhs, path) < 0)
1269
+     return;
1270
+ 
1271
+   msgcount = 0;
1272
+   msg_unread = 0;
1273
+   msg_flagged = 0;
1274
+   for (i = 0; i <= mhs.max; i++)
1275
+     msgcount++;
1276
+     if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
1277
+       msg_unread++;
1278
+     }
1279
+     if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
1280
+       msg_flagged++;
1281
+   mhs_free_sequences (&mhs);
1282
+   *sb_last_checked = time(NULL);
1283
+ }
1284
+ 
1285
  static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
1286
  {
1287
    int fd;
1288
*** mutt-1.5.23-orig/mutt_curses.h	2014-03-12 11:03:45.000000000 -0500
1289
--- mutt-1.5.23/mutt_curses.h	2014-04-11 10:14:01.000000000 -0500
1290
***************
1291
*** 64,69 ****
1292
--- 64,70 ----
1293
  #undef lines
1294
  #endif /* lines */
1295
  
1296
+ #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
1297
  #define CLEARLINE(x) move(x,0), clrtoeol()
1298
  #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
1299
  #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
1300
***************
1301
*** 120,125 ****
1302
--- 121,128 ----
1303
    MT_COLOR_BOLD,
1304
    MT_COLOR_UNDERLINE,
1305
    MT_COLOR_INDEX,
1306
+   MT_COLOR_NEW,
1307
+   MT_COLOR_FLAGGED,
1308
    MT_COLOR_MAX
1309
  };
1310
  
1311
*** mutt-1.5.23-orig/mutt_menu.h	2014-03-12 11:06:17.000000000 -0500
1312
--- mutt-1.5.23/mutt_menu.h	2014-04-11 10:14:01.000000000 -0500
1313
***************
1314
*** 34,39 ****
1315
--- 34,40 ----
1316
  #define REDRAW_FULL		(1<<5)
1317
  #define REDRAW_BODY		(1<<6)
1318
  #define REDRAW_SIGWINCH		(1<<7)
1319
+ #define REDRAW_SIDEBAR		(1<<8)
1320
  
1321
  #define M_MODEFMT "-- Mutt: %s"
1322
  
1323
*** mutt-1.5.23-orig/mutt.h	2014-03-12 11:06:17.000000000 -0500
1324
--- mutt-1.5.23/mutt.h	2014-04-11 10:14:01.000000000 -0500
1325
***************
1326
*** 421,426 ****
1327
--- 421,430 ----
1328
    OPTSAVEEMPTY,
1329
    OPTSAVENAME,
1330
    OPTSCORE,
1331
+   OPTSIDEBAR,
1332
+   OPTSIDEBARSHORTPATH,
1333
+   OPTSIDEBARSORT,
1334
+   OPTSIDEBARFOLDERINDENT,
1335
    OPTSIGDASHES,
1336
    OPTSIGONTOP,
1337
    OPTSORTRE,
1338
***************
1339
*** 861,866 ****
1340
--- 865,871 ----
1341
  {
1342
    char *path;
1343
    FILE *fp;
1344
+   time_t atime;
1345
    time_t mtime;
1346
    off_t size;
1347
    off_t vsize;
1348
***************
1349
*** 895,900 ****
1350
--- 900,906 ----
1351
    unsigned int quiet : 1;	/* inhibit status messages? */
1352
    unsigned int collapsed : 1;   /* are all threads collapsed? */
1353
    unsigned int closing : 1;	/* mailbox is being closed */
1354
+   unsigned int peekonly : 1;	/* just taking a glance, revert atime */
1355
  
1356
    /* driver hooks */
1357
    void *data;			/* driver specific data */
1358
*** mutt-1.5.23-orig/muttlib.c	2014-03-12 11:03:45.000000000 -0500
1359
--- mutt-1.5.23/muttlib.c	2014-04-11 10:14:01.000000000 -0500
1360
***************
1361
*** 1281,1286 ****
1362
--- 1281,1288 ----
1363
  	  pl = pw = 1;
1364
  
1365
  	/* see if there's room to add content, else ignore */
1366
+         if ( DrawFullLine )
1367
+         {
1368
  	if ((col < COLS && wlen < destlen) || soft)
1369
  	{
1370
  	  int pad;
1371
***************
1372
*** 1324,1329 ****
1373
--- 1326,1377 ----
1374
  	  col += wid;
1375
  	  src += pl;
1376
  	}
1377
+         }
1378
+         else
1379
+         {
1380
+ 	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
1381
+         {
1382
+ 	  int pad;
1383
+ 
1384
+ 	  /* get contents after padding */
1385
+ 	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
1386
+ 	  len = mutt_strlen (buf);
1387
+ 	  wid = mutt_strwidth (buf);
1388
+ 
1389
+ 	  /* try to consume as many columns as we can, if we don't have
1390
+ 	   * memory for that, use as much memory as possible */
1391
+ 	  pad = (COLS - SidebarWidth - col - wid) / pw;
1392
+ 	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
1393
+ 	    pad = ((signed)(destlen - wlen - len)) / pl;
1394
+ 	  if (pad > 0)
1395
+ 	  {
1396
+ 	    while (pad--)
1397
+ 	    {
1398
+ 	      memcpy (wptr, src, pl);
1399
+ 	      wptr += pl;
1400
+ 	      wlen += pl;
1401
+ 	      col += pw;
1402
+ 	    }
1403
+ 	  }
1404
+ 	  else if (soft && pad < 0)
1405
+ 	  {
1406
+ 	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
1407
+ 	    *wptr = 0;
1408
+ 	    /* make sure right part is at most as wide as display */
1409
+ 	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
1410
+ 	    /* truncate left so that right part fits completely in */
1411
+ 	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
1412
+ 	    wptr = dest + wlen;
1413
+ 	  }
1414
+ 	  if (len + wlen > destlen)
1415
+ 	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
1416
+ 	  memcpy (wptr, buf, len);
1417
+ 	  wptr += len;
1418
+ 	  wlen += len;
1419
+ 	  col += wid;
1420
+ 	  src += pl;
1421
+ 	}
1422
+         }
1423
  	break; /* skip rest of input */
1424
        }
1425
        else if (ch == '|')
1426
*** mutt-1.5.23-orig/mx.c	2014-03-12 11:03:45.000000000 -0500
1427
--- mutt-1.5.23/mx.c	2014-04-11 10:14:01.000000000 -0500
1428
***************
1429
*** 580,585 ****
1430
--- 580,586 ----
1431
   *		M_APPEND	open mailbox for appending
1432
   *		M_READONLY	open mailbox in read-only mode
1433
   *		M_QUIET		only print error messages
1434
+  *		M_PEEK		revert atime where applicable
1435
   *	ctx	if non-null, context struct to use
541
   */
1436
   */
542
+  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
1437
  CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
543
+  /*
1438
***************
544
+  ** .pp
1439
*** 602,607 ****
545
+  ** This specifies the delimiter between the sidebar (if visible) and 
1440
--- 603,610 ----
546
+  ** other screens.
1441
      ctx->quiet = 1;
547
+  */
1442
    if (flags & M_READONLY)
548
+  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
1443
      ctx->readonly = 1;
549
+  /*
1444
+   if (flags & M_PEEK)
550
+  ** .pp
1445
+     ctx->peekonly = 1;
551
+  ** This specifies whether or not to show sidebar (left-side list of folders).
1446
  
552
+  */
1447
    if (flags & (M_APPEND|M_NEWFOLDER))
553
+  { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
1448
    {
554
+  /*
1449
***************
555
+  ** .pp
1450
*** 701,713 ****
556
+  ** This specifies whether or not to sort the sidebar alphabetically.
1451
  void mx_fastclose_mailbox (CONTEXT *ctx)
557
+  */
1452
  {
558
+  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
1453
    int i;
559
+  /*
1454
  
560
+  ** .pp
1455
    if(!ctx) 
561
+  ** The width of the sidebar.
1456
      return;
562
+  */
1457
  
563
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
1458
    /* never announce that a mailbox we've just left has new mail. #3290
564
   /*
1459
     * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
565
   ** .pp
1460
!   mutt_buffy_setnotified(ctx->path);
566
diff -uNp -r mutt-1.5.22.orig/mailbox.h mutt-1.5.22/mailbox.h
1461
  
567
--- mutt-1.5.22.orig/mailbox.h	Sun Feb 21 22:10:41 2010
1462
    if (ctx->mx_close)
568
+++ mutt-1.5.22/mailbox.h	Fri Oct 18 10:18:45 2013
1463
      ctx->mx_close (ctx);
569
@@ -27,6 +27,7 @@
1464
--- 704,729 ----
570
 #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
1465
  void mx_fastclose_mailbox (CONTEXT *ctx)
571
 				* safe_fopen() for mbox-style folders.
1466
  {
572
 				*/
1467
    int i;
573
+#define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
1468
+ #ifndef BUFFY_SIZE
574
 
1469
+   struct utimbuf ut;
575
 /* mx_open_new_message() */
1470
+ #endif
576
 #define M_ADD_FROM	1	/* add a From_ line */
1471
  
577
diff -uNp -r mutt-1.5.22.orig/mbox.c mutt-1.5.22/mbox.c
1472
    if(!ctx) 
578
--- mutt-1.5.22.orig/mbox.c	Fri Oct 18 05:48:24 2013
1473
      return;
579
+++ mutt-1.5.22/mbox.c	Fri Oct 18 10:18:45 2013
1474
+ #ifndef BUFFY_SIZE
580
@@ -100,6 +100,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
1475
+   /* fix up the times so buffy won't get confused */
581
     mutt_perror (ctx->path);
1476
+   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
582
     return (-1);
1477
+   {
583
   }
1478
+     ut.actime = ctx->atime;
584
+  ctx->atime = sb.st_atime;
1479
+     ut.modtime = ctx->mtime;
585
   ctx->mtime = sb.st_mtime;
1480
+     utime (ctx->path, &ut); 
586
   ctx->size = sb.st_size;
1481
+   }
587
 
1482
+ #endif
588
@@ -251,6 +252,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
1483
  
589
 
1484
    /* never announce that a mailbox we've just left has new mail. #3290
590
   ctx->size = sb.st_size;
1485
     * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
591
   ctx->mtime = sb.st_mtime;
1486
!   if(!ctx->peekonly)
592
+  ctx->atime = sb.st_atime;
1487
!     mutt_buffy_setnotified(ctx->path);
593
 
1488
  
594
 #ifdef NFS_ATTRIBUTE_HACK
1489
    if (ctx->mx_close)
595
   if (sb.st_mtime > sb.st_atime)
1490
      ctx->mx_close (ctx);
596
diff -uNp -r mutt-1.5.22.orig/menu.c mutt-1.5.22/menu.c
1491
***************
597
--- mutt-1.5.22.orig/menu.c	Tue Jan 15 07:37:15 2013
1492
*** 719,724 ****
598
+++ mutt-1.5.22/menu.c	Fri Oct 18 10:18:45 2013
1493
--- 735,742 ----
599
@@ -24,6 +24,7 @@
1494
    mutt_clear_threads (ctx);
600
 #include "mutt_curses.h"
1495
    for (i = 0; i < ctx->msgcount; i++)
601
 #include "mutt_menu.h"
1496
      mutt_free_header (&ctx->hdrs[i]);
602
 #include "mbyte.h"
1497
+   ctx->msgcount -= ctx->deleted;
603
+#include "sidebar.h"
1498
+   set_buffystats(ctx);
604
 
1499
    FREE (&ctx->hdrs);
605
 extern size_t UngetCount;
1500
    FREE (&ctx->v2r);
606
 
1501
    FREE (&ctx->path);
607
@@ -186,7 +187,7 @@ static void menu_pad_string (char *s, size_t n)
1502
***************
608
 {
1503
*** 812,817 ****
609
   char *scratch = safe_strdup (s);
1504
--- 830,839 ----
610
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
1505
      if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 
611
-  int cols = COLS - shift;
1506
          && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
612
+  int cols = COLS - shift - SidebarWidth;
1507
        read_msgs++;
613
 
1508
+     if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
614
   mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1509
+       ctx->unread--;
615
   s[n - 1] = 0;
1510
+     if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
616
@@ -239,6 +240,7 @@ void menu_redraw_index (MUTTMENU *menu)
1511
+       ctx->flagged--;
617
   int do_color;
1512
    }
618
   int attr;
1513
  
619
 
1514
    if (read_msgs && quadoption (OPT_MOVE) != M_NO)
620
+  draw_sidebar(1);
1515
*** mutt-1.5.23-orig/mx.h	2014-03-12 11:03:45.000000000 -0500
621
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
1516
--- mutt-1.5.23/mx.h	2014-04-11 11:11:47.000000000 -0500
622
   {
1517
***************
623
     if (i < menu->max)
1518
*** 57,62 ****
624
@@ -249,7 +251,7 @@ void menu_redraw_index (MUTTMENU *menu)
1519
--- 57,63 ----
625
       menu_pad_string (buf, sizeof (buf));
1520
  int mh_read_dir (CONTEXT *, const char *);
626
 
1521
  int mh_sync_mailbox (CONTEXT *, int *);
627
       ATTRSET(attr);
1522
  int mh_check_mailbox (CONTEXT *, int *);
628
-      move(i - menu->top + menu->offset, 0);
1523
+ void mh_buffy_update (const char *, int *, int *, int *, time_t *);
629
+      move(i - menu->top + menu->offset, SidebarWidth);
1524
  int mh_check_empty (const char *);
630
       do_color = 1;
1525
  
631
 
1526
  int maildir_read_dir (CONTEXT *);
632
       if (i == menu->current)
1527
*** mutt-1.5.23-orig/OPS	2014-03-12 11:03:44.000000000 -0500
633
@@ -272,7 +274,7 @@ void menu_redraw_index (MUTTMENU *menu)
1528
--- mutt-1.5.23/OPS	2014-04-11 10:14:01.000000000 -0500
634
     else
1529
***************
635
     {
1530
*** 179,181 ****
636
       NORMAL_COLOR;
1531
--- 179,186 ----
637
-      CLEARLINE(i - menu->top + menu->offset);
1532
  OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
638
+      CLEARLINE_WIN(i - menu->top + menu->offset);
1533
  OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
639
     }
1534
  OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
640
   }
1535
+ OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
641
   NORMAL_COLOR;
1536
+ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
642
@@ -289,7 +291,7 @@ void menu_redraw_motion (MUTTMENU *menu)
1537
+ OP_SIDEBAR_NEXT "go down to next mailbox"
643
     return;
1538
+ OP_SIDEBAR_PREV "go to previous mailbox"
644
   }
1539
+ OP_SIDEBAR_OPEN "open hilighted mailbox"
1540
*** mutt-1.5.23-orig/pager.c	2014-03-12 11:06:17.000000000 -0500
1541
--- mutt-1.5.23/pager.c	2014-04-12 21:53:15.000000000 -0500
1542
***************
1543
*** 29,34 ****
1544
--- 29,35 ----
1545
  #include "pager.h"
1546
  #include "attach.h"
1547
  #include "mbyte.h"
1548
+ #include "sidebar.h"
1549
  
1550
  #include "mutt_crypt.h"
1551
  
1552
***************
1553
*** 1095,1100 ****
1554
--- 1096,1102 ----
1555
    wchar_t wc;
1556
    mbstate_t mbstate;
1557
    int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
1558
+   wrap_cols -= SidebarWidth;
1559
  
1560
    if (check_attachment_marker ((char *)buf) == 0)
1561
      wrap_cols = COLS;
1562
***************
1563
*** 1572,1577 ****
1564
--- 1574,1580 ----
1565
  
1566
    int bodyoffset = 1;			/* offset of first line of real text */
1567
    int statusoffset = 0; 		/* offset for the status bar */
1568
+   int statuswidth;
1569
    int helpoffset = LINES - 2;		/* offset for the help bar. */
1570
    int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */
1571
  
1572
***************
1573
*** 1746,1752 ****
1574
      if ((redraw & REDRAW_BODY) || topline != oldtopline)
1575
      {
1576
        do {
1577
! 	move (bodyoffset, 0);
1578
  	curline = oldtopline = topline;
1579
  	lines = 0;
1580
  	force_redraw = 0;
1581
--- 1749,1755 ----
1582
      if ((redraw & REDRAW_BODY) || topline != oldtopline)
1583
      {
1584
        do {
1585
! 	move (bodyoffset, SidebarWidth);
1586
  	curline = oldtopline = topline;
1587
  	lines = 0;
1588
  	force_redraw = 0;
1589
***************
1590
*** 1759,1764 ****
1591
--- 1762,1768 ----
1592
  			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
1593
  	    lines++;
1594
  	  curline++;
1595
+   	  move(lines + bodyoffset, SidebarWidth);
1596
  	}
1597
  	last_offset = lineInfo[curline].offset;
1598
        } while (force_redraw);
1599
***************
1600
*** 1771,1776 ****
1601
--- 1775,1781 ----
1602
  	  addch ('~');
1603
  	addch ('\n');
1604
  	lines++;
1605
+   	move(lines + bodyoffset, SidebarWidth);
1606
        }
1607
        NORMAL_COLOR;
1608
  
1609
***************
1610
*** 1788,1816 ****
1611
        hfi.ctx = Context;
1612
        hfi.pager_progress = pager_progress_str;
1613
  
1614
        if (last_pos < sb.st_size - 1)
1615
  	snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1616
        else
1617
  	strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1618
  
1619
        /* print out the pager status bar */
1620
!       move (statusoffset, 0);
1621
        SETCOLOR (MT_COLOR_STATUS);
1622
  
1623
        if (IsHeader (extra) || IsMsgAttach (extra))
1624
        {
1625
! 	size_t l1 = COLS * MB_LEN_MAX;
1626
  	size_t l2 = sizeof (buffer);
1627
  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1628
  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1629
! 	mutt_paddstr (COLS, buffer);
1630
        }
1631
        else
1632
        {
1633
  	char bn[STRING];
1634
  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1635
! 	mutt_paddstr (COLS, bn);
1636
        }
1637
        NORMAL_COLOR;
1638
      }
1639
  
1640
--- 1793,1831 ----
1641
        hfi.ctx = Context;
1642
        hfi.pager_progress = pager_progress_str;
1643
  
1644
+       statuswidth = COLS - (option(OPTSTATUSONTOP) && PagerIndexLines > 0 ? SidebarWidth : 0);
1645
+ 
1646
        if (last_pos < sb.st_size - 1)
1647
  	snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1648
        else
1649
  	strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1650
  
1651
        /* print out the pager status bar */
1652
!       move (statusoffset, SidebarWidth);
1653
        SETCOLOR (MT_COLOR_STATUS);
1654
+       if(option(OPTSTATUSONTOP) && PagerIndexLines > 0) {
1655
+           CLEARLINE_WIN (statusoffset);
1656
+       } else {
1657
+           CLEARLINE (statusoffset);
1658
+           DrawFullLine = 1; /* for mutt_make_string_info */
1659
+       }
1660
  
1661
        if (IsHeader (extra) || IsMsgAttach (extra))
1662
        {
1663
! 	size_t l1 = statuswidth * MB_LEN_MAX;
1664
  	size_t l2 = sizeof (buffer);
1665
  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1666
  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1667
! 	mutt_paddstr (statuswidth, buffer);
1668
        }
1669
        else
1670
        {
1671
  	char bn[STRING];
1672
  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1673
! 	mutt_paddstr (statuswidth, bn);
1674
        }
1675
+       if(!option(OPTSTATUSONTOP) || PagerIndexLines == 0)
1676
+           DrawFullLine = 0; /* reset */
1677
        NORMAL_COLOR;
1678
      }
1679
  
1680
***************
1681
*** 1819,1834 ****
1682
        /* redraw the pager_index indicator, because the
1683
         * flags for this message might have changed. */
1684
        menu_redraw_current (index);
1685
  
1686
        /* print out the index status bar */
1687
        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
645
   
1688
   
646
-  move (menu->oldcurrent + menu->offset - menu->top, 0);
1689
!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
647
+  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
1690
        SETCOLOR (MT_COLOR_STATUS);
648
   ATTRSET(menu->color (menu->oldcurrent));
1691
!       mutt_paddstr (COLS, buffer);
649
 
1692
        NORMAL_COLOR;
650
   if (option (OPTARROWCURSOR))
1693
      }
651
@@ -301,13 +303,13 @@ void menu_redraw_motion (MUTTMENU *menu)
1694
  
652
     {
1695
      redraw = 0;
653
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1696
  
654
       menu_pad_string (buf, sizeof (buf));
1697
      if (option(OPTBRAILLEFRIENDLY)) {
655
-      move (menu->oldcurrent + menu->offset - menu->top, 3);
1698
--- 1834,1855 ----
656
+      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
1699
        /* redraw the pager_index indicator, because the
657
       print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1700
         * flags for this message might have changed. */
658
     }
1701
        menu_redraw_current (index);
659
 
1702
+       draw_sidebar(MENU_PAGER);
660
     /* now draw it in the new location */
1703
  
661
     SETCOLOR(MT_COLOR_INDICATOR);
1704
        /* print out the index status bar */
662
-    mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
1705
        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
663
+    mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
664
   }
665
   else
666
   {
667
@@ -320,7 +322,7 @@ void menu_redraw_motion (MUTTMENU *menu)
668
     menu_make_entry (buf, sizeof (buf), menu, menu->current);
669
     menu_pad_string (buf, sizeof (buf));
670
     SETCOLOR(MT_COLOR_INDICATOR);
671
-    move(menu->current - menu->top + menu->offset, 0);
672
+    move(menu->current - menu->top + menu->offset, SidebarWidth);
673
     print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
674
   }
675
   menu->redraw &= REDRAW_STATUS;
676
@@ -332,7 +334,7 @@ void menu_redraw_current (MUTTMENU *menu)
677
   char buf[LONG_STRING];
678
   int attr = menu->color (menu->current);
679
   
1706
   
680
-  move (menu->current + menu->offset - menu->top, 0);
1707
!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
681
+  move (menu->current + menu->offset - menu->top, SidebarWidth);
1708
!           (option(OPTSTATUSONTOP) ? 0: SidebarWidth));
682
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
1709
        SETCOLOR (MT_COLOR_STATUS);
683
   menu_pad_string (buf, sizeof (buf));
1710
!       mutt_paddstr (COLS - (option(OPTSTATUSONTOP) ? 0 : SidebarWidth), buffer);
684
 
1711
        NORMAL_COLOR;
685
@@ -872,7 +874,7 @@ int mutt_menuLoop (MUTTMENU *menu)
1712
      }
686
     
1713
  
687
     
1714
+     /* if we're not using the index, update every time */
688
     if (option (OPTARROWCURSOR))
1715
+     if ( index == 0 )
689
-      move (menu->current - menu->top + menu->offset, 2);
1716
+       draw_sidebar(MENU_PAGER);
690
+      move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
1717
+ 
691
     else if (option (OPTBRAILLEFRIENDLY))
1718
      redraw = 0;
692
       move (menu->current - menu->top + menu->offset, 0);
1719
  
693
     else
1720
      if (option(OPTBRAILLEFRIENDLY)) {
694
diff -uNp -r mutt-1.5.22.orig/mh.c mutt-1.5.22/mh.c
1721
***************
695
--- mutt-1.5.22.orig/mh.c	Mon Apr 22 07:14:53 2013
1722
*** 2763,2768 ****
696
+++ mutt-1.5.22/mh.c	Fri Oct 18 10:18:45 2013
1723
--- 2784,2796 ----
697
@@ -295,6 +295,28 @@ void mh_buffy(BUFFY *b)
1724
  	mutt_what_key ();
698
   mhs_free_sequences (&mhs);
1725
  	break;
699
 }
1726
  
700
 
1727
+       case OP_SIDEBAR_SCROLL_UP:
701
+void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged)
1728
+       case OP_SIDEBAR_SCROLL_DOWN:
702
+{
1729
+       case OP_SIDEBAR_NEXT:
703
+  int i;
1730
+       case OP_SIDEBAR_PREV:
704
+  struct mh_sequences mhs;
1731
+ 	scroll_sidebar(ch, MENU_PAGER);
705
+  memset (&mhs, 0, sizeof (mhs));
1732
+  	break;
706
+
1733
+ 
707
+  if (mh_read_sequences (&mhs, path) < 0)
1734
        default:
708
+    return;
1735
  	ch = -1;
709
+
1736
  	break;
710
+  msgcount = 0;
1737
*** mutt-1.5.23-orig/pattern.c	2014-03-12 11:03:45.000000000 -0500
711
+  msg_unread = 0;
1738
--- mutt-1.5.23/pattern.c	2014-04-11 10:14:01.000000000 -0500
712
+  msg_flagged = 0;
1739
***************
713
+  for (i = 0; i <= mhs.max; i++)
1740
*** 154,159 ****
714
+    msgcount++;
1741
--- 154,163 ----
715
+  if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
1742
    HEADER *h = ctx->hdrs[msgno];
716
+    msg_unread++;
1743
    char *buf;
717
+  }
1744
    size_t blen;
718
+  if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
1745
+ #ifdef HAVE_FMEMOPEN
719
+    msg_flagged++;
1746
+   char *temp;
720
+  mhs_free_sequences (&mhs);
1747
+   size_t tempsize;
721
+}
1748
+ #endif
722
+
1749
  
723
 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
1750
    if ((msg = mx_open_message (ctx, msgno)) != NULL)
724
 {
1751
    {
725
   int fd;
1752
***************
726
diff -uNp -r mutt-1.5.22.orig/mutt.h mutt-1.5.22/mutt.h
1753
*** 163,174 ****
727
--- mutt-1.5.22.orig/mutt.h	Fri Oct 18 05:48:24 2013
1754
--- 167,186 ----
728
+++ mutt-1.5.22/mutt.h	Fri Oct 18 10:18:45 2013
1755
        memset (&s, 0, sizeof (s));
729
@@ -420,6 +420,8 @@ enum
1756
        s.fpin = msg->fp;
730
   OPTSAVEEMPTY,
1757
        s.flags = M_CHARCONV;
731
   OPTSAVENAME,
1758
+ #ifdef HAVE_FMEMOPEN
732
   OPTSCORE,
1759
+       if((s.fpout = open_memstream(&temp, &tempsize)) == NULL)
733
+  OPTSIDEBAR,
1760
+       {
734
+  OPTSIDEBARSORT,
1761
+ 	mutt_perror ("Error opening memstream");
735
   OPTSIGDASHES,
1762
+ 	return (0);
736
   OPTSIGONTOP,
1763
+       }
737
   OPTSORTRE,
1764
+ #else
738
@@ -860,6 +862,7 @@ typedef struct _context
1765
        mutt_mktemp (tempfile, sizeof (tempfile));
739
 {
1766
        if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL)
740
   char *path;
1767
        {
741
   FILE *fp;
1768
  	mutt_perror (tempfile);
742
+  time_t atime;
1769
  	return (0);
743
   time_t mtime;
1770
        }
744
   off_t size;
1771
+ #endif
745
   off_t vsize;
1772
  
746
@@ -894,6 +897,7 @@ typedef struct _context
1773
        if (pat->op != M_BODY)
747
   unsigned int quiet : 1;	/* inhibit status messages? */
1774
  	mutt_copy_header (msg->fp, h, s.fpout, CH_FROM | CH_DECODE, NULL);
748
   unsigned int collapsed : 1;   /* are all threads collapsed? */
1775
***************
749
   unsigned int closing : 1;	/* mailbox is being closed */
1776
*** 184,190 ****
750
+  unsigned int peekonly : 1;	/* just taking a glance, revert atime */
1777
--- 196,206 ----
751
 
1778
  	  if (s.fpout)
752
   /* driver hooks */
1779
  	  {
753
   void *data;			/* driver specific data */
1780
  	    safe_fclose (&s.fpout);
754
diff -uNp -r mutt-1.5.22.orig/mutt_curses.h mutt-1.5.22/mutt_curses.h
1781
+ #ifdef HAVE_FMEMOPEN
755
--- mutt-1.5.22.orig/mutt_curses.h	Tue Jan 15 07:37:15 2013
1782
+             FREE(&temp);
756
+++ mutt-1.5.22/mutt_curses.h	Fri Oct 18 10:22:32 2013
1783
+ #else
757
@@ -64,6 +64,7 @@
1784
  	    unlink (tempfile);
758
 #undef lines
1785
+ #endif
759
 #endif /* lines */
1786
  	  }
760
 
1787
  	  return (0);
761
+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
1788
  	}
762
 #define CLEARLINE(x) move(x,0), clrtoeol()
1789
***************
763
 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
1790
*** 193,203 ****
764
 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
1791
--- 209,236 ----
765
@@ -120,6 +121,8 @@ enum
1792
  	mutt_body_handler (h->content, &s);
766
   MT_COLOR_BOLD,
1793
        }
767
   MT_COLOR_UNDERLINE,
1794
  
768
   MT_COLOR_INDEX,
1795
+ #ifdef HAVE_FMEMOPEN
769
+  MT_COLOR_NEW,
1796
+       fclose(s.fpout);
770
+  MT_COLOR_FLAGGED,
1797
+       lng = tempsize;
771
   MT_COLOR_MAX
1798
+ 
772
 };
1799
+       if(tempsize) {
773
 
1800
+           if ((fp = fmemopen(temp, tempsize, "r")) == NULL) {
774
diff -uNp -r mutt-1.5.22.orig/muttlib.c mutt-1.5.22/muttlib.c
1801
+             mutt_perror ("Error re-opening memstream");
775
--- mutt-1.5.22.orig/muttlib.c	Fri Oct 18 05:48:24 2013
1802
+             return (0);
776
+++ mutt-1.5.22/muttlib.c	Fri Oct 18 10:18:45 2013
1803
+           }
777
@@ -1286,6 +1286,8 @@ void mutt_FormatString (char *dest,		/* output buffer 
1804
+       } else { /* fmemopen cannot handle empty buffers */
778
 	  pl = pw = 1;
1805
+           if ((fp = safe_fopen ("/dev/null", "r")) == NULL) {
779
 
1806
+             mutt_perror ("Error opening /dev/null");
780
 	/* see if there's room to add content, else ignore */
1807
+             return (0);
781
+        if ( DrawFullLine )
1808
+           }
782
+        {
1809
+       }
783
 	if ((col < COLS && wlen < destlen) || soft)
1810
+ #else
784
 	{
1811
        fp = s.fpout;
785
 	  int pad;
1812
        fflush (fp);
786
@@ -1329,6 +1331,52 @@ void mutt_FormatString (char *dest,		/* output buffer 
1813
        fseek (fp, 0, 0);
787
 	  col += wid;
1814
        fstat (fileno (fp), &st);
788
 	  src += pl;
1815
        lng = (long) st.st_size;
789
 	}
1816
+ #endif
790
+        }
1817
      }
791
+        else
1818
      else
792
+        {
1819
      {
793
+	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
1820
***************
794
+        {
1821
*** 244,250 ****
795
+	  int pad;
1822
--- 277,288 ----
796
+
1823
      if (option (OPTTHOROUGHSRC))
797
+	  /* get contents after padding */
1824
      {
798
+	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
1825
        safe_fclose (&fp);
799
+	  len = mutt_strlen (buf);
1826
+ #ifdef HAVE_FMEMOPEN
800
+	  wid = mutt_strwidth (buf);
1827
+       if(tempsize)
801
+
1828
+           FREE (&temp);
802
+	  /* try to consume as many columns as we can, if we don't have
1829
+ #else
803
+	   * memory for that, use as much memory as possible */
1830
        unlink (tempfile);
804
+	  pad = (COLS - SidebarWidth - col - wid) / pw;
1831
+ #endif
805
+	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
1832
      }
806
+	    pad = ((signed)(destlen - wlen - len)) / pl;
1833
    }
807
+	  if (pad > 0)
1834
  
808
+	  {
1835
*** mutt-1.5.23-orig/PATCHES	2014-03-12 11:03:44.000000000 -0500
809
+	    while (pad--)
1836
--- mutt-1.5.23/PATCHES	2014-04-12 12:36:35.000000000 -0500
810
+	    {
1837
***************
811
+	      memcpy (wptr, src, pl);
1838
*** 0 ****
812
+	      wptr += pl;
1839
--- 1 ----
813
+	      wlen += pl;
1840
+ patch-1.5.23.sidebar.20140412.txt
814
+	      col += pw;
1841
*** mutt-1.5.23-orig/protos.h	2014-03-12 11:06:17.000000000 -0500
815
+	    }
1842
--- mutt-1.5.23/protos.h	2014-04-11 10:14:01.000000000 -0500
816
+	  }
1843
***************
817
+	  else if (soft && pad < 0)
1844
*** 36,41 ****
818
+	  {
1845
--- 36,48 ----
819
+	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
1846
    const char *pager_progress;
820
+	    *wptr = 0;
1847
  };
821
+	    /* make sure right part is at most as wide as display */
1848
  
822
+	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
1849
+ struct sidebar_entry {
823
+	    /* truncate left so that right part fits completely in */
1850
+     char                box[SHORT_STRING];
824
+	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
1851
+     unsigned int        size;
825
+	    wptr = dest + wlen;
1852
+     unsigned int        new;
826
+	  }
1853
+     unsigned int        flagged;
827
+	  if (len + wlen > destlen)
1854
+ };
828
+	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
1855
+ 
829
+	  memcpy (wptr, buf, len);
1856
  void mutt_make_string_info (char *, size_t, const char *, struct hdr_format_info *, format_flag);
830
+	  wptr += len;
1857
  
831
+	  wlen += len;
1858
  int mutt_extract_token (BUFFER *, BUFFER *, int);
832
+	  col += wid;
1859
*** mutt-1.5.23-orig/sidebar.c	1969-12-31 18:00:00.000000000 -0600
833
+	  src += pl;
1860
--- mutt-1.5.23/sidebar.c	2014-04-11 10:14:01.000000000 -0500
834
+	}
1861
***************
835
+        }
1862
*** 0 ****
836
 	break; /* skip rest of input */
1863
--- 1,405 ----
837
       }
1864
+ /*
838
       else if (ch == '|')
1865
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
839
diff -uNp -r mutt-1.5.22.orig/mx.c mutt-1.5.22/mx.c
1866
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
840
--- mutt-1.5.22.orig/mx.c	Fri Oct 18 05:48:24 2013
1867
+  * 
841
+++ mutt-1.5.22/mx.c	Fri Oct 18 10:18:45 2013
1868
+  *     This program is free software; you can redistribute it and/or modify
842
@@ -580,6 +580,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int f
1869
+  *     it under the terms of the GNU General Public License as published by
843
  *		M_APPEND	open mailbox for appending
1870
+  *     the Free Software Foundation; either version 2 of the License, or
844
  *		M_READONLY	open mailbox in read-only mode
1871
+  *     (at your option) any later version.
845
  *		M_QUIET		only print error messages
1872
+  * 
846
+ *		M_PEEK		revert atime where applicable
1873
+  *     This program is distributed in the hope that it will be useful,
847
  *	ctx	if non-null, context struct to use
1874
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
848
  */
1875
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
849
 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
1876
+  *     GNU General Public License for more details.
850
@@ -602,6 +603,8 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
1877
+  * 
851
     ctx->quiet = 1;
1878
+  *     You should have received a copy of the GNU General Public License
852
   if (flags & M_READONLY)
1879
+  *     along with this program; if not, write to the Free Software
853
     ctx->readonly = 1;
1880
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
854
+  if (flags & M_PEEK)
1881
+  */ 
855
+    ctx->peekonly = 1;
1882
+ 
856
 
1883
+ 
857
   if (flags & (M_APPEND|M_NEWFOLDER))
1884
+ #if HAVE_CONFIG_H
858
   {
1885
+ # include "config.h"
859
@@ -701,9 +704,21 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
1886
+ #endif
860
 void mx_fastclose_mailbox (CONTEXT *ctx)
1887
+ 
861
 {
1888
+ #include "mutt.h"
862
   int i;
1889
+ #include "mutt_menu.h"
863
+#ifndef BUFFY_SIZE
1890
+ #include "mutt_curses.h"
864
+  struct utimbuf ut;
1891
+ #include "sidebar.h"
865
+#endif
1892
+ #include "buffy.h"
866
 
1893
+ #include <libgen.h>
867
   if(!ctx) 
1894
+ #include "keymap.h"
868
     return;
1895
+ #include <stdbool.h>
869
+#ifndef BUFFY_SIZE
1896
+ 
870
+  /* fix up the times so buffy won't get confused */
1897
+ /*BUFFY *CurBuffy = 0;*/
871
+  if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
1898
+ static BUFFY *TopBuffy = 0;
872
+  {
1899
+ static BUFFY *BottomBuffy = 0;
873
+    ut.actime = ctx->atime;
1900
+ static int known_lines = 0;
874
+    ut.modtime = ctx->mtime;
1901
+ 
875
+    utime (ctx->path, &ut); 
1902
+ void calc_boundaries() {
876
+  }
1903
+ 
877
+#endif
1904
+     BUFFY *tmp = Incoming;
878
 
1905
+ 
879
   /* never announce that a mailbox we've just left has new mail. #3290
1906
+ 	int count = LINES - 2 - (option(OPTHELP) ? 1 : 0);
880
    * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
1907
+ 
881
diff -uNp -r mutt-1.5.22.orig/mx.h mutt-1.5.22/mx.h
1908
+ 	if ( known_lines != LINES ) {
882
--- mutt-1.5.22.orig/mx.h	Mon Apr 22 07:14:53 2013
1909
+ 		TopBuffy = BottomBuffy = 0;
883
+++ mutt-1.5.22/mx.h	Fri Oct 18 10:18:45 2013
1910
+ 		known_lines = LINES;
884
@@ -57,6 +57,7 @@ void mbox_reset_atime (CONTEXT *, struct stat *);
1911
+ 	}
885
 int mh_read_dir (CONTEXT *, const char *);
1912
+ 	for ( ; tmp->next != 0; tmp = tmp->next )
886
 int mh_sync_mailbox (CONTEXT *, int *);
1913
+ 		tmp->next->prev = tmp;
887
 int mh_check_mailbox (CONTEXT *, int *);
1914
+ 
888
+void mh_buffy_update (const char *, int *, int *, int *);
1915
+ 	if ( TopBuffy == 0 && BottomBuffy == 0 )
889
 int mh_check_empty (const char *);
1916
+ 		TopBuffy = Incoming;
890
 
1917
+ 	if ( BottomBuffy == 0 ) {
891
 int maildir_read_dir (CONTEXT *);
1918
+ 		BottomBuffy = TopBuffy;
892
diff -uNp -r mutt-1.5.22.orig/pager.c mutt-1.5.22/pager.c
1919
+ 		while ( --count && BottomBuffy->next )
893
--- mutt-1.5.22.orig/pager.c	Mon Apr 22 07:17:32 2013
1920
+ 			BottomBuffy = BottomBuffy->next;
894
+++ mutt-1.5.22/pager.c	Fri Oct 18 10:18:45 2013
1921
+ 	}
895
@@ -29,6 +29,7 @@
1922
+ 	else if ( TopBuffy == CurBuffy->next ) {
896
 #include "pager.h"
1923
+ 		BottomBuffy = CurBuffy;
897
 #include "attach.h"
1924
+ 		tmp = BottomBuffy;
898
 #include "mbyte.h"
1925
+ 		while ( --count && tmp->prev)
899
+#include "sidebar.h"
1926
+ 			tmp = tmp->prev;
900
 
1927
+ 		TopBuffy = tmp;
901
 #include "mutt_crypt.h"
1928
+ 	}
902
 
1929
+ 	else if ( BottomBuffy == CurBuffy->prev ) {
903
@@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int 
1930
+ 		TopBuffy = CurBuffy;
904
   wchar_t wc;
1931
+ 		tmp = TopBuffy;
905
   mbstate_t mbstate;
1932
+ 		while ( --count && tmp->next )
906
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
1933
+ 			tmp = tmp->next;
907
+  wrap_cols -= SidebarWidth;
1934
+ 		BottomBuffy = tmp;
908
 
1935
+ 	}
909
   if (check_attachment_marker ((char *)buf) == 0)
1936
+ }
910
     wrap_cols = COLS;
1937
+ 
911
@@ -1746,7 +1748,7 @@ mutt_pager (const char *banner, const char *fname, int
1938
+ static const char *
912
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
1939
+ sidebar_format_str (char *dest,
913
     {
1940
+ 			size_t destlen,
914
       do {
1941
+ 			size_t col,
915
-	move (bodyoffset, 0);
1942
+ 			char op,
916
+	move (bodyoffset, SidebarWidth);
1943
+ 			const char *src,
917
 	curline = oldtopline = topline;
1944
+ 			const char *prefix,
918
 	lines = 0;
1945
+ 			const char *ifstring,
919
 	force_redraw = 0;
1946
+ 			const char *elsestring,
920
@@ -1759,6 +1761,7 @@ mutt_pager (const char *banner, const char *fname, int
1947
+ 			unsigned long data,
921
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
1948
+ 			format_flag flags)
922
 	    lines++;
1949
+ {
923
 	  curline++;
1950
+ /* casting from unsigned long - srsly?! */
924
+  	  move(lines + bodyoffset, SidebarWidth);
1951
+ struct sidebar_entry *sbe = (struct sidebar_entry *) data;
925
 	}
1952
+ unsigned int optional;
926
 	last_offset = lineInfo[curline].offset;
1953
+ char fmt[SHORT_STRING], buf[SHORT_STRING];
927
       } while (force_redraw);
1954
+ 
928
@@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int
1955
+ optional = flags & M_FORMAT_OPTIONAL;
929
 	  addch ('~');
1956
+ 
930
 	addch ('\n');
1957
+ switch(op) {
931
 	lines++;
1958
+ 	case 'F':
932
+  	move(lines + bodyoffset, SidebarWidth);
1959
+ 		if(!optional) {
933
       }
1960
+ 			snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
934
       NORMAL_COLOR;
1961
+ 			snprintf (dest, destlen, fmt, sbe->flagged);
935
 
1962
+ 		} else if(sbe->flagged == 0) {
936
@@ -1799,17 +1803,17 @@ mutt_pager (const char *banner, const char *fname, int
1963
+ 			optional = 0;
937
 
1964
+ 		}
938
       if (IsHeader (extra) || IsMsgAttach (extra))
1965
+ 		break;
939
       {
1966
+ 
940
-	size_t l1 = COLS * MB_LEN_MAX;
1967
+ 	case '!':
941
+	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
1968
+ 		if(sbe->flagged == 0)
942
 	size_t l2 = sizeof (buffer);
1969
+ 			mutt_format_s(dest, destlen, prefix, "");
943
 	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1970
+ 		if(sbe->flagged == 1)
944
 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1971
+ 			mutt_format_s(dest, destlen, prefix, "!");
945
-	mutt_paddstr (COLS, buffer);
1972
+ 		if(sbe->flagged == 2)
946
+	mutt_paddstr (COLS-SidebarWidth, buffer);
1973
+ 			mutt_format_s(dest, destlen, prefix, "!!");
947
       }
1974
+ 		if(sbe->flagged > 2) {
948
       else
1975
+ 			snprintf (buf, sizeof (buf), "%d!", sbe->flagged);
949
       {
1976
+ 			mutt_format_s(dest, destlen, prefix, buf);
950
 	char bn[STRING];
1977
+ 		}
951
 	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1978
+ 		break;
952
-	mutt_paddstr (COLS, bn);
1979
+ 
953
+	mutt_paddstr (COLS-SidebarWidth, bn);
1980
+ 	case 'S':
954
       }
1981
+ 		snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
955
       NORMAL_COLOR;
1982
+ 		snprintf (dest, destlen, fmt, sbe->size);
956
     }
1983
+ 		break;
957
@@ -1819,16 +1823,21 @@ mutt_pager (const char *banner, const char *fname, int
1984
+ 
958
       /* redraw the pager_index indicator, because the
1985
+ 	case 'N':
959
        * flags for this message might have changed. */
1986
+ 		if(!optional) {
960
       menu_redraw_current (index);
1987
+ 			snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
961
+      draw_sidebar(MENU_PAGER);
1988
+ 			snprintf (dest, destlen, fmt, sbe->new);
962
 
1989
+ 		} else if(sbe->new == 0) {
963
       /* print out the index status bar */
1990
+ 			optional = 0;
964
       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
1991
+ 		}
965
  
1992
+ 		break;
966
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
1993
+ 
967
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
1994
+ 	case 'B':
968
       SETCOLOR (MT_COLOR_STATUS);
1995
+ 		mutt_format_s(dest, destlen, prefix, sbe->box);
969
-      mutt_paddstr (COLS, buffer);
1996
+ 		break;
970
+      mutt_paddstr (COLS-SidebarWidth, buffer);
1997
+ 	}
971
       NORMAL_COLOR;
1998
+ 
972
     }
1999
+ 	if(optional)
973
 
2000
+ 		mutt_FormatString (dest, destlen, col, ifstring, sidebar_format_str, (unsigned long) sbe, flags);
974
+    /* if we're not using the index, update every time */
2001
+ 	else if (flags & M_FORMAT_OPTIONAL)
975
+    if ( index == 0 )
2002
+ 		mutt_FormatString (dest, destlen, col, elsestring, sidebar_format_str, (unsigned long) sbe, flags);
976
+      draw_sidebar(MENU_PAGER);
2003
+ 
977
+
2004
+ 	return (src);
978
     redraw = 0;
2005
+ }
979
 
2006
+ 
980
     if (option(OPTBRAILLEFRIENDLY)) {
2007
+ char *make_sidebar_entry(char *box, unsigned int size, unsigned int new, unsigned int flagged) {
981
@@ -2762,6 +2771,13 @@ search_next:
2008
+     static char *entry = 0;
982
       case OP_WHAT_KEY:
2009
+     struct sidebar_entry sbe;
983
 	mutt_what_key ();
2010
+     int SBvisual;
984
 	break;
2011
+ 
985
+
2012
+     SBvisual = SidebarWidth - strlen(SidebarDelim);
986
+      case OP_SIDEBAR_SCROLL_UP:
2013
+     if (SBvisual < 1)
987
+      case OP_SIDEBAR_SCROLL_DOWN:
2014
+         return NULL;
988
+      case OP_SIDEBAR_NEXT:
2015
+ 
989
+      case OP_SIDEBAR_PREV:
2016
+     sbe.new = new;
990
+	scroll_sidebar(ch, MENU_PAGER);
2017
+     sbe.flagged = flagged;
991
+ 	break;
2018
+     sbe.size = size;
992
 
2019
+     strncpy(sbe.box, box, 31);
993
       default:
2020
+ 
994
 	ch = -1;
2021
+     safe_realloc(&entry, SBvisual + 2);
995
diff -uNp -r mutt-1.5.22.orig/sidebar.c mutt-1.5.22/sidebar.c
2022
+     entry[SBvisual + 1] = '\0';
996
--- mutt-1.5.22.orig/sidebar.c	Thu Jan  1 01:00:00 1970
2023
+ 
997
+++ mutt-1.5.22/sidebar.c	Fri Oct 18 10:18:45 2013
2024
+     mutt_FormatString (entry, SBvisual+1, 0, SidebarFormat, sidebar_format_str, (unsigned long) &sbe, 0);
998
@@ -0,0 +1,333 @@
2025
+ 
999
+/*
2026
+     return entry;
1000
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
2027
+ }
1001
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
2028
+ 
1002
+ * 
2029
+ void set_curbuffy(char buf[LONG_STRING])
1003
+ *     This program is free software; you can redistribute it and/or modify
2030
+ {
1004
+ *     it under the terms of the GNU General Public License as published by
2031
+   BUFFY* tmp = CurBuffy = Incoming;
1005
+ *     the Free Software Foundation; either version 2 of the License, or
2032
+ 
1006
+ *     (at your option) any later version.
2033
+   if (!Incoming)
1007
+ * 
2034
+     return;
1008
+ *     This program is distributed in the hope that it will be useful,
2035
+ 
1009
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
2036
+   while(1) {
1010
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2037
+     if(!strcmp(tmp->path, buf) || !strcmp(tmp->realpath, buf)) {
1011
+ *     GNU General Public License for more details.
2038
+       CurBuffy = tmp;
1012
+ * 
2039
+       break;
1013
+ *     You should have received a copy of the GNU General Public License
2040
+     }
1014
+ *     along with this program; if not, write to the Free Software
2041
+ 
1015
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
2042
+     if(tmp->next)
1016
+ */ 
2043
+       tmp = tmp->next;
1017
+
2044
+     else
1018
+
2045
+       break;
1019
+#if HAVE_CONFIG_H
2046
+   }
1020
+# include "config.h"
2047
+ }
1021
+#endif
2048
+ 
1022
+
2049
+ int draw_sidebar(int menu) {
1023
+#include "mutt.h"
2050
+ 
1024
+#include "mutt_menu.h"
2051
+ 	BUFFY *tmp;
1025
+#include "mutt_curses.h"
2052
+ #ifndef USE_SLANG_CURSES
1026
+#include "sidebar.h"
2053
+         attr_t attrs;
1027
+#include "buffy.h"
2054
+ #endif
1028
+#include <libgen.h>
2055
+         short delim_len = strlen(SidebarDelim);
1029
+#include "keymap.h"
2056
+         short color_pair;
1030
+#include <stdbool.h>
2057
+ 
1031
+
2058
+         static bool initialized = false;
1032
+/*BUFFY *CurBuffy = 0;*/
2059
+         static int prev_show_value;
1033
+static BUFFY *TopBuffy = 0;
2060
+         static short saveSidebarWidth;
1034
+static BUFFY *BottomBuffy = 0;
2061
+         int lines = 0;
1035
+static int known_lines = 0;
2062
+         int SidebarHeight;
1036
+
2063
+         
1037
+static int quick_log10(int n)
2064
+         if(option(OPTSTATUSONTOP) || option(OPTHELP))
1038
+{
2065
+                 lines++; /* either one will occupy the first line */
1039
+        char string[32];
2066
+ 
1040
+        sprintf(string, "%d", n);
2067
+         /* initialize first time */
1041
+        return strlen(string);
2068
+         if(!initialized) {
1042
+}
2069
+                 prev_show_value = option(OPTSIDEBAR);
1043
+
2070
+                 saveSidebarWidth = SidebarWidth;
1044
+void calc_boundaries (int menu)
2071
+                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1045
+{
2072
+                 initialized = true;
1046
+	BUFFY *tmp = Incoming;
2073
+         }
1047
+
2074
+ 
1048
+	if ( known_lines != LINES ) {
2075
+         /* save or restore the value SidebarWidth */
1049
+		TopBuffy = BottomBuffy = 0;
2076
+         if(prev_show_value != option(OPTSIDEBAR)) {
1050
+		known_lines = LINES;
2077
+                 if(prev_show_value && !option(OPTSIDEBAR)) {
1051
+	}
2078
+                         saveSidebarWidth = SidebarWidth;
1052
+	for ( ; tmp->next != 0; tmp = tmp->next )
2079
+                         SidebarWidth = 0;
1053
+		tmp->next->prev = tmp;
2080
+                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
1054
+
2081
+                         mutt_buffy_check(1); /* we probably have bad or no numbers */
1055
+	if ( TopBuffy == 0 && BottomBuffy == 0 )
2082
+                         SidebarWidth = saveSidebarWidth;
1056
+		TopBuffy = Incoming;
2083
+                 }
1057
+	if ( BottomBuffy == 0 ) {
2084
+                 prev_show_value = option(OPTSIDEBAR);
1058
+		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
2085
+         }
1059
+		BottomBuffy = TopBuffy;
2086
+ 
1060
+		while ( --count && BottomBuffy->next )
2087
+ 
1061
+			BottomBuffy = BottomBuffy->next;
2088
+ /*	if ( SidebarWidth == 0 ) return 0; */
1062
+	}
2089
+        if (SidebarWidth > 0 && option (OPTSIDEBAR)
1063
+	else if ( TopBuffy == CurBuffy->next ) {
2090
+            && delim_len >= SidebarWidth) {
1064
+		int count = LINES - 2 - (menu != MENU_PAGER);
2091
+          unset_option (OPTSIDEBAR);
1065
+		BottomBuffy = CurBuffy;
2092
+          /* saveSidebarWidth = SidebarWidth; */
1066
+		tmp = BottomBuffy;
2093
+          if (saveSidebarWidth > delim_len) {
1067
+		while ( --count && tmp->prev)
2094
+            SidebarWidth = saveSidebarWidth;
1068
+			tmp = tmp->prev;
2095
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1069
+		TopBuffy = tmp;
2096
+            sleep (2);
1070
+	}
1071
+	else if ( BottomBuffy == CurBuffy->prev ) {
1072
+		int count = LINES - 2 - (menu != MENU_PAGER);
1073
+		TopBuffy = CurBuffy;
1074
+		tmp = TopBuffy;
1075
+		while ( --count && tmp->next )
1076
+			tmp = tmp->next;
1077
+		BottomBuffy = tmp;
1078
+	}
1079
+}
1080
+
1081
+char *make_sidebar_entry(char *box, int size, int new, int flagged)
1082
+{
1083
+	static char *entry = 0;
1084
+	char *c;
1085
+	int i = 0;
1086
+	int delim_len = strlen(SidebarDelim);
1087
+
1088
+	c = realloc(entry, SidebarWidth - delim_len + 2);
1089
+	if ( c ) entry = c;
1090
+	entry[SidebarWidth - delim_len + 1] = 0;
1091
+	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1092
+	i = strlen(box);
1093
+	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1094
+
1095
+        if (size == -1)
1096
+                sprintf(entry + SidebarWidth - delim_len - 3, "?");
1097
+        else if ( new ) {
1098
+          if (flagged > 0) {
1099
+              sprintf(
1100
+		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1101
+		        "% d(%d)[%d]", size, new, flagged);
1102
+          } else {
2097
+          } else {
1103
+              sprintf(
2098
+            SidebarWidth = 0;
1104
+                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
2099
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1105
+                      "% d(%d)", size, new);
2100
+            sleep (4); /* the advise to set a sane value should be seen long enough */
1106
+          }
2101
+          }
1107
+        } else if (flagged > 0) {
2102
+          saveSidebarWidth = 0;
1108
+              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
2103
+          return (0);
1109
+        } else {
1110
+              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1111
+        }
1112
+	return entry;
1113
+}
1114
+
1115
+void set_curbuffy(char buf[LONG_STRING])
1116
+{
1117
+  BUFFY* tmp = CurBuffy = Incoming;
1118
+
1119
+  if (!Incoming)
1120
+    return;
1121
+
1122
+  while(1) {
1123
+    if(!strcmp(tmp->path, buf)) {
1124
+      CurBuffy = tmp;
1125
+      break;
1126
+    }
1127
+
1128
+    if(tmp->next)
1129
+      tmp = tmp->next;
1130
+    else
1131
+      break;
1132
+  }
1133
+}
1134
+
1135
+int draw_sidebar(int menu) {
1136
+
1137
+	int lines = option(OPTHELP) ? 1 : 0;
1138
+	BUFFY *tmp;
1139
+#ifndef USE_SLANG_CURSES
1140
+        attr_t attrs;
1141
+#endif
1142
+        short delim_len = strlen(SidebarDelim);
1143
+        short color_pair;
1144
+
1145
+        static bool initialized = false;
1146
+        static int prev_show_value;
1147
+        static short saveSidebarWidth;
1148
+
1149
+        /* initialize first time */
1150
+        if(!initialized) {
1151
+                prev_show_value = option(OPTSIDEBAR);
1152
+                saveSidebarWidth = SidebarWidth;
1153
+                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1154
+                initialized = true;
1155
+        }
2104
+        }
1156
+
2105
+ 
1157
+        /* save or restore the value SidebarWidth */
2106
+     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1158
+        if(prev_show_value != option(OPTSIDEBAR)) {
2107
+       if (SidebarWidth > 0) {
1159
+                if(prev_show_value && !option(OPTSIDEBAR)) {
2108
+         saveSidebarWidth = SidebarWidth;
1160
+                        saveSidebarWidth = SidebarWidth;
2109
+         SidebarWidth = 0;
1161
+                        SidebarWidth = 0;
1162
+                } else if(!prev_show_value && option(OPTSIDEBAR)) {
1163
+                        SidebarWidth = saveSidebarWidth;
1164
+                }
1165
+                prev_show_value = option(OPTSIDEBAR);
1166
+        }
1167
+
1168
+
1169
+//	if ( SidebarWidth == 0 ) return 0;
1170
+       if (SidebarWidth > 0 && option (OPTSIDEBAR)
1171
+           && delim_len >= SidebarWidth) {
1172
+         unset_option (OPTSIDEBAR);
1173
+         /* saveSidebarWidth = SidebarWidth; */
1174
+         if (saveSidebarWidth > delim_len) {
1175
+           SidebarWidth = saveSidebarWidth;
1176
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1177
+           sleep (2);
1178
+         } else {
1179
+           SidebarWidth = 0;
1180
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1181
+           sleep (4); /* the advise to set a sane value should be seen long enough */
1182
+         }
1183
+         saveSidebarWidth = 0;
1184
+         return (0);
1185
+       }
2110
+       }
1186
+
2111
+       unset_option(OPTSIDEBAR);
1187
+    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
2112
+       return 0;
1188
+      if (SidebarWidth > 0) {
2113
+     }
1189
+        saveSidebarWidth = SidebarWidth;
2114
+ 
1190
+        SidebarWidth = 0;
2115
+         /* get attributes for divider */
1191
+      }
2116
+ 	SETCOLOR(MT_COLOR_STATUS);
1192
+      unset_option(OPTSIDEBAR);
2117
+ #ifndef USE_SLANG_CURSES
1193
+      return 0;
2118
+         attr_get(&attrs, &color_pair, 0);
1194
+    }
2119
+ #else
1195
+
2120
+         color_pair = attr_get();
1196
+        /* get attributes for divider */
2121
+ #endif
1197
+	SETCOLOR(MT_COLOR_STATUS);
2122
+ 	SETCOLOR(MT_COLOR_NORMAL);
1198
+#ifndef USE_SLANG_CURSES
2123
+ 
1199
+        attr_get(&attrs, &color_pair, 0);
2124
+ 	/* draw the divider */
1200
+#else
2125
+ 
1201
+        color_pair = attr_get();
2126
+ 	SidebarHeight =  LINES - 1;
1202
+#endif
2127
+ 	if(option(OPTHELP) || !option(OPTSTATUSONTOP))
1203
+	SETCOLOR(MT_COLOR_NORMAL);
2128
+ 		SidebarHeight--;
1204
+
2129
+ 
1205
+	/* draw the divider */
2130
+ 	for ( ; lines < SidebarHeight; lines++ ) {
1206
+
2131
+ 		move(lines, SidebarWidth - delim_len);
1207
+	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
2132
+ 		addstr(NONULL(SidebarDelim));
1208
+		move(lines, SidebarWidth - delim_len);
2133
+ #ifndef USE_SLANG_CURSES
1209
+		addstr(NONULL(SidebarDelim));
2134
+                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1210
+#ifndef USE_SLANG_CURSES
2135
+ #endif
1211
+                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
2136
+ 	}
1212
+#endif
2137
+ 
1213
+	}
2138
+ 	if ( Incoming == 0 ) return 0;
1214
+
2139
+         lines = 0;
1215
+	if ( Incoming == 0 ) return 0;
2140
+         if(option(OPTSTATUSONTOP) || option(OPTHELP))
1216
+	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
2141
+                 lines++; /* either one will occupy the first line */
1217
+
2142
+ 
1218
+	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
2143
+ 	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1219
+		calc_boundaries(menu);
2144
+ 		calc_boundaries(menu);
1220
+	if ( CurBuffy == 0 ) CurBuffy = Incoming;
2145
+ 	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1221
+
2146
+ 
1222
+	tmp = TopBuffy;
2147
+ 	tmp = TopBuffy;
1223
+
2148
+ 
1224
+	SETCOLOR(MT_COLOR_NORMAL);
2149
+ 	SETCOLOR(MT_COLOR_NORMAL);
1225
+
2150
+ 
1226
+	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
2151
+ 	for ( ; tmp && lines < SidebarHeight; tmp = tmp->next ) {
1227
+		if ( tmp == CurBuffy )
2152
+ 		if ( tmp == CurBuffy )
1228
+			SETCOLOR(MT_COLOR_INDICATOR);
2153
+ 			SETCOLOR(MT_COLOR_INDICATOR);
1229
+		else if ( tmp->msg_unread > 0 )
2154
+ 		else if ( tmp->msg_unread > 0 )
1230
+			SETCOLOR(MT_COLOR_NEW);
2155
+ 			SETCOLOR(MT_COLOR_NEW);
1231
+		else if ( tmp->msg_flagged > 0 )
2156
+ 		else if ( tmp->msg_flagged > 0 )
1232
+		        SETCOLOR(MT_COLOR_FLAGGED);
2157
+ 		        SETCOLOR(MT_COLOR_FLAGGED);
1233
+		else
2158
+ 		else
1234
+			SETCOLOR(MT_COLOR_NORMAL);
2159
+ 			SETCOLOR(MT_COLOR_NORMAL);
1235
+
2160
+ 
1236
+		move( lines, 0 );
2161
+ 		move( lines, 0 );
1237
+		if ( Context && !strcmp( tmp->path, Context->path ) ) {
2162
+ 		if ( Context && (!strcmp(tmp->path, Context->path)||
1238
+			tmp->msg_unread = Context->unread;
2163
+ 				 !strcmp(tmp->realpath, Context->path)) ) {
1239
+			tmp->msgcount = Context->msgcount;
2164
+ 			tmp->msg_unread = Context->unread;
1240
+			tmp->msg_flagged = Context->flagged;
2165
+ 			tmp->msgcount = Context->msgcount;
1241
+		}
2166
+ 			tmp->msg_flagged = Context->flagged;
1242
+		// check whether Maildir is a prefix of the current folder's path
2167
+ 		}
1243
+		short maildir_is_prefix = 0;
2168
+ 		/* check whether Maildir is a prefix of the current folder's path */
1244
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
2169
+ 		short maildir_is_prefix = 0;
1245
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
2170
+ 		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1246
+        		maildir_is_prefix = 1;
2171
+ 			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1247
+		// calculate depth of current folder and generate its display name with indented spaces
2172
+         		maildir_is_prefix = 1;
1248
+		int sidebar_folder_depth = 0;
2173
+ 		/* calculate depth of current folder and generate its display name with indented spaces */
1249
+		char *sidebar_folder_name;
2174
+ 		int sidebar_folder_depth = 0;
1250
+		sidebar_folder_name = basename(tmp->path);
2175
+ 		char *sidebar_folder_name;
1251
+		if ( maildir_is_prefix ) {
2176
+ 		sidebar_folder_name = option(OPTSIDEBARSHORTPATH) ? mutt_basename(tmp->path) : tmp->path + maildir_is_prefix*(strlen(Maildir) + 1);
1252
+			char *tmp_folder_name;
2177
+ 		if ( maildir_is_prefix && option(OPTSIDEBARFOLDERINDENT) ) {
1253
+			int i;
2178
+ 			char *tmp_folder_name;
1254
+			tmp_folder_name = tmp->path + strlen(Maildir);
2179
+ 			int i;
1255
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
2180
+ 			tmp_folder_name = tmp->path + strlen(Maildir) + 1;
1256
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
2181
+ 			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1257
+			}   
2182
+  				if (tmp_folder_name[i] == '/'  || tmp_folder_name[i] == '.') sidebar_folder_depth++;
1258
+			if (sidebar_folder_depth > 0) {
2183
+ 			}   
1259
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
2184
+ 			if (sidebar_folder_depth > 0) {
1260
+				for (i=0; i < sidebar_folder_depth; i++)
2185
+  				if (option(OPTSIDEBARSHORTPATH)) {
1261
+					sidebar_folder_name[i]=' ';
2186
+  					tmp_folder_name = strrchr(tmp->path, '.');
1262
+				sidebar_folder_name[i]=0;
2187
+  					if (tmp_folder_name == NULL)
1263
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
2188
+  						tmp_folder_name = mutt_basename(tmp->path);
1264
+			}
2189
+  					else
1265
+		}
2190
+ 						tmp_folder_name++;
1266
+		printw( "%.*s", SidebarWidth - delim_len + 1,
2191
+  				}
1267
+			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
2192
+  				else
1268
+			tmp->msg_unread, tmp->msg_flagged));
2193
+  					tmp_folder_name = tmp->path + strlen(Maildir) + 1;
1269
+		if (sidebar_folder_depth > 0)
2194
+  				sidebar_folder_name = malloc(strlen(tmp_folder_name) + sidebar_folder_depth*strlen(NONULL(SidebarIndentStr)) + 1);
1270
+		        free(sidebar_folder_name);
2195
+ 				sidebar_folder_name[0]=0;
1271
+		lines++;
2196
+ 				for (i=0; i < sidebar_folder_depth; i++)
1272
+	}
2197
+ 					strncat(sidebar_folder_name, NONULL(SidebarIndentStr), strlen(NONULL(SidebarIndentStr)));
1273
+	SETCOLOR(MT_COLOR_NORMAL);
2198
+ 				strncat(sidebar_folder_name, tmp_folder_name, strlen(tmp_folder_name));
1274
+	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
2199
+ 			}
1275
+		int i = 0;
2200
+ 		}
1276
+		move( lines, 0 );
2201
+ 		printw( "%.*s", SidebarWidth - delim_len + 1,
1277
+		for ( ; i < SidebarWidth - delim_len; i++ )
2202
+ 			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1278
+			addch(' ');
2203
+ 			tmp->msg_unread, tmp->msg_flagged));
1279
+	}
2204
+ 		if (sidebar_folder_depth > 0)
1280
+	return 0;
2205
+ 		        free(sidebar_folder_name);
1281
+}
2206
+ 		lines++;
1282
+
2207
+ 	}
1283
+
2208
+ 	SETCOLOR(MT_COLOR_NORMAL);
1284
+void set_buffystats(CONTEXT* Context)
2209
+ 	for ( ; lines < SidebarHeight; lines++ ) {
1285
+{
2210
+ 		int i = 0;
1286
+        BUFFY *tmp = Incoming;
2211
+ 		move( lines, 0 );
1287
+        while(tmp) {
2212
+ 		for ( ; i < SidebarWidth - delim_len; i++ )
1288
+                if(Context && !strcmp(tmp->path, Context->path)) {
2213
+ 			addch(' ');
1289
+			tmp->msg_unread = Context->unread;
2214
+ 	}
1290
+			tmp->msgcount = Context->msgcount;
2215
+ 	return 0;
1291
+                        break;
2216
+ }
1292
+                }
2217
+ 
1293
+                tmp = tmp->next;
2218
+ 
1294
+        }
2219
+ void set_buffystats(CONTEXT* Context)
1295
+}
2220
+ {
1296
+
2221
+         BUFFY *tmp = Incoming;
1297
+void scroll_sidebar(int op, int menu)
2222
+         while(tmp) {
1298
+{
2223
+                 if(Context && (!strcmp(tmp->path, Context->path) ||
1299
+        if(!SidebarWidth) return;
2224
+                                !strcmp(tmp->realpath, Context->path))) {
1300
+        if(!CurBuffy) return;
2225
+ 			tmp->msg_unread = Context->unread;
1301
+
2226
+ 			tmp->msgcount = Context->msgcount;
1302
+	switch (op) {
2227
+ 			tmp->msg_flagged = Context->flagged;
1303
+		case OP_SIDEBAR_NEXT:
2228
+                         break;
1304
+			if ( CurBuffy->next == NULL ) return;
2229
+                 }
1305
+			CurBuffy = CurBuffy->next;
2230
+                 tmp = tmp->next;
1306
+			break;
2231
+         }
1307
+		case OP_SIDEBAR_PREV:
2232
+ }
1308
+			if ( CurBuffy->prev == NULL ) return;
2233
+ 
1309
+			CurBuffy = CurBuffy->prev;
2234
+ void scroll_sidebar(int op, int menu)
1310
+			break;
2235
+ {
1311
+		case OP_SIDEBAR_SCROLL_UP:
2236
+         if(!SidebarWidth) return;
1312
+			CurBuffy = TopBuffy;
2237
+         if(!CurBuffy) return;
1313
+			if ( CurBuffy != Incoming ) {
2238
+ 
1314
+				calc_boundaries(menu);
2239
+ 	switch (op) {
1315
+				CurBuffy = CurBuffy->prev;
2240
+ 		case OP_SIDEBAR_NEXT:
1316
+			}
2241
+ 			if ( CurBuffy->next == NULL ) return;
1317
+			break;
2242
+ 			CurBuffy = CurBuffy->next;
1318
+		case OP_SIDEBAR_SCROLL_DOWN:
2243
+ 			break;
1319
+			CurBuffy = BottomBuffy;
2244
+ 		case OP_SIDEBAR_PREV:
1320
+			if ( CurBuffy->next ) {
2245
+ 			if ( CurBuffy->prev == NULL ) return;
1321
+				calc_boundaries(menu);
2246
+ 			CurBuffy = CurBuffy->prev;
1322
+				CurBuffy = CurBuffy->next;
2247
+ 			break;
1323
+			}
2248
+ 		case OP_SIDEBAR_SCROLL_UP:
1324
+			break;
2249
+ 			CurBuffy = TopBuffy;
1325
+		default:
2250
+ 			if ( CurBuffy != Incoming ) {
1326
+			return;
2251
+ 				calc_boundaries(menu);
1327
+	}
2252
+ 				CurBuffy = CurBuffy->prev;
1328
+	calc_boundaries(menu);
2253
+ 			}
1329
+	draw_sidebar(menu);
2254
+ 			break;
1330
+}
2255
+ 		case OP_SIDEBAR_SCROLL_DOWN:
1331
+
2256
+ 			CurBuffy = BottomBuffy;
1332
diff -uNp -r mutt-1.5.22.orig/sidebar.h mutt-1.5.22/sidebar.h
2257
+ 			if ( CurBuffy->next ) {
1333
--- mutt-1.5.22.orig/sidebar.h	Thu Jan  1 01:00:00 1970
2258
+ 				calc_boundaries(menu);
1334
+++ mutt-1.5.22/sidebar.h	Fri Oct 18 10:18:45 2013
2259
+ 				CurBuffy = CurBuffy->next;
1335
@@ -0,0 +1,36 @@
2260
+ 			}
1336
+/*
2261
+ 			break;
1337
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
2262
+ 		default:
1338
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
2263
+ 			return;
1339
+ * 
2264
+ 	}
1340
+ *     This program is free software; you can redistribute it and/or modify
2265
+ 	calc_boundaries(menu);
1341
+ *     it under the terms of the GNU General Public License as published by
2266
+ 	draw_sidebar(menu);
1342
+ *     the Free Software Foundation; either version 2 of the License, or
2267
+ }
1343
+ *     (at your option) any later version.
2268
+ 
1344
+ * 
2269
*** mutt-1.5.23-orig/sidebar.h	1969-12-31 18:00:00.000000000 -0600
1345
+ *     This program is distributed in the hope that it will be useful,
2270
--- mutt-1.5.23/sidebar.h	2014-04-11 10:14:01.000000000 -0500
1346
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
2271
***************
1347
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2272
*** 0 ****
1348
+ *     GNU General Public License for more details.
2273
--- 1,36 ----
1349
+ * 
2274
+ /*
1350
+ *     You should have received a copy of the GNU General Public License
2275
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1351
+ *     along with this program; if not, write to the Free Software
2276
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1352
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
2277
+  * 
1353
+ */ 
2278
+  *     This program is free software; you can redistribute it and/or modify
1354
+
2279
+  *     it under the terms of the GNU General Public License as published by
1355
+#ifndef SIDEBAR_H
2280
+  *     the Free Software Foundation; either version 2 of the License, or
1356
+#define SIDEBAR_H
2281
+  *     (at your option) any later version.
1357
+
2282
+  * 
1358
+struct MBOX_LIST {
2283
+  *     This program is distributed in the hope that it will be useful,
1359
+	char *path;
2284
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1360
+	int msgcount;
2285
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1361
+	int new;
2286
+  *     GNU General Public License for more details.
1362
+} MBLIST;
2287
+  * 
1363
+
2288
+  *     You should have received a copy of the GNU General Public License
1364
+/* parameter is whether or not to go to the status line */
2289
+  *     along with this program; if not, write to the Free Software
1365
+/* used for omitting the last | that covers up the status bar in the index */
2290
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1366
+int draw_sidebar(int);
2291
+  */ 
1367
+void scroll_sidebar(int, int);
2292
+ 
1368
+void set_curbuffy(char*);
2293
+ #ifndef SIDEBAR_H
1369
+void set_buffystats(CONTEXT*);
2294
+ #define SIDEBAR_H
1370
+
2295
+ 
1371
+#endif /* SIDEBAR_H */
2296
+ struct MBOX_LIST {
1372
--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
2297
+ 	char *path;
1373
+++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
2298
+ 	int msgcount;
1374
@@ -34,7 +34,7 @@
2299
+ 	int new;
1375
 	score.c send.c sendlib.c signal.c sort.c \
2300
+ } MBLIST;
1376
 	status.c system.c thread.c charset.c history.c lib.c \
2301
+ 
1377
 	muttlib.c editmsg.c mbyte.c \
2302
+ /* parameter is whether or not to go to the status line */
1378
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
2303
+ /* used for omitting the last | that covers up the status bar in the index */
1379
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
2304
+ int draw_sidebar(int);
1380
 
2305
+ void scroll_sidebar(int, int);
1381
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
2306
+ void set_curbuffy(char*);
1382
 
2307
+ void set_buffystats(CONTEXT*);
1383
--- orig/Makefile.in.orig	2013-10-25 08:23:07.000000000 +0200
2308
+ 
1384
+++ new/Makefile.in	2013-10-25 08:26:20.000000000 +0200
2309
+ #endif /* SIDEBAR_H */
1385
@@ -133,7 +133,7 @@
2310
*** mutt-1.5.23-orig/doc/Muttrc	2014-03-12 11:27:11.000000000 -0500
1386
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
2311
--- mutt-1.5.23/doc/Muttrc	2014-04-11 10:14:01.000000000 -0500
1387
 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
1388
 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
1389
-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
1390
+	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
1391
 am__objects_1 =
1392
 am__objects_2 = patchlist.$(OBJEXT) conststrings.$(OBJEXT) \
1393
 	$(am__objects_1)
1394
@@ -472,7 +472,7 @@
1395
 	score.c send.c sendlib.c signal.c sort.c \
1396
 	status.c system.c thread.c charset.c history.c lib.c \
1397
 	muttlib.c editmsg.c mbyte.c \
1398
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1399
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
1400
 
1401
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
1402
 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
1403
@@ -504,7 +504,7 @@
1404
 	README.SSL smime.h group.h \
1405
 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
1406
 	ChangeLog mkchangelog.sh mutt_idna.h \
1407
-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \
1408
+	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in \
1409
 	txt2c.c txt2c.sh version.sh check_sec.sh
1410
 
1411
 EXTRA_SCRIPTS = smime_keys
1412
*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
1413
--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
1414
***************
2312
***************
1415
*** 657,662 ****
2313
*** 657,662 ****
1416
--- 657,682 ----
2314
--- 657,682 ----
Lines 1440-1442 Link Here
1440
  # set crypt_autosign=no
2338
  # set crypt_autosign=no
1441
  #
2339
  #
1442
  # Name: crypt_autosign
2340
  # Name: crypt_autosign
2341
*** mutt-1.5.23-orig/imap/imap.c	2014-03-12 11:03:45.000000000 -0500
2342
--- mutt-1.5.23/imap/imap.c	2014-04-11 10:14:01.000000000 -0500
2343
***************
2344
*** 1514,1520 ****
2345
  
2346
      imap_munge_mbox_name (munged, sizeof (munged), name);
2347
      snprintf (command, sizeof (command),
2348
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
2349
  
2350
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2351
      {
2352
--- 1514,1520 ----
2353
  
2354
      imap_munge_mbox_name (munged, sizeof (munged), name);
2355
      snprintf (command, sizeof (command),
2356
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
2357
  
2358
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2359
      {
2360
*** mutt-1.5.23-orig/imap/command.c	2014-03-12 11:03:45.000000000 -0500
2361
--- mutt-1.5.23/imap/command.c	2014-04-11 10:14:01.000000000 -0500
2362
***************
2363
*** 1012,1017 ****
2364
--- 1012,1024 ----
2365
  	     opened */
2366
  	  status->uidnext = oldun;
2367
  
2368
+         /* Added to make the sidebar show the correct numbers */
2369
+         if (status->messages)
2370
+         {
2371
+           inc->msgcount = status->messages;
2372
+           inc->msg_unread = status->unseen;
2373
+         }
2374
+ 
2375
          FREE (&value);
2376
          return;
2377
        }
(-)./files/extra-patch-sidebar-nntp (-1285 / +2122 lines)
Lines 1-226 Link Here
1
Based on Gentoo's updated version of the Mutt Sidebar patch,
1
Taken from http://lunar-linux.org/~tchan/mutt/patch-1.5.23.sidebar.20140412.txt
2
rebased to apply to pristine Mutt sources.
3
2
4
http://prefix.gentooexperimental.org:8000/mutt-patches/file/8117acc3edc0/sidebar.patch
5
6
diff -uNp -r mutt-1.5.22.orig/OPS mutt-1.5.22/OPS
7
--- mutt-1.5.22.orig/OPS	Tue Feb 23 06:57:28 2010
8
+++ mutt-1.5.22/OPS	Fri Oct 18 10:18:45 2013
9
@@ -179,3 +179,8 @@ OP_WHAT_KEY "display the keycode for a key press"
10
 OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
11
 OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
12
 OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
13
+OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
14
+OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
15
+OP_SIDEBAR_NEXT "go down to next mailbox"
16
+OP_SIDEBAR_PREV "go to previous mailbox"
17
+OP_SIDEBAR_OPEN "open hilighted mailbox"
18
diff -uNp -r mutt-1.5.22.orig/PATCHES mutt-1.5.22/PATCHES
19
--- mutt-1.5.22.orig/PATCHES	Sun Feb 21 05:51:26 2010
20
+++ mutt-1.5.22/PATCHES	Fri Oct 18 10:19:14 2013
21
@@ -0,0 +1 @@
22
+patch-1.5.22.sidebar.gentoo-openbsd
23
diff -uNp -r mutt-1.5.22.orig/buffy.c mutt-1.5.22/buffy.c
3
diff -uNp -r mutt-1.5.22.orig/buffy.c mutt-1.5.22/buffy.c
24
--- mutt-1.5.22.orig/buffy.c	Mon Apr 22 07:14:53 2013
4
*** mutt-1.5.23-orig/buffy.c	2014-03-12 11:03:44.000000000 -0500
25
+++ mutt-1.5.22/buffy.c	Fri Oct 18 10:18:45 2013
5
--- mutt-1.5.23/buffy.c	2014-04-12 15:33:54.000000000 -0500
26
@@ -161,6 +161,49 @@ void mutt_buffy_cleanup (const char *buf, struct stat 
6
***************
27
   }
7
*** 161,166 ****
28
 }
8
--- 161,209 ----
29
 
9
    }
30
+static int buffy_compare_name(const void *a, const void *b) {
10
  }
31
+  const BUFFY *b1 = * (BUFFY * const *) a;
11
  
32
+  const BUFFY *b2 = * (BUFFY * const *) b;
12
+ static int buffy_compare_name(const void *a, const void *b) {
33
+
13
+   const BUFFY *b1 = * (BUFFY * const *) a;
34
+  return mutt_strcoll(b1->path, b2->path);
14
+   const BUFFY *b2 = * (BUFFY * const *) b;
35
+}
15
+ 
36
+
16
+   return mutt_strcoll(b1->path, b2->path);
37
+static BUFFY *buffy_sort(BUFFY *b)
17
+ }
38
+{
18
+ 
39
+  BUFFY *tmp = b;
19
+ static BUFFY *buffy_sort(BUFFY *b)
40
+  int buffycount = 0;
20
+ {
41
+  BUFFY **ary;
21
+   BUFFY *tmp = b;
42
+  int i;
22
+   int buffycount = 0;
43
+
23
+   BUFFY **ary;
44
+  if (!option(OPTSIDEBARSORT))
24
+   int i;
45
+    return b;
25
+ 
46
+
26
+   if (!option(OPTSIDEBARSORT))
47
+  for (; tmp != NULL; tmp = tmp->next)
27
+     return b;
48
+    buffycount++;
28
+ 
49
+
29
+   for (; tmp != NULL; tmp = tmp->next)
50
+  ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
30
+     buffycount++;
51
+
31
+ 
52
+  tmp = b;
32
+   ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary));
53
+  for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
33
+ 
54
+    ary[i] = tmp;
34
+   tmp = b;
55
+  }
35
+   for (i = 0; tmp != NULL; tmp = tmp->next, i++) {
56
+
36
+     ary[i] = tmp;
57
+  qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
37
+   }
58
+
38
+ 
59
+  for (i = 0; i < buffycount - 1; i++) {
39
+   qsort(ary, buffycount, sizeof(*ary), buffy_compare_name);
60
+    ary[i]->next = ary[i+1];
40
+ 
61
+  }
41
+   for (i = 0; i < buffycount - 1; i++) {
62
+  ary[buffycount - 1]->next = NULL;
42
+     ary[i]->next = ary[i+1];
63
+  for (i = 1; i < buffycount; i++) {
43
+   }
64
+    ary[i]->prev = ary[i-1];
44
+   ary[buffycount - 1]->next = NULL;
65
+  }
45
+   for (i = 1; i < buffycount; i++) {
66
+  ary[0]->prev = NULL;
46
+     ary[i]->prev = ary[i-1];
67
+
47
+   }
68
+  tmp = ary[0];
48
+   ary[0]->prev = NULL;
69
+  free(ary);
49
+ 
70
+  return tmp;
50
+   tmp = ary[0];
71
+}
51
+   free(ary);
72
+
52
+   return tmp;
73
 BUFFY *mutt_find_mailbox (const char *path)
53
+ }
74
 {
54
+ 
75
   BUFFY *tmp = NULL;
55
  BUFFY *mutt_find_mailbox (const char *path)
76
@@ -282,6 +325,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, uns
56
  {
77
     else
57
    BUFFY *tmp = NULL;
78
       (*tmp)->size = 0;
58
***************
79
   }
59
*** 196,204 ****
80
+  Incoming = buffy_sort(Incoming);
60
--- 239,251 ----
81
   return 0;
61
  static BUFFY *buffy_new (const char *path)
82
 }
62
  {
83
 
63
    BUFFY* buffy;
84
@@ -340,6 +384,68 @@ static int buffy_maildir_hasnew (BUFFY* mailbox)
64
+   char rp[PATH_MAX];
85
   return rc;
65
+   char *r;
86
 }
66
  
87
 
67
    buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
88
+/* update message counts for the sidebar */
68
    strfcpy (buffy->path, path, sizeof (buffy->path));
89
+void buffy_maildir_update (BUFFY* mailbox)
69
+   r = realpath(path, rp);
90
+{
70
+   strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
91
+  char path[_POSIX_PATH_MAX];
71
    buffy->next = NULL;
92
+  DIR *dirp;
72
    buffy->magic = 0;
93
+  struct dirent *de;
73
  
94
+  char *p;
74
***************
95
+
75
*** 243,250 ****
96
+  mailbox->msgcount = 0;
76
      p = realpath (buf, f1);
97
+  mailbox->msg_unread = 0;
77
      for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
98
+  mailbox->msg_flagged = 0;
78
      {
99
+
79
!       q = realpath ((*tmp)->path, f2);
100
+  snprintf (path, sizeof (path), "%s/new", mailbox->path);
80
!       if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0)
101
+        
81
        {
102
+  if ((dirp = opendir (path)) == NULL)
82
  	dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
103
+  {   
83
  	break;
104
+    mailbox->magic = 0;
84
--- 290,297 ----
105
+    return;
85
      p = realpath (buf, f1);
106
+  } 
86
      for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next))
107
+      
87
      {
108
+  while ((de = readdir (dirp)) != NULL)
88
!       q = (*tmp)->realpath;
109
+  {
89
!       if (mutt_strcmp (p ? p : buf, q) == 0)
110
+    if (*de->d_name == '.')
90
        {
111
+      continue;
91
  	dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path));
112
+
92
  	break;
113
+    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
93
***************
114
+      mailbox->new = 1;
94
*** 282,287 ****
115
+      mailbox->msgcount++;
95
--- 329,335 ----
116
+      mailbox->msg_unread++;
96
      else
117
+    }
97
        (*tmp)->size = 0;
118
+  }
98
    }
119
+
99
+   Incoming = buffy_sort(Incoming);
120
+  closedir (dirp);
100
    return 0;
121
+  snprintf (path, sizeof (path), "%s/cur", mailbox->path);
101
  }
122
+        
102
  
123
+  if ((dirp = opendir (path)) == NULL)
103
***************
124
+  {   
104
*** 306,311 ****
125
+    mailbox->magic = 0;
105
--- 354,364 ----
126
+    return;
106
        return 0;
127
+  } 
107
    }
128
+      
108
  
129
+  while ((de = readdir (dirp)) != NULL)
109
+   if (option(OPTSIDEBAR) && mailbox->msg_unread > 0) {
130
+  {
110
+       mailbox->new = 1;
131
+    if (*de->d_name == '.')
111
+       return 1;
132
+      continue;
112
+   }
133
+
113
+ 
134
+    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
114
    if ((dirp = opendir (path)) == NULL)
135
+      mailbox->msgcount++;
115
    {
136
+      if ((p = strstr (de->d_name, ":2,"))) {
116
      mailbox->magic = 0;
137
+        if (!strchr (p + 3, 'T')) {
117
***************
138
+          if (!strchr (p + 3, 'S'))
118
*** 340,345 ****
139
+            mailbox->msg_unread++;
119
--- 393,464 ----
140
+          if (strchr(p + 3, 'F'))
120
    return rc;
141
+            mailbox->msg_flagged++;
121
  }
142
+        }
122
  
143
+      }
123
+ /* update message counts for the sidebar */
144
+    }
124
+ void buffy_maildir_update (BUFFY* mailbox)
145
+  }
125
+ {
146
+
126
+   char path[_POSIX_PATH_MAX];
147
+  closedir (dirp);
127
+   DIR *dirp;
148
+}
128
+   struct dirent *de;
149
+
129
+   char *p;
150
 /* returns 1 if mailbox has new mail */ 
130
+ 
151
 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
131
+   if(!option(OPTSIDEBAR))
152
 {
132
+       return;
153
@@ -371,6 +477,20 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct s
133
+ 
154
   return rc;
134
+   mailbox->msgcount = 0;
155
 }
135
+   mailbox->msg_unread = 0;
156
 
136
+   mailbox->msg_flagged = 0;
157
+/* update message counts for the sidebar */
137
+ 
158
+void buffy_mbox_update (BUFFY* mailbox)
138
+   snprintf (path, sizeof (path), "%s/new", mailbox->path);
159
+{
139
+         
160
+  CONTEXT *ctx = NULL;
140
+   if ((dirp = opendir (path)) == NULL)
161
+
141
+   {   
162
+  ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
142
+     mailbox->magic = 0;
163
+  if(ctx)
143
+     return;
164
+  {
144
+   } 
165
+    mailbox->msgcount = ctx->msgcount;
145
+       
166
+    mailbox->msg_unread = ctx->unread;
146
+   while ((de = readdir (dirp)) != NULL)
167
+    mx_close_mailbox(ctx, 0);
147
+   {
168
+  }
148
+     if (*de->d_name == '.')
169
+}
149
+       continue;
170
+
150
+ 
171
 int mutt_buffy_check (int force)
151
+     if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
172
 {
152
+       mailbox->new = 1;
173
   BUFFY *tmp;
153
+       mailbox->msgcount++;
174
@@ -444,16 +564,19 @@ int mutt_buffy_check (int force)
154
+       mailbox->msg_unread++;
175
       {
155
+     }
176
       case M_MBOX:
156
+   }
177
       case M_MMDF:
157
+ 
178
+	buffy_mbox_update (tmp);
158
+   closedir (dirp);
179
 	if (buffy_mbox_hasnew (tmp, &sb) > 0)
159
+   snprintf (path, sizeof (path), "%s/cur", mailbox->path);
180
 	  BuffyCount++;
160
+         
181
 	break;
161
+   if ((dirp = opendir (path)) == NULL)
182
 
162
+   {   
183
       case M_MAILDIR:
163
+     mailbox->magic = 0;
184
+	buffy_maildir_update (tmp);
164
+     return;
185
 	if (buffy_maildir_hasnew (tmp) > 0)
165
+   } 
186
 	  BuffyCount++;
166
+       
187
 	break;
167
+   while ((de = readdir (dirp)) != NULL)
188
 
168
+   {
189
       case M_MH:
169
+     if (*de->d_name == '.')
190
+	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
170
+       continue;
191
 	mh_buffy(tmp);
171
+ 
192
 	if (tmp->new)
172
+     if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) {
193
 	  BuffyCount++;
173
+       mailbox->msgcount++;
194
diff -uNp -r mutt-1.5.22.orig/buffy.h mutt-1.5.22/buffy.h
174
+       if ((p = strstr (de->d_name, ":2,"))) {
195
--- mutt-1.5.22.orig/buffy.h	Mon Apr 22 07:14:53 2013
175
+         if (!strchr (p + 3, 'T')) {
196
+++ mutt-1.5.22/buffy.h	Fri Oct 18 10:18:45 2013
176
+           if (!strchr (p + 3, 'S'))
197
@@ -25,7 +25,11 @@ typedef struct buffy_t
177
+             mailbox->msg_unread++;
198
   char path[_POSIX_PATH_MAX];
178
+           if (strchr(p + 3, 'F'))
199
   off_t size;
179
+             mailbox->msg_flagged++;
200
   struct buffy_t *next;
180
+         }
201
+  struct buffy_t *prev;
181
+       }
202
   short new;			/* mailbox has new mail */
182
+     }
203
+  int msgcount;			/* total number of messages */
183
+   }
204
+  int msg_unread;		/* number of unread messages */
184
+ 
205
+  int msg_flagged;		/* number of flagged messages */
185
+   mailbox->sb_last_checked = time(NULL);
206
   short notified;		/* user has been notified */
186
+   closedir (dirp);
207
   short magic;			/* mailbox type */
187
+ }
208
   short newly_created;		/* mbox or mmdf just popped into existence */
188
+ 
209
diff -uNp -r mutt-1.5.22.orig/color.c mutt-1.5.22/color.c
189
  /* returns 1 if mailbox has new mail */ 
210
--- mutt-1.5.22.orig/color.c	Tue Jan 15 07:37:15 2013
190
  static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb)
211
+++ mutt-1.5.22/color.c	Fri Oct 18 10:19:53 2013
191
  {
212
@@ -93,6 +93,8 @@ static const struct mapping_t Fields[] =
192
***************
213
   { "bold",		MT_COLOR_BOLD },
193
*** 351,357 ****
214
   { "underline",	MT_COLOR_UNDERLINE },
194
    else
215
   { "index",		MT_COLOR_INDEX },
195
      statcheck = sb->st_mtime > sb->st_atime
216
+  { "sidebar_new",	MT_COLOR_NEW },
196
        || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
217
+  { "sidebar_flagged",	MT_COLOR_FLAGGED },
197
!   if (statcheck)
218
   { NULL,		0 }
198
    {
219
 };
199
      if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
220
 
200
      {
221
diff -uNp -r mutt-1.5.22.orig/compose.c mutt-1.5.22/compose.c
201
--- 470,476 ----
222
--- mutt-1.5.22.orig/compose.c.orig	2013-10-25 08:31:26.000000000 +0200
202
    else
223
+++ mutt-1.5.22/compose.c	2013-10-25 08:44:32.000000000 +0200
203
      statcheck = sb->st_mtime > sb->st_atime
204
        || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime);
205
!   if ((!option(OPTSIDEBAR) && statcheck) || (option(OPTSIDEBAR) && mailbox->msg_unread > 0))
206
    {
207
      if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited)
208
      {
209
***************
210
*** 371,376 ****
211
--- 490,516 ----
212
    return rc;
213
  }
214
  
215
+ /* update message counts for the sidebar */
216
+ void buffy_mbox_update (BUFFY* mailbox, struct stat *sb)
217
+ {
218
+   CONTEXT *ctx = NULL;
219
+ 
220
+   if(!option(OPTSIDEBAR))
221
+       return;
222
+   if(mailbox->sb_last_checked > sb->st_mtime && mailbox->msgcount != 0)
223
+       return; /* no check necessary */
224
+ 
225
+   ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL);
226
+   if(ctx)
227
+   {
228
+     mailbox->msgcount = ctx->msgcount;
229
+     mailbox->msg_unread = ctx->unread;
230
+     mailbox->msg_flagged = ctx->flagged;
231
+     mailbox->sb_last_checked = time(NULL);
232
+     mx_close_mailbox(ctx, 0);
233
+   }
234
+ }
235
+ 
236
  int mutt_buffy_check (int force)
237
  {
238
    BUFFY *tmp;
239
***************
240
*** 444,460 ****
241
        {
242
        case M_MBOX:
243
        case M_MMDF:
244
  	if (buffy_mbox_hasnew (tmp, &sb) > 0)
245
  	  BuffyCount++;
246
  	break;
247
  
248
        case M_MAILDIR:
249
  	if (buffy_maildir_hasnew (tmp) > 0)
250
  	  BuffyCount++;
251
  	break;
252
  
253
        case M_MH:
254
! 	mh_buffy(tmp);
255
  	if (tmp->new)
256
  	  BuffyCount++;
257
  	break;
258
--- 584,603 ----
259
        {
260
        case M_MBOX:
261
        case M_MMDF:
262
+ 	buffy_mbox_update (tmp, &sb);
263
  	if (buffy_mbox_hasnew (tmp, &sb) > 0)
264
  	  BuffyCount++;
265
  	break;
266
  
267
        case M_MAILDIR:
268
+ 	buffy_maildir_update (tmp);
269
  	if (buffy_maildir_hasnew (tmp) > 0)
270
  	  BuffyCount++;
271
  	break;
272
  
273
        case M_MH:
274
! 	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
275
!         mh_buffy(tmp);
276
  	if (tmp->new)
277
  	  BuffyCount++;
278
  	break;
279
*** mutt-1.5.23-orig/buffy.h	2014-03-12 11:03:44.000000000 -0500
280
--- mutt-1.5.23/buffy.h	2014-04-11 10:14:01.000000000 -0500
281
***************
282
*** 23,35 ****
283
--- 23,41 ----
284
  typedef struct buffy_t
285
  {
286
    char path[_POSIX_PATH_MAX];
287
+   char realpath[_POSIX_PATH_MAX];
288
    off_t size;
289
    struct buffy_t *next;
290
+   struct buffy_t *prev;
291
    short new;			/* mailbox has new mail */
292
+   int msgcount;			/* total number of messages */
293
+   int msg_unread;		/* number of unread messages */
294
+   int msg_flagged;		/* number of flagged messages */
295
    short notified;		/* user has been notified */
296
    short magic;			/* mailbox type */
297
    short newly_created;		/* mbox or mmdf just popped into existence */
298
    time_t last_visited;		/* time of last exit from this mailbox */
299
+   time_t sb_last_checked;      /* time of last buffy check from sidebar */
300
  }
301
  BUFFY;
302
  
303
*** mutt-1.5.23-orig/color.c	2014-03-12 11:03:45.000000000 -0500
304
--- mutt-1.5.23/color.c	2014-04-11 10:14:01.000000000 -0500
305
***************
306
*** 93,98 ****
307
--- 93,100 ----
308
    { "bold",		MT_COLOR_BOLD },
309
    { "underline",	MT_COLOR_UNDERLINE },
310
    { "index",		MT_COLOR_INDEX },
311
+   { "sidebar_new",	MT_COLOR_NEW },
312
+   { "sidebar_flagged",	MT_COLOR_FLAGGED },
313
    { NULL,		0 }
314
  };
315
  
316
*** mutt-1.5.23-orig/compose.c.orig	2014-04-13 09:37:15.000000000 +0200
317
--- mutt-1.5.23/compose.c	2014-04-13 09:41:42.000000000 +0200
224
@@ -83,7 +83,7 @@
318
@@ -83,7 +83,7 @@
225
 
319
 
226
 #define HDR_XOFFSET 14
320
 #define HDR_XOFFSET 14
Lines 347-1430 Link Here
347
 	  mutt_paddstr (W, fcc);
441
 	  mutt_paddstr (W, fcc);
348
 	  fccSet = 1;
442
 	  fccSet = 1;
349
 	}
443
 	}
350
diff -uNp -r mutt-1.5.22.orig/curs_main.c mutt-1.5.22/curs_main.c
444
*** mutt-1.5.23-orig/configure.ac	2014-03-12 11:26:40.000000000 -0500
351
--- mutt-1.5.22.orig/curs_main.c	Tue Jan 15 07:37:15 2013
445
--- mutt-1.5.23/configure.ac	2014-04-11 10:14:01.000000000 -0500
352
+++ mutt-1.5.22/curs_main.c	Fri Oct 18 10:18:45 2013
446
***************
353
@@ -26,7 +26,9 @@
447
*** 1276,1281 ****
354
 #include "mailbox.h"
448
--- 1276,1283 ----
355
 #include "mapping.h"
449
    AC_DEFINE(HAVE_LANGINFO_YESEXPR,1,[ Define if you have <langinfo.h> and nl_langinfo(YESEXPR). ])
356
 #include "sort.h"
450
  fi
357
+#include "buffy.h"
451
  
358
 #include "mx.h"
452
+ AC_CHECK_FUNCS(fmemopen open_memstream)
359
+#include "sidebar.h"
453
+ 
360
 
454
  dnl Documentation tools
361
 #ifdef USE_POP
455
  have_openjade="no"
362
 #include "pop.h"
456
  AC_PATH_PROG([OSPCAT], [ospcat], [none])
363
@@ -519,8 +521,12 @@ int mutt_index_menu (void)
457
*** mutt-1.5.23-orig/curs_main.c	2014-03-12 11:06:17.000000000 -0500
364
        menu->redraw |= REDRAW_STATUS;
458
--- mutt-1.5.23/curs_main.c	2014-04-12 21:45:21.000000000 -0500
365
      if (do_buffy_notify)
459
***************
460
*** 26,32 ****
461
--- 26,34 ----
462
  #include "mailbox.h"
463
  #include "mapping.h"
464
  #include "sort.h"
465
+ #include "buffy.h"
466
  #include "mx.h"
467
+ #include "sidebar.h"
468
  
469
  #ifdef USE_POP
470
  #include "pop.h"
471
***************
472
*** 519,538 ****
473
         menu->redraw |= REDRAW_STATUS;
474
       if (do_buffy_notify)
475
       {
476
!        if (mutt_buffy_notify () && option (OPTBEEPNEW))
477
!  	beep ();
478
       }
479
       else
480
         do_buffy_notify = 1;
481
      }
482
  
483
      if (op != -1)
484
        mutt_curs_set (0);
485
  
486
      if (menu->redraw & REDRAW_FULL)
366
      {
487
      {
367
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
488
        menu_redraw_full (menu);
368
- 	beep ();
489
        mutt_show_error ();
369
+       if (mutt_buffy_notify ())
370
+       {
371
+         menu->redraw |= REDRAW_FULL;
372
+         if (option (OPTBEEPNEW))
373
+           beep ();
374
+       }
375
      }
490
      }
376
      else
491
  
377
        do_buffy_notify = 1;
492
      if (menu->menu == MENU_MAIN)
378
@@ -532,6 +538,7 @@ int mutt_index_menu (void)
493
--- 521,551 ----
379
     if (menu->redraw & REDRAW_FULL)
494
         menu->redraw |= REDRAW_STATUS;
380
     {
495
       if (do_buffy_notify)
381
       menu_redraw_full (menu);
382
+      draw_sidebar(menu->menu);
383
       mutt_show_error ();
384
     }
385
 
386
@@ -554,9 +561,12 @@ int mutt_index_menu (void)
387
 
388
       if (menu->redraw & REDRAW_STATUS)
389
       {
496
       {
390
+	DrawFullLine = 1;
497
!        if (mutt_buffy_notify ())
391
 	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
498
!        {
392
+	DrawFullLine = 0;
499
!          menu->redraw |= REDRAW_STATUS;
393
 	move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
500
!          if (option (OPTBEEPNEW))
394
 	SETCOLOR (MT_COLOR_STATUS);
501
!            beep ();
395
+	set_buffystats(Context);
502
!        }
396
 	mutt_paddstr (COLS, buf);
503
       }
397
 	NORMAL_COLOR;
398
 	menu->redraw &= ~REDRAW_STATUS;
399
@@ -569,7 +579,7 @@ int mutt_index_menu (void)
400
 	menu->oldcurrent = -1;
401
 
402
       if (option (OPTARROWCURSOR))
403
-	move (menu->current - menu->top + menu->offset, 2);
404
+	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
405
       else if (option (OPTBRAILLEFRIENDLY))
406
 	move (menu->current - menu->top + menu->offset, 0);
407
       else
504
       else
408
@@ -1070,6 +1080,7 @@ int mutt_index_menu (void)
505
         do_buffy_notify = 1;
409
 	  menu->redraw = REDRAW_FULL;
506
      }
410
 	break;
507
  
411
 
508
+     if(option(OPTSIDEBAR))
412
+      case OP_SIDEBAR_OPEN:
509
+         menu->redraw |= REDRAW_SIDEBAR;
413
       case OP_MAIN_CHANGE_FOLDER:
510
+ 
414
       case OP_MAIN_NEXT_UNREAD_MAILBOX:
511
      if (op != -1)
415
 
512
        mutt_curs_set (0);
416
@@ -1101,7 +1112,11 @@ int mutt_index_menu (void)
513
  
417
 	{
514
      if (menu->redraw & REDRAW_FULL)
418
 	  mutt_buffy (buf, sizeof (buf));
515
      {
419
 
516
        menu_redraw_full (menu);
420
-	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
517
+       draw_sidebar(menu->menu);
421
+          if ( op == OP_SIDEBAR_OPEN ) {
518
        mutt_show_error ();
422
+              if(!CurBuffy)
519
+     } else if(menu->redraw & REDRAW_SIDEBAR) {
423
+                break;
520
+         draw_sidebar(menu->menu);
424
+            strncpy( buf, CurBuffy->path, sizeof(buf) );  
521
+         menu->redraw &= ~REDRAW_SIDEBAR;
425
+	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
522
      }
426
 	  {
523
  
427
 	    if (menu->menu == MENU_PAGER)
524
      if (menu->menu == MENU_MAIN)
428
 	    {
525
***************
429
@@ -1119,6 +1134,7 @@ int mutt_index_menu (void)
526
*** 554,562 ****
430
 	}
527
--- 567,578 ----
431
 
528
  
432
 	mutt_expand_path (buf, sizeof (buf));
529
        if (menu->redraw & REDRAW_STATUS)
433
+        set_curbuffy(buf);
530
        {
434
 	if (mx_get_magic (buf) <= 0)
531
+         DrawFullLine = 1;
435
 	{
532
  	menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
436
 	  mutt_error (_("%s is not a mailbox."), buf);
533
+         DrawFullLine = 0;
437
@@ -2209,6 +2225,12 @@ int mutt_index_menu (void)
534
  	move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0);
438
 	mutt_what_key();
535
  	SETCOLOR (MT_COLOR_STATUS);
439
 	break;
536
+         set_buffystats(Context);
440
 
537
  	mutt_paddstr (COLS, buf);
441
+      case OP_SIDEBAR_SCROLL_UP:
538
  	NORMAL_COLOR;
442
+      case OP_SIDEBAR_SCROLL_DOWN:
539
  	menu->redraw &= ~REDRAW_STATUS;
443
+      case OP_SIDEBAR_NEXT:
540
***************
444
+      case OP_SIDEBAR_PREV:
541
*** 569,575 ****
445
+        scroll_sidebar(op, menu->menu);
542
  	menu->oldcurrent = -1;
446
+        break;
543
  
447
       default:
544
        if (option (OPTARROWCURSOR))
448
 	if (menu->menu == MENU_MAIN)
545
! 	move (menu->current - menu->top + menu->offset, 2);
449
 	  km_error_key (MENU_MAIN);
546
        else if (option (OPTBRAILLEFRIENDLY))
450
diff -uNp -r mutt-1.5.22.orig/flags.c mutt-1.5.22/flags.c
547
  	move (menu->current - menu->top + menu->offset, 0);
451
--- mutt-1.5.22.orig/flags.c	Sun Feb 21 22:10:41 2010
548
        else
452
+++ mutt-1.5.22/flags.c	Fri Oct 18 10:18:45 2013
549
--- 585,591 ----
453
@@ -22,8 +22,10 @@
550
  	menu->oldcurrent = -1;
454
 
551
  
455
 #include "mutt.h"
552
        if (option (OPTARROWCURSOR))
456
 #include "mutt_curses.h"
553
! 	move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
457
+#include "mutt_menu.h"
554
        else if (option (OPTBRAILLEFRIENDLY))
458
 #include "sort.h"
555
  	move (menu->current - menu->top + menu->offset, 0);
459
 #include "mx.h"
556
        else
460
+#include "sidebar.h"
557
***************
461
 
558
*** 1011,1016 ****
462
 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
559
--- 1027,1033 ----
463
 {
560
  	  break;
464
@@ -263,6 +265,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag
561
  
465
    */
562
  	CHECK_MSGCOUNT;
466
   if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
563
+         CHECK_VISIBLE;
467
     h->searched = 0;
564
  	CHECK_READONLY;
468
+	draw_sidebar(0);
565
  	{
469
 }
566
  	  int oldvcount = Context->vcount;
470
 
567
***************
471
 void mutt_tag_set_flag (int flag, int bf)
568
*** 1070,1075 ****
472
diff -uNp -r mutt-1.5.22.orig/functions.h mutt-1.5.22/functions.h
569
--- 1087,1093 ----
473
--- mutt-1.5.22.orig/functions.h	Sat Dec  3 19:10:04 2011
570
  	  menu->redraw = REDRAW_FULL;
474
+++ mutt-1.5.22/functions.h	Fri Oct 18 10:18:45 2013
571
  	break;
475
@@ -169,6 +169,11 @@ const struct binding_t OpMain[] = { /* map: index */
572
  
476
   { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
573
+       case OP_SIDEBAR_OPEN:
477
 
574
        case OP_MAIN_CHANGE_FOLDER:
478
 
575
        case OP_MAIN_NEXT_UNREAD_MAILBOX:
479
+ { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
576
  
480
+ { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
577
***************
481
+ { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
578
*** 1101,1107 ****
482
+ { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
579
  	{
483
+ { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
580
  	  mutt_buffy (buf, sizeof (buf));
484
   { NULL,			0,				NULL }
581
  
485
 };
582
! 	  if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
486
 
583
  	  {
487
@@ -272,6 +277,11 @@ const struct binding_t OpPager[] = { /* map: pager */
584
  	    if (menu->menu == MENU_PAGER)
488
 
585
  	    {
489
   { "what-key",		OP_WHAT_KEY,		NULL },
586
--- 1119,1129 ----
490
 
587
  	{
588
  	  mutt_buffy (buf, sizeof (buf));
589
  
590
!           if ( op == OP_SIDEBAR_OPEN ) {
591
!               if(!CurBuffy)
592
!                 break;
593
!             strncpy( buf, CurBuffy->path, sizeof(buf) );  
594
! 	    } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
595
  	  {
596
  	    if (menu->menu == MENU_PAGER)
597
  	    {
598
***************
599
*** 1119,1124 ****
600
--- 1141,1147 ----
601
  	}
602
  
603
  	mutt_expand_path (buf, sizeof (buf));
604
+         set_curbuffy(buf);
605
  	if (mx_get_magic (buf) <= 0)
606
  	{
607
  	  mutt_error (_("%s is not a mailbox."), buf);
608
***************
609
*** 2209,2214 ****
610
--- 2232,2243 ----
611
  	mutt_what_key();
612
  	break;
613
  
614
+       case OP_SIDEBAR_SCROLL_UP:
615
+       case OP_SIDEBAR_SCROLL_DOWN:
616
+       case OP_SIDEBAR_NEXT:
617
+       case OP_SIDEBAR_PREV:
618
+         scroll_sidebar(op, menu->menu);
619
+         break;
620
        default:
621
  	if (menu->menu == MENU_MAIN)
622
  	  km_error_key (MENU_MAIN);
623
*** mutt-1.5.23-orig/flags.c	2014-03-12 11:03:45.000000000 -0500
624
--- mutt-1.5.23/flags.c	2014-04-11 10:14:01.000000000 -0500
625
***************
626
*** 22,29 ****
627
--- 22,31 ----
628
  
629
  #include "mutt.h"
630
  #include "mutt_curses.h"
631
+ #include "mutt_menu.h"
632
  #include "sort.h"
633
  #include "mx.h"
634
+ #include "sidebar.h"
635
  
636
  void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
637
  {
638
***************
639
*** 263,268 ****
640
--- 265,271 ----
641
     */
642
    if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged))
643
      h->searched = 0;
644
+ 	draw_sidebar(0);
645
  }
646
  
647
  void mutt_tag_set_flag (int flag, int bf)
648
*** mutt-1.5.23-orig/functions.h	2014-03-12 11:03:45.000000000 -0500
649
--- mutt-1.5.23/functions.h	2014-04-11 10:14:01.000000000 -0500
650
***************
651
*** 169,174 ****
652
--- 169,179 ----
653
    { "decrypt-save",		OP_DECRYPT_SAVE,		NULL },
654
  
655
  
491
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
656
+  { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
492
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
657
+  { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
493
+  { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
658
+  { "sidebar-next",		OP_SIDEBAR_NEXT, NULL },
494
+  { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
659
+  { "sidebar-prev",		OP_SIDEBAR_PREV, NULL },
495
+  { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
660
+  { "sidebar-open",		OP_SIDEBAR_OPEN, NULL },
496
   { NULL,		0,				NULL }
661
    { NULL,			0,				NULL }
497
 };
662
  };
498
 
663
  
499
diff -uNp -r mutt-1.5.22.orig/globals.h mutt-1.5.22/globals.h
664
***************
500
--- mutt-1.5.22.orig/globals.h	Sat Dec  3 19:10:04 2011
665
*** 272,277 ****
501
+++ mutt-1.5.22/globals.h	Fri Oct 18 10:18:45 2013
666
--- 277,287 ----
502
@@ -117,6 +117,7 @@ WHERE short SearchContext;
667
  
503
 WHERE char *SendCharset;
668
    { "what-key",		OP_WHAT_KEY,		NULL },
504
 WHERE char *Sendmail;
669
  
505
 WHERE char *Shell;
670
+   { "sidebar-scroll-up",	OP_SIDEBAR_SCROLL_UP, NULL },
506
+WHERE char *SidebarDelim;
671
+   { "sidebar-scroll-down",	OP_SIDEBAR_SCROLL_DOWN, NULL },
507
 WHERE char *Signature;
672
+   { "sidebar-next",	OP_SIDEBAR_NEXT, NULL },
508
 WHERE char *SimpleSearch;
673
+   { "sidebar-prev",	OP_SIDEBAR_PREV, NULL },
509
 #if USE_SMTP
674
+   { "sidebar-open", OP_SIDEBAR_OPEN, NULL },
510
@@ -208,6 +209,9 @@ WHERE short ScoreThresholdDelete;
675
    { NULL,		0,				NULL }
511
 WHERE short ScoreThresholdRead;
676
  };
512
 WHERE short ScoreThresholdFlag;
677
  
513
 
678
*** mutt-1.5.23-orig/globals.h	2014-03-12 11:06:17.000000000 -0500
514
+WHERE struct buffy_t *CurBuffy INITVAL(0);
679
--- mutt-1.5.23/globals.h	2014-04-11 10:14:01.000000000 -0500
515
+WHERE short DrawFullLine INITVAL(0);
680
***************
516
+WHERE short SidebarWidth;
681
*** 117,122 ****
517
 #ifdef USE_IMAP
682
--- 117,125 ----
518
 WHERE short ImapKeepalive;
683
  WHERE char *SendCharset;
519
 WHERE short ImapPipelineDepth;
684
  WHERE char *Sendmail;
520
diff -uNp -r mutt-1.5.22.orig/imap/command.c mutt-1.5.22/imap/command.c
685
  WHERE char *Shell;
521
--- mutt-1.5.22.orig/imap/command.c	Fri Oct 18 05:48:24 2013
686
+ WHERE char *SidebarDelim;
522
+++ mutt-1.5.22/imap/command.c	Fri Oct 18 10:18:45 2013
687
+ WHERE char *SidebarFormat;
523
@@ -1012,6 +1012,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* 
688
+ WHERE char *SidebarIndentStr;
524
 	     opened */
689
  WHERE char *Signature;
525
 	  status->uidnext = oldun;
690
  WHERE char *SimpleSearch;
526
 
691
  #if USE_SMTP
527
+        /* Added to make the sidebar show the correct numbers */
692
***************
528
+        if (status->messages)
693
*** 208,213 ****
529
+        {
694
--- 211,219 ----
530
+          inc->msgcount = status->messages;
695
  WHERE short ScoreThresholdRead;
531
+          inc->msg_unread = status->unseen;
696
  WHERE short ScoreThresholdFlag;
532
+        }
697
  
533
+
698
+ WHERE struct buffy_t *CurBuffy INITVAL(0);
534
         FREE (&value);
699
+ WHERE short DrawFullLine INITVAL(0);
535
         return;
700
+ WHERE short SidebarWidth;
536
       }
701
  #ifdef USE_IMAP
537
diff -uNp -r mutt-1.5.22.orig/imap/imap.c mutt-1.5.22/imap/imap.c
702
  WHERE short ImapKeepalive;
538
--- mutt-1.5.22.orig/imap/imap.c	Fri Oct 18 05:48:24 2013
703
  WHERE short ImapPipelineDepth;
539
+++ mutt-1.5.22/imap/imap.c	Fri Oct 18 10:18:45 2013
704
*** mutt-1.5.23-orig/handler.c	2014-03-12 11:03:45.000000000 -0500
540
@@ -1514,7 +1514,7 @@ int imap_buffy_check (int force)
705
--- mutt-1.5.23/handler.c	2014-04-11 10:14:01.000000000 -0500
541
 
706
***************
542
     imap_munge_mbox_name (munged, sizeof (munged), name);
707
*** 1599,1604 ****
543
     snprintf (command, sizeof (command),
708
--- 1599,1609 ----
544
-	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
709
    size_t tmplength = 0;
545
+	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
710
    int rc = 0;
546
 
711
  
547
     if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
712
+ #ifdef HAVE_FMEMOPEN
548
     {
713
+   char *temp;
549
diff -uNp -r mutt-1.5.22.orig/init.h mutt-1.5.22/init.h
714
+   size_t tempsize;
550
--- mutt-1.5.22.orig/init.h	Tue Jan 15 07:37:15 2013
715
+ #endif
551
+++ mutt-1.5.22/init.h	Fri Oct 18 10:18:45 2013
716
+ 
552
@@ -1966,6 +1966,27 @@ struct option_t MuttVars[] = {
717
    int oflags = s->flags;
553
   ** not used.
718
    
554
   ** (PGP only)
719
    /* first determine which handler to use to process this part */
720
***************
721
*** 1711,1716 ****
722
--- 1716,1729 ----
723
        {
724
  	/* decode to a tempfile, saving the original destination */
725
  	fp = s->fpout;
726
+ #ifdef HAVE_FMEMOPEN
727
+ 	if ((s->fpout = open_memstream(&temp, &tempsize)) == NULL)
728
+ 	{
729
+ 	  mutt_error _("Unable to open memory stream!");
730
+ 	  dprint (1, (debugfile, "Can't open memory stream.\n"));
731
+ 	  goto bail;
732
+ 	}
733
+ #else
734
  	mutt_mktemp (tempfile, sizeof (tempfile));
735
  	if ((s->fpout = safe_fopen (tempfile, "w")) == NULL)
736
  	{
737
***************
738
*** 1718,1723 ****
739
--- 1731,1737 ----
740
  	  dprint (1, (debugfile, "Can't open %s.\n", tempfile));
741
  	  goto bail;
742
  	}
743
+ #endif
744
  	/* decoding the attachment changes the size and offset, so save a copy
745
  	 * of the "real" values now, and restore them after processing
746
  	 */
747
***************
748
*** 1746,1753 ****
749
--- 1760,1778 ----
750
  	/* restore final destination and substitute the tempfile for input */
751
  	s->fpout = fp;
752
  	fp = s->fpin;
753
+ #ifdef HAVE_FMEMOPEN
754
+ 	if(tempsize)
755
+ 		s->fpin = fmemopen(temp, tempsize, "r");
756
+ 	else /* fmemopen cannot handle zero-length buffers */
757
+ 		s->fpin = safe_fopen ("/dev/null", "r");
758
+ 	if(s->fpin == NULL) {
759
+ 		mutt_perror("failed to re-open memstream!");
760
+ 		return (-1);
761
+ 	}
762
+ #else
763
  	s->fpin = fopen (tempfile, "r");
764
  	unlink (tempfile);
765
+ #endif
766
  
767
  	/* restore the prefix */
768
  	s->prefix = savePrefix;
769
***************
770
*** 1773,1778 ****
771
--- 1798,1807 ----
772
  
773
  	/* restore the original source stream */
774
  	safe_fclose (&s->fpin);
775
+ #ifdef HAVE_FMEMOPEN
776
+ 	if(tempsize)
777
+ 	    FREE(&temp);
778
+ #endif
779
  	s->fpin = fp;
780
        }
781
      }
782
*** mutt-1.5.23-orig/init.h	2014-03-12 11:06:17.000000000 -0500
783
--- mutt-1.5.23/init.h	2014-04-11 10:14:01.000000000 -0500
784
***************
785
*** 1966,1971 ****
786
--- 1966,2019 ----
787
    ** not used.
788
    ** (PGP only)
789
    */
790
+   {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, UL "|"},
791
+   /*
792
+   ** .pp
793
+   ** This specifies the delimiter between the sidebar (if visible) and 
794
+   ** other screens.
795
+   */
796
+   {"sidebar_indentstr", DT_STR, R_BOTH, UL &SidebarIndentStr, UL " "},
797
+   /*
798
+   ** .pp
799
+   ** This specifies the string that is used to indent items
800
+   ** with sidebar_folderindent= yes
801
+   */
802
+   { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
803
+   /*
804
+   ** .pp
805
+   ** This specifies whether or not to show sidebar (left-side list of folders).
806
+   */
807
+   { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
808
+   /*
809
+   ** .pp
810
+   ** This specifies whether or not to sort the sidebar alphabetically.
811
+   */
812
+   { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
813
+   /*
814
+   ** .pp
815
+   ** The width of the sidebar.
816
+   */
817
+   { "sidebar_shortpath", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 1 },
818
+   /*
819
+   ** .pp
820
+   ** Should the sidebar shorten the path showed.
821
+   */
822
+   {"sidebar_format", DT_STR, R_NONE, UL &SidebarFormat, UL "%B%?F? [%F]?%* %?N?%N/?%4S"},
823
+   /*
824
+   ** .pp
825
+   ** Format string for the sidebar. The sequences `%N', `%F' and `%S'
826
+   ** will be replaced by the number of new or flagged messages or the total
827
+   ** size of them mailbox. `%B' will be replaced with the name of the mailbox.
828
+   ** The `%!' sequence will be expanded to `!' if there is one flagged message;
829
+   ** to `!!' if there are two flagged messages; and to `n!' for n flagged
830
+   ** messages, n>2.
831
+   */
832
+   { "sidebar_folderindent", DT_BOOL, R_BOTH, OPTSIDEBARFOLDERINDENT, 0 },
833
+   /*
834
+   ** .pp
835
+   ** Should folders be indented in the sidebar.
836
+   */
837
+ 
838
    { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
839
    /*
840
    ** .pp
841
*** mutt-1.5.23-orig/mailbox.h	2014-03-12 11:03:45.000000000 -0500
842
--- mutt-1.5.23/mailbox.h	2014-04-11 10:14:01.000000000 -0500
843
***************
844
*** 27,32 ****
845
--- 27,33 ----
846
  #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
847
  				* safe_fopen() for mbox-style folders.
848
  				*/
849
+ #define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
850
  
851
  /* mx_open_new_message() */
852
  #define M_ADD_FROM	1	/* add a From_ line */
853
*** mutt-1.5.23-orig/main.c	2014-03-12 11:06:17.000000000 -0500
854
--- mutt-1.5.23/main.c	2014-04-11 10:14:01.000000000 -0500
855
***************
856
*** 50,55 ****
857
--- 50,56 ----
858
  #include <unistd.h>
859
  #include <errno.h>
860
  #include <sys/stat.h>
861
+ #include <limits.h>
862
  #include <sys/utsname.h>
863
  
864
  #ifdef HAVE_GETOPT_H
865
***************
866
*** 555,561 ****
867
  
868
  int main (int argc, char **argv)
869
  {
870
!   char folder[_POSIX_PATH_MAX] = "";
871
    char *subject = NULL;
872
    char *includeFile = NULL;
873
    char *draftFile = NULL;
874
--- 556,562 ----
875
  
876
  int main (int argc, char **argv)
877
  {
878
!   char folder[PATH_MAX] = "";
879
    char *subject = NULL;
880
    char *includeFile = NULL;
881
    char *draftFile = NULL;
882
***************
883
*** 1025,1030 ****
884
--- 1026,1038 ----
885
        strfcpy (folder, NONULL(Spoolfile), sizeof (folder));
886
      mutt_expand_path (folder, sizeof (folder));
887
  
888
+     {
889
+       char tmpfolder[PATH_MAX];
890
+       strfcpy (tmpfolder, folder, sizeof (tmpfolder));
891
+       if(!realpath(tmpfolder, folder))
892
+           strfcpy (folder, tmpfolder, sizeof (tmpfolder));
893
+     }
894
+ 
895
      mutt_str_replace (&CurrentFolder, folder);
896
      mutt_str_replace (&LastFolder, folder);
897
  
898
***************
899
*** 1047,1052 ****
900
--- 1055,1061 ----
901
      if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL))
902
         || !explicit_folder)
903
      {
904
+       set_curbuffy(folder);
905
        mutt_index_menu ();
906
        if (Context)
907
  	FREE (&Context);
908
*** mutt-1.5.23-orig/Makefile.am	2014-03-12 11:03:44.000000000 -0500
909
--- mutt-1.5.23/Makefile.am	2014-04-11 10:14:01.000000000 -0500
910
***************
911
*** 32,37 ****
912
--- 32,38 ----
913
  	rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \
914
  	score.c send.c sendlib.c signal.c sort.c \
915
  	status.c system.c thread.c charset.c history.c lib.c \
916
+ 	sidebar.c \
917
  	muttlib.c editmsg.c mbyte.c \
918
  	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
919
  
920
*** mutt-1.5.23-orig/Makefile.in	2014-03-12 11:26:44.000000000 -0500
921
--- mutt-1.5.23/Makefile.in	2014-04-12 12:12:38.000000000 -0500
922
***************
923
*** 129,135 ****
924
  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
925
  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
926
  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
927
! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
928
  am__objects_1 =
929
  am__objects_2 = patchlist.$(OBJEXT) conststrings.$(OBJEXT) \
930
  	$(am__objects_1)
931
--- 129,136 ----
932
  	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
933
  	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
934
  	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
935
! 	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) \
936
! 	sidebar.$(OBJEXT)
937
  am__objects_1 =
938
  am__objects_2 = patchlist.$(OBJEXT) conststrings.$(OBJEXT) \
939
  	$(am__objects_1)
940
***************
941
*** 468,474 ****
942
  	score.c send.c sendlib.c signal.c sort.c \
943
  	status.c system.c thread.c charset.c history.c lib.c \
944
  	muttlib.c editmsg.c mbyte.c \
945
! 	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
946
  
947
  nodist_mutt_SOURCES = $(BUILT_SOURCES)
948
  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
949
--- 469,476 ----
950
  	score.c send.c sendlib.c signal.c sort.c \
951
  	status.c system.c thread.c charset.c history.c lib.c \
952
  	muttlib.c editmsg.c mbyte.c \
953
! 	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c \
954
! 	sidebar.c
955
  
956
  nodist_mutt_SOURCES = $(BUILT_SOURCES)
957
  mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
958
***************
959
*** 500,506 ****
960
  	README.SSL smime.h group.h \
961
  	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
962
  	ChangeLog mkchangelog.sh mutt_idna.h \
963
! 	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \
964
  	txt2c.c txt2c.sh version.sh check_sec.sh
965
  
966
  EXTRA_SCRIPTS = smime_keys
967
--- 502,508 ----
968
  	README.SSL smime.h group.h \
969
  	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
970
  	ChangeLog mkchangelog.sh mutt_idna.h \
971
! 	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in \
972
  	txt2c.c txt2c.sh version.sh check_sec.sh
973
  
974
  EXTRA_SCRIPTS = smime_keys
975
*** mutt-1.5.23-orig/mbox.c	2014-03-12 11:03:45.000000000 -0500
976
--- mutt-1.5.23/mbox.c	2014-04-11 10:14:01.000000000 -0500
977
***************
978
*** 100,105 ****
979
--- 100,106 ----
980
      mutt_perror (ctx->path);
981
      return (-1);
982
    }
983
+   ctx->atime = sb.st_atime;
984
    ctx->mtime = sb.st_mtime;
985
    ctx->size = sb.st_size;
986
  
987
***************
988
*** 251,256 ****
989
--- 252,258 ----
990
  
991
    ctx->size = sb.st_size;
992
    ctx->mtime = sb.st_mtime;
993
+   ctx->atime = sb.st_atime;
994
  
995
  #ifdef NFS_ATTRIBUTE_HACK
996
    if (sb.st_mtime > sb.st_atime)
997
*** mutt-1.5.23-orig/menu.c	2014-03-12 11:03:45.000000000 -0500
998
--- mutt-1.5.23/menu.c	2014-04-12 21:31:16.000000000 -0500
999
***************
1000
*** 24,29 ****
1001
--- 24,30 ----
1002
  #include "mutt_curses.h"
1003
  #include "mutt_menu.h"
1004
  #include "mbyte.h"
1005
+ #include "sidebar.h"
1006
  
1007
  extern size_t UngetCount;
1008
  
1009
***************
1010
*** 186,192 ****
1011
  {
1012
    char *scratch = safe_strdup (s);
1013
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
1014
!   int cols = COLS - shift;
1015
  
1016
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1017
    s[n - 1] = 0;
1018
--- 187,193 ----
1019
  {
1020
    char *scratch = safe_strdup (s);
1021
    int shift = option (OPTARROWCURSOR) ? 3 : 0;
1022
!   int cols = COLS - shift - SidebarWidth;
1023
  
1024
    mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1025
    s[n - 1] = 0;
1026
***************
1027
*** 239,244 ****
1028
--- 240,246 ----
1029
    int do_color;
1030
    int attr;
1031
  
1032
+   draw_sidebar(1);
1033
    for (i = menu->top; i < menu->top + menu->pagelen; i++)
1034
    {
1035
      if (i < menu->max)
1036
***************
1037
*** 249,255 ****
1038
        menu_pad_string (buf, sizeof (buf));
1039
  
1040
        ATTRSET(attr);
1041
!       move(i - menu->top + menu->offset, 0);
1042
        do_color = 1;
1043
  
1044
        if (i == menu->current)
1045
--- 251,257 ----
1046
        menu_pad_string (buf, sizeof (buf));
1047
  
1048
        ATTRSET(attr);
1049
!       move(i - menu->top + menu->offset, SidebarWidth);
1050
        do_color = 1;
1051
  
1052
        if (i == menu->current)
1053
***************
1054
*** 272,278 ****
1055
      else
1056
      {
1057
        NORMAL_COLOR;
1058
!       CLEARLINE(i - menu->top + menu->offset);
1059
      }
1060
    }
1061
    NORMAL_COLOR;
1062
--- 274,280 ----
1063
      else
1064
      {
1065
        NORMAL_COLOR;
1066
!       CLEARLINE_WIN (i - menu->top + menu->offset);
1067
      }
1068
    }
1069
    NORMAL_COLOR;
1070
***************
1071
*** 289,295 ****
1072
      return;
1073
    }
1074
    
1075
!   move (menu->oldcurrent + menu->offset - menu->top, 0);
1076
    ATTRSET(menu->color (menu->oldcurrent));
1077
  
1078
    if (option (OPTARROWCURSOR))
1079
--- 291,297 ----
1080
      return;
1081
    }
1082
    
1083
!   move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
1084
    ATTRSET(menu->color (menu->oldcurrent));
1085
  
1086
    if (option (OPTARROWCURSOR))
1087
***************
1088
*** 301,313 ****
1089
      {
1090
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1091
        menu_pad_string (buf, sizeof (buf));
1092
!       move (menu->oldcurrent + menu->offset - menu->top, 3);
1093
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1094
      }
1095
  
1096
      /* now draw it in the new location */
1097
      SETCOLOR(MT_COLOR_INDICATOR);
1098
!     mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
1099
    }
1100
    else
1101
    {
1102
--- 303,315 ----
1103
      {
1104
        menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1105
        menu_pad_string (buf, sizeof (buf));
1106
!       move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
1107
        print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1108
      }
1109
  
1110
      /* now draw it in the new location */
1111
      SETCOLOR(MT_COLOR_INDICATOR);
1112
!     mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
1113
    }
1114
    else
1115
    {
1116
***************
1117
*** 320,326 ****
1118
      menu_make_entry (buf, sizeof (buf), menu, menu->current);
1119
      menu_pad_string (buf, sizeof (buf));
1120
      SETCOLOR(MT_COLOR_INDICATOR);
1121
!     move(menu->current - menu->top + menu->offset, 0);
1122
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1123
    }
1124
    menu->redraw &= REDRAW_STATUS;
1125
--- 322,328 ----
1126
      menu_make_entry (buf, sizeof (buf), menu, menu->current);
1127
      menu_pad_string (buf, sizeof (buf));
1128
      SETCOLOR(MT_COLOR_INDICATOR);
1129
!     move(menu->current - menu->top + menu->offset, SidebarWidth);
1130
      print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
1131
    }
1132
    menu->redraw &= REDRAW_STATUS;
1133
***************
1134
*** 332,338 ****
1135
    char buf[LONG_STRING];
1136
    int attr = menu->color (menu->current);
1137
    
1138
!   move (menu->current + menu->offset - menu->top, 0);
1139
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
1140
    menu_pad_string (buf, sizeof (buf));
1141
  
1142
--- 334,340 ----
1143
    char buf[LONG_STRING];
1144
    int attr = menu->color (menu->current);
1145
    
1146
!   move (menu->current + menu->offset - menu->top, SidebarWidth);
1147
    menu_make_entry (buf, sizeof (buf), menu, menu->current);
1148
    menu_pad_string (buf, sizeof (buf));
1149
  
1150
***************
1151
*** 872,878 ****
1152
      
1153
      
1154
      if (option (OPTARROWCURSOR))
1155
!       move (menu->current - menu->top + menu->offset, 2);
1156
      else if (option (OPTBRAILLEFRIENDLY))
1157
        move (menu->current - menu->top + menu->offset, 0);
1158
      else
1159
--- 874,880 ----
1160
      
1161
      
1162
      if (option (OPTARROWCURSOR))
1163
!       move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
1164
      else if (option (OPTBRAILLEFRIENDLY))
1165
        move (menu->current - menu->top + menu->offset, 0);
1166
      else
1167
*** mutt-1.5.23-orig/mh.c	2014-03-12 11:03:45.000000000 -0500
1168
--- mutt-1.5.23/mh.c	2014-04-11 11:04:59.000000000 -0500
1169
***************
1170
*** 295,300 ****
1171
--- 295,326 ----
1172
    mhs_free_sequences (&mhs);
1173
  }
1174
  
1175
+ void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged, time_t *sb_last_checked)
1176
+ {
1177
+   int i;
1178
+   struct mh_sequences mhs;
1179
+   memset (&mhs, 0, sizeof (mhs));
1180
+ 
1181
+   if(!option(OPTSIDEBAR))
1182
+       return;
1183
+ 
1184
+   if (mh_read_sequences (&mhs, path) < 0)
1185
+     return;
1186
+ 
1187
+   msgcount = 0;
1188
+   msg_unread = 0;
1189
+   msg_flagged = 0;
1190
+   for (i = 0; i <= mhs.max; i++)
1191
+     msgcount++;
1192
+     if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
1193
+       msg_unread++;
1194
+     }
1195
+     if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
1196
+       msg_flagged++;
1197
+   mhs_free_sequences (&mhs);
1198
+   *sb_last_checked = time(NULL);
1199
+ }
1200
+ 
1201
  static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
1202
  {
1203
    int fd;
1204
*** mutt-1.5.23-orig/mutt_curses.h	2014-03-12 11:03:45.000000000 -0500
1205
--- mutt-1.5.23/mutt_curses.h	2014-04-11 10:14:01.000000000 -0500
1206
***************
1207
*** 64,69 ****
1208
--- 64,70 ----
1209
  #undef lines
1210
  #endif /* lines */
1211
  
1212
+ #define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
1213
  #define CLEARLINE(x) move(x,0), clrtoeol()
1214
  #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
1215
  #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
1216
***************
1217
*** 120,125 ****
1218
--- 121,128 ----
1219
    MT_COLOR_BOLD,
1220
    MT_COLOR_UNDERLINE,
1221
    MT_COLOR_INDEX,
1222
+   MT_COLOR_NEW,
1223
+   MT_COLOR_FLAGGED,
1224
    MT_COLOR_MAX
1225
  };
1226
  
1227
*** mutt-1.5.23-orig/mutt_menu.h	2014-03-12 11:06:17.000000000 -0500
1228
--- mutt-1.5.23/mutt_menu.h	2014-04-11 10:14:01.000000000 -0500
1229
***************
1230
*** 34,39 ****
1231
--- 34,40 ----
1232
  #define REDRAW_FULL		(1<<5)
1233
  #define REDRAW_BODY		(1<<6)
1234
  #define REDRAW_SIGWINCH		(1<<7)
1235
+ #define REDRAW_SIDEBAR		(1<<8)
1236
  
1237
  #define M_MODEFMT "-- Mutt: %s"
1238
  
1239
*** mutt-1.5.23-orig/mutt.h	2014-03-12 11:06:17.000000000 -0500
1240
--- mutt-1.5.23/mutt.h	2014-04-11 10:14:01.000000000 -0500
1241
***************
1242
*** 421,426 ****
1243
--- 421,430 ----
1244
    OPTSAVEEMPTY,
1245
    OPTSAVENAME,
1246
    OPTSCORE,
1247
+   OPTSIDEBAR,
1248
+   OPTSIDEBARSHORTPATH,
1249
+   OPTSIDEBARSORT,
1250
+   OPTSIDEBARFOLDERINDENT,
1251
    OPTSIGDASHES,
1252
    OPTSIGONTOP,
1253
    OPTSORTRE,
1254
***************
1255
*** 861,866 ****
1256
--- 865,871 ----
1257
  {
1258
    char *path;
1259
    FILE *fp;
1260
+   time_t atime;
1261
    time_t mtime;
1262
    off_t size;
1263
    off_t vsize;
1264
***************
1265
*** 895,900 ****
1266
--- 900,906 ----
1267
    unsigned int quiet : 1;	/* inhibit status messages? */
1268
    unsigned int collapsed : 1;   /* are all threads collapsed? */
1269
    unsigned int closing : 1;	/* mailbox is being closed */
1270
+   unsigned int peekonly : 1;	/* just taking a glance, revert atime */
1271
  
1272
    /* driver hooks */
1273
    void *data;			/* driver specific data */
1274
*** mutt-1.5.23-orig/muttlib.c	2014-03-12 11:03:45.000000000 -0500
1275
--- mutt-1.5.23/muttlib.c	2014-04-11 10:14:01.000000000 -0500
1276
***************
1277
*** 1281,1286 ****
1278
--- 1281,1288 ----
1279
  	  pl = pw = 1;
1280
  
1281
  	/* see if there's room to add content, else ignore */
1282
+         if ( DrawFullLine )
1283
+         {
1284
  	if ((col < COLS && wlen < destlen) || soft)
1285
  	{
1286
  	  int pad;
1287
***************
1288
*** 1324,1329 ****
1289
--- 1326,1377 ----
1290
  	  col += wid;
1291
  	  src += pl;
1292
  	}
1293
+         }
1294
+         else
1295
+         {
1296
+ 	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
1297
+         {
1298
+ 	  int pad;
1299
+ 
1300
+ 	  /* get contents after padding */
1301
+ 	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
1302
+ 	  len = mutt_strlen (buf);
1303
+ 	  wid = mutt_strwidth (buf);
1304
+ 
1305
+ 	  /* try to consume as many columns as we can, if we don't have
1306
+ 	   * memory for that, use as much memory as possible */
1307
+ 	  pad = (COLS - SidebarWidth - col - wid) / pw;
1308
+ 	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
1309
+ 	    pad = ((signed)(destlen - wlen - len)) / pl;
1310
+ 	  if (pad > 0)
1311
+ 	  {
1312
+ 	    while (pad--)
1313
+ 	    {
1314
+ 	      memcpy (wptr, src, pl);
1315
+ 	      wptr += pl;
1316
+ 	      wlen += pl;
1317
+ 	      col += pw;
1318
+ 	    }
1319
+ 	  }
1320
+ 	  else if (soft && pad < 0)
1321
+ 	  {
1322
+ 	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
1323
+ 	    *wptr = 0;
1324
+ 	    /* make sure right part is at most as wide as display */
1325
+ 	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
1326
+ 	    /* truncate left so that right part fits completely in */
1327
+ 	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
1328
+ 	    wptr = dest + wlen;
1329
+ 	  }
1330
+ 	  if (len + wlen > destlen)
1331
+ 	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
1332
+ 	  memcpy (wptr, buf, len);
1333
+ 	  wptr += len;
1334
+ 	  wlen += len;
1335
+ 	  col += wid;
1336
+ 	  src += pl;
1337
+ 	}
1338
+         }
1339
  	break; /* skip rest of input */
1340
        }
1341
        else if (ch == '|')
1342
*** mutt-1.5.23-orig/mx.c	2014-03-12 11:03:45.000000000 -0500
1343
--- mutt-1.5.23/mx.c	2014-04-11 10:14:01.000000000 -0500
1344
***************
1345
*** 580,585 ****
1346
--- 580,586 ----
1347
   *		M_APPEND	open mailbox for appending
1348
   *		M_READONLY	open mailbox in read-only mode
1349
   *		M_QUIET		only print error messages
1350
+  *		M_PEEK		revert atime where applicable
1351
   *	ctx	if non-null, context struct to use
555
   */
1352
   */
556
+  {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"},
1353
  CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
557
+  /*
1354
***************
558
+  ** .pp
1355
*** 602,607 ****
559
+  ** This specifies the delimiter between the sidebar (if visible) and 
1356
--- 603,610 ----
560
+  ** other screens.
1357
      ctx->quiet = 1;
561
+  */
1358
    if (flags & M_READONLY)
562
+  { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 },
1359
      ctx->readonly = 1;
563
+  /*
1360
+   if (flags & M_PEEK)
564
+  ** .pp
1361
+     ctx->peekonly = 1;
565
+  ** This specifies whether or not to show sidebar (left-side list of folders).
1362
  
566
+  */
1363
    if (flags & (M_APPEND|M_NEWFOLDER))
567
+  { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 },
1364
    {
568
+  /*
1365
***************
569
+  ** .pp
1366
*** 701,713 ****
570
+  ** This specifies whether or not to sort the sidebar alphabetically.
1367
  void mx_fastclose_mailbox (CONTEXT *ctx)
571
+  */
1368
  {
572
+  { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 },
1369
    int i;
573
+  /*
1370
  
574
+  ** .pp
1371
    if(!ctx) 
575
+  ** The width of the sidebar.
1372
      return;
576
+  */
1373
  
577
   { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
1374
    /* never announce that a mailbox we've just left has new mail. #3290
578
   /*
1375
     * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
579
   ** .pp
1376
!   mutt_buffy_setnotified(ctx->path);
580
diff -uNp -r mutt-1.5.22.orig/mailbox.h mutt-1.5.22/mailbox.h
1377
  
581
--- mutt-1.5.22.orig/mailbox.h	Sun Feb 21 22:10:41 2010
1378
    if (ctx->mx_close)
582
+++ mutt-1.5.22/mailbox.h	Fri Oct 18 10:18:45 2013
1379
      ctx->mx_close (ctx);
583
@@ -27,6 +27,7 @@
1380
--- 704,729 ----
584
 #define M_NEWFOLDER	(1<<4) /* create a new folder - same as M_APPEND, but uses
1381
  void mx_fastclose_mailbox (CONTEXT *ctx)
585
 				* safe_fopen() for mbox-style folders.
1382
  {
586
 				*/
1383
    int i;
587
+#define M_PEEK		(1<<5) /* revert atime back after taking a look (if applicable) */
1384
+ #ifndef BUFFY_SIZE
588
 
1385
+   struct utimbuf ut;
589
 /* mx_open_new_message() */
1386
+ #endif
590
 #define M_ADD_FROM	1	/* add a From_ line */
1387
  
591
diff -uNp -r mutt-1.5.22.orig/mbox.c mutt-1.5.22/mbox.c
1388
    if(!ctx) 
592
--- mutt-1.5.22.orig/mbox.c	Fri Oct 18 05:48:24 2013
1389
      return;
593
+++ mutt-1.5.22/mbox.c	Fri Oct 18 10:18:45 2013
1390
+ #ifndef BUFFY_SIZE
594
@@ -100,6 +100,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
1391
+   /* fix up the times so buffy won't get confused */
595
     mutt_perror (ctx->path);
1392
+   if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
596
     return (-1);
1393
+   {
597
   }
1394
+     ut.actime = ctx->atime;
598
+  ctx->atime = sb.st_atime;
1395
+     ut.modtime = ctx->mtime;
599
   ctx->mtime = sb.st_mtime;
1396
+     utime (ctx->path, &ut); 
600
   ctx->size = sb.st_size;
1397
+   }
601
 
1398
+ #endif
602
@@ -251,6 +252,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
1399
  
603
 
1400
    /* never announce that a mailbox we've just left has new mail. #3290
604
   ctx->size = sb.st_size;
1401
     * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
605
   ctx->mtime = sb.st_mtime;
1402
!   if(!ctx->peekonly)
606
+  ctx->atime = sb.st_atime;
1403
!     mutt_buffy_setnotified(ctx->path);
607
 
1404
  
608
 #ifdef NFS_ATTRIBUTE_HACK
1405
    if (ctx->mx_close)
609
   if (sb.st_mtime > sb.st_atime)
1406
      ctx->mx_close (ctx);
610
diff -uNp -r mutt-1.5.22.orig/menu.c mutt-1.5.22/menu.c
1407
***************
611
--- mutt-1.5.22.orig/menu.c	Tue Jan 15 07:37:15 2013
1408
*** 719,724 ****
612
+++ mutt-1.5.22/menu.c	Fri Oct 18 10:18:45 2013
1409
--- 735,742 ----
613
@@ -24,6 +24,7 @@
1410
    mutt_clear_threads (ctx);
614
 #include "mutt_curses.h"
1411
    for (i = 0; i < ctx->msgcount; i++)
615
 #include "mutt_menu.h"
1412
      mutt_free_header (&ctx->hdrs[i]);
616
 #include "mbyte.h"
1413
+   ctx->msgcount -= ctx->deleted;
617
+#include "sidebar.h"
1414
+   set_buffystats(ctx);
618
 
1415
    FREE (&ctx->hdrs);
619
 extern size_t UngetCount;
1416
    FREE (&ctx->v2r);
620
 
1417
    FREE (&ctx->path);
621
@@ -186,7 +187,7 @@ static void menu_pad_string (char *s, size_t n)
1418
***************
622
 {
1419
*** 812,817 ****
623
   char *scratch = safe_strdup (s);
1420
--- 830,839 ----
624
   int shift = option (OPTARROWCURSOR) ? 3 : 0;
1421
      if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 
625
-  int cols = COLS - shift;
1422
          && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
626
+  int cols = COLS - shift - SidebarWidth;
1423
        read_msgs++;
627
 
1424
+     if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read)
628
   mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1);
1425
+       ctx->unread--;
629
   s[n - 1] = 0;
1426
+     if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged)
630
@@ -239,6 +240,7 @@ void menu_redraw_index (MUTTMENU *menu)
1427
+       ctx->flagged--;
631
   int do_color;
1428
    }
632
   int attr;
1429
  
633
 
1430
    if (read_msgs && quadoption (OPT_MOVE) != M_NO)
634
+  draw_sidebar(1);
1431
*** mutt-1.5.23-orig/mx.h	2014-03-12 11:03:45.000000000 -0500
635
   for (i = menu->top; i < menu->top + menu->pagelen; i++)
1432
--- mutt-1.5.23/mx.h	2014-04-11 11:11:47.000000000 -0500
636
   {
1433
***************
637
     if (i < menu->max)
1434
*** 57,62 ****
638
@@ -249,7 +251,7 @@ void menu_redraw_index (MUTTMENU *menu)
1435
--- 57,63 ----
639
       menu_pad_string (buf, sizeof (buf));
1436
  int mh_read_dir (CONTEXT *, const char *);
640
 
1437
  int mh_sync_mailbox (CONTEXT *, int *);
641
       ATTRSET(attr);
1438
  int mh_check_mailbox (CONTEXT *, int *);
642
-      move(i - menu->top + menu->offset, 0);
1439
+ void mh_buffy_update (const char *, int *, int *, int *, time_t *);
643
+      move(i - menu->top + menu->offset, SidebarWidth);
1440
  int mh_check_empty (const char *);
644
       do_color = 1;
1441
  
645
 
1442
  int maildir_read_dir (CONTEXT *);
646
       if (i == menu->current)
1443
*** mutt-1.5.23-orig/OPS	2014-03-12 11:03:44.000000000 -0500
647
@@ -272,7 +274,7 @@ void menu_redraw_index (MUTTMENU *menu)
1444
--- mutt-1.5.23/OPS	2014-04-11 10:14:01.000000000 -0500
648
     else
1445
***************
649
     {
1446
*** 179,181 ****
650
       NORMAL_COLOR;
1447
--- 179,186 ----
651
-      CLEARLINE(i - menu->top + menu->offset);
1448
  OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
652
+      CLEARLINE_WIN(i - menu->top + menu->offset);
1449
  OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
653
     }
1450
  OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
654
   }
1451
+ OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page"
655
   NORMAL_COLOR;
1452
+ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page"
656
@@ -289,7 +291,7 @@ void menu_redraw_motion (MUTTMENU *menu)
1453
+ OP_SIDEBAR_NEXT "go down to next mailbox"
657
     return;
1454
+ OP_SIDEBAR_PREV "go to previous mailbox"
658
   }
1455
+ OP_SIDEBAR_OPEN "open hilighted mailbox"
1456
*** mutt-1.5.23-orig/pager.c	2014-03-12 11:06:17.000000000 -0500
1457
--- mutt-1.5.23/pager.c	2014-04-12 21:53:15.000000000 -0500
1458
***************
1459
*** 29,34 ****
1460
--- 29,35 ----
1461
  #include "pager.h"
1462
  #include "attach.h"
1463
  #include "mbyte.h"
1464
+ #include "sidebar.h"
1465
  
1466
  #include "mutt_crypt.h"
1467
  
1468
***************
1469
*** 1095,1100 ****
1470
--- 1096,1102 ----
1471
    wchar_t wc;
1472
    mbstate_t mbstate;
1473
    int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
1474
+   wrap_cols -= SidebarWidth;
1475
  
1476
    if (check_attachment_marker ((char *)buf) == 0)
1477
      wrap_cols = COLS;
1478
***************
1479
*** 1572,1577 ****
1480
--- 1574,1580 ----
1481
  
1482
    int bodyoffset = 1;			/* offset of first line of real text */
1483
    int statusoffset = 0; 		/* offset for the status bar */
1484
+   int statuswidth;
1485
    int helpoffset = LINES - 2;		/* offset for the help bar. */
1486
    int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */
1487
  
1488
***************
1489
*** 1746,1752 ****
1490
      if ((redraw & REDRAW_BODY) || topline != oldtopline)
1491
      {
1492
        do {
1493
! 	move (bodyoffset, 0);
1494
  	curline = oldtopline = topline;
1495
  	lines = 0;
1496
  	force_redraw = 0;
1497
--- 1749,1755 ----
1498
      if ((redraw & REDRAW_BODY) || topline != oldtopline)
1499
      {
1500
        do {
1501
! 	move (bodyoffset, SidebarWidth);
1502
  	curline = oldtopline = topline;
1503
  	lines = 0;
1504
  	force_redraw = 0;
1505
***************
1506
*** 1759,1764 ****
1507
--- 1762,1768 ----
1508
  			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
1509
  	    lines++;
1510
  	  curline++;
1511
+   	  move(lines + bodyoffset, SidebarWidth);
1512
  	}
1513
  	last_offset = lineInfo[curline].offset;
1514
        } while (force_redraw);
1515
***************
1516
*** 1771,1776 ****
1517
--- 1775,1781 ----
1518
  	  addch ('~');
1519
  	addch ('\n');
1520
  	lines++;
1521
+   	move(lines + bodyoffset, SidebarWidth);
1522
        }
1523
        NORMAL_COLOR;
1524
  
1525
***************
1526
*** 1788,1816 ****
1527
        hfi.ctx = Context;
1528
        hfi.pager_progress = pager_progress_str;
1529
  
1530
        if (last_pos < sb.st_size - 1)
1531
  	snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1532
        else
1533
  	strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1534
  
1535
        /* print out the pager status bar */
1536
!       move (statusoffset, 0);
1537
        SETCOLOR (MT_COLOR_STATUS);
1538
  
1539
        if (IsHeader (extra) || IsMsgAttach (extra))
1540
        {
1541
! 	size_t l1 = COLS * MB_LEN_MAX;
1542
  	size_t l2 = sizeof (buffer);
1543
  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1544
  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1545
! 	mutt_paddstr (COLS, buffer);
1546
        }
1547
        else
1548
        {
1549
  	char bn[STRING];
1550
  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1551
! 	mutt_paddstr (COLS, bn);
1552
        }
1553
        NORMAL_COLOR;
1554
      }
1555
  
1556
--- 1793,1831 ----
1557
        hfi.ctx = Context;
1558
        hfi.pager_progress = pager_progress_str;
1559
  
1560
+       statuswidth = COLS - (option(OPTSTATUSONTOP) && PagerIndexLines > 0 ? SidebarWidth : 0);
1561
+ 
1562
        if (last_pos < sb.st_size - 1)
1563
  	snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size));
1564
        else
1565
  	strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str));
1566
  
1567
        /* print out the pager status bar */
1568
!       move (statusoffset, SidebarWidth);
1569
        SETCOLOR (MT_COLOR_STATUS);
1570
+       if(option(OPTSTATUSONTOP) && PagerIndexLines > 0) {
1571
+           CLEARLINE_WIN (statusoffset);
1572
+       } else {
1573
+           CLEARLINE (statusoffset);
1574
+           DrawFullLine = 1; /* for mutt_make_string_info */
1575
+       }
1576
  
1577
        if (IsHeader (extra) || IsMsgAttach (extra))
1578
        {
1579
! 	size_t l1 = statuswidth * MB_LEN_MAX;
1580
  	size_t l2 = sizeof (buffer);
1581
  	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
1582
  	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
1583
! 	mutt_paddstr (statuswidth, buffer);
1584
        }
1585
        else
1586
        {
1587
  	char bn[STRING];
1588
  	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
1589
! 	mutt_paddstr (statuswidth, bn);
1590
        }
1591
+       if(!option(OPTSTATUSONTOP) || PagerIndexLines == 0)
1592
+           DrawFullLine = 0; /* reset */
1593
        NORMAL_COLOR;
1594
      }
1595
  
1596
***************
1597
*** 1819,1834 ****
1598
        /* redraw the pager_index indicator, because the
1599
         * flags for this message might have changed. */
1600
        menu_redraw_current (index);
1601
  
1602
        /* print out the index status bar */
1603
        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
659
   
1604
   
660
-  move (menu->oldcurrent + menu->offset - menu->top, 0);
1605
!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
661
+  move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth);
1606
        SETCOLOR (MT_COLOR_STATUS);
662
   ATTRSET(menu->color (menu->oldcurrent));
1607
!       mutt_paddstr (COLS, buffer);
663
 
1608
        NORMAL_COLOR;
664
   if (option (OPTARROWCURSOR))
1609
      }
665
@@ -301,13 +303,13 @@ void menu_redraw_motion (MUTTMENU *menu)
1610
  
666
     {
1611
      redraw = 0;
667
       menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
1612
  
668
       menu_pad_string (buf, sizeof (buf));
1613
      if (option(OPTBRAILLEFRIENDLY)) {
669
-      move (menu->oldcurrent + menu->offset - menu->top, 3);
1614
--- 1834,1855 ----
670
+      move (menu->oldcurrent + menu->offset - menu->top, SidebarWidth + 3);
1615
        /* redraw the pager_index indicator, because the
671
       print_enriched_string (menu->color(menu->oldcurrent), (unsigned char *) buf, 1);
1616
         * flags for this message might have changed. */
672
     }
1617
        menu_redraw_current (index);
673
 
1618
+       draw_sidebar(MENU_PAGER);
674
     /* now draw it in the new location */
1619
  
675
     SETCOLOR(MT_COLOR_INDICATOR);
1620
        /* print out the index status bar */
676
-    mvaddstr(menu->current + menu->offset - menu->top, 0, "->");
1621
        menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
677
+    mvaddstr(menu->current + menu->offset - menu->top, SidebarWidth, "->");
678
   }
679
   else
680
   {
681
@@ -320,7 +322,7 @@ void menu_redraw_motion (MUTTMENU *menu)
682
     menu_make_entry (buf, sizeof (buf), menu, menu->current);
683
     menu_pad_string (buf, sizeof (buf));
684
     SETCOLOR(MT_COLOR_INDICATOR);
685
-    move(menu->current - menu->top + menu->offset, 0);
686
+    move(menu->current - menu->top + menu->offset, SidebarWidth);
687
     print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0);
688
   }
689
   menu->redraw &= REDRAW_STATUS;
690
@@ -332,7 +334,7 @@ void menu_redraw_current (MUTTMENU *menu)
691
   char buf[LONG_STRING];
692
   int attr = menu->color (menu->current);
693
   
1622
   
694
-  move (menu->current + menu->offset - menu->top, 0);
1623
!       move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)),
695
+  move (menu->current + menu->offset - menu->top, SidebarWidth);
1624
!           (option(OPTSTATUSONTOP) ? 0: SidebarWidth));
696
   menu_make_entry (buf, sizeof (buf), menu, menu->current);
1625
        SETCOLOR (MT_COLOR_STATUS);
697
   menu_pad_string (buf, sizeof (buf));
1626
!       mutt_paddstr (COLS - (option(OPTSTATUSONTOP) ? 0 : SidebarWidth), buffer);
698
 
1627
        NORMAL_COLOR;
699
@@ -872,7 +874,7 @@ int mutt_menuLoop (MUTTMENU *menu)
1628
      }
700
     
701
     
702
     if (option (OPTARROWCURSOR))
703
-      move (menu->current - menu->top + menu->offset, 2);
704
+      move (menu->current - menu->top + menu->offset, SidebarWidth + 2);
705
     else if (option (OPTBRAILLEFRIENDLY))
706
       move (menu->current - menu->top + menu->offset, 0);
707
     else
708
diff -uNp -r mutt-1.5.22.orig/mh.c mutt-1.5.22/mh.c
709
--- mutt-1.5.22.orig/mh.c	Mon Apr 22 07:14:53 2013
710
+++ mutt-1.5.22/mh.c	Fri Oct 18 10:18:45 2013
711
@@ -295,6 +295,28 @@ void mh_buffy(BUFFY *b)
712
   mhs_free_sequences (&mhs);
713
 }
714
 
715
+void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged)
716
+{
717
+  int i;
718
+  struct mh_sequences mhs;
719
+  memset (&mhs, 0, sizeof (mhs));
720
+
721
+  if (mh_read_sequences (&mhs, path) < 0)
722
+    return;
723
+
724
+  msgcount = 0;
725
+  msg_unread = 0;
726
+  msg_flagged = 0;
727
+  for (i = 0; i <= mhs.max; i++)
728
+    msgcount++;
729
+  if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) {
730
+    msg_unread++;
731
+  }
732
+  if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED)
733
+    msg_flagged++;
734
+  mhs_free_sequences (&mhs);
735
+}
736
+
737
 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
738
 {
739
   int fd;
740
diff -uNp -r mutt-1.5.22.orig/mutt.h mutt-1.5.22/mutt.h
741
--- mutt-1.5.22.orig/mutt.h	Fri Oct 18 05:48:24 2013
742
+++ mutt-1.5.22/mutt.h	Fri Oct 18 10:18:45 2013
743
@@ -420,6 +420,8 @@ enum
744
   OPTSAVEEMPTY,
745
   OPTSAVENAME,
746
   OPTSCORE,
747
+  OPTSIDEBAR,
748
+  OPTSIDEBARSORT,
749
   OPTSIGDASHES,
750
   OPTSIGONTOP,
751
   OPTSORTRE,
752
@@ -860,6 +862,7 @@ typedef struct _context
753
 {
754
   char *path;
755
   FILE *fp;
756
+  time_t atime;
757
   time_t mtime;
758
   off_t size;
759
   off_t vsize;
760
@@ -894,6 +897,7 @@ typedef struct _context
761
   unsigned int quiet : 1;	/* inhibit status messages? */
762
   unsigned int collapsed : 1;   /* are all threads collapsed? */
763
   unsigned int closing : 1;	/* mailbox is being closed */
764
+  unsigned int peekonly : 1;	/* just taking a glance, revert atime */
765
 
766
   /* driver hooks */
767
   void *data;			/* driver specific data */
768
diff -uNp -r mutt-1.5.22.orig/mutt_curses.h mutt-1.5.22/mutt_curses.h
769
--- mutt-1.5.22.orig/mutt_curses.h	Tue Jan 15 07:37:15 2013
770
+++ mutt-1.5.22/mutt_curses.h	Fri Oct 18 10:22:32 2013
771
@@ -64,6 +64,7 @@
772
 #undef lines
773
 #endif /* lines */
774
 
775
+#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol()
776
 #define CLEARLINE(x) move(x,0), clrtoeol()
777
 #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x)
778
 #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0)
779
@@ -120,6 +121,8 @@ enum
780
   MT_COLOR_BOLD,
781
   MT_COLOR_UNDERLINE,
782
   MT_COLOR_INDEX,
783
+  MT_COLOR_NEW,
784
+  MT_COLOR_FLAGGED,
785
   MT_COLOR_MAX
786
 };
787
 
788
diff -uNp -r mutt-1.5.22.orig/muttlib.c mutt-1.5.22/muttlib.c
789
--- mutt-1.5.22.orig/muttlib.c	Fri Oct 18 05:48:24 2013
790
+++ mutt-1.5.22/muttlib.c	Fri Oct 18 10:18:45 2013
791
@@ -1286,6 +1286,8 @@ void mutt_FormatString (char *dest,		/* output buffer 
792
 	  pl = pw = 1;
793
 
794
 	/* see if there's room to add content, else ignore */
795
+        if ( DrawFullLine )
796
+        {
797
 	if ((col < COLS && wlen < destlen) || soft)
798
 	{
799
 	  int pad;
800
@@ -1329,6 +1331,52 @@ void mutt_FormatString (char *dest,		/* output buffer 
801
 	  col += wid;
802
 	  src += pl;
803
 	}
804
+        }
805
+        else
806
+        {
807
+	if ((col < COLS-SidebarWidth && wlen < destlen) || soft)
808
+        {
809
+	  int pad;
810
+
811
+	  /* get contents after padding */
812
+	  mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags);
813
+	  len = mutt_strlen (buf);
814
+	  wid = mutt_strwidth (buf);
815
+
816
+	  /* try to consume as many columns as we can, if we don't have
817
+	   * memory for that, use as much memory as possible */
818
+	  pad = (COLS - SidebarWidth - col - wid) / pw;
819
+	  if (pad > 0 && wlen + (pad * pl) + len > destlen)
820
+	    pad = ((signed)(destlen - wlen - len)) / pl;
821
+	  if (pad > 0)
822
+	  {
823
+	    while (pad--)
824
+	    {
825
+	      memcpy (wptr, src, pl);
826
+	      wptr += pl;
827
+	      wlen += pl;
828
+	      col += pw;
829
+	    }
830
+	  }
831
+	  else if (soft && pad < 0)
832
+	  {
833
+	    /* \0-terminate dest for length computation in mutt_wstr_trunc() */
834
+	    *wptr = 0;
835
+	    /* make sure right part is at most as wide as display */
836
+	    len = mutt_wstr_trunc (buf, destlen, COLS, &wid);
837
+	    /* truncate left so that right part fits completely in */
838
+	    wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col);
839
+	    wptr = dest + wlen;
840
+	  }
841
+	  if (len + wlen > destlen)
842
+	    len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL);
843
+	  memcpy (wptr, buf, len);
844
+	  wptr += len;
845
+	  wlen += len;
846
+	  col += wid;
847
+	  src += pl;
848
+	}
849
+        }
850
 	break; /* skip rest of input */
851
       }
852
       else if (ch == '|')
853
diff -uNp -r mutt-1.5.22.orig/mx.c mutt-1.5.22/mx.c
854
--- mutt-1.5.22.orig/mx.c	Fri Oct 18 05:48:24 2013
855
+++ mutt-1.5.22/mx.c	Fri Oct 18 10:18:45 2013
856
@@ -580,6 +580,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int f
857
  *		M_APPEND	open mailbox for appending
858
  *		M_READONLY	open mailbox in read-only mode
859
  *		M_QUIET		only print error messages
860
+ *		M_PEEK		revert atime where applicable
861
  *	ctx	if non-null, context struct to use
862
  */
863
 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
864
@@ -602,6 +603,8 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
865
     ctx->quiet = 1;
866
   if (flags & M_READONLY)
867
     ctx->readonly = 1;
868
+  if (flags & M_PEEK)
869
+    ctx->peekonly = 1;
870
 
871
   if (flags & (M_APPEND|M_NEWFOLDER))
872
   {
873
@@ -701,9 +704,21 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
874
 void mx_fastclose_mailbox (CONTEXT *ctx)
875
 {
876
   int i;
877
+#ifndef BUFFY_SIZE
878
+  struct utimbuf ut;
879
+#endif
880
 
881
   if(!ctx) 
882
     return;
883
+#ifndef BUFFY_SIZE
884
+  /* fix up the times so buffy won't get confused */
885
+  if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime)
886
+  {
887
+    ut.actime = ctx->atime;
888
+    ut.modtime = ctx->mtime;
889
+    utime (ctx->path, &ut); 
890
+  }
891
+#endif
892
 
893
   /* never announce that a mailbox we've just left has new mail. #3290
894
    * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
895
diff -uNp -r mutt-1.5.22.orig/mx.h mutt-1.5.22/mx.h
896
--- mutt-1.5.22.orig/mx.h	Mon Apr 22 07:14:53 2013
897
+++ mutt-1.5.22/mx.h	Fri Oct 18 10:18:45 2013
898
@@ -57,6 +57,7 @@ void mbox_reset_atime (CONTEXT *, struct stat *);
899
 int mh_read_dir (CONTEXT *, const char *);
900
 int mh_sync_mailbox (CONTEXT *, int *);
901
 int mh_check_mailbox (CONTEXT *, int *);
902
+void mh_buffy_update (const char *, int *, int *, int *);
903
 int mh_check_empty (const char *);
904
 
905
 int maildir_read_dir (CONTEXT *);
906
diff -uNp -r mutt-1.5.22.orig/pager.c mutt-1.5.22/pager.c
907
--- mutt-1.5.22.orig/pager.c	Mon Apr 22 07:17:32 2013
908
+++ mutt-1.5.22/pager.c	Fri Oct 18 10:18:45 2013
909
@@ -29,6 +29,7 @@
910
 #include "pager.h"
911
 #include "attach.h"
912
 #include "mbyte.h"
913
+#include "sidebar.h"
914
 
915
 #include "mutt_crypt.h"
916
 
917
@@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int 
918
   wchar_t wc;
919
   mbstate_t mbstate;
920
   int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap);
921
+  wrap_cols -= SidebarWidth;
922
 
923
   if (check_attachment_marker ((char *)buf) == 0)
924
     wrap_cols = COLS;
925
@@ -1746,7 +1748,7 @@ mutt_pager (const char *banner, const char *fname, int
926
     if ((redraw & REDRAW_BODY) || topline != oldtopline)
927
     {
928
       do {
929
-	move (bodyoffset, 0);
930
+	move (bodyoffset, SidebarWidth);
931
 	curline = oldtopline = topline;
932
 	lines = 0;
933
 	force_redraw = 0;
934
@@ -1759,6 +1761,7 @@ mutt_pager (const char *banner, const char *fname, int
935
 			    &QuoteList, &q_level, &force_redraw, &SearchRE) > 0)
936
 	    lines++;
937
 	  curline++;
938
+  	  move(lines + bodyoffset, SidebarWidth);
939
 	}
940
 	last_offset = lineInfo[curline].offset;
941
       } while (force_redraw);
942
@@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int
943
 	  addch ('~');
944
 	addch ('\n');
945
 	lines++;
946
+  	move(lines + bodyoffset, SidebarWidth);
947
       }
948
       NORMAL_COLOR;
949
 
950
@@ -1799,17 +1803,17 @@ mutt_pager (const char *banner, const char *fname, int
951
 
952
       if (IsHeader (extra) || IsMsgAttach (extra))
953
       {
954
-	size_t l1 = COLS * MB_LEN_MAX;
955
+	size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX;
956
 	size_t l2 = sizeof (buffer);
957
 	hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr;
958
 	mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT);
959
-	mutt_paddstr (COLS, buffer);
960
+	mutt_paddstr (COLS-SidebarWidth, buffer);
961
       }
962
       else
963
       {
964
 	char bn[STRING];
965
 	snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str);
966
-	mutt_paddstr (COLS, bn);
967
+	mutt_paddstr (COLS-SidebarWidth, bn);
968
       }
969
       NORMAL_COLOR;
970
     }
971
@@ -1819,16 +1823,21 @@ mutt_pager (const char *banner, const char *fname, int
972
       /* redraw the pager_index indicator, because the
973
        * flags for this message might have changed. */
974
       menu_redraw_current (index);
975
+      draw_sidebar(MENU_PAGER);
976
 
977
       /* print out the index status bar */
978
       menu_status_line (buffer, sizeof (buffer), index, NONULL(Status));
979
  
1629
  
980
-      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0);
1630
+     /* if we're not using the index, update every time */
981
+      move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth);
1631
+     if ( index == 0 )
982
       SETCOLOR (MT_COLOR_STATUS);
1632
+       draw_sidebar(MENU_PAGER);
983
-      mutt_paddstr (COLS, buffer);
1633
+ 
984
+      mutt_paddstr (COLS-SidebarWidth, buffer);
1634
      redraw = 0;
985
       NORMAL_COLOR;
1635
  
986
     }
1636
      if (option(OPTBRAILLEFRIENDLY)) {
987
 
1637
***************
988
+    /* if we're not using the index, update every time */
1638
*** 2763,2768 ****
989
+    if ( index == 0 )
1639
--- 2784,2796 ----
990
+      draw_sidebar(MENU_PAGER);
1640
  	mutt_what_key ();
991
+
1641
  	break;
992
     redraw = 0;
1642
  
993
 
1643
+       case OP_SIDEBAR_SCROLL_UP:
994
     if (option(OPTBRAILLEFRIENDLY)) {
1644
+       case OP_SIDEBAR_SCROLL_DOWN:
995
@@ -2762,6 +2771,13 @@ search_next:
1645
+       case OP_SIDEBAR_NEXT:
996
       case OP_WHAT_KEY:
1646
+       case OP_SIDEBAR_PREV:
997
 	mutt_what_key ();
1647
+ 	scroll_sidebar(ch, MENU_PAGER);
998
 	break;
1648
+  	break;
999
+
1649
+ 
1000
+      case OP_SIDEBAR_SCROLL_UP:
1650
        default:
1001
+      case OP_SIDEBAR_SCROLL_DOWN:
1651
  	ch = -1;
1002
+      case OP_SIDEBAR_NEXT:
1652
  	break;
1003
+      case OP_SIDEBAR_PREV:
1653
*** mutt-1.5.23-orig/pattern.c	2014-03-12 11:03:45.000000000 -0500
1004
+	scroll_sidebar(ch, MENU_PAGER);
1654
--- mutt-1.5.23/pattern.c	2014-04-11 10:14:01.000000000 -0500
1005
+ 	break;
1655
***************
1006
 
1656
*** 154,159 ****
1007
       default:
1657
--- 154,163 ----
1008
 	ch = -1;
1658
    HEADER *h = ctx->hdrs[msgno];
1009
diff -uNp -r mutt-1.5.22.orig/sidebar.c mutt-1.5.22/sidebar.c
1659
    char *buf;
1010
--- mutt-1.5.22.orig/sidebar.c	Thu Jan  1 01:00:00 1970
1660
    size_t blen;
1011
+++ mutt-1.5.22/sidebar.c	Fri Oct 18 10:18:45 2013
1661
+ #ifdef HAVE_FMEMOPEN
1012
@@ -0,0 +1,333 @@
1662
+   char *temp;
1013
+/*
1663
+   size_t tempsize;
1014
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1664
+ #endif
1015
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1665
  
1016
+ * 
1666
    if ((msg = mx_open_message (ctx, msgno)) != NULL)
1017
+ *     This program is free software; you can redistribute it and/or modify
1667
    {
1018
+ *     it under the terms of the GNU General Public License as published by
1668
***************
1019
+ *     the Free Software Foundation; either version 2 of the License, or
1669
*** 163,174 ****
1020
+ *     (at your option) any later version.
1670
--- 167,186 ----
1021
+ * 
1671
        memset (&s, 0, sizeof (s));
1022
+ *     This program is distributed in the hope that it will be useful,
1672
        s.fpin = msg->fp;
1023
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1673
        s.flags = M_CHARCONV;
1024
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1674
+ #ifdef HAVE_FMEMOPEN
1025
+ *     GNU General Public License for more details.
1675
+       if((s.fpout = open_memstream(&temp, &tempsize)) == NULL)
1026
+ * 
1676
+       {
1027
+ *     You should have received a copy of the GNU General Public License
1677
+ 	mutt_perror ("Error opening memstream");
1028
+ *     along with this program; if not, write to the Free Software
1678
+ 	return (0);
1029
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1679
+       }
1030
+ */ 
1680
+ #else
1031
+
1681
        mutt_mktemp (tempfile, sizeof (tempfile));
1032
+
1682
        if ((s.fpout = safe_fopen (tempfile, "w+")) == NULL)
1033
+#if HAVE_CONFIG_H
1683
        {
1034
+# include "config.h"
1684
  	mutt_perror (tempfile);
1035
+#endif
1685
  	return (0);
1036
+
1686
        }
1037
+#include "mutt.h"
1687
+ #endif
1038
+#include "mutt_menu.h"
1688
  
1039
+#include "mutt_curses.h"
1689
        if (pat->op != M_BODY)
1040
+#include "sidebar.h"
1690
  	mutt_copy_header (msg->fp, h, s.fpout, CH_FROM | CH_DECODE, NULL);
1041
+#include "buffy.h"
1691
***************
1042
+#include <libgen.h>
1692
*** 184,190 ****
1043
+#include "keymap.h"
1693
--- 196,206 ----
1044
+#include <stdbool.h>
1694
  	  if (s.fpout)
1045
+
1695
  	  {
1046
+/*BUFFY *CurBuffy = 0;*/
1696
  	    safe_fclose (&s.fpout);
1047
+static BUFFY *TopBuffy = 0;
1697
+ #ifdef HAVE_FMEMOPEN
1048
+static BUFFY *BottomBuffy = 0;
1698
+             FREE(&temp);
1049
+static int known_lines = 0;
1699
+ #else
1050
+
1700
  	    unlink (tempfile);
1051
+static int quick_log10(int n)
1701
+ #endif
1052
+{
1702
  	  }
1053
+        char string[32];
1703
  	  return (0);
1054
+        sprintf(string, "%d", n);
1704
  	}
1055
+        return strlen(string);
1705
***************
1056
+}
1706
*** 193,203 ****
1057
+
1707
--- 209,236 ----
1058
+void calc_boundaries (int menu)
1708
  	mutt_body_handler (h->content, &s);
1059
+{
1709
        }
1060
+	BUFFY *tmp = Incoming;
1710
  
1061
+
1711
+ #ifdef HAVE_FMEMOPEN
1062
+	if ( known_lines != LINES ) {
1712
+       fclose(s.fpout);
1063
+		TopBuffy = BottomBuffy = 0;
1713
+       lng = tempsize;
1064
+		known_lines = LINES;
1714
+ 
1065
+	}
1715
+       if(tempsize) {
1066
+	for ( ; tmp->next != 0; tmp = tmp->next )
1716
+           if ((fp = fmemopen(temp, tempsize, "r")) == NULL) {
1067
+		tmp->next->prev = tmp;
1717
+             mutt_perror ("Error re-opening memstream");
1068
+
1718
+             return (0);
1069
+	if ( TopBuffy == 0 && BottomBuffy == 0 )
1719
+           }
1070
+		TopBuffy = Incoming;
1720
+       } else { /* fmemopen cannot handle empty buffers */
1071
+	if ( BottomBuffy == 0 ) {
1721
+           if ((fp = safe_fopen ("/dev/null", "r")) == NULL) {
1072
+		int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP));
1722
+             mutt_perror ("Error opening /dev/null");
1073
+		BottomBuffy = TopBuffy;
1723
+             return (0);
1074
+		while ( --count && BottomBuffy->next )
1724
+           }
1075
+			BottomBuffy = BottomBuffy->next;
1725
+       }
1076
+	}
1726
+ #else
1077
+	else if ( TopBuffy == CurBuffy->next ) {
1727
        fp = s.fpout;
1078
+		int count = LINES - 2 - (menu != MENU_PAGER);
1728
        fflush (fp);
1079
+		BottomBuffy = CurBuffy;
1729
        fseek (fp, 0, 0);
1080
+		tmp = BottomBuffy;
1730
        fstat (fileno (fp), &st);
1081
+		while ( --count && tmp->prev)
1731
        lng = (long) st.st_size;
1082
+			tmp = tmp->prev;
1732
+ #endif
1083
+		TopBuffy = tmp;
1733
      }
1084
+	}
1734
      else
1085
+	else if ( BottomBuffy == CurBuffy->prev ) {
1735
      {
1086
+		int count = LINES - 2 - (menu != MENU_PAGER);
1736
***************
1087
+		TopBuffy = CurBuffy;
1737
*** 244,250 ****
1088
+		tmp = TopBuffy;
1738
--- 277,288 ----
1089
+		while ( --count && tmp->next )
1739
      if (option (OPTTHOROUGHSRC))
1090
+			tmp = tmp->next;
1740
      {
1091
+		BottomBuffy = tmp;
1741
        safe_fclose (&fp);
1092
+	}
1742
+ #ifdef HAVE_FMEMOPEN
1093
+}
1743
+       if(tempsize)
1094
+
1744
+           FREE (&temp);
1095
+char *make_sidebar_entry(char *box, int size, int new, int flagged)
1745
+ #else
1096
+{
1746
        unlink (tempfile);
1097
+	static char *entry = 0;
1747
+ #endif
1098
+	char *c;
1748
      }
1099
+	int i = 0;
1749
    }
1100
+	int delim_len = strlen(SidebarDelim);
1750
  
1101
+
1751
*** mutt-1.5.23-orig/PATCHES	2014-03-12 11:03:44.000000000 -0500
1102
+	c = realloc(entry, SidebarWidth - delim_len + 2);
1752
--- mutt-1.5.23/PATCHES	2014-04-12 12:36:35.000000000 -0500
1103
+	if ( c ) entry = c;
1753
***************
1104
+	entry[SidebarWidth - delim_len + 1] = 0;
1754
*** 0 ****
1105
+	for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' );
1755
--- 1 ----
1106
+	i = strlen(box);
1756
+ patch-1.5.23.sidebar.20140412.txt
1107
+	strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) );
1757
*** mutt-1.5.23-orig/protos.h	2014-03-12 11:06:17.000000000 -0500
1108
+
1758
--- mutt-1.5.23/protos.h	2014-04-11 10:14:01.000000000 -0500
1109
+        if (size == -1)
1759
***************
1110
+                sprintf(entry + SidebarWidth - delim_len - 3, "?");
1760
*** 36,41 ****
1111
+        else if ( new ) {
1761
--- 36,48 ----
1112
+          if (flagged > 0) {
1762
    const char *pager_progress;
1113
+              sprintf(
1763
  };
1114
+		        entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged),
1764
  
1115
+		        "% d(%d)[%d]", size, new, flagged);
1765
+ struct sidebar_entry {
1766
+     char                box[SHORT_STRING];
1767
+     unsigned int        size;
1768
+     unsigned int        new;
1769
+     unsigned int        flagged;
1770
+ };
1771
+ 
1772
  void mutt_make_string_info (char *, size_t, const char *, struct hdr_format_info *, format_flag);
1773
  
1774
  int mutt_extract_token (BUFFER *, BUFFER *, int);
1775
*** mutt-1.5.23-orig/sidebar.c	1969-12-31 18:00:00.000000000 -0600
1776
--- mutt-1.5.23/sidebar.c	2014-04-11 10:14:01.000000000 -0500
1777
***************
1778
*** 0 ****
1779
--- 1,405 ----
1780
+ /*
1781
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1782
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1783
+  * 
1784
+  *     This program is free software; you can redistribute it and/or modify
1785
+  *     it under the terms of the GNU General Public License as published by
1786
+  *     the Free Software Foundation; either version 2 of the License, or
1787
+  *     (at your option) any later version.
1788
+  * 
1789
+  *     This program is distributed in the hope that it will be useful,
1790
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1791
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1792
+  *     GNU General Public License for more details.
1793
+  * 
1794
+  *     You should have received a copy of the GNU General Public License
1795
+  *     along with this program; if not, write to the Free Software
1796
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1797
+  */ 
1798
+ 
1799
+ 
1800
+ #if HAVE_CONFIG_H
1801
+ # include "config.h"
1802
+ #endif
1803
+ 
1804
+ #include "mutt.h"
1805
+ #include "mutt_menu.h"
1806
+ #include "mutt_curses.h"
1807
+ #include "sidebar.h"
1808
+ #include "buffy.h"
1809
+ #include <libgen.h>
1810
+ #include "keymap.h"
1811
+ #include <stdbool.h>
1812
+ 
1813
+ /*BUFFY *CurBuffy = 0;*/
1814
+ static BUFFY *TopBuffy = 0;
1815
+ static BUFFY *BottomBuffy = 0;
1816
+ static int known_lines = 0;
1817
+ 
1818
+ void calc_boundaries() {
1819
+ 
1820
+     BUFFY *tmp = Incoming;
1821
+ 
1822
+ 	int count = LINES - 2 - (option(OPTHELP) ? 1 : 0);
1823
+ 
1824
+ 	if ( known_lines != LINES ) {
1825
+ 		TopBuffy = BottomBuffy = 0;
1826
+ 		known_lines = LINES;
1827
+ 	}
1828
+ 	for ( ; tmp->next != 0; tmp = tmp->next )
1829
+ 		tmp->next->prev = tmp;
1830
+ 
1831
+ 	if ( TopBuffy == 0 && BottomBuffy == 0 )
1832
+ 		TopBuffy = Incoming;
1833
+ 	if ( BottomBuffy == 0 ) {
1834
+ 		BottomBuffy = TopBuffy;
1835
+ 		while ( --count && BottomBuffy->next )
1836
+ 			BottomBuffy = BottomBuffy->next;
1837
+ 	}
1838
+ 	else if ( TopBuffy == CurBuffy->next ) {
1839
+ 		BottomBuffy = CurBuffy;
1840
+ 		tmp = BottomBuffy;
1841
+ 		while ( --count && tmp->prev)
1842
+ 			tmp = tmp->prev;
1843
+ 		TopBuffy = tmp;
1844
+ 	}
1845
+ 	else if ( BottomBuffy == CurBuffy->prev ) {
1846
+ 		TopBuffy = CurBuffy;
1847
+ 		tmp = TopBuffy;
1848
+ 		while ( --count && tmp->next )
1849
+ 			tmp = tmp->next;
1850
+ 		BottomBuffy = tmp;
1851
+ 	}
1852
+ }
1853
+ 
1854
+ static const char *
1855
+ sidebar_format_str (char *dest,
1856
+ 			size_t destlen,
1857
+ 			size_t col,
1858
+ 			char op,
1859
+ 			const char *src,
1860
+ 			const char *prefix,
1861
+ 			const char *ifstring,
1862
+ 			const char *elsestring,
1863
+ 			unsigned long data,
1864
+ 			format_flag flags)
1865
+ {
1866
+ /* casting from unsigned long - srsly?! */
1867
+ struct sidebar_entry *sbe = (struct sidebar_entry *) data;
1868
+ unsigned int optional;
1869
+ char fmt[SHORT_STRING], buf[SHORT_STRING];
1870
+ 
1871
+ optional = flags & M_FORMAT_OPTIONAL;
1872
+ 
1873
+ switch(op) {
1874
+ 	case 'F':
1875
+ 		if(!optional) {
1876
+ 			snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1877
+ 			snprintf (dest, destlen, fmt, sbe->flagged);
1878
+ 		} else if(sbe->flagged == 0) {
1879
+ 			optional = 0;
1880
+ 		}
1881
+ 		break;
1882
+ 
1883
+ 	case '!':
1884
+ 		if(sbe->flagged == 0)
1885
+ 			mutt_format_s(dest, destlen, prefix, "");
1886
+ 		if(sbe->flagged == 1)
1887
+ 			mutt_format_s(dest, destlen, prefix, "!");
1888
+ 		if(sbe->flagged == 2)
1889
+ 			mutt_format_s(dest, destlen, prefix, "!!");
1890
+ 		if(sbe->flagged > 2) {
1891
+ 			snprintf (buf, sizeof (buf), "%d!", sbe->flagged);
1892
+ 			mutt_format_s(dest, destlen, prefix, buf);
1893
+ 		}
1894
+ 		break;
1895
+ 
1896
+ 	case 'S':
1897
+ 		snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1898
+ 		snprintf (dest, destlen, fmt, sbe->size);
1899
+ 		break;
1900
+ 
1901
+ 	case 'N':
1902
+ 		if(!optional) {
1903
+ 			snprintf (fmt, sizeof (fmt), "%%%sd", prefix);
1904
+ 			snprintf (dest, destlen, fmt, sbe->new);
1905
+ 		} else if(sbe->new == 0) {
1906
+ 			optional = 0;
1907
+ 		}
1908
+ 		break;
1909
+ 
1910
+ 	case 'B':
1911
+ 		mutt_format_s(dest, destlen, prefix, sbe->box);
1912
+ 		break;
1913
+ 	}
1914
+ 
1915
+ 	if(optional)
1916
+ 		mutt_FormatString (dest, destlen, col, ifstring, sidebar_format_str, (unsigned long) sbe, flags);
1917
+ 	else if (flags & M_FORMAT_OPTIONAL)
1918
+ 		mutt_FormatString (dest, destlen, col, elsestring, sidebar_format_str, (unsigned long) sbe, flags);
1919
+ 
1920
+ 	return (src);
1921
+ }
1922
+ 
1923
+ char *make_sidebar_entry(char *box, unsigned int size, unsigned int new, unsigned int flagged) {
1924
+     static char *entry = 0;
1925
+     struct sidebar_entry sbe;
1926
+     int SBvisual;
1927
+ 
1928
+     SBvisual = SidebarWidth - strlen(SidebarDelim);
1929
+     if (SBvisual < 1)
1930
+         return NULL;
1931
+ 
1932
+     sbe.new = new;
1933
+     sbe.flagged = flagged;
1934
+     sbe.size = size;
1935
+     strncpy(sbe.box, box, 31);
1936
+ 
1937
+     safe_realloc(&entry, SBvisual + 2);
1938
+     entry[SBvisual + 1] = '\0';
1939
+ 
1940
+     mutt_FormatString (entry, SBvisual+1, 0, SidebarFormat, sidebar_format_str, (unsigned long) &sbe, 0);
1941
+ 
1942
+     return entry;
1943
+ }
1944
+ 
1945
+ void set_curbuffy(char buf[LONG_STRING])
1946
+ {
1947
+   BUFFY* tmp = CurBuffy = Incoming;
1948
+ 
1949
+   if (!Incoming)
1950
+     return;
1951
+ 
1952
+   while(1) {
1953
+     if(!strcmp(tmp->path, buf) || !strcmp(tmp->realpath, buf)) {
1954
+       CurBuffy = tmp;
1955
+       break;
1956
+     }
1957
+ 
1958
+     if(tmp->next)
1959
+       tmp = tmp->next;
1960
+     else
1961
+       break;
1962
+   }
1963
+ }
1964
+ 
1965
+ int draw_sidebar(int menu) {
1966
+ 
1967
+ 	BUFFY *tmp;
1968
+ #ifndef USE_SLANG_CURSES
1969
+         attr_t attrs;
1970
+ #endif
1971
+         short delim_len = strlen(SidebarDelim);
1972
+         short color_pair;
1973
+ 
1974
+         static bool initialized = false;
1975
+         static int prev_show_value;
1976
+         static short saveSidebarWidth;
1977
+         int lines = 0;
1978
+         int SidebarHeight;
1979
+         
1980
+         if(option(OPTSTATUSONTOP) || option(OPTHELP))
1981
+                 lines++; /* either one will occupy the first line */
1982
+ 
1983
+         /* initialize first time */
1984
+         if(!initialized) {
1985
+                 prev_show_value = option(OPTSIDEBAR);
1986
+                 saveSidebarWidth = SidebarWidth;
1987
+                 if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1988
+                 initialized = true;
1989
+         }
1990
+ 
1991
+         /* save or restore the value SidebarWidth */
1992
+         if(prev_show_value != option(OPTSIDEBAR)) {
1993
+                 if(prev_show_value && !option(OPTSIDEBAR)) {
1994
+                         saveSidebarWidth = SidebarWidth;
1995
+                         SidebarWidth = 0;
1996
+                 } else if(!prev_show_value && option(OPTSIDEBAR)) {
1997
+                         mutt_buffy_check(1); /* we probably have bad or no numbers */
1998
+                         SidebarWidth = saveSidebarWidth;
1999
+                 }
2000
+                 prev_show_value = option(OPTSIDEBAR);
2001
+         }
2002
+ 
2003
+ 
2004
+ /*	if ( SidebarWidth == 0 ) return 0; */
2005
+        if (SidebarWidth > 0 && option (OPTSIDEBAR)
2006
+            && delim_len >= SidebarWidth) {
2007
+          unset_option (OPTSIDEBAR);
2008
+          /* saveSidebarWidth = SidebarWidth; */
2009
+          if (saveSidebarWidth > delim_len) {
2010
+            SidebarWidth = saveSidebarWidth;
2011
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
2012
+            sleep (2);
1116
+          } else {
2013
+          } else {
1117
+              sprintf(
2014
+            SidebarWidth = 0;
1118
+                      entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new),
2015
+            mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1119
+                      "% d(%d)", size, new);
2016
+            sleep (4); /* the advise to set a sane value should be seen long enough */
1120
+          }
2017
+          }
1121
+        } else if (flagged > 0) {
2018
+          saveSidebarWidth = 0;
1122
+              sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged);
2019
+          return (0);
1123
+        } else {
1124
+              sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size);
1125
+        }
1126
+	return entry;
1127
+}
1128
+
1129
+void set_curbuffy(char buf[LONG_STRING])
1130
+{
1131
+  BUFFY* tmp = CurBuffy = Incoming;
1132
+
1133
+  if (!Incoming)
1134
+    return;
1135
+
1136
+  while(1) {
1137
+    if(!strcmp(tmp->path, buf)) {
1138
+      CurBuffy = tmp;
1139
+      break;
1140
+    }
1141
+
1142
+    if(tmp->next)
1143
+      tmp = tmp->next;
1144
+    else
1145
+      break;
1146
+  }
1147
+}
1148
+
1149
+int draw_sidebar(int menu) {
1150
+
1151
+	int lines = option(OPTHELP) ? 1 : 0;
1152
+	BUFFY *tmp;
1153
+#ifndef USE_SLANG_CURSES
1154
+        attr_t attrs;
1155
+#endif
1156
+        short delim_len = strlen(SidebarDelim);
1157
+        short color_pair;
1158
+
1159
+        static bool initialized = false;
1160
+        static int prev_show_value;
1161
+        static short saveSidebarWidth;
1162
+
1163
+        /* initialize first time */
1164
+        if(!initialized) {
1165
+                prev_show_value = option(OPTSIDEBAR);
1166
+                saveSidebarWidth = SidebarWidth;
1167
+                if(!option(OPTSIDEBAR)) SidebarWidth = 0;
1168
+                initialized = true;
1169
+        }
1170
+
1171
+        /* save or restore the value SidebarWidth */
1172
+        if(prev_show_value != option(OPTSIDEBAR)) {
1173
+                if(prev_show_value && !option(OPTSIDEBAR)) {
1174
+                        saveSidebarWidth = SidebarWidth;
1175
+                        SidebarWidth = 0;
1176
+                } else if(!prev_show_value && option(OPTSIDEBAR)) {
1177
+                        SidebarWidth = saveSidebarWidth;
1178
+                }
1179
+                prev_show_value = option(OPTSIDEBAR);
1180
+        }
2020
+        }
1181
+
2021
+ 
1182
+
2022
+     if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
1183
+//	if ( SidebarWidth == 0 ) return 0;
2023
+       if (SidebarWidth > 0) {
1184
+       if (SidebarWidth > 0 && option (OPTSIDEBAR)
2024
+         saveSidebarWidth = SidebarWidth;
1185
+           && delim_len >= SidebarWidth) {
2025
+         SidebarWidth = 0;
1186
+         unset_option (OPTSIDEBAR);
1187
+         /* saveSidebarWidth = SidebarWidth; */
1188
+         if (saveSidebarWidth > delim_len) {
1189
+           SidebarWidth = saveSidebarWidth;
1190
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar."));
1191
+           sleep (2);
1192
+         } else {
1193
+           SidebarWidth = 0;
1194
+           mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value."));
1195
+           sleep (4); /* the advise to set a sane value should be seen long enough */
1196
+         }
1197
+         saveSidebarWidth = 0;
1198
+         return (0);
1199
+       }
2026
+       }
1200
+
2027
+       unset_option(OPTSIDEBAR);
1201
+    if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) {
2028
+       return 0;
1202
+      if (SidebarWidth > 0) {
2029
+     }
1203
+        saveSidebarWidth = SidebarWidth;
2030
+ 
1204
+        SidebarWidth = 0;
2031
+         /* get attributes for divider */
1205
+      }
2032
+ 	SETCOLOR(MT_COLOR_STATUS);
1206
+      unset_option(OPTSIDEBAR);
2033
+ #ifndef USE_SLANG_CURSES
1207
+      return 0;
2034
+         attr_get(&attrs, &color_pair, 0);
1208
+    }
2035
+ #else
1209
+
2036
+         color_pair = attr_get();
1210
+        /* get attributes for divider */
2037
+ #endif
1211
+	SETCOLOR(MT_COLOR_STATUS);
2038
+ 	SETCOLOR(MT_COLOR_NORMAL);
1212
+#ifndef USE_SLANG_CURSES
2039
+ 
1213
+        attr_get(&attrs, &color_pair, 0);
2040
+ 	/* draw the divider */
1214
+#else
2041
+ 
1215
+        color_pair = attr_get();
2042
+ 	SidebarHeight =  LINES - 1;
1216
+#endif
2043
+ 	if(option(OPTHELP) || !option(OPTSTATUSONTOP))
1217
+	SETCOLOR(MT_COLOR_NORMAL);
2044
+ 		SidebarHeight--;
1218
+
2045
+ 
1219
+	/* draw the divider */
2046
+ 	for ( ; lines < SidebarHeight; lines++ ) {
1220
+
2047
+ 		move(lines, SidebarWidth - delim_len);
1221
+	for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
2048
+ 		addstr(NONULL(SidebarDelim));
1222
+		move(lines, SidebarWidth - delim_len);
2049
+ #ifndef USE_SLANG_CURSES
1223
+		addstr(NONULL(SidebarDelim));
2050
+                 mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
1224
+#ifndef USE_SLANG_CURSES
2051
+ #endif
1225
+                mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL);
2052
+ 	}
1226
+#endif
2053
+ 
1227
+	}
2054
+ 	if ( Incoming == 0 ) return 0;
1228
+
2055
+         lines = 0;
1229
+	if ( Incoming == 0 ) return 0;
2056
+         if(option(OPTSTATUSONTOP) || option(OPTHELP))
1230
+	lines = option(OPTHELP) ? 1 : 0; /* go back to the top */
2057
+                 lines++; /* either one will occupy the first line */
1231
+
2058
+ 
1232
+	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
2059
+ 	if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 
1233
+		calc_boundaries(menu);
2060
+ 		calc_boundaries(menu);
1234
+	if ( CurBuffy == 0 ) CurBuffy = Incoming;
2061
+ 	if ( CurBuffy == 0 ) CurBuffy = Incoming;
1235
+
2062
+ 
1236
+	tmp = TopBuffy;
2063
+ 	tmp = TopBuffy;
1237
+
2064
+ 
1238
+	SETCOLOR(MT_COLOR_NORMAL);
2065
+ 	SETCOLOR(MT_COLOR_NORMAL);
1239
+
2066
+ 
1240
+	for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) {
2067
+ 	for ( ; tmp && lines < SidebarHeight; tmp = tmp->next ) {
1241
+		if ( tmp == CurBuffy )
2068
+ 		if ( tmp == CurBuffy )
1242
+			SETCOLOR(MT_COLOR_INDICATOR);
2069
+ 			SETCOLOR(MT_COLOR_INDICATOR);
1243
+		else if ( tmp->msg_unread > 0 )
2070
+ 		else if ( tmp->msg_unread > 0 )
1244
+			SETCOLOR(MT_COLOR_NEW);
2071
+ 			SETCOLOR(MT_COLOR_NEW);
1245
+		else if ( tmp->msg_flagged > 0 )
2072
+ 		else if ( tmp->msg_flagged > 0 )
1246
+		        SETCOLOR(MT_COLOR_FLAGGED);
2073
+ 		        SETCOLOR(MT_COLOR_FLAGGED);
1247
+		else
2074
+ 		else
1248
+			SETCOLOR(MT_COLOR_NORMAL);
2075
+ 			SETCOLOR(MT_COLOR_NORMAL);
1249
+
2076
+ 
1250
+		move( lines, 0 );
2077
+ 		move( lines, 0 );
1251
+		if ( Context && !strcmp( tmp->path, Context->path ) ) {
2078
+ 		if ( Context && (!strcmp(tmp->path, Context->path)||
1252
+			tmp->msg_unread = Context->unread;
2079
+ 				 !strcmp(tmp->realpath, Context->path)) ) {
1253
+			tmp->msgcount = Context->msgcount;
2080
+ 			tmp->msg_unread = Context->unread;
1254
+			tmp->msg_flagged = Context->flagged;
2081
+ 			tmp->msgcount = Context->msgcount;
1255
+		}
2082
+ 			tmp->msg_flagged = Context->flagged;
1256
+		// check whether Maildir is a prefix of the current folder's path
2083
+ 		}
1257
+		short maildir_is_prefix = 0;
2084
+ 		/* check whether Maildir is a prefix of the current folder's path */
1258
+		if ( (strlen(tmp->path) > strlen(Maildir)) &&
2085
+ 		short maildir_is_prefix = 0;
1259
+			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
2086
+ 		if ( (strlen(tmp->path) > strlen(Maildir)) &&
1260
+        		maildir_is_prefix = 1;
2087
+ 			(strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) )
1261
+		// calculate depth of current folder and generate its display name with indented spaces
2088
+         		maildir_is_prefix = 1;
1262
+		int sidebar_folder_depth = 0;
2089
+ 		/* calculate depth of current folder and generate its display name with indented spaces */
1263
+		char *sidebar_folder_name;
2090
+ 		int sidebar_folder_depth = 0;
1264
+		sidebar_folder_name = basename(tmp->path);
2091
+ 		char *sidebar_folder_name;
1265
+		if ( maildir_is_prefix ) {
2092
+ 		sidebar_folder_name = option(OPTSIDEBARSHORTPATH) ? mutt_basename(tmp->path) : tmp->path + maildir_is_prefix*(strlen(Maildir) + 1);
1266
+			char *tmp_folder_name;
2093
+ 		if ( maildir_is_prefix && option(OPTSIDEBARFOLDERINDENT) ) {
1267
+			int i;
2094
+ 			char *tmp_folder_name;
1268
+			tmp_folder_name = tmp->path + strlen(Maildir);
2095
+ 			int i;
1269
+			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
2096
+ 			tmp_folder_name = tmp->path + strlen(Maildir) + 1;
1270
+				if (tmp_folder_name[i] == '/') sidebar_folder_depth++;
2097
+ 			for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) {
1271
+			}   
2098
+  				if (tmp_folder_name[i] == '/'  || tmp_folder_name[i] == '.') sidebar_folder_depth++;
1272
+			if (sidebar_folder_depth > 0) {
2099
+ 			}   
1273
+				sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1);
2100
+ 			if (sidebar_folder_depth > 0) {
1274
+				for (i=0; i < sidebar_folder_depth; i++)
2101
+  				if (option(OPTSIDEBARSHORTPATH)) {
1275
+					sidebar_folder_name[i]=' ';
2102
+  					tmp_folder_name = strrchr(tmp->path, '.');
1276
+				sidebar_folder_name[i]=0;
2103
+  					if (tmp_folder_name == NULL)
1277
+				strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth);
2104
+  						tmp_folder_name = mutt_basename(tmp->path);
1278
+			}
2105
+  					else
1279
+		}
2106
+ 						tmp_folder_name++;
1280
+		printw( "%.*s", SidebarWidth - delim_len + 1,
2107
+  				}
1281
+			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
2108
+  				else
1282
+			tmp->msg_unread, tmp->msg_flagged));
2109
+  					tmp_folder_name = tmp->path + strlen(Maildir) + 1;
1283
+		if (sidebar_folder_depth > 0)
2110
+  				sidebar_folder_name = malloc(strlen(tmp_folder_name) + sidebar_folder_depth*strlen(NONULL(SidebarIndentStr)) + 1);
1284
+		        free(sidebar_folder_name);
2111
+ 				sidebar_folder_name[0]=0;
1285
+		lines++;
2112
+ 				for (i=0; i < sidebar_folder_depth; i++)
1286
+	}
2113
+ 					strncat(sidebar_folder_name, NONULL(SidebarIndentStr), strlen(NONULL(SidebarIndentStr)));
1287
+	SETCOLOR(MT_COLOR_NORMAL);
2114
+ 				strncat(sidebar_folder_name, tmp_folder_name, strlen(tmp_folder_name));
1288
+	for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) {
2115
+ 			}
1289
+		int i = 0;
2116
+ 		}
1290
+		move( lines, 0 );
2117
+ 		printw( "%.*s", SidebarWidth - delim_len + 1,
1291
+		for ( ; i < SidebarWidth - delim_len; i++ )
2118
+ 			make_sidebar_entry(sidebar_folder_name, tmp->msgcount,
1292
+			addch(' ');
2119
+ 			tmp->msg_unread, tmp->msg_flagged));
1293
+	}
2120
+ 		if (sidebar_folder_depth > 0)
1294
+	return 0;
2121
+ 		        free(sidebar_folder_name);
1295
+}
2122
+ 		lines++;
1296
+
2123
+ 	}
1297
+
2124
+ 	SETCOLOR(MT_COLOR_NORMAL);
1298
+void set_buffystats(CONTEXT* Context)
2125
+ 	for ( ; lines < SidebarHeight; lines++ ) {
1299
+{
2126
+ 		int i = 0;
1300
+        BUFFY *tmp = Incoming;
2127
+ 		move( lines, 0 );
1301
+        while(tmp) {
2128
+ 		for ( ; i < SidebarWidth - delim_len; i++ )
1302
+                if(Context && !strcmp(tmp->path, Context->path)) {
2129
+ 			addch(' ');
1303
+			tmp->msg_unread = Context->unread;
2130
+ 	}
1304
+			tmp->msgcount = Context->msgcount;
2131
+ 	return 0;
1305
+                        break;
2132
+ }
1306
+                }
2133
+ 
1307
+                tmp = tmp->next;
2134
+ 
1308
+        }
2135
+ void set_buffystats(CONTEXT* Context)
1309
+}
2136
+ {
1310
+
2137
+         BUFFY *tmp = Incoming;
1311
+void scroll_sidebar(int op, int menu)
2138
+         while(tmp) {
1312
+{
2139
+                 if(Context && (!strcmp(tmp->path, Context->path) ||
1313
+        if(!SidebarWidth) return;
2140
+                                !strcmp(tmp->realpath, Context->path))) {
1314
+        if(!CurBuffy) return;
2141
+ 			tmp->msg_unread = Context->unread;
1315
+
2142
+ 			tmp->msgcount = Context->msgcount;
1316
+	switch (op) {
2143
+ 			tmp->msg_flagged = Context->flagged;
1317
+		case OP_SIDEBAR_NEXT:
2144
+                         break;
1318
+			if ( CurBuffy->next == NULL ) return;
2145
+                 }
1319
+			CurBuffy = CurBuffy->next;
2146
+                 tmp = tmp->next;
1320
+			break;
2147
+         }
1321
+		case OP_SIDEBAR_PREV:
2148
+ }
1322
+			if ( CurBuffy->prev == NULL ) return;
2149
+ 
1323
+			CurBuffy = CurBuffy->prev;
2150
+ void scroll_sidebar(int op, int menu)
1324
+			break;
2151
+ {
1325
+		case OP_SIDEBAR_SCROLL_UP:
2152
+         if(!SidebarWidth) return;
1326
+			CurBuffy = TopBuffy;
2153
+         if(!CurBuffy) return;
1327
+			if ( CurBuffy != Incoming ) {
2154
+ 
1328
+				calc_boundaries(menu);
2155
+ 	switch (op) {
1329
+				CurBuffy = CurBuffy->prev;
2156
+ 		case OP_SIDEBAR_NEXT:
1330
+			}
2157
+ 			if ( CurBuffy->next == NULL ) return;
1331
+			break;
2158
+ 			CurBuffy = CurBuffy->next;
1332
+		case OP_SIDEBAR_SCROLL_DOWN:
2159
+ 			break;
1333
+			CurBuffy = BottomBuffy;
2160
+ 		case OP_SIDEBAR_PREV:
1334
+			if ( CurBuffy->next ) {
2161
+ 			if ( CurBuffy->prev == NULL ) return;
1335
+				calc_boundaries(menu);
2162
+ 			CurBuffy = CurBuffy->prev;
1336
+				CurBuffy = CurBuffy->next;
2163
+ 			break;
1337
+			}
2164
+ 		case OP_SIDEBAR_SCROLL_UP:
1338
+			break;
2165
+ 			CurBuffy = TopBuffy;
1339
+		default:
2166
+ 			if ( CurBuffy != Incoming ) {
1340
+			return;
2167
+ 				calc_boundaries(menu);
1341
+	}
2168
+ 				CurBuffy = CurBuffy->prev;
1342
+	calc_boundaries(menu);
2169
+ 			}
1343
+	draw_sidebar(menu);
2170
+ 			break;
1344
+}
2171
+ 		case OP_SIDEBAR_SCROLL_DOWN:
1345
+
2172
+ 			CurBuffy = BottomBuffy;
1346
diff -uNp -r mutt-1.5.22.orig/sidebar.h mutt-1.5.22/sidebar.h
2173
+ 			if ( CurBuffy->next ) {
1347
--- mutt-1.5.22.orig/sidebar.h	Thu Jan  1 01:00:00 1970
2174
+ 				calc_boundaries(menu);
1348
+++ mutt-1.5.22/sidebar.h	Fri Oct 18 10:18:45 2013
2175
+ 				CurBuffy = CurBuffy->next;
1349
@@ -0,0 +1,36 @@
2176
+ 			}
1350
+/*
2177
+ 			break;
1351
+ * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
2178
+ 		default:
1352
+ * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
2179
+ 			return;
1353
+ * 
2180
+ 	}
1354
+ *     This program is free software; you can redistribute it and/or modify
2181
+ 	calc_boundaries(menu);
1355
+ *     it under the terms of the GNU General Public License as published by
2182
+ 	draw_sidebar(menu);
1356
+ *     the Free Software Foundation; either version 2 of the License, or
2183
+ }
1357
+ *     (at your option) any later version.
2184
+ 
1358
+ * 
2185
*** mutt-1.5.23-orig/sidebar.h	1969-12-31 18:00:00.000000000 -0600
1359
+ *     This program is distributed in the hope that it will be useful,
2186
--- mutt-1.5.23/sidebar.h	2014-04-11 10:14:01.000000000 -0500
1360
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
2187
***************
1361
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2188
*** 0 ****
1362
+ *     GNU General Public License for more details.
2189
--- 1,36 ----
1363
+ * 
2190
+ /*
1364
+ *     You should have received a copy of the GNU General Public License
2191
+  * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu>
1365
+ *     along with this program; if not, write to the Free Software
2192
+  * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com>
1366
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
2193
+  * 
1367
+ */ 
2194
+  *     This program is free software; you can redistribute it and/or modify
1368
+
2195
+  *     it under the terms of the GNU General Public License as published by
1369
+#ifndef SIDEBAR_H
2196
+  *     the Free Software Foundation; either version 2 of the License, or
1370
+#define SIDEBAR_H
2197
+  *     (at your option) any later version.
1371
+
2198
+  * 
1372
+struct MBOX_LIST {
2199
+  *     This program is distributed in the hope that it will be useful,
1373
+	char *path;
2200
+  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
1374
+	int msgcount;
2201
+  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1375
+	int new;
2202
+  *     GNU General Public License for more details.
1376
+} MBLIST;
2203
+  * 
1377
+
2204
+  *     You should have received a copy of the GNU General Public License
1378
+/* parameter is whether or not to go to the status line */
2205
+  *     along with this program; if not, write to the Free Software
1379
+/* used for omitting the last | that covers up the status bar in the index */
2206
+  *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
1380
+int draw_sidebar(int);
2207
+  */ 
1381
+void scroll_sidebar(int, int);
2208
+ 
1382
+void set_curbuffy(char*);
2209
+ #ifndef SIDEBAR_H
1383
+void set_buffystats(CONTEXT*);
2210
+ #define SIDEBAR_H
1384
+
2211
+ 
1385
+#endif /* SIDEBAR_H */
2212
+ struct MBOX_LIST {
1386
--- orig/Makefile.am.orig	2010-09-18 13:23:19.000000000 +0200
2213
+ 	char *path;
1387
+++ new/Makefile.am	2010-09-18 13:25:19.000000000 +0200
2214
+ 	int msgcount;
1388
@@ -34,7 +34,7 @@
2215
+ 	int new;
1389
 	score.c send.c sendlib.c signal.c sort.c \
2216
+ } MBLIST;
1390
 	status.c system.c thread.c charset.c history.c lib.c \
2217
+ 
1391
 	muttlib.c editmsg.c mbyte.c \
2218
+ /* parameter is whether or not to go to the status line */
1392
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
2219
+ /* used for omitting the last | that covers up the status bar in the index */
1393
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
2220
+ int draw_sidebar(int);
1394
 
2221
+ void scroll_sidebar(int, int);
1395
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
2222
+ void set_curbuffy(char*);
1396
 
2223
+ void set_buffystats(CONTEXT*);
1397
--- orig/Makefile.in.orig	2013-10-25 08:23:07.000000000 +0200
2224
+ 
1398
+++ new/Makefile.in	2013-10-25 08:26:20.000000000 +0200
2225
+ #endif /* SIDEBAR_H */
1399
@@ -133,7 +133,7 @@
2226
*** mutt-1.5.23-orig/doc/Muttrc	2014-03-12 11:27:11.000000000 -0500
1400
 	system.$(OBJEXT) thread.$(OBJEXT) charset.$(OBJEXT) \
2227
--- mutt-1.5.23/doc/Muttrc	2014-04-11 10:14:01.000000000 -0500
1401
 	history.$(OBJEXT) lib.$(OBJEXT) muttlib.$(OBJEXT) \
1402
 	editmsg.$(OBJEXT) mbyte.$(OBJEXT) url.$(OBJEXT) \
1403
-	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT)
1404
+	ascii.$(OBJEXT) crypt-mod.$(OBJEXT) safe_asprintf.$(OBJEXT) sidebar.$(OBJEXT)
1405
 am__objects_1 =
1406
 am__objects_2 = patchlist.$(OBJEXT) conststrings.$(OBJEXT) \
1407
 	$(am__objects_1)
1408
@@ -472,7 +472,7 @@
1409
 	score.c send.c sendlib.c signal.c sort.c \
1410
 	status.c system.c thread.c charset.c history.c lib.c \
1411
 	muttlib.c editmsg.c mbyte.c \
1412
-	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c
1413
+	url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c sidebar.c
1414
 
1415
 nodist_mutt_SOURCES = $(BUILT_SOURCES)
1416
 mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
1417
@@ -504,7 +504,7 @@
1418
 	README.SSL smime.h group.h \
1419
 	muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
1420
 	ChangeLog mkchangelog.sh mutt_idna.h \
1421
-	snprintf.c regex.c crypt-gpgme.h hcachever.sh.in \
1422
+	snprintf.c regex.c crypt-gpgme.h sidebar.h hcachever.sh.in \
1423
 	txt2c.c txt2c.sh version.sh check_sec.sh
1424
 
1425
 EXTRA_SCRIPTS = smime_keys
1426
*** mutt-1.5.20-orig/doc/Muttrc	2009-06-14 13:53:24.000000000 -0500
1427
--- mutt-1.5.20-patched/doc/Muttrc	2009-06-19 22:07:04.000000000 -0500
1428
***************
2228
***************
1429
*** 657,662 ****
2229
*** 657,662 ****
1430
--- 657,682 ----
2230
--- 657,682 ----
Lines 1454-1456 Link Here
1454
  # set crypt_autosign=no
2254
  # set crypt_autosign=no
1455
  #
2255
  #
1456
  # Name: crypt_autosign
2256
  # Name: crypt_autosign
2257
*** mutt-1.5.23-orig/imap/imap.c	2014-03-12 11:03:45.000000000 -0500
2258
--- mutt-1.5.23/imap/imap.c	2014-04-11 10:14:01.000000000 -0500
2259
***************
2260
*** 1514,1520 ****
2261
  
2262
      imap_munge_mbox_name (munged, sizeof (munged), name);
2263
      snprintf (command, sizeof (command),
2264
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged);
2265
  
2266
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2267
      {
2268
--- 1514,1520 ----
2269
  
2270
      imap_munge_mbox_name (munged, sizeof (munged), name);
2271
      snprintf (command, sizeof (command),
2272
! 	      "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged);
2273
  
2274
      if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0)
2275
      {
2276
*** mutt-1.5.23-orig/imap/command.c	2014-03-12 11:03:45.000000000 -0500
2277
--- mutt-1.5.23/imap/command.c	2014-04-11 10:14:01.000000000 -0500
2278
***************
2279
*** 1012,1017 ****
2280
--- 1012,1024 ----
2281
  	     opened */
2282
  	  status->uidnext = oldun;
2283
  
2284
+         /* Added to make the sidebar show the correct numbers */
2285
+         if (status->messages)
2286
+         {
2287
+           inc->msgcount = status->messages;
2288
+           inc->msg_unread = status->unseen;
2289
+         }
2290
+ 
2291
          FREE (&value);
2292
          return;
2293
        }
(-)./files/extra-patch-sidebar-refresh (-10 / +10 lines)
Lines 1-5 Link Here
1
--- mutt.orig/buffy.c	2012-11-02 13:16:39.000000000 +0100
1
--- mutt.orig/buffy.c.orig	2015-04-22 08:09:04.000000000 +0200
2
+++ mutt/buffy.c	2012-11-02 13:20:52.000000000 +0100
2
+++ mutt/buffy.c	2015-04-22 08:12:54.000000000 +0200
3
@@ -26,6 +26,7 @@
3
@@ -26,6 +26,7 @@
4
 #include "mx.h"
4
 #include "mx.h"
5
 
5
 
Lines 8-20 Link Here
8
 
8
 
9
 #ifdef USE_IMAP
9
 #ifdef USE_IMAP
10
 #include "imap.h"
10
 #include "imap.h"
11
@@ -564,19 +565,28 @@
11
@@ -584,19 +585,28 @@
12
       {
12
       {
13
       case M_MBOX:
13
       case M_MBOX:
14
       case M_MMDF:
14
       case M_MMDF:
15
-	buffy_mbox_update (tmp);
15
-	buffy_mbox_update (tmp, &sb);
16
+	if (sidebar_should_refresh()) {
16
+	if (sidebar_should_refresh()) {
17
+	  buffy_mbox_update (tmp);
17
+	  buffy_mbox_update (tmp, &sb);
18
+	  sidebar_updated();
18
+	  sidebar_updated();
19
+	}
19
+	}
20
 	if (buffy_mbox_hasnew (tmp, &sb) > 0)
20
 	if (buffy_mbox_hasnew (tmp, &sb) > 0)
Lines 26-43 Link Here
26
+	if (sidebar_should_refresh()) {
26
+	if (sidebar_should_refresh()) {
27
+	  buffy_maildir_update (tmp);
27
+	  buffy_maildir_update (tmp);
28
+	  sidebar_updated();
28
+	  sidebar_updated();
29
+	}
29
+ 	}
30
 	if (buffy_maildir_hasnew (tmp) > 0)
30
 	if (buffy_maildir_hasnew (tmp) > 0)
31
 	  BuffyCount++;
31
 	  BuffyCount++;
32
 	break;
32
 	break;
33
 
33
 
34
       case M_MH:
34
       case M_MH:
35
-	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
35
-	mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
36
+	if (sidebar_should_refresh()) {
36
+	if (sidebar_should_refresh()) {
37
+	  mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged);
37
+	  mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged, &tmp->sb_last_checked);
38
+	  sidebar_updated();
38
+	  sidebar_updated();
39
+	}
39
+ 	}
40
 	mh_buffy(tmp);
40
         mh_buffy(tmp);
41
 	if (tmp->new)
41
 	if (tmp->new)
42
 	  BuffyCount++;
42
 	  BuffyCount++;
43
Index: mutt/globals.h
43
Index: mutt/globals.h
(-)./files/patch-pgpkey.c (+18 lines)
Line 0 Link Here
1
--- pgpkey.c.orig	2014-03-12 17:03:44.000000000 +0100
2
+++ pgpkey.c	2015-04-13 17:50:05.000000000 +0200
3
@@ -985,13 +985,13 @@
4
       pgp_remove_key (&matches, k);
5
 
6
     pgp_free_key (&matches);
7
-    if (!p[l-1])
8
+    if (l && !p[l-1])
9
       p[l-1] = '!';
10
     return k;
11
   }
12
 
13
 out:
14
-  if (!p[l-1])
15
+  if (l && !p[l-1])
16
     p[l-1] = '!';
17
   return NULL;
18
 }

Return to bug 199727