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

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

Return to bug 213180