Merge pull request #16805 from rnhmjoj/mutt

mutt: 1.6.0 -> 1.6.2

authored by

joachifm and committed by
GitHub
99039235 9aa3e78a

+4625 -1780
+40 -46
pkgs/applications/networking/mailreaders/mutt/default.nix
··· 1 1 { stdenv, fetchurl, ncurses, which, perl, autoreconfHook 2 - , sslSupport ? true 3 - , imapSupport ? true 4 - , headerCache ? true 5 - , saslSupport ? true 6 - , gpgmeSupport ? true 7 2 , gdbm ? null 8 3 , openssl ? null 9 4 , cyrus_sasl ? null 10 5 , gpgme ? null 11 - , withSidebar ? false 6 + , aclocal ? null 7 + , headerCache ? true 8 + , sslSupport ? true 9 + , saslSupport ? true 10 + , gpgmeSupport ? true 11 + , imapSupport ? true 12 + , withSidebar ? false 13 + , withTrash ? false 12 14 }: 13 15 14 - assert headerCache -> gdbm != null; 15 - assert sslSupport -> openssl != null; 16 - assert saslSupport -> cyrus_sasl != null; 17 - assert gpgmeSupport -> gpgme != null; 16 + assert headerCache -> gdbm != null; 17 + assert sslSupport -> openssl != null; 18 + assert saslSupport -> cyrus_sasl != null; 19 + assert gpgmeSupport -> gpgme != null; 20 + 21 + with stdenv.lib; 18 22 19 - let 20 - version = "1.6.0"; 21 - in 22 23 stdenv.mkDerivation rec { 23 - name = "mutt${stdenv.lib.optionalString withSidebar "-with-sidebar"}-${version}"; 24 + name = "mutt-${version}"; 25 + version = "1.6.2"; 24 26 25 27 src = fetchurl { 26 - url = "http://ftp.mutt.org/pub/mutt/mutt-${version}.tar.gz"; 27 - sha256 = "06bc2drbgalkk68rzg7hq2v5m5qgjxff5357wg0419dpi8ivdbr9"; 28 + url = "http://ftp.mutt.org/pub/mutt/${name}.tar.gz"; 29 + sha256 = "13hxmji7v9m2agmvzrs7gzx8s3c9jiwrv7pbkr7z1kc6ckq2xl65"; 28 30 }; 29 31 30 - buildInputs = with stdenv.lib; 32 + buildInputs = 31 33 [ ncurses which perl ] 32 - ++ optional headerCache gdbm 33 - ++ optional sslSupport openssl 34 - ++ optional saslSupport cyrus_sasl 35 - ++ optional gpgmeSupport gpgme; 36 - 37 - nativeBuildInputs = stdenv.lib.optional withSidebar autoreconfHook; 34 + ++ optional headerCache gdbm 35 + ++ optional sslSupport openssl 36 + ++ optional saslSupport cyrus_sasl 37 + ++ optional gpgmeSupport gpgme 38 + ++ optional withSidebar autoreconfHook; 38 39 39 40 configureFlags = [ 40 - "--with-mailpath=" "--enable-smtp" 41 + (enableFeature headerCache "hcache") 42 + (enableFeature gpgmeSupport "gpgme") 43 + (enableFeature imapSupport "imap") 44 + (enableFeature withSidebar "sidebar") 45 + "--enable-smtp" 46 + "--enable-pop" 47 + "--enable-imap" 48 + "--with-mailpath=" 41 49 42 50 # Look in $PATH at runtime, instead of hardcoding /usr/bin/sendmail 43 51 "ac_cv_path_SENDMAIL=sendmail" ··· 45 53 # This allows calls with "-d N", that output debug info into ~/.muttdebug* 46 54 "--enable-debug" 47 55 48 - "--enable-pop" "--enable-imap" 49 - 50 56 # The next allows building mutt without having anything setgid 51 57 # set by the installer, and removing the need for the group 'mail' 52 58 # I set the value 'mailbox' because it is a default in the configure script 53 59 "--with-homespool=mailbox" 54 - (if headerCache then "--enable-hcache" else "--disable-hcache") 55 - (if sslSupport then "--with-ssl" else "--without-ssl") 56 - (if imapSupport then "--enable-imap" else "--disable-imap") 57 - (if saslSupport then "--with-sasl" else "--without-sasl") 58 - (if gpgmeSupport then "--enable-gpgme" else "--disable-gpgme") 59 - ]; 60 + ] ++ optional sslSupport "--with-ssl" 61 + ++ optional saslSupport "--with-sasl"; 60 62 61 - # Adding the sidebar 62 - patches = stdenv.lib.optional withSidebar [ 63 - ./trash-folder.patch 64 - ./sidebar.patch 65 - ./sidebar-dotpathsep.patch 66 - ./sidebar-utf8.patch 67 - ./sidebar-newonly.patch 68 - ./sidebar-delimnullwide.patch 69 - ./sidebar-compose.patch 70 - ./sidebar-new.patch 71 - ]; 63 + patches = 64 + optional withTrash ./trash.patch ++ 65 + optional withSidebar ./sidebar.patch; 72 66 73 - meta = with stdenv.lib; { 67 + meta = { 74 68 description = "A small but very powerful text-based mail client"; 75 69 homepage = http://www.mutt.org; 76 - license = stdenv.lib.licenses.gpl2Plus; 70 + license = licenses.gpl2Plus; 77 71 platforms = platforms.unix; 78 - maintainers = with maintainers; [ the-kenny ]; 72 + maintainers = with maintainers; [ the-kenny rnhmjoj ]; 79 73 }; 80 74 }
-40
pkgs/applications/networking/mailreaders/mutt/sidebar-compose.patch
··· 1 - From: Evgeni Golov <evgeni@debian.org> 2 - Date: Fri, 14 Mar 2014 08:54:47 +0100 3 - Subject: sidebar-compose 4 - 5 - draw_sidebar sets SidebarWidth to 0 when sidebar_visible is false. 6 - However, if you start mutt in compose mode, draw_sidebar won't be 7 - called until the next redraw and your header lines will be off by 8 - the width of the sidebar, even when you did not want a sidebar at 9 - all. 10 - 11 - Can be tested with: 12 - HOME=/ LC_ALL=C mutt -e 'unset sidebar_visible' -s test recipient 13 - 14 - Closes: #502627 15 - 16 - Gbp-Pq: Topic mutt-patched 17 - --- 18 - compose.c | 2 ++ 19 - 1 file changed, 2 insertions(+) 20 - 21 - diff --git a/compose.c b/compose.c 22 - index b63695f..0fa6df2 100644 23 - --- a/compose.c 24 - +++ b/compose.c 25 - @@ -32,6 +32,7 @@ 26 - #include "mailbox.h" 27 - #include "sort.h" 28 - #include "charset.h" 29 - +#include "sidebar.h" 30 - 31 - #ifdef MIXMASTER 32 - #include "remailer.h" 33 - @@ -248,6 +249,7 @@ static void draw_envelope_addr (int line, ADDRESS *addr) 34 - 35 - static void draw_envelope (HEADER *msg, char *fcc) 36 - { 37 - + draw_sidebar (MENU_COMPOSE); 38 - draw_envelope_addr (HDR_FROM, msg->env->from); 39 - draw_envelope_addr (HDR_TO, msg->env->to); 40 - draw_envelope_addr (HDR_CC, msg->env->cc);
-38
pkgs/applications/networking/mailreaders/mutt/sidebar-delimnullwide.patch
··· 1 - From: Evgeni Golov <sargentd@die-welt.net> 2 - Date: Wed, 5 Mar 2014 17:46:07 +0100 3 - Subject: sidebar-delimnullwide 4 - 5 - SidebarDelim can be NULL and strlen(NULL) is a bad idea, as it will segfault. 6 - Wrap it with NONULL(). 7 - 8 - While at it, change strlen to mbstowcs for better utf8 support. 9 - 10 - Closes: #696145, #663883 11 - 12 - Gbp-Pq: Topic mutt-patched 13 - --- 14 - sidebar.c | 4 ++-- 15 - 1 file changed, 2 insertions(+), 2 deletions(-) 16 - 17 - diff --git a/sidebar.c b/sidebar.c 18 - index 51a25ca..c3ea338 100644 19 - --- a/sidebar.c 20 - +++ b/sidebar.c 21 - @@ -88,7 +88,7 @@ char *make_sidebar_entry(char *box, int size, int new, int flagged) 22 - int box_len, box_bytes; 23 - int int_len; 24 - int right_offset = 0; 25 - - int delim_len = strlen(SidebarDelim); 26 - + int delim_len = mbstowcs(NULL, NONULL(SidebarDelim), 0); 27 - static char *entry; 28 - 29 - right_width = left_width = 0; 30 - @@ -178,7 +178,7 @@ int draw_sidebar(int menu) { 31 - #ifndef USE_SLANG_CURSES 32 - attr_t attrs; 33 - #endif 34 - - short delim_len = strlen(SidebarDelim); 35 - + short delim_len = mbstowcs(NULL, NONULL(SidebarDelim), 0); 36 - short color_pair; 37 - 38 - static bool initialized = false;
-98
pkgs/applications/networking/mailreaders/mutt/sidebar-dotpathsep.patch
··· 1 - From: Fabian Groffen <grobian@gentoo.org> 2 - Date: Tue, 4 Mar 2014 21:12:15 +0100 3 - Subject: sidebar-dotpathsep 4 - 5 - Make path separators for sidebar folders configurable. 6 - 7 - When using IMAP, a '.' is often used as path separator, hence make the 8 - path separators configurable through sidebar_delim_chars variable. 9 - It defaults to "/." to work for both mboxes as well as IMAP folders. It 10 - can be set to only "/" or "." or whichever character desired as needed. 11 - 12 - Gbp-Pq: Topic mutt-patched 13 - --- 14 - globals.h | 1 + 15 - init.h | 8 ++++++++ 16 - sidebar.c | 31 ++++++++++++++++++++++++------- 17 - 3 files changed, 33 insertions(+), 7 deletions(-) 18 - 19 - diff --git a/globals.h b/globals.h 20 - index 004c795..602f932 100644 21 - --- a/globals.h 22 - +++ b/globals.h 23 - @@ -119,6 +119,7 @@ WHERE char *SendCharset; 24 - WHERE char *Sendmail; 25 - WHERE char *Shell; 26 - WHERE char *SidebarDelim; 27 - +WHERE char *SidebarDelimChars INITVAL (NULL); 28 - WHERE char *Signature; 29 - WHERE char *SimpleSearch; 30 - #if USE_SMTP 31 - diff --git a/init.h b/init.h 32 - index c664e5f..166671b 100644 33 - --- a/init.h 34 - +++ b/init.h 35 - @@ -2051,6 +2051,14 @@ struct option_t MuttVars[] = { 36 - ** .pp 37 - ** The width of the sidebar. 38 - */ 39 - + { "sidebar_delim_chars", DT_STR, R_NONE, UL &SidebarDelimChars, UL "/." }, 40 - + /* 41 - + ** .pp 42 - + ** This contains the list of characters which you would like to treat 43 - + ** as folder separators for displaying paths in the sidebar. If 44 - + ** you're not using IMAP folders, you probably prefer setting this to "/" 45 - + ** alone. 46 - + */ 47 - { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, 48 - /* 49 - ** .pp 50 - diff --git a/sidebar.c b/sidebar.c 51 - index 6098c2a..4356ffc 100644 52 - --- a/sidebar.c 53 - +++ b/sidebar.c 54 - @@ -249,20 +249,37 @@ int draw_sidebar(int menu) { 55 - // calculate depth of current folder and generate its display name with indented spaces 56 - int sidebar_folder_depth = 0; 57 - char *sidebar_folder_name; 58 - - sidebar_folder_name = basename(tmp->path); 59 - + int i; 60 - + sidebar_folder_name = tmp->path; 61 - + /* disregard a trailing separator, so strlen() - 2 62 - + * https://bugs.gentoo.org/show_bug.cgi?id=373197#c16 */ 63 - + for (i = strlen(sidebar_folder_name) - 2; i >= 0; i--) { 64 - + if (SidebarDelimChars && 65 - + strchr(SidebarDelimChars, sidebar_folder_name[i])) 66 - + { 67 - + sidebar_folder_name += i + 1; 68 - + break; 69 - + } 70 - + } 71 - if ( maildir_is_prefix ) { 72 - char *tmp_folder_name; 73 - - int i; 74 - + int lastsep = 0; 75 - tmp_folder_name = tmp->path + strlen(Maildir); 76 - - for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { 77 - - if (tmp_folder_name[i] == '/') sidebar_folder_depth++; 78 - - } 79 - + for (i = 0; i < strlen(tmp_folder_name) - 1; i++) { 80 - + if (SidebarDelimChars && 81 - + strchr(SidebarDelimChars, tmp_folder_name[i])) 82 - + { 83 - + sidebar_folder_depth++; 84 - + lastsep = i + 1; 85 - + } 86 - + } 87 - if (sidebar_folder_depth > 0) { 88 - - sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); 89 - + tmp_folder_name += lastsep; /* basename */ 90 - + sidebar_folder_name = malloc(strlen(tmp_folder_name) + sidebar_folder_depth + 1); 91 - for (i=0; i < sidebar_folder_depth; i++) 92 - sidebar_folder_name[i]=' '; 93 - sidebar_folder_name[i]=0; 94 - - strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); 95 - + strncat(sidebar_folder_name, tmp_folder_name, strlen(tmp_folder_name) + sidebar_folder_depth); 96 - } 97 - } 98 - printw( "%.*s", SidebarWidth - delim_len + 1,
-97
pkgs/applications/networking/mailreaders/mutt/sidebar-new.patch
··· 1 - From 355399bde98203af59d20821f9e840fc056bd383 Mon Sep 17 00:00:00 2001 2 - From: Julius Haertl <jus@bitgrid.net> 3 - Date: Tue, 9 Sep 2014 22:31:49 +0200 4 - Subject: Patch for sidebar iteration functionality 5 - 6 - sidebar-new will move the selected folder to the next with new messages. 7 - If the end is reached, it will start at the top. 8 - 9 - Useful macros would be: 10 - 11 - macro index <esc>a "<sidebar-new><sidebar-open>" 12 - macro pager <esc>a "<exit><sidebar-new><sidebar-open>" 13 - --- 14 - OPS | 1 + 15 - curs_main.c | 1 + 16 - functions.h | 2 ++ 17 - pager.c | 1 + 18 - sidebar.c | 10 ++++++++++ 19 - 5 files changed, 15 insertions(+) 20 - 21 - diff --git a/OPS b/OPS 22 - index 1ed9c96..3ffb82a 100644 23 - --- a/OPS 24 - +++ b/OPS 25 - @@ -187,3 +187,4 @@ OP_SIDEBAR_PREV "go to previous mailbox" 26 - OP_SIDEBAR_OPEN "open hilighted mailbox" 27 - OP_SIDEBAR_NEXT_NEW "go down to next mailbox with new mail" 28 - OP_SIDEBAR_PREV_NEW "go to previous mailbox with new mail" 29 - +OP_SIDEBAR_NEW "iterate though mailboxes with new mail" 30 - diff --git a/curs_main.c b/curs_main.c 31 - index acb106d..2e35f90 100644 32 - --- a/curs_main.c 33 - +++ b/curs_main.c 34 - @@ -2328,6 +2328,7 @@ int mutt_index_menu (void) 35 - case OP_SIDEBAR_PREV: 36 - case OP_SIDEBAR_NEXT_NEW: 37 - case OP_SIDEBAR_PREV_NEW: 38 - + case OP_SIDEBAR_NEW: 39 - scroll_sidebar(op, menu->menu); 40 - break; 41 - default: 42 - diff --git a/functions.h b/functions.h 43 - index 363b4d5..1485080 100644 44 - --- a/functions.h 45 - +++ b/functions.h 46 - @@ -176,6 +176,7 @@ const struct binding_t OpMain[] = { /* map: index */ 47 - { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 48 - { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL}, 49 - { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL}, 50 - + { "sidebar-new", OP_SIDEBAR_NEW, NULL }, 51 - { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 52 - { NULL, 0, NULL } 53 - }; 54 - @@ -287,6 +288,7 @@ const struct binding_t OpPager[] = { /* map: pager */ 55 - { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 56 - { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL}, 57 - { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL}, 58 - + { "sidebar-new", OP_SIDEBAR_NEW, NULL }, 59 - { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 60 - { NULL, 0, NULL } 61 - }; 62 - diff --git a/pager.c b/pager.c 63 - index 8d64fe1..696e55c 100644 64 - --- a/pager.c 65 - +++ b/pager.c 66 - @@ -2791,6 +2791,7 @@ search_next: 67 - case OP_SIDEBAR_PREV: 68 - case OP_SIDEBAR_NEXT_NEW: 69 - case OP_SIDEBAR_PREV_NEW: 70 - + case OP_SIDEBAR_NEW: 71 - scroll_sidebar(ch, MENU_PAGER); 72 - break; 73 - 74 - diff --git a/sidebar.c b/sidebar.c 75 - index c3ea338..eb8ecd2 100644 76 - --- a/sidebar.c 77 - +++ b/sidebar.c 78 - @@ -429,6 +429,16 @@ void scroll_sidebar(int op, int menu) 79 - CurBuffy = CurBuffy->next; 80 - } 81 - break; 82 - + case OP_SIDEBAR_NEW: 83 - + if ( (tmp = exist_next_new()) == NULL) 84 - + tmp = TopBuffy; 85 - + if ( tmp->msg_unread == 0 ) { 86 - + CurBuffy = tmp; 87 - + tmp = exist_next_new(); 88 - + } 89 - + if ( tmp != NULL ) 90 - + CurBuffy = tmp; 91 - + break; 92 - default: 93 - return; 94 - } 95 - -- 96 - 2.6.0.rc0.2.g7662973.dirty 97 -
-198
pkgs/applications/networking/mailreaders/mutt/sidebar-newonly.patch
··· 1 - From: Steve Kemp <steve@steve.org.uk> 2 - Date: Tue, 4 Mar 2014 22:07:06 +0100 3 - Subject: sidebar-newonly 4 - 5 - patches written by Steve Kemp, it adds two new functionalities to the sidebar, 6 - so only the mailbox with new messages will be shown (and/or) selected 7 - See Debian bug http://bugs.debian.org/532510 8 - 9 - Gbp-Pq: Topic mutt-patched 10 - --- 11 - OPS | 2 ++ 12 - curs_main.c | 2 ++ 13 - functions.h | 4 ++++ 14 - init.h | 5 +++++ 15 - mutt.h | 2 ++ 16 - pager.c | 2 ++ 17 - sidebar.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 18 - 7 files changed, 70 insertions(+), 2 deletions(-) 19 - 20 - diff --git a/OPS b/OPS 21 - index b036db9..1ed9c96 100644 22 - --- a/OPS 23 - +++ b/OPS 24 - @@ -185,3 +185,5 @@ OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" 25 - OP_SIDEBAR_NEXT "go down to next mailbox" 26 - OP_SIDEBAR_PREV "go to previous mailbox" 27 - OP_SIDEBAR_OPEN "open hilighted mailbox" 28 - +OP_SIDEBAR_NEXT_NEW "go down to next mailbox with new mail" 29 - +OP_SIDEBAR_PREV_NEW "go to previous mailbox with new mail" 30 - diff --git a/curs_main.c b/curs_main.c 31 - index ea530a6..acb106d 100644 32 - --- a/curs_main.c 33 - +++ b/curs_main.c 34 - @@ -2326,6 +2326,8 @@ int mutt_index_menu (void) 35 - case OP_SIDEBAR_SCROLL_DOWN: 36 - case OP_SIDEBAR_NEXT: 37 - case OP_SIDEBAR_PREV: 38 - + case OP_SIDEBAR_NEXT_NEW: 39 - + case OP_SIDEBAR_PREV_NEW: 40 - scroll_sidebar(op, menu->menu); 41 - break; 42 - default: 43 - diff --git a/functions.h b/functions.h 44 - index ef8937a..363b4d5 100644 45 - --- a/functions.h 46 - +++ b/functions.h 47 - @@ -174,6 +174,8 @@ const struct binding_t OpMain[] = { /* map: index */ 48 - { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, 49 - { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 50 - { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 51 - + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL}, 52 - + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL}, 53 - { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 54 - { NULL, 0, NULL } 55 - }; 56 - @@ -283,6 +285,8 @@ const struct binding_t OpPager[] = { /* map: pager */ 57 - { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, 58 - { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 59 - { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 60 - + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL}, 61 - + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL}, 62 - { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 63 - { NULL, 0, NULL } 64 - }; 65 - diff --git a/init.h b/init.h 66 - index 166671b..a5d4238 100644 67 - --- a/init.h 68 - +++ b/init.h 69 - @@ -2059,6 +2059,11 @@ struct option_t MuttVars[] = { 70 - ** you're not using IMAP folders, you probably prefer setting this to "/" 71 - ** alone. 72 - */ 73 - + {"sidebar_newmail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0 }, 74 - + /* 75 - + ** .pp 76 - + ** Show only new mail in the sidebar. 77 - + */ 78 - { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, 79 - /* 80 - ** .pp 81 - diff --git a/mutt.h b/mutt.h 82 - index 5f25406..d73e514 100644 83 - --- a/mutt.h 84 - +++ b/mutt.h 85 - @@ -529,6 +529,8 @@ enum 86 - OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ 87 - OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */ 88 - 89 - + OPTSIDEBARNEWMAILONLY, 90 - + 91 - OPTMAX 92 - }; 93 - 94 - diff --git a/pager.c b/pager.c 95 - index 5cfcb75..8d64fe1 100644 96 - --- a/pager.c 97 - +++ b/pager.c 98 - @@ -2789,6 +2789,8 @@ search_next: 99 - case OP_SIDEBAR_SCROLL_DOWN: 100 - case OP_SIDEBAR_NEXT: 101 - case OP_SIDEBAR_PREV: 102 - + case OP_SIDEBAR_NEXT_NEW: 103 - + case OP_SIDEBAR_PREV_NEW: 104 - scroll_sidebar(ch, MENU_PAGER); 105 - break; 106 - 107 - diff --git a/sidebar.c b/sidebar.c 108 - index 8f58f85..51a25ca 100644 109 - --- a/sidebar.c 110 - +++ b/sidebar.c 111 - @@ -269,8 +269,21 @@ int draw_sidebar(int menu) { 112 - SETCOLOR(MT_COLOR_NEW); 113 - else if ( tmp->msg_flagged > 0 ) 114 - SETCOLOR(MT_COLOR_FLAGGED); 115 - - else 116 - - SETCOLOR(MT_COLOR_NORMAL); 117 - + else { 118 - + /* make sure the path is either: 119 - + 1. Containing new mail. 120 - + 2. The inbox. 121 - + 3. The current box. 122 - + */ 123 - + if ((option (OPTSIDEBARNEWMAILONLY)) && 124 - + ( (tmp->msg_unread <= 0) && 125 - + ( tmp != Incoming ) && 126 - + Context && 127 - + ( strcmp( tmp->path, Context->path ) != 0 ) ) ) 128 - + continue; 129 - + else 130 - + SETCOLOR(MT_COLOR_NORMAL); 131 - + } 132 - 133 - move( lines, 0 ); 134 - if ( Context && !strcmp( tmp->path, Context->path ) ) { 135 - @@ -336,6 +349,29 @@ int draw_sidebar(int menu) { 136 - return 0; 137 - } 138 - 139 - +BUFFY * exist_next_new() 140 - +{ 141 - + BUFFY *tmp = CurBuffy; 142 - + if(tmp == NULL) return NULL; 143 - + while (tmp->next != NULL) 144 - + { 145 - + tmp = tmp->next; 146 - + if(tmp->msg_unread) return tmp; 147 - + } 148 - + return NULL; 149 - +} 150 - + 151 - +BUFFY * exist_prev_new() 152 - +{ 153 - + BUFFY *tmp = CurBuffy; 154 - + if(tmp == NULL) return NULL; 155 - + while (tmp->prev != NULL) 156 - + { 157 - + tmp = tmp->prev; 158 - + if(tmp->msg_unread) return tmp; 159 - + } 160 - + return NULL; 161 - +} 162 - 163 - void set_buffystats(CONTEXT* Context) 164 - { 165 - @@ -352,18 +388,33 @@ void set_buffystats(CONTEXT* Context) 166 - 167 - void scroll_sidebar(int op, int menu) 168 - { 169 - + BUFFY *tmp; 170 - if(!SidebarWidth) return; 171 - if(!CurBuffy) return; 172 - 173 - switch (op) { 174 - case OP_SIDEBAR_NEXT: 175 - + if (!option (OPTSIDEBARNEWMAILONLY)) { 176 - if ( CurBuffy->next == NULL ) return; 177 - CurBuffy = CurBuffy->next; 178 - break; 179 - + } 180 - + case OP_SIDEBAR_NEXT_NEW: 181 - + if ( (tmp = exist_next_new()) == NULL) 182 - + return; 183 - + else CurBuffy = tmp; 184 - + break; 185 - case OP_SIDEBAR_PREV: 186 - + if (!option (OPTSIDEBARNEWMAILONLY)) { 187 - if ( CurBuffy->prev == NULL ) return; 188 - CurBuffy = CurBuffy->prev; 189 - break; 190 - + } 191 - + case OP_SIDEBAR_PREV_NEW: 192 - + if ( (tmp = exist_prev_new()) == NULL) 193 - + return; 194 - + else CurBuffy = tmp; 195 - + break; 196 - case OP_SIDEBAR_SCROLL_UP: 197 - CurBuffy = TopBuffy; 198 - if ( CurBuffy != Incoming ) {
-132
pkgs/applications/networking/mailreaders/mutt/sidebar-utf8.patch
··· 1 - From: Antonio Radici <antonio@debian.org> 2 - Date: Tue, 4 Mar 2014 15:39:14 +0100 3 - Subject: sidebar-utf8 4 - 5 - This patch fixes a problem with utf-8 strings and the sidebar, 6 - it rewrites entirely make_sidebar_entry so it also fixes some 7 - segfaults due to misallocations and overflows. 8 - 9 - See: 10 - http://bugs.debian.org/584581 11 - http://bugs.debian.org/603287 12 - 13 - Gbp-Pq: Topic mutt-patched 14 - --- 15 - sidebar.c | 97 +++++++++++++++++++++++++++++++++++++++++++-------------------- 16 - 1 file changed, 67 insertions(+), 30 deletions(-) 17 - 18 - diff --git a/sidebar.c b/sidebar.c 19 - index 4356ffc..8f58f85 100644 20 - --- a/sidebar.c 21 - +++ b/sidebar.c 22 - @@ -30,6 +30,7 @@ 23 - #include <libgen.h> 24 - #include "keymap.h" 25 - #include <stdbool.h> 26 - +#include <wchar.h> 27 - 28 - /*BUFFY *CurBuffy = 0;*/ 29 - static BUFFY *TopBuffy = 0; 30 - @@ -82,36 +83,72 @@ void calc_boundaries (int menu) 31 - 32 - char *make_sidebar_entry(char *box, int size, int new, int flagged) 33 - { 34 - - static char *entry = 0; 35 - - char *c; 36 - - int i = 0; 37 - - int delim_len = strlen(SidebarDelim); 38 - - 39 - - c = realloc(entry, SidebarWidth - delim_len + 2); 40 - - if ( c ) entry = c; 41 - - entry[SidebarWidth - delim_len + 1] = 0; 42 - - for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); 43 - - i = strlen(box); 44 - - strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); 45 - - 46 - - if (size == -1) 47 - - sprintf(entry + SidebarWidth - delim_len - 3, "?"); 48 - - else if ( new ) { 49 - - if (flagged > 0) { 50 - - sprintf( 51 - - entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), 52 - - "% d(%d)[%d]", size, new, flagged); 53 - - } else { 54 - - sprintf( 55 - - entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), 56 - - "% d(%d)", size, new); 57 - - } 58 - - } else if (flagged > 0) { 59 - - sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); 60 - - } else { 61 - - sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); 62 - - } 63 - - return entry; 64 - + char int_store[20]; // up to 64 bits integers 65 - + int right_width, left_width; 66 - + int box_len, box_bytes; 67 - + int int_len; 68 - + int right_offset = 0; 69 - + int delim_len = strlen(SidebarDelim); 70 - + static char *entry; 71 - + 72 - + right_width = left_width = 0; 73 - + box_len = box_bytes = 0; 74 - + 75 - + // allocate an entry big enough to contain SidebarWidth wide chars 76 - + entry = malloc((SidebarWidth*4)+1); // TODO: error check 77 - + 78 - + // determine the right space (i.e.: how big are the numbers that we want to print) 79 - + if ( size > 0 ) { 80 - + int_len = snprintf(int_store, sizeof(int_store), "%d", size); 81 - + right_width += int_len; 82 - + } else { 83 - + right_width = 1; // to represent 0 84 - + } 85 - + if ( new > 0 ) { 86 - + int_len = snprintf(int_store, sizeof(int_store), "%d", new); 87 - + right_width += int_len + 2; // 2 is for () 88 - + } 89 - + if ( flagged > 0 ) { 90 - + int_len = snprintf(int_store, sizeof(int_store), "%d", flagged); 91 - + right_width += int_len + 2; // 2 is for [] 92 - + } 93 - + 94 - + // determine how much space we have for *box and its padding (if any) 95 - + left_width = SidebarWidth - right_width - 1 - delim_len; // 1 is for the space 96 - + //fprintf(stdout, "left_width: %d right_width: %d\n", left_width, right_width); 97 - + // right side overflow case 98 - + if ( left_width <= 0 ) { 99 - + snprintf(entry, SidebarWidth*4, "%-*.*s ...", SidebarWidth-4-delim_len, SidebarWidth-4-delim_len, box); 100 - + return entry; 101 - + } 102 - + right_width -= delim_len; 103 - + 104 - + // to support utf-8 chars we need to add enough space padding in case there 105 - + // are less chars than bytes in *box 106 - + box_len = mbstowcs(NULL, box, 0); 107 - + box_bytes = strlen(box); 108 - + // debug 109 - + //fprintf(stdout, "box_len: %d box_bytes: %d (diff: %d)\n", box_len, box_bytes, (box_bytes-box_len)); 110 - + // if there is less string than the space we allow, then we will add the 111 - + // spaces 112 - + if ( box_len != -1 && box_len < left_width ) { 113 - + left_width += (box_bytes - box_len); 114 - + } 115 - + // otherwise sprintf will truncate the string for us (therefore, no else case) 116 - + 117 - + // print the sidebar entry (without new and flagged messages, at the moment) 118 - + //fprintf(stdout, "left_width: %d right_width: %d\n", left_width, right_width); 119 - + right_offset = snprintf(entry, SidebarWidth*4, "%-*.*s %d", left_width, left_width, box, size); 120 - + 121 - + // then pad new and flagged messages if any 122 - + if ( new > 0 ) { 123 - + right_offset += snprintf(entry+right_offset, SidebarWidth*4-right_offset, "(%d)", new); 124 - + } 125 - + if ( flagged > 0 ) { 126 - + right_offset += snprintf(entry+right_offset, SidebarWidth*4-right_offset, "[%d]", flagged); 127 - + } 128 - + 129 - + return entry; 130 - } 131 - 132 - void set_curbuffy(char buf[LONG_STRING])
+3788 -815
pkgs/applications/networking/mailreaders/mutt/sidebar.patch
··· 1 - From: Antonio Radici <antonio@debian.org> 2 - Date: Tue, 4 Mar 2014 15:21:10 +0100 3 - Subject: sidebar 4 - 5 - When enabled, mutt will show a list of mailboxes with (new) message counts in a 6 - separate column on the left side of the screen. 7 - 8 - As this feature is still considered to be unstable, this patch is only applied 9 - in the "mutt-patched" package. 10 - 11 - * Configuration variables: 12 - 13 - sidebar_delim (string, default "|") 14 - 15 - This specifies the delimiter between the sidebar (if visible) and 16 - other screens. 17 - 18 - sidebar_visible (boolean, default no) 19 - 20 - This specifies whether or not to show sidebar (left-side list of folders). 21 - 22 - sidebar_width (integer, default 0) 23 - - 24 - The width of the sidebar. 25 - 26 - * Patch source: 27 - - http://www.lunar-linux.org/index.php?page=mutt-sidebar 28 - - http://lunar-linux.org/~tchan/mutt/patch-1.5.19.sidebar.20090522.txt 29 - 30 - * Changes made: 31 - - 2008-08-02 myon: Refreshed patch using quilt push -f to remove hunks we do 32 - not need (Makefile.in). 33 - 34 - - 2014-03-04 evgeni: refresh sidebar patch with the version from OpenBSD 35 - Source: 36 - ftp://ftp.openbsd.org/pub/OpenBSD/distfiles/mutt/sidebar-1.5.22.diff1.gz 37 - 38 - Signed-off-by: Matteo F. Vescovi <mfvescovi@gmail.com> 39 - Signed-off-by: Evgeni Golov <evgeni@debian.org> 40 - 41 - Gbp-Pq: Topic mutt-patched 42 - --- 43 - Makefile.am | 1 + 44 - OPS | 5 + 45 - buffy.c | 124 +++++++++++++++++++++ 46 - buffy.h | 4 + 47 - color.c | 2 + 48 - compose.c | 26 ++--- 49 - curs_main.c | 30 +++++- 50 - flags.c | 3 + 51 - functions.h | 10 ++ 52 - globals.h | 4 + 53 - imap/command.c | 7 ++ 54 - imap/imap.c | 2 +- 55 - init.h | 21 ++++ 56 - mailbox.h | 1 + 57 - mbox.c | 2 + 58 - menu.c | 20 ++-- 59 - mh.c | 22 ++++ 60 - mutt.h | 4 + 61 - mutt_curses.h | 3 + 62 - muttlib.c | 48 +++++++++ 63 - mx.c | 15 +++ 64 - mx.h | 1 + 65 - pager.c | 30 ++++-- 66 - sidebar.c | 333 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 67 - sidebar.h | 36 +++++++ 68 - 25 files changed, 720 insertions(+), 34 deletions(-) 69 - create mode 100644 sidebar.c 70 - create mode 100644 sidebar.h 71 - 72 - diff --git a/Makefile.am b/Makefile.am 73 - index 5dfeff6..cf1ac98 100644 74 - --- a/Makefile.am 75 - +++ b/Makefile.am 76 - @@ -33,6 +33,7 @@ mutt_SOURCES = \ 77 - rfc822.c rfc1524.c rfc2047.c rfc2231.c rfc3676.c \ 78 - score.c send.c sendlib.c signal.c sort.c \ 79 - status.c system.c thread.c charset.c history.c lib.c \ 80 - + sidebar.c \ 81 - muttlib.c editmsg.c mbyte.c mutt_idna.c \ 82 - url.c ascii.c crypt-mod.c crypt-mod.h safe_asprintf.c 1 + diff -urN mutt-1.6.1/buffy.c mutt-1.6.1-sidebar/buffy.c 2 + --- mutt-1.6.1/buffy.c 2016-06-12 18:43:00.397447512 +0100 3 + +++ mutt-1.6.1-sidebar/buffy.c 2016-06-12 18:43:03.951502935 +0100 4 + @@ -27,6 +27,10 @@ 83 5 84 - diff --git a/OPS b/OPS 85 - index 02cea8e..b036db9 100644 86 - --- a/OPS 87 - +++ b/OPS 88 - @@ -180,3 +180,8 @@ OP_WHAT_KEY "display the keycode for a key press" 89 - OP_MAIN_SHOW_LIMIT "show currently active limit pattern" 90 - OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread" 91 - OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads" 92 - +OP_SIDEBAR_SCROLL_UP "scroll the mailbox pane up 1 page" 93 - +OP_SIDEBAR_SCROLL_DOWN "scroll the mailbox pane down 1 page" 94 - +OP_SIDEBAR_NEXT "go down to next mailbox" 95 - +OP_SIDEBAR_PREV "go to previous mailbox" 96 - +OP_SIDEBAR_OPEN "open hilighted mailbox" 97 - diff --git a/buffy.c b/buffy.c 98 - index 12a16d1..90ca6db 100644 99 - --- a/buffy.c 100 - +++ b/buffy.c 101 - @@ -161,6 +161,49 @@ void mutt_buffy_cleanup (const char *buf, struct stat *st) 102 - } 103 - } 6 + #include "mutt_curses.h" 104 7 105 - +static int buffy_compare_name(const void *a, const void *b) { 106 - + const BUFFY *b1 = * (BUFFY * const *) a; 107 - + const BUFFY *b2 = * (BUFFY * const *) b; 108 - + 109 - + return mutt_strcoll(b1->path, b2->path); 110 - +} 111 - + 112 - +static BUFFY *buffy_sort(BUFFY *b) 113 - +{ 114 - + BUFFY *tmp = b; 115 - + int buffycount = 0; 116 - + BUFFY **ary; 117 - + int i; 118 - + 119 - + if (!option(OPTSIDEBARSORT)) 120 - + return b; 121 - + 122 - + for (; tmp != NULL; tmp = tmp->next) 123 - + buffycount++; 124 - + 125 - + ary = (BUFFY **) safe_calloc(buffycount, sizeof (*ary)); 126 - + 127 - + tmp = b; 128 - + for (i = 0; tmp != NULL; tmp = tmp->next, i++) { 129 - + ary[i] = tmp; 130 - + } 131 - + 132 - + qsort(ary, buffycount, sizeof(*ary), buffy_compare_name); 133 - + 134 - + for (i = 0; i < buffycount - 1; i++) { 135 - + ary[i]->next = ary[i+1]; 136 - + } 137 - + ary[buffycount - 1]->next = NULL; 138 - + for (i = 1; i < buffycount; i++) { 139 - + ary[i]->prev = ary[i-1]; 140 - + } 141 - + ary[0]->prev = NULL; 8 + +#ifdef USE_SIDEBAR 9 + +#include "sidebar.h" 10 + +#endif 142 11 + 143 - + tmp = ary[0]; 144 - + free(ary); 145 - + return tmp; 146 - +} 147 - + 148 - BUFFY *mutt_find_mailbox (const char *path) 12 + #ifdef USE_IMAP 13 + #include "imap.h" 14 + #endif 15 + @@ -196,9 +200,17 @@ 16 + static BUFFY *buffy_new (const char *path) 149 17 { 150 - BUFFY *tmp = NULL; 151 - @@ -282,6 +325,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e 152 - else 153 - (*tmp)->size = 0; 18 + BUFFY* buffy; 19 + +#ifdef USE_SIDEBAR 20 + + char rp[PATH_MAX] = ""; 21 + + char *r = NULL; 22 + +#endif 23 + 24 + buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY)); 25 + strfcpy (buffy->path, path, sizeof (buffy->path)); 26 + +#ifdef USE_SIDEBAR 27 + + r = realpath (path, rp); 28 + + strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath)); 29 + +#endif 30 + buffy->next = NULL; 31 + buffy->magic = 0; 32 + 33 + @@ -215,7 +227,10 @@ 34 + BUFFY **tmp,*tmp1; 35 + char buf[_POSIX_PATH_MAX]; 36 + struct stat sb; 37 + - char f1[PATH_MAX], f2[PATH_MAX]; 38 + + char f1[PATH_MAX]; 39 + +#ifndef USE_SIDEBAR 40 + + char f2[PATH_MAX]; 41 + +#endif 42 + char *p, *q; 43 + 44 + while (MoreArgs (s)) 45 + @@ -228,6 +243,9 @@ 46 + for (tmp = &Incoming; *tmp;) 47 + { 48 + tmp1=(*tmp)->next; 49 + +#ifdef USE_SIDEBAR 50 + + mutt_sb_notify_mailbox (*tmp, 0); 51 + +#endif 52 + buffy_free (tmp); 53 + *tmp=tmp1; 54 + } 55 + @@ -243,8 +261,13 @@ 56 + p = realpath (buf, f1); 57 + for (tmp = &Incoming; *tmp; tmp = &((*tmp)->next)) 58 + { 59 + +#ifdef USE_SIDEBAR 60 + + q = (*tmp)->realpath; 61 + + if (mutt_strcmp (p ? p : buf, q) == 0) 62 + +#else 63 + q = realpath ((*tmp)->path, f2); 64 + if (mutt_strcmp (p ? p : buf, q ? q : (*tmp)->path) == 0) 65 + +#endif 66 + { 67 + dprint(3,(debugfile,"mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path)); 68 + break; 69 + @@ -256,14 +279,21 @@ 70 + if(*tmp) 71 + { 72 + tmp1=(*tmp)->next; 73 + +#ifdef USE_SIDEBAR 74 + + mutt_sb_notify_mailbox (*tmp, 0); 75 + +#endif 76 + buffy_free (tmp); 77 + *tmp=tmp1; 78 + } 79 + continue; 80 + } 81 + 82 + - if (!*tmp) 83 + + if (!*tmp) { 84 + *tmp = buffy_new (buf); 85 + +#ifdef USE_SIDEBAR 86 + + mutt_sb_notify_mailbox (*tmp, 1); 87 + +#endif 88 + + } 89 + 90 + (*tmp)->new = 0; 91 + (*tmp)->notified = 1; 92 + @@ -306,6 +336,13 @@ 93 + return 0; 154 94 } 155 - + Incoming = buffy_sort(Incoming); 156 - return 0; 157 - } 158 95 159 - @@ -357,6 +401,69 @@ static int buffy_maildir_hasnew (BUFFY* mailbox) 96 + +#ifdef USE_SIDEBAR 97 + + if (option (OPTSIDEBAR) && mailbox->msg_unread > 0) { 98 + + mailbox->new = 1; 99 + + return 1; 100 + + } 101 + +#endif 102 + + 103 + if ((dirp = opendir (path)) == NULL) 104 + { 105 + mailbox->magic = 0; 106 + @@ -357,6 +394,93 @@ 160 107 161 108 return 0; 162 109 } 163 110 + 164 - +/* update message counts for the sidebar */ 165 - +void buffy_maildir_update (BUFFY* mailbox) 111 + +#ifdef USE_SIDEBAR 112 + +/** 113 + + * buffy_maildir_update_dir - Update counts for one directory 114 + + * @mailbox: BUFFY representing a maildir mailbox 115 + + * @dir: Which directory to search 116 + + * 117 + + * Look through one directory of a maildir mailbox. The directory could 118 + + * be either "new" or "cur". 119 + + * 120 + + * Count how many new, or flagged, messages there are. 121 + + */ 122 + +static void 123 + +buffy_maildir_update_dir (BUFFY *mailbox, const char *dir) 166 124 +{ 167 - + char path[_POSIX_PATH_MAX]; 168 - + DIR *dirp; 169 - + struct dirent *de; 170 - + char *p; 125 + + char path[_POSIX_PATH_MAX] = ""; 126 + + DIR *dirp = NULL; 127 + + struct dirent *de = NULL; 128 + + char *p = NULL; 129 + + int read; 171 130 + 172 - + mailbox->msgcount = 0; 173 - + mailbox->msg_unread = 0; 174 - + mailbox->msg_flagged = 0; 131 + + snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir); 175 132 + 176 - + snprintf (path, sizeof (path), "%s/new", mailbox->path); 177 - + 178 - + if ((dirp = opendir (path)) == NULL) 179 - + { 133 + + dirp = opendir (path); 134 + + if (!dirp) 135 + + { 180 136 + mailbox->magic = 0; 181 137 + return; 182 - + } 183 - + 138 + + } 139 + + 184 140 + while ((de = readdir (dirp)) != NULL) 185 141 + { 186 142 + if (*de->d_name == '.') 187 143 + continue; 188 144 + 189 - + if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { 190 - + mailbox->new = 1; 191 - + mailbox->msgcount++; 145 + + /* Matches maildir_parse_flags logic */ 146 + + read = 0; 147 + + mailbox->msg_count++; 148 + + p = strstr (de->d_name, ":2,"); 149 + + if (p) 150 + + { 151 + + p += 3; 152 + + if (strchr (p, 'S')) 153 + + read = 1; 154 + + if (strchr (p, 'F')) 155 + + mailbox->msg_flagged++; 156 + + } 157 + + if (!read) { 192 158 + mailbox->msg_unread++; 193 159 + } 194 160 + } 195 161 + 196 162 + closedir (dirp); 197 - + snprintf (path, sizeof (path), "%s/cur", mailbox->path); 198 - + 199 - + if ((dirp = opendir (path)) == NULL) 200 - + { 201 - + mailbox->magic = 0; 202 - + return; 203 - + } 204 - + 205 - + while ((de = readdir (dirp)) != NULL) 206 - + { 207 - + if (*de->d_name == '.') 208 - + continue; 163 + +} 209 164 + 210 - + if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { 211 - + mailbox->msgcount++; 212 - + if ((p = strstr (de->d_name, ":2,"))) { 213 - + if (!strchr (p + 3, 'T')) { 214 - + if (!strchr (p + 3, 'S')) 215 - + mailbox->msg_unread++; 216 - + if (strchr(p + 3, 'F')) 217 - + mailbox->msg_flagged++; 218 - + } 219 - + } 220 - + } 221 - + } 165 + +/** 166 + + * buffy_maildir_update - Update messages counts for a maildir mailbox 167 + + * @mailbox: BUFFY representing a maildir mailbox 168 + + * 169 + + * Open a mailbox directories and update our record of how many new, or 170 + + * flagged, messages there are. 171 + + */ 172 + +void 173 + +buffy_maildir_update (BUFFY *mailbox) 174 + +{ 175 + + if (!option (OPTSIDEBAR)) 176 + + return; 222 177 + 223 - + closedir (dirp); 178 + + mailbox->msg_count = 0; 179 + + mailbox->msg_unread = 0; 180 + + mailbox->msg_flagged = 0; 181 + + 182 + + buffy_maildir_update_dir (mailbox, "new"); 183 + + if (mailbox->msg_count) { 184 + + mailbox->new = 1; 185 + + } 186 + + buffy_maildir_update_dir (mailbox, "cur"); 187 + + 188 + + mailbox->sb_last_checked = time (NULL); 189 + + 190 + + /* make sure the updates are actually put on screen */ 191 + + if (SidebarWidth) 192 + + mutt_sb_draw(); 224 193 +} 194 + + 195 + +#endif 225 196 + 226 197 /* returns 1 if mailbox has new mail */ 227 198 static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) 228 199 { 229 - @@ -388,6 +495,20 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) 200 + @@ -368,7 +491,11 @@ 201 + else 202 + statcheck = sb->st_mtime > sb->st_atime 203 + || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime); 204 + +#ifdef USE_SIDEBAR 205 + + if ((!option (OPTSIDEBAR) && statcheck) || (option (OPTSIDEBAR) && mailbox->msg_unread > 0)) 206 + +#else 207 + if (statcheck) 208 + +#endif 209 + { 210 + if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited) 211 + { 212 + @@ -388,6 +515,42 @@ 230 213 return rc; 231 214 } 232 215 233 - +/* update message counts for the sidebar */ 234 - +void buffy_mbox_update (BUFFY* mailbox) 216 + +#ifdef USE_SIDEBAR 217 + +/** 218 + + * buffy_mbox_update - Update messages counts for an mbox mailbox 219 + + * @mailbox: BUFFY representing an mbox mailbox 220 + + * @sb: stat(2) infomation about the mailbox file 221 + + * 222 + + * Open a mbox file and update our record of how many new, or flagged, 223 + + * messages there are. If the mailbox hasn't changed since the last call, 224 + + * the function does nothing. 225 + + */ 226 + +void 227 + +buffy_mbox_update (BUFFY *mailbox, struct stat *sb) 235 228 +{ 236 229 + CONTEXT *ctx = NULL; 237 230 + 238 - + ctx = mx_open_mailbox(mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); 239 - + if(ctx) 231 + + if (!option (OPTSIDEBAR)) 232 + + return; 233 + + if ((mailbox->sb_last_checked > sb->st_mtime) && (mailbox->msg_count != 0)) 234 + + return; /* no check necessary */ 235 + + 236 + + ctx = mx_open_mailbox (mailbox->path, M_READONLY | M_QUIET | M_NOSORT | M_PEEK, NULL); 237 + + if (ctx) 240 238 + { 241 - + mailbox->msgcount = ctx->msgcount; 242 - + mailbox->msg_unread = ctx->unread; 243 - + mx_close_mailbox(ctx, 0); 239 + + mailbox->msg_count = ctx->msgcount; 240 + + mailbox->msg_unread = ctx->unread; 241 + + mailbox->msg_flagged = ctx->flagged; 242 + + mailbox->sb_last_checked = time (NULL); 243 + + mx_close_mailbox (ctx, 0); 244 244 + } 245 + + 246 + + /* make sure the updates are actually put on screen */ 247 + + if (SidebarWidth) 248 + + mutt_sb_draw(); 245 249 +} 250 + +#endif 246 251 + 247 252 int mutt_buffy_check (int force) 248 253 { 249 254 BUFFY *tmp; 250 - @@ -461,16 +582,19 @@ int mutt_buffy_check (int force) 255 + @@ -461,16 +623,25 @@ 251 256 { 252 257 case M_MBOX: 253 258 case M_MMDF: 254 - + buffy_mbox_update (tmp); 259 + +#ifdef USE_SIDEBAR 260 + + buffy_mbox_update (tmp, &sb); 261 + +#endif 255 262 if (buffy_mbox_hasnew (tmp, &sb) > 0) 256 263 BuffyCount++; 257 264 break; 258 265 259 266 case M_MAILDIR: 267 + +#ifdef USE_SIDEBAR 260 268 + buffy_maildir_update (tmp); 269 + +#endif 261 270 if (buffy_maildir_hasnew (tmp) > 0) 262 271 BuffyCount++; 263 272 break; 264 273 265 274 case M_MH: 266 - + mh_buffy_update (tmp->path, &tmp->msgcount, &tmp->msg_unread, &tmp->msg_flagged); 275 + +#ifdef USE_SIDEBAR 276 + + mh_buffy_update (tmp); 277 + +#endif 267 278 mh_buffy(tmp); 268 279 if (tmp->new) 269 280 BuffyCount++; 270 - diff --git a/buffy.h b/buffy.h 271 - index f9fc55a..672d178 100644 272 - --- a/buffy.h 273 - +++ b/buffy.h 274 - @@ -25,7 +25,11 @@ typedef struct buffy_t 281 + diff -urN mutt-1.6.1/buffy.h mutt-1.6.1-sidebar/buffy.h 282 + --- mutt-1.6.1/buffy.h 2016-06-12 18:43:00.397447512 +0100 283 + +++ mutt-1.6.1-sidebar/buffy.h 2016-06-12 18:43:03.951502935 +0100 284 + @@ -16,6 +16,9 @@ 285 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 286 + */ 287 + 288 + +#ifndef _BUFFY_H 289 + +#define _BUFFY_H 290 + + 291 + /*parameter to mutt_parse_mailboxes*/ 292 + #define M_MAILBOXES 1 293 + #define M_UNMAILBOXES 2 294 + @@ -23,13 +26,28 @@ 295 + typedef struct buffy_t 296 + { 275 297 char path[_POSIX_PATH_MAX]; 298 + +#ifdef USE_SIDEBAR 299 + + char realpath[_POSIX_PATH_MAX]; 300 + +#endif 276 301 off_t size; 277 302 struct buffy_t *next; 303 + +#ifdef USE_SIDEBAR 278 304 + struct buffy_t *prev; 305 + +#endif 279 306 short new; /* mailbox has new mail */ 280 - + int msgcount; /* total number of messages */ 307 + +#ifdef USE_SIDEBAR 308 + + int msg_count; /* total number of messages */ 281 309 + int msg_unread; /* number of unread messages */ 282 310 + int msg_flagged; /* number of flagged messages */ 311 + + short is_hidden; /* is hidden from the sidebar */ 312 + +#endif 283 313 short notified; /* user has been notified */ 284 314 short magic; /* mailbox type */ 285 315 short newly_created; /* mbox or mmdf just popped into existence */ 286 - diff --git a/color.c b/color.c 287 - index 64a46dc..d6f9198 100644 288 - --- a/color.c 289 - +++ b/color.c 290 - @@ -94,6 +94,8 @@ static const struct mapping_t Fields[] = 316 + time_t last_visited; /* time of last exit from this mailbox */ 317 + +#ifdef USE_SIDEBAR 318 + + time_t sb_last_checked; /* time of last buffy check from sidebar */ 319 + +#endif 320 + } 321 + BUFFY; 322 + 323 + @@ -49,3 +67,5 @@ 324 + void mutt_buffy_setnotified (const char *path); 325 + 326 + void mh_buffy (BUFFY *); 327 + + 328 + +#endif /* _BUFFY_H */ 329 + diff -urN mutt-1.6.1/color.c mutt-1.6.1-sidebar/color.c 330 + --- mutt-1.6.1/color.c 2016-06-12 18:43:00.397447512 +0100 331 + +++ mutt-1.6.1-sidebar/color.c 2016-06-12 18:43:03.951502935 +0100 332 + @@ -94,6 +94,14 @@ 291 333 { "underline", MT_COLOR_UNDERLINE }, 292 334 { "index", MT_COLOR_INDEX }, 293 335 { "prompt", MT_COLOR_PROMPT }, 336 + +#ifdef USE_SIDEBAR 337 + + { "sidebar_divider", MT_COLOR_DIVIDER }, 338 + + { "sidebar_flagged", MT_COLOR_FLAGGED }, 339 + + { "sidebar_highlight",MT_COLOR_HIGHLIGHT }, 340 + + { "sidebar_indicator",MT_COLOR_SB_INDICATOR }, 294 341 + { "sidebar_new", MT_COLOR_NEW }, 295 - + { "sidebar_flagged", MT_COLOR_FLAGGED }, 342 + + { "sidebar_spoolfile",MT_COLOR_SB_SPOOLFILE }, 343 + +#endif 296 344 { NULL, 0 } 297 345 }; 298 346 299 - diff --git a/compose.c b/compose.c 300 - index 9d87060..b63695f 100644 301 - --- a/compose.c 302 - +++ b/compose.c 303 - @@ -72,7 +72,7 @@ enum 347 + @@ -146,6 +154,9 @@ 348 + ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE; 349 + ColorDefs[MT_COLOR_SEARCH] = A_REVERSE; 350 + ColorDefs[MT_COLOR_MARKERS] = A_REVERSE; 351 + +#ifdef USE_SIDEBAR 352 + + ColorDefs[MT_COLOR_HIGHLIGHT] = A_UNDERLINE; 353 + +#endif 354 + /* special meaning: toggle the relevant attribute */ 355 + ColorDefs[MT_COLOR_BOLD] = 0; 356 + ColorDefs[MT_COLOR_UNDERLINE] = 0; 357 + diff -urN mutt-1.6.1/compose.c mutt-1.6.1-sidebar/compose.c 358 + --- mutt-1.6.1/compose.c 2016-06-12 18:43:00.398447528 +0100 359 + +++ mutt-1.6.1-sidebar/compose.c 2016-06-12 18:43:03.952502951 +0100 360 + @@ -32,6 +32,9 @@ 361 + #include "mailbox.h" 362 + #include "sort.h" 363 + #include "charset.h" 364 + +#ifdef USE_SIDEBAR 365 + +#include "sidebar.h" 366 + +#endif 367 + 368 + #ifdef MIXMASTER 369 + #include "remailer.h" 370 + @@ -72,7 +75,7 @@ 304 371 305 372 #define HDR_XOFFSET 10 306 373 #define TITLE_FMT "%10s" /* Used for Prompts, which are ASCII */ ··· 309 376 310 377 static const char * const Prompts[] = 311 378 { 312 - @@ -110,7 +110,7 @@ static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num) 379 + @@ -110,7 +113,7 @@ 313 380 314 381 static void redraw_crypt_lines (HEADER *msg) 315 382 { 316 383 - mvaddstr (HDR_CRYPT, 0, "Security: "); 317 - + mvaddstr (HDR_CRYPT, SidebarWidth, "Security: "); 384 + + mvprintw (HDR_CRYPT, SidebarWidth, TITLE_FMT, "Security: "); 318 385 319 386 if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0) 320 387 { 321 - @@ -145,7 +145,7 @@ static void redraw_crypt_lines (HEADER *msg) 388 + @@ -145,16 +148,16 @@ 322 389 addstr (_(" (OppEnc mode)")); 323 390 324 391 clrtoeol (); ··· 327 394 clrtoeol (); 328 395 329 396 if ((WithCrypto & APPLICATION_PGP) 330 - @@ -162,7 +162,7 @@ static void redraw_crypt_lines (HEADER *msg) 397 + && (msg->security & APPLICATION_PGP) && (msg->security & SIGN)) 398 + - printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); 399 + + printw (TITLE_FMT "%s", _("sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); 400 + 401 + if ((WithCrypto & APPLICATION_SMIME) 402 + && (msg->security & APPLICATION_SMIME) && (msg->security & SIGN)) { 403 + - printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); 404 + + printw (TITLE_FMT "%s", _("sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>")); 405 + } 406 + 407 + if ((WithCrypto & APPLICATION_SMIME) 408 + @@ -162,7 +165,7 @@ 331 409 && (msg->security & ENCRYPT) 332 410 && SmimeCryptAlg 333 411 && *SmimeCryptAlg) { ··· 336 414 NONULL(SmimeCryptAlg)); 337 415 } 338 416 } 339 - @@ -175,7 +175,7 @@ static void redraw_mix_line (LIST *chain) 417 + @@ -175,7 +178,8 @@ 340 418 int c; 341 419 char *t; 342 420 343 421 - mvaddstr (HDR_MIX, 0, " Mix: "); 344 - + mvaddstr (HDR_MIX, SidebarWidth, " Mix: "); 422 + + /* L10N: "Mix" refers to the MixMaster chain for anonymous email */ 423 + + mvprintw (HDR_MIX, SidebarWidth, TITLE_FMT, _("Mix: ")); 345 424 346 425 if (!chain) 347 426 { 348 - @@ -190,7 +190,7 @@ static void redraw_mix_line (LIST *chain) 427 + @@ -190,7 +194,7 @@ 349 428 if (t && t[0] == '0' && t[1] == '\0') 350 429 t = "<random>"; 351 430 ··· 354 433 break; 355 434 356 435 addstr (NONULL(t)); 357 - @@ -242,7 +242,7 @@ static void draw_envelope_addr (int line, ADDRESS *addr) 436 + @@ -242,20 +246,23 @@ 358 437 359 438 buf[0] = 0; 360 439 rfc822_write_address (buf, sizeof (buf), addr, 1); ··· 363 442 mutt_paddstr (W, buf); 364 443 } 365 444 366 - @@ -252,10 +252,10 @@ static void draw_envelope (HEADER *msg, char *fcc) 445 + static void draw_envelope (HEADER *msg, char *fcc) 446 + { 447 + +#ifdef USE_SIDEBAR 448 + + mutt_sb_draw(); 449 + +#endif 450 + draw_envelope_addr (HDR_FROM, msg->env->from); 367 451 draw_envelope_addr (HDR_TO, msg->env->to); 368 452 draw_envelope_addr (HDR_CC, msg->env->cc); 369 453 draw_envelope_addr (HDR_BCC, msg->env->bcc); ··· 376 460 mutt_paddstr (W, fcc); 377 461 378 462 if (WithCrypto) 379 - @@ -266,7 +266,7 @@ static void draw_envelope (HEADER *msg, char *fcc) 463 + @@ -266,7 +273,7 @@ 380 464 #endif 381 465 382 466 SETCOLOR (MT_COLOR_STATUS); ··· 385 469 clrtoeol (); 386 470 387 471 NORMAL_COLOR; 388 - @@ -302,7 +302,7 @@ static int edit_address_list (int line, ADDRESS **addr) 472 + @@ -302,7 +309,7 @@ 389 473 /* redraw the expanded list so the user can see the result */ 390 474 buf[0] = 0; 391 475 rfc822_write_address (buf, sizeof (buf), *addr, 1); 392 476 - move (line, HDR_XOFFSET); 393 - + move (line, HDR_XOFFSET+SidebarWidth); 477 + + move (line, HDR_XOFFSET + SidebarWidth); 394 478 mutt_paddstr (W, buf); 395 479 396 480 return 0; 397 - @@ -562,7 +562,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ 481 + @@ -515,7 +522,7 @@ 482 + menu->tag = mutt_tag_attach; 483 + menu->data = idx; 484 + menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); 485 + - 486 + + 487 + while (loop) 488 + { 489 + switch (op = mutt_menuLoop (menu)) 490 + @@ -564,7 +571,7 @@ 398 491 if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) 399 492 { 400 493 mutt_str_replace (&msg->env->subject, buf); ··· 403 496 if (msg->env->subject) 404 497 mutt_paddstr (W, msg->env->subject); 405 498 else 406 - @@ -580,7 +580,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ 499 + @@ -582,7 +589,7 @@ 407 500 { 408 501 strfcpy (fcc, buf, fcclen); 409 502 mutt_pretty_mailbox (fcc, fcclen); ··· 412 505 mutt_paddstr (W, fcc); 413 506 fccSet = 1; 414 507 } 415 - diff --git a/curs_main.c b/curs_main.c 416 - index 9d718ee..ea530a6 100644 417 - --- a/curs_main.c 418 - +++ b/curs_main.c 419 - @@ -26,7 +26,9 @@ 508 + diff -urN mutt-1.6.1/configure.ac mutt-1.6.1-sidebar/configure.ac 509 + --- mutt-1.6.1/configure.ac 2016-06-12 18:43:00.398447528 +0100 510 + +++ mutt-1.6.1-sidebar/configure.ac 2016-06-12 18:43:03.952502951 +0100 511 + @@ -175,6 +175,14 @@ 512 + SMIMEAUX_TARGET="smime_keys" 513 + fi 514 + 515 + +AC_ARG_ENABLE(sidebar, AC_HELP_STRING([--enable-sidebar], [Enable Sidebar support]), 516 + +[ if test x$enableval = xyes ; then 517 + + AC_DEFINE(USE_SIDEBAR, 1, [Define if you want support for the sidebar.]) 518 + + OPS="$OPS \$(srcdir)/OPS.SIDEBAR" 519 + + MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS sidebar.o" 520 + + fi 521 + +]) 522 + + 523 + AC_ARG_WITH(mixmaster, AS_HELP_STRING([--with-mixmaster@<:@=PATH@:>@],[Include Mixmaster support]), 524 + [if test "$withval" != no 525 + then 526 + diff -urN mutt-1.6.1/copy.c mutt-1.6.1-sidebar/copy.c 527 + --- mutt-1.6.1/copy.c 2016-06-12 18:43:00.398447528 +0100 528 + +++ mutt-1.6.1-sidebar/copy.c 2016-06-12 18:43:03.952502951 +0100 529 + @@ -288,7 +288,8 @@ 530 + if (flags & (CH_DECODE|CH_PREFIX)) 531 + { 532 + if (mutt_write_one_header (out, 0, headers[x], 533 + - flags & CH_PREFIX ? prefix : 0, mutt_term_width (Wrap), flags) == -1) 534 + + flags & CH_PREFIX ? prefix : 0, 535 + + mutt_term_width (Wrap), flags) == -1) 536 + { 537 + error = TRUE; 538 + break; 539 + diff -urN mutt-1.6.1/curs_main.c mutt-1.6.1-sidebar/curs_main.c 540 + --- mutt-1.6.1/curs_main.c 2016-06-12 18:43:00.399447544 +0100 541 + +++ mutt-1.6.1-sidebar/curs_main.c 2016-06-12 18:43:03.953502966 +0100 542 + @@ -26,8 +26,13 @@ 420 543 #include "mailbox.h" 421 544 #include "mapping.h" 422 545 #include "sort.h" 423 546 +#include "buffy.h" 424 547 #include "mx.h" 548 + 549 + +#ifdef USE_SIDEBAR 425 550 +#include "sidebar.h" 426 - 551 + +#endif 552 + + 427 553 #ifdef USE_POP 428 554 #include "pop.h" 429 - @@ -596,8 +598,12 @@ int mutt_index_menu (void) 555 + #endif 556 + @@ -595,21 +600,39 @@ 430 557 menu->redraw |= REDRAW_STATUS; 431 558 if (do_buffy_notify) 432 559 { 433 560 - if (mutt_buffy_notify () && option (OPTBEEPNEW)) 434 561 - beep (); 435 - + if (mutt_buffy_notify ()) 562 + + if (mutt_buffy_notify()) 436 563 + { 437 - + menu->redraw |= REDRAW_FULL; 564 + + menu->redraw |= REDRAW_STATUS; 438 565 + if (option (OPTBEEPNEW)) 439 - + beep (); 566 + + beep(); 440 567 + } 441 568 } 442 569 else 443 570 do_buffy_notify = 1; 444 - @@ -609,6 +615,7 @@ int mutt_index_menu (void) 571 + } 572 + 573 + +#ifdef USE_SIDEBAR 574 + + if (option (OPTSIDEBAR)) 575 + + menu->redraw |= REDRAW_SIDEBAR; 576 + +#endif 577 + + 578 + if (op != -1) 579 + mutt_curs_set (0); 580 + 445 581 if (menu->redraw & REDRAW_FULL) 446 582 { 447 583 menu_redraw_full (menu); 448 - + draw_sidebar(menu->menu); 584 + +#ifdef USE_SIDEBAR 585 + + mutt_sb_draw(); 586 + +#endif 449 587 mutt_show_error (); 450 588 } 589 + +#ifdef USE_SIDEBAR 590 + + else if (menu->redraw & REDRAW_SIDEBAR) { 591 + + mutt_sb_draw(); 592 + + menu->redraw &= ~REDRAW_SIDEBAR; 593 + + } 594 + +#endif 451 595 452 - @@ -631,9 +638,12 @@ int mutt_index_menu (void) 596 + if (menu->menu == MENU_MAIN) 597 + { 598 + @@ -630,9 +653,20 @@ 453 599 454 600 if (menu->redraw & REDRAW_STATUS) 455 601 { 456 - + DrawFullLine = 1; 602 + +#ifdef USE_SIDEBAR 603 + + /* Temporarily lie about the sidebar width */ 604 + + short sw = SidebarWidth; 605 + + SidebarWidth = 0; 606 + +#endif 457 607 menu_status_line (buf, sizeof (buf), menu, NONULL (Status)); 458 - + DrawFullLine = 0; 608 + +#ifdef USE_SIDEBAR 609 + + SidebarWidth = sw; /* Restore the sidebar width */ 610 + +#endif 459 611 move (option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); 460 612 SETCOLOR (MT_COLOR_STATUS); 461 - + set_buffystats(Context); 613 + +#ifdef USE_SIDEBAR 614 + + mutt_sb_set_buffystats (Context); 615 + +#endif 462 616 mutt_paddstr (COLS, buf); 463 617 NORMAL_COLOR; 464 618 menu->redraw &= ~REDRAW_STATUS; 465 - @@ -653,7 +663,7 @@ int mutt_index_menu (void) 619 + @@ -652,7 +686,7 @@ 466 620 menu->oldcurrent = -1; 467 621 468 622 if (option (OPTARROWCURSOR)) ··· 471 625 else if (option (OPTBRAILLEFRIENDLY)) 472 626 move (menu->current - menu->top + menu->offset, 0); 473 627 else 474 - @@ -1154,6 +1164,7 @@ int mutt_index_menu (void) 628 + @@ -1091,6 +1125,9 @@ 629 + break; 630 + 631 + CHECK_MSGCOUNT; 632 + +#ifdef USE_SIDEBAR 633 + + CHECK_VISIBLE; 634 + +#endif 635 + CHECK_READONLY; 636 + { 637 + int oldvcount = Context->vcount; 638 + @@ -1150,6 +1187,9 @@ 475 639 menu->redraw = REDRAW_FULL; 476 640 break; 477 641 642 + +#ifdef USE_SIDEBAR 478 643 + case OP_SIDEBAR_OPEN: 644 + +#endif 479 645 case OP_MAIN_CHANGE_FOLDER: 480 646 case OP_MAIN_NEXT_UNREAD_MAILBOX: 481 647 482 - @@ -1185,7 +1196,11 @@ int mutt_index_menu (void) 648 + @@ -1181,6 +1221,14 @@ 483 649 { 484 650 mutt_buffy (buf, sizeof (buf)); 485 651 486 - - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 487 - + if ( op == OP_SIDEBAR_OPEN ) { 488 - + if(!CurBuffy) 489 - + break; 490 - + strncpy( buf, CurBuffy->path, sizeof(buf) ); 491 - + } else if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 652 + +#ifdef USE_SIDEBAR 653 + + if (op == OP_SIDEBAR_OPEN) { 654 + + const char *path = mutt_sb_get_highlight(); 655 + + if (!path) 656 + + break; 657 + + strncpy (buf, path, sizeof (buf)); 658 + + } else 659 + +#endif 660 + if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) 492 661 { 493 662 if (menu->menu == MENU_PAGER) 494 - { 495 - @@ -1203,6 +1218,7 @@ int mutt_index_menu (void) 663 + @@ -1199,6 +1247,9 @@ 496 664 } 497 665 498 666 mutt_expand_path (buf, sizeof (buf)); 499 - + set_curbuffy(buf); 667 + +#ifdef USE_SIDEBAR 668 + + mutt_sb_set_open_buffy (buf); 669 + +#endif 500 670 if (mx_get_magic (buf) <= 0) 501 671 { 502 672 mutt_error (_("%s is not a mailbox."), buf); 503 - @@ -2306,6 +2322,12 @@ int mutt_index_menu (void) 673 + @@ -2310,6 +2361,21 @@ 504 674 mutt_what_key(); 505 675 break; 506 676 507 - + case OP_SIDEBAR_SCROLL_UP: 508 - + case OP_SIDEBAR_SCROLL_DOWN: 677 + +#ifdef USE_SIDEBAR 509 678 + case OP_SIDEBAR_NEXT: 679 + + case OP_SIDEBAR_NEXT_NEW: 680 + + case OP_SIDEBAR_PAGE_DOWN: 681 + + case OP_SIDEBAR_PAGE_UP: 510 682 + case OP_SIDEBAR_PREV: 511 - + scroll_sidebar(op, menu->menu); 683 + + case OP_SIDEBAR_PREV_NEW: 684 + + mutt_sb_change_mailbox (op); 512 685 + break; 686 + + 687 + + case OP_SIDEBAR_TOGGLE_VISIBLE: 688 + + toggle_option (OPTSIDEBAR); 689 + + menu->redraw = REDRAW_FULL; 690 + + break; 691 + +#endif 513 692 default: 514 693 if (menu->menu == MENU_MAIN) 515 694 km_error_key (MENU_MAIN); 516 - diff --git a/flags.c b/flags.c 517 - index 133fa35..48fb287 100644 518 - --- a/flags.c 519 - +++ b/flags.c 520 - @@ -22,8 +22,10 @@ 695 + diff -urN mutt-1.6.1/doc/manual.xml.head mutt-1.6.1-sidebar/doc/manual.xml.head 696 + --- mutt-1.6.1/doc/manual.xml.head 2016-06-12 18:43:00.402447590 +0100 697 + +++ mutt-1.6.1-sidebar/doc/manual.xml.head 2016-06-12 18:43:03.955502998 +0100 698 + @@ -405,6 +405,623 @@ 699 + 700 + </sect2> 701 + 702 + +<sect2 id="intro-sidebar"> 703 + + <title>Sidebar</title> 704 + + <para> 705 + + The Sidebar shows a list of all your mailboxes. The list can be 706 + + turned on and off, it can be themed and the list style can be 707 + + configured. 708 + + </para> 709 + + <para> 710 + + This part of the manual is suitable for beginners. 711 + + If you already know Mutt you could skip ahead to the main 712 + + <link linkend="sidebar">Sidebar guide</link>. 713 + + If you just want to get started, you could use the sample 714 + + <link linkend="sidebar-muttrc">Sidebar muttrc</link>. 715 + + </para> 716 + + <para> 717 + + This version of Sidebar is based on Terry Chan's 718 + + <ulink url="http://www.lunar-linux.org/mutt-sidebar/">2015-11-11 release</ulink>. 719 + + It contains many 720 + + <emphasis role="bold"><link linkend="intro-sidebar-features">new features</link></emphasis>, 721 + + lots of 722 + + <emphasis role="bold"><link linkend="intro-sidebar-bugfixes">bugfixes</link></emphasis> 723 + + and a generous helping of 724 + + <emphasis role="bold">new documentation</emphasis> which you are already reading. 725 + + </para> 726 + + <para> 727 + + To check if Mutt supports <quote>Sidebar</quote>, look for the string 728 + + <literal>+USE_SIDEBAR</literal> in the mutt version. 729 + + </para> 730 + +<screen> 731 + +mutt -v 732 + +</screen> 733 + + <para> 734 + + <emphasis role="bold">Let's turn on the Sidebar:</emphasis> 735 + + </para> 736 + + <screen>set sidebar_visible</screen> 737 + + <para> 738 + + You will see something like this. 739 + + A list of mailboxes on the left. 740 + + A list of emails, from the selected mailbox, on the right. 741 + + </para> 742 + +<screen> 743 + +<emphasis role="indicator">Fruit [1] 3/8</emphasis>| 1 + Jan 24 Rhys Lee (192) Yew 744 + +Animals [1] 2/6| 2 + Feb 11 Grace Hall (167) Ilama 745 + +Cars 4| 3 Feb 23 Aimee Scott (450) Nectarine 746 + +Seas 1/7| 4 ! Feb 28 Summer Jackson (264) Lemon 747 + + | 5 Mar 07 Callum Harrison (464) Raspberry 748 + + |<emphasis role="indicator"> 6 N + Mar 24 Samuel Harris (353) Tangerine </emphasis> 749 + + | 7 N + Sep 05 Sofia Graham (335) Cherry 750 + + | 8 N Sep 16 Ewan Brown (105) Ugli 751 + + | 752 + + | 753 + +</screen> 754 + +<para> 755 + + This user has four mailboxes: <quote>Fruit</quote>, 756 + + <quote>Cars</quote>, <quote>Animals</quote> and 757 + + <quote>Seas</quote>. 758 + +</para> 759 + +<para> 760 + + The current, open, mailbox is <quote>Fruit</quote>. We can 761 + + also see information about the other mailboxes. For example: 762 + + The <quote>Animals</quote> mailbox contains, 1 flagged email, 2 763 + + new emails out of a total of 6 emails. 764 + +</para> 765 + + <sect3 id="intro-sidebar-navigation"> 766 + + <title>Navigation</title> 767 + + <para> 768 + + The Sidebar adds some new <link linkend="sidebar-functions">functions</link> 769 + + to Mutt. 770 + + </para> 771 + + <para> 772 + + The user pressed the <quote>c</quote> key to 773 + + <literal>&lt;change-folder&gt;</literal> to the 774 + + <quote>Animals</quote> mailbox. The Sidebar automatically 775 + + updated the indicator to match. 776 + + </para> 777 + +<screen> 778 + +Fruit [1] 3/8| 1 Jan 03 Tia Gibson (362) Caiman 779 + +<emphasis role="indicator">Animals [1] 2/6</emphasis>| 2 + Jan 22 Rhys Lee ( 48) Dolphin 780 + +Cars 4| 3 ! Aug 16 Ewan Brown (333) Hummingbird 781 + +Seas 1/7| 4 Sep 25 Grace Hall ( 27) Capybara 782 + + |<emphasis role="indicator"> 5 N + Nov 12 Evelyn Rogers (453) Tapir </emphasis> 783 + + | 6 N + Nov 16 Callum Harrison (498) Hedgehog 784 + + | 785 + + | 786 + + | 787 + + | 788 + +</screen> 789 + + <para> 790 + + Let's map some functions: 791 + + </para> 792 + +<screen> 793 + +bind index,pager \CP sidebar-prev <emphasis role="comment"># Ctrl-Shift-P - Previous Mailbox</emphasis> 794 + +bind index,pager \CN sidebar-next <emphasis role="comment"># Ctrl-Shift-N - Next Mailbox</emphasis> 795 + +bind index,pager \CO sidebar-open <emphasis role="comment"># Ctrl-Shift-O - Open Highlighted Mailbox</emphasis> 796 + +</screen> 797 + + <para> 798 + + Press <quote>Ctrl-Shift-N</quote> (Next mailbox) twice will 799 + + move the Sidebar <emphasis role="bold">highlight</emphasis> to 800 + + down to the <quote>Seas</quote> mailbox. 801 + + </para> 802 + +<screen> 803 + +Fruit [1] 3/8| 1 Jan 03 Tia Gibson (362) Caiman 804 + +<emphasis role="indicator">Animals [1] 2/6</emphasis>| 2 + Jan 22 Rhys Lee ( 48) Dolphin 805 + +Cars 4| 3 ! Aug 16 Ewan Brown (333) Hummingbird 806 + +<emphasis role="highlight">Seas 1/7</emphasis>| 4 Sep 25 Grace Hall ( 27) Capybara 807 + + |<emphasis role="indicator"> 5 N + Nov 12 Evelyn Rogers (453) Tapir </emphasis> 808 + + | 6 N + Nov 16 Callum Harrison (498) Hedgehog 809 + + | 810 + + | 811 + + | 812 + + | 813 + +</screen> 814 + + <note> 815 + + Functions <literal>&lt;sidebar-next&gt;</literal> and 816 + + <literal>&lt;sidebar-prev&gt;</literal> move the Sidebar 817 + + <emphasis role="bold">highlight</emphasis>. 818 + + They <emphasis role="bold">do not</emphasis> change the open 819 + + mailbox. 820 + + </note> 821 + + <para> 822 + + Press <quote>Ctrl-Shift-O</quote> 823 + + (<literal>&lt;sidebar-open&gt;</literal>) 824 + + to open the highlighted mailbox. 825 + + </para> 826 + +<screen> 827 + +Fruit [1] 3/8| 1 ! Mar 07 Finley Jones (139) Molucca Sea 828 + +Animals [1] 2/6| 2 + Mar 24 Summer Jackson ( 25) Arafura Sea 829 + +Cars 4| 3 + Feb 28 Imogen Baker (193) Pechora Sea 830 + +<emphasis role="indicator">Seas 1/7</emphasis>|<emphasis role="indicator"> 4 N + Feb 23 Isla Hussain (348) Balearic Sea </emphasis> 831 + + | 832 + + | 833 + + | 834 + + | 835 + + | 836 + + | 837 + +</screen> 838 + + </sect3> 839 + + <sect3 id="intro-sidebar-features"> 840 + + <title>Features</title> 841 + + <para> 842 + + The Sidebar shows a list of mailboxes in a panel. 843 + + <para> 844 + + </para> 845 + + Everything about the Sidebar can be configured. 846 + + </para> 847 + + <itemizedlist> 848 + + <title><link linkend="intro-sidebar-basics">State of the Sidebar</link></title> 849 + + <listitem><para>Visibility</para></listitem> 850 + + <listitem><para>Width</para></listitem> 851 + + </itemizedlist> 852 + + <itemizedlist> 853 + + <title><link linkend="intro-sidebar-limit">Which mailboxes are displayed</link></title> 854 + + <listitem><para>Display all</para></listitem> 855 + + <listitem><para>Limit to mailboxes with new mail</para></listitem> 856 + + <listitem><para>Whitelist mailboxes to display always</para></listitem> 857 + + </itemizedlist> 858 + + <itemizedlist> 859 + + <title><link linkend="sidebar-sort">The order in which mailboxes are displayed</link></title> 860 + + <title></title> 861 + + <listitem><para>Unsorted (order of mailboxes commands)</para></listitem> 862 + + <listitem><para>Sorted alphabetically</para></listitem> 863 + + <listitem><para>Sorted by number of new mails</para></listitem> 864 + + </itemizedlist> 865 + + <itemizedlist> 866 + + <title><link linkend="intro-sidebar-colors">Color</link></title> 867 + + <listitem><para>Sidebar indicators and divider</para></listitem> 868 + + <listitem><para>Mailboxes depending on their type</para></listitem> 869 + + <listitem><para>Mailboxes depending on their contents</para></listitem> 870 + + </itemizedlist> 871 + + <itemizedlist> 872 + + <title><link linkend="sidebar-functions">Key bindings</link></title> 873 + + <listitem><para>Hide/Unhide the Sidebar</para></listitem> 874 + + <listitem><para>Select previous/next mailbox</para></listitem> 875 + + <listitem><para>Select previous/next mailbox with new mail</para></listitem> 876 + + <listitem><para>Page up/down through a list of mailboxes</para></listitem> 877 + + </itemizedlist> 878 + + <itemizedlist> 879 + + <title>Misc</title> 880 + + <listitem><para><link linkend="intro-sidebar-format">Formatting string for mailbox</link></para></listitem> 881 + + <listitem><para><link linkend="sidebar-next-new-wrap">Wraparound searching</link></para></listitem> 882 + + <listitem><para><link linkend="intro-sidebar-abbrev">Flexible mailbox abbreviations</link></para></listitem> 883 + + <listitem><para>Support for Unicode mailbox names (utf-8)</para></listitem> 884 + + </itemizedlist> 885 + + </sect3> 886 + + <sect3 id="intro-sidebar-display"> 887 + + <title>Display</title> 888 + + <para> 889 + + Everything about the Sidebar can be configured. 890 + + </para> 891 + + <itemizedlist> 892 + + <title>For a quick reference:</title> 893 + + <listitem><para><link linkend="sidebar-variables">Sidebar variables to set</link> </para></listitem> 894 + + <listitem><para><link linkend="sidebar-colors">Sidebar colors to apply</link></para></listitem> 895 + + <listitem><para><link linkend="sidebar-sort">Sidebar sort methods</link></para></listitem> 896 + + </itemizedlist> 897 + + <sect4 id="intro-sidebar-basics"> 898 + + <title>Sidebar Basics</title> 899 + + <para> 900 + + The most important variable is <literal>$sidebar_visible</literal>. 901 + + You can set this in your <quote>muttrc</quote>, or bind a key to the 902 + + function <literal>&lt;sidebar-toggle-visible&gt;</literal>. 903 + + </para> 904 + +<screen> 905 + +set sidebar_visible <emphasis role="comment"># Make the Sidebar visible by default</emphasis> 906 + +bind index,pager B sidebar-toggle-visible <emphasis role="comment"># Use 'B' to switch the Sidebar on and off</emphasis> 907 + +</screen> 908 + + <para> 909 + + Next, decide how wide you want the Sidebar to be. 25 910 + + characters might be enough for the mailbox name and some numbers. 911 + + Remember, you can hide/show the Sidebar at the press of button. 912 + + </para> 913 + + <para> 914 + + Finally, you might want to change the divider character. 915 + + By default, Sidebar draws an ASCII line between it and the Index panel 916 + + If your terminal supports it, you can use a Unicode line-drawing character. 917 + + </para> 918 + +<screen> 919 + +set sidebar_width = 25 <emphasis role="comment"># Plenty of space</emphasis> 920 + +set sidebar_divider_char = '│' <emphasis role="comment"># Pretty line-drawing character</emphasis> 921 + +</screen> 922 + + </sect4> 923 + + <sect4 id="intro-sidebar-format"> 924 + + <title>Sidebar Format String</title> 925 + + <para> 926 + + <literal>$sidebar_format</literal> allows you to customize the Sidebar display. 927 + + For an introduction, read <link linkend="index-format">format strings</link> 928 + + including the section about <link linkend="formatstrings-conditionals">conditionals</link>. 929 + + </para> 930 + + <para> 931 + + The default value is <literal>%B%?F? [%F]?%* %?N?%N/?%S</literal> 932 + + </para> 933 + + <itemizedlist> 934 + + <title>Which breaks down as:</title> 935 + + <listitem><para><literal>%B</literal> - Mailbox name</para></listitem> 936 + + <listitem><para><literal>%?F? [%F]?</literal> - If flagged emails <literal>[%F]</literal>, otherwise nothing</para></listitem> 937 + + <listitem><para><literal>%* </literal> - Pad with spaces</para></listitem> 938 + + <listitem><para><literal>%?N?%N/?</literal> - If new emails <literal>%N/</literal>, otherwise nothing</para></listitem> 939 + + <listitem><para><literal>%S</literal> - Total number of emails</para></listitem> 940 + + </itemizedlist> 941 + + <table> 942 + + <title>sidebar_format</title> 943 + + <tgroup cols="3"> 944 + + <thead> 945 + + <row> 946 + + <entry>Format</entry> 947 + + <entry>Notes</entry> 948 + + <entry>Description</entry> 949 + + </row> 950 + + </thead> 951 + + <tbody> 952 + + <row> 953 + + <entry>%B</entry> 954 + + <entry></entry> 955 + + <entry>Name of the mailbox</entry> 956 + + </row> 957 + + <row> 958 + + <entry>%S</entry> 959 + + <entry>*</entry> 960 + + <entry>Size of mailbox (total number of messages)</entry> 961 + + </row> 962 + + <row> 963 + + <entry>%N</entry> 964 + + <entry>*</entry> 965 + + <entry>Number of New messages in the mailbox</entry> 966 + + </row> 967 + + <row> 968 + + <entry>%F</entry> 969 + + <entry>*</entry> 970 + + <entry>Number of Flagged messages in the mailbox</entry> 971 + + </row> 972 + + <row> 973 + + <entry>%!</entry> 974 + + <entry></entry> 975 + + <entry> 976 + + <quote>!</quote>: one flagged message; 977 + + <quote>!!</quote>: two flagged messages; 978 + + <quote>n!</quote>: n flagged messages (for n &gt; 2). 979 + + Otherwise prints nothing. 980 + + </entry> 981 + + </row> 982 + + <row> 983 + + <entry>%d</entry> 984 + + <entry>* ‡</entry> 985 + + <entry>Number of deleted messages</entry> 986 + + </row> 987 + + <row> 988 + + <entry>%L</entry> 989 + + <entry>* ‡</entry> 990 + + <entry>Number of messages after limiting</entry> 991 + + </row> 992 + + <row> 993 + + <entry>%t</entry> 994 + + <entry>* ‡</entry> 995 + + <entry>Number of tagged messages</entry> 996 + + </row> 997 + + <row> 998 + + <entry>%&gt;X</entry> 999 + + <entry></entry> 1000 + + <entry>Right justify the rest of the string and pad with <quote>X</quote></entry> 1001 + + </row> 1002 + + <row> 1003 + + <entry>%|X</entry> 1004 + + <entry></entry> 1005 + + <entry>Pad to the end of the line with 1006 + + <quote>X</quote></entry> 1007 + + </row> 1008 + + <row> 1009 + + <entry>%*X</entry> 1010 + + <entry></entry> 1011 + + <entry>Soft-fill with character <quote>X</quote>as pad</entry> 1012 + + </row> 1013 + + </tbody> 1014 + + </tgroup> 1015 + + </table> 1016 + + <para> 1017 + + * = Can be optionally printed if nonzero 1018 + + </para> 1019 + + <para> 1020 + + ‡ = Only applicable to the current folder 1021 + + </para> 1022 + + <para> 1023 + + Here are some examples. 1024 + + They show the number of (F)lagged, (N)ew and (S)ize. 1025 + + </para> 1026 + + <table> 1027 + + <title>sidebar_format</title> 1028 + + <tgroup cols="2"> 1029 + + <thead> 1030 + + <row> 1031 + + <entry>Format</entry> 1032 + + <entry>Example</entry> 1033 + + </row> 1034 + + </thead> 1035 + + <tbody> 1036 + + <row> 1037 + + <entry><literal>%B%?F? [%F]?%* %?N?%N/?%S</literal></entry> 1038 + + <entry><screen>mailbox [F] N/S</screen></entry> 1039 + + </row> 1040 + + <row> 1041 + + <entry><literal>%B%* %F:%N:%S</literal></entry> 1042 + + <entry><screen>mailbox F:N:S</screen></entry> 1043 + + </row> 1044 + + <row> 1045 + + <entry><literal>%B %?N?(%N)?%* %S</literal></entry> 1046 + + <entry><screen>mailbox (N) S</screen></entry> 1047 + + </row> 1048 + + <row> 1049 + + <entry><literal>%B%* ?F?%F/?%N</literal></entry> 1050 + + <entry><screen>mailbox F/S</screen></entry> 1051 + + </row> 1052 + + </tbody> 1053 + + </tgroup> 1054 + + </table> 1055 + + </sect4> 1056 + + <sect4 id="intro-sidebar-abbrev"> 1057 + + <title>Abbreviating Mailbox Names</title> 1058 + + <para> 1059 + + <literal>$sidebar_delim_chars</literal> tells Sidebar 1060 + + how to split up mailbox paths. For local directories 1061 + + use <quote>/</quote>; for IMAP folders use <quote>.</quote> 1062 + + </para> 1063 + + <sect5 id="intro-sidebar-abbrev-ex1"> 1064 + + <title>Example 1</title> 1065 + + <para> 1066 + + This example works well if your mailboxes have unique names 1067 + + after the last separator. 1068 + + </para> 1069 + + <para> 1070 + + Add some mailboxes of diffent depths. 1071 + + </para> 1072 + +<screen> 1073 + +set folder="~/mail" 1074 + +mailboxes =fruit/apple =fruit/banana =fruit/cherry 1075 + +mailboxes =water/sea/sicily =water/sea/archipelago =water/sea/sibuyan 1076 + +mailboxes =water/ocean/atlantic =water/ocean/pacific =water/ocean/arctic 1077 + +</screen> 1078 + + <para> 1079 + + Shorten the names: 1080 + + </para> 1081 + +<screen> 1082 + +set sidebar_short_path <emphasis role="comment"># Shorten mailbox names</emphasis> 1083 + +set sidebar_delim_chars="/" <emphasis role="comment"># Delete everything up to the last / character</emphasis> 1084 + +</screen> 1085 + + <para> 1086 + + The screenshot below shows what the Sidebar would look like 1087 + + before and after shortening. 1088 + + </para> 1089 + +<screen> 1090 + +|fruit/apple |apple 1091 + +|fruit/banana |banana 1092 + +|fruit/cherry |cherry 1093 + +|water/sea/sicily |sicily 1094 + +|water/sea/archipelago |archipelago 1095 + +|water/sea/sibuyan |sibuyan 1096 + +|water/ocean/atlantic |atlantic 1097 + +|water/ocean/pacific |pacific 1098 + +|water/ocean/arctic |arctic 1099 + +</screen> 1100 + + </sect5> 1101 + + <sect5 id="intro-sidebar-abbrev-ex2"> 1102 + + <title>Example 2</title> 1103 + + <para> 1104 + + This example works well if you have lots of mailboxes which are arranged 1105 + + in a tree. 1106 + + </para> 1107 + + <para> 1108 + + Add some mailboxes of diffent depths. 1109 + + </para> 1110 + +<screen> 1111 + +set folder="~/mail" 1112 + +mailboxes =fruit 1113 + +mailboxes =fruit/apple =fruit/banana =fruit/cherry 1114 + +mailboxes =water 1115 + +mailboxes =water/sea 1116 + +mailboxes =water/sea/sicily =water/sea/archipelago =water/sea/sibuyan 1117 + +mailboxes =water/ocean 1118 + +mailboxes =water/ocean/atlantic =water/ocean/pacific =water/ocean/arctic 1119 + +</screen> 1120 + + <para> 1121 + + Shorten the names: 1122 + + </para> 1123 + +<screen> 1124 + +set sidebar_short_path <emphasis role="comment"># Shorten mailbox names</emphasis> 1125 + +set sidebar_delim_chars="/" <emphasis role="comment"># Delete everything up to the last / character</emphasis> 1126 + +set sidebar_folder_indent <emphasis role="comment"># Indent folders whose names we've shortened</emphasis> 1127 + +set sidebar_indent_string=" " <emphasis role="comment"># Indent with two spaces</emphasis> 1128 + +</screen> 1129 + + <para> 1130 + + The screenshot below shows what the Sidebar would look like 1131 + + before and after shortening. 1132 + + </para> 1133 + +<screen> 1134 + +|fruit |fruit 1135 + +|fruit/apple | apple 1136 + +|fruit/banana | banana 1137 + +|fruit/cherry | cherry 1138 + +|water |water 1139 + +|water/sea | sea 1140 + +|water/sea/sicily | sicily 1141 + +|water/sea/archipelago | archipelago 1142 + +|water/sea/sibuyan | sibuyan 1143 + +|water/ocean | ocean 1144 + +|water/ocean/atlantic | atlantic 1145 + +|water/ocean/pacific | pacific 1146 + +|water/ocean/arctic | arctic 1147 + +</screen> 1148 + + <para> 1149 + + Sometimes, it will be necessary to add mailboxes, that you 1150 + + don't use, to fill in part of the tree. This will trade 1151 + + vertical space for horizonal space (but it looks good). 1152 + + </para> 1153 + + </sect5> 1154 + + </sect4> 1155 + + <sect4 id="intro-sidebar-limit"> 1156 + + <title>Limiting the Number of Mailboxes</title> 1157 + + <para> 1158 + + If you have a lot of mailboxes, sometimes it can be useful to hide 1159 + + the ones you aren't using. <literal>$sidebar_new_mail_only</literal> 1160 + + tells Sidebar to only show mailboxes that contain new, or flagged, email. 1161 + + </para> 1162 + + <para> 1163 + + If you want some mailboxes to be always visible, then use the 1164 + + <literal>sidebar_whitelist</literal> command. It takes a list of 1165 + + mailboxes as parameters. 1166 + + </para> 1167 + +<screen> 1168 + +set sidebar_new_mail_only <emphasis role="comment"># Only mailboxes with new/flagged email</emphasis> 1169 + +sidebar_whitelist fruit fruit/apple <emphasis role="comment"># Always display these two mailboxes</emphasis> 1170 + +</screen> 1171 + + </sect4> 1172 + + </sect3> 1173 + + <sect3 id="intro-sidebar-colors"> 1174 + + <title>Colors</title> 1175 + + <para> 1176 + + Here is a sample color scheme: 1177 + + </para> 1178 + +<screen> 1179 + +color sidebar_indicator default color17 <emphasis role="comment"># Dark blue background</emphasis> 1180 + +color sidebar_highlight white color238 <emphasis role="comment"># Grey background</emphasis> 1181 + +color sidebar_spoolfile yellow default <emphasis role="comment"># Yellow</emphasis> 1182 + +color sidebar_new green default <emphasis role="comment"># Green</emphasis> 1183 + +color sidebar_flagged red default <emphasis role="comment"># Red</emphasis> 1184 + +color sidebar_divider color8 default <emphasis role="comment"># Dark grey</emphasis> 1185 + +</screen> 1186 + + <para> 1187 + + There is a priority order when coloring Sidebar mailboxes. 1188 + + e.g. If a mailbox has new mail it will have the 1189 + + <literal>sidebar_new</literal> color, even if it also contains 1190 + + flagged mails. 1191 + + </para> 1192 + + <table id="table-intro-sidebar-colors"> 1193 + + <title>Sidebar Color Priority</title> 1194 + + <tgroup cols="3"> 1195 + + <thead> 1196 + + <row> 1197 + + <entry>Priority</entry> 1198 + + <entry>Color</entry> 1199 + + <entry>Description</entry> 1200 + + </row> 1201 + + </thead> 1202 + + <tbody> 1203 + + <row> 1204 + + <entry>Highest</entry> 1205 + + <entry><literal>sidebar_indicator</literal></entry> 1206 + + <entry>Mailbox is open</entry> 1207 + + </row> 1208 + + <row> 1209 + + <entry></entry> 1210 + + <entry><literal>sidebar_highlight</literal></entry> 1211 + + <entry>Mailbox is highlighed</entry> 1212 + + </row> 1213 + + <row> 1214 + + <entry></entry> 1215 + + <entry><literal>sidebar_spoolfile</literal></entry> 1216 + + <entry>Mailbox is the spoolfile (receives incoming mail)</entry> 1217 + + </row> 1218 + + <row> 1219 + + <entry></entry> 1220 + + <entry><literal>sidebar_new</literal></entry> 1221 + + <entry>Mailbox contains new mail</entry> 1222 + + </row> 1223 + + <row> 1224 + + <entry></entry> 1225 + + <entry><literal>sidebar_flagged</literal></entry> 1226 + + <entry>Mailbox contains flagged mail</entry> 1227 + + </row> 1228 + + <row> 1229 + + <entry>Lowest</entry> 1230 + + <entry>(None)</entry> 1231 + + <entry>Mailbox does not match above</entry> 1232 + + </row> 1233 + + </tbody> 1234 + + </tgroup> 1235 + + </table> 1236 + + </sect3> 1237 + + <sect3 id="intro-sidebar-bugfixes"> 1238 + + <title>Bug-fixes</title> 1239 + + <para> 1240 + + If you haven't used Sidebar before, you can ignore this section. 1241 + + </para> 1242 + + <para> 1243 + + These bugs have been fixed since the previous Sidebar release: 2015-11-11. 1244 + + </para> 1245 + + <itemizedlist> 1246 + + <listitem><para>Fix bug when starting in compose mode</para></listitem> 1247 + + <listitem><para>Fix bug with empty sidebar_divider_char string</para></listitem> 1248 + + <listitem><para>Fix bug with header wrapping</para></listitem> 1249 + + <listitem><para>Correctly handle utf8 character sequences</para></listitem> 1250 + + <listitem><para>Fix a bug in mh_buffy_update</para></listitem> 1251 + + <listitem><para>Fix refresh -- time overflowed short</para></listitem> 1252 + + <listitem><para>Protect against empty format strings</para></listitem> 1253 + + <listitem><para>Limit Sidebar width to COLS</para></listitem> 1254 + + <listitem><para>Handle unmailboxes * safely</para></listitem> 1255 + + <listitem><para>Refresh Sidebar after timeout</para></listitem> 1256 + + </itemizedlist> 1257 + + </sect3> 1258 + + <sect3 id="intro-sidebar-config-changes"> 1259 + + <title>Config Changes</title> 1260 + + <para> 1261 + + If you haven't used Sidebar before, you can ignore this section. 1262 + + </para> 1263 + + <para> 1264 + + Some of the Sidebar config has been changed to make its meaning clearer. 1265 + + These changes have been made since the previous Sidebar release: 2015-11-11. 1266 + + </para> 1267 + + <table id="table-intro-sidebar-config-changes"> 1268 + + <title>Config Changes</title> 1269 + + <tgroup cols="2"> 1270 + + <thead> 1271 + + <row> 1272 + + <entry>Old Name</entry> 1273 + + <entry>New Name</entry> 1274 + + </row> 1275 + + </thead> 1276 + + <tbody> 1277 + + <row> 1278 + + <entry><literal>$sidebar_delim</literal></entry> 1279 + + <entry><literal>$sidebar_divider_char</literal></entry> 1280 + + </row> 1281 + + <row> 1282 + + <entry><literal>$sidebar_folderindent</literal></entry> 1283 + + <entry><literal>$sidebar_folder_indent</literal></entry> 1284 + + </row> 1285 + + <row> 1286 + + <entry><literal>$sidebar_indentstr</literal></entry> 1287 + + <entry><literal>$sidebar_indent_string</literal></entry> 1288 + + </row> 1289 + + <row> 1290 + + <entry><literal>$sidebar_newmail_only</literal></entry> 1291 + + <entry><literal>$sidebar_new_mail_only</literal></entry> 1292 + + </row> 1293 + + <row> 1294 + + <entry><literal>$sidebar_refresh</literal></entry> 1295 + + <entry><literal>$sidebar_refresh_time</literal></entry> 1296 + + </row> 1297 + + <row> 1298 + + <entry><literal>$sidebar_shortpath</literal></entry> 1299 + + <entry><literal>$sidebar_short_path</literal></entry> 1300 + + </row> 1301 + + <row> 1302 + + <entry><literal>$sidebar_sort</literal></entry> 1303 + + <entry><literal>$sidebar_sort_method</literal></entry> 1304 + + </row> 1305 + + <row> 1306 + + <entry><literal>&lt;sidebar-scroll-down&gt;</literal></entry> 1307 + + <entry><literal>&lt;sidebar-page-down&gt;</literal></entry> 1308 + + </row> 1309 + + <row> 1310 + + <entry><literal>&lt;sidebar-scroll-up&gt;</literal></entry> 1311 + + <entry><literal>&lt;sidebar-page-up&gt;</literal></entry> 1312 + + </row> 1313 + + </tbody> 1314 + + </tgroup> 1315 + + </table> 1316 + + </sect3> 1317 + +</sect2> 1318 + + 1319 + <sect2 id="intro-help"> 1320 + <title>Help</title> 1321 + 1322 + @@ -6773,6 +7390,17 @@ 1323 + </para> 1324 + 1325 + <para> 1326 + +Mutt will set the <literal>COLUMNS</literal> environment variable to 1327 + +the width of the pager. Some programs make use of this environment 1328 + +variable automatically. Others provide a command line argument that 1329 + +can use this to set the output width: 1330 + +</para> 1331 + + 1332 + +<screen> 1333 + +text/html; lynx -dump -width ${COLUMNS:-80} %s; copiousoutput 1334 + +</screen> 1335 + + 1336 + +<para> 1337 + Note that when using the built-in pager, <emphasis>only</emphasis> 1338 + entries with this flag will be considered a handler for a MIME type 1339 + &mdash; all other entries will be ignored. 1340 + @@ -7467,6 +8095,16 @@ 1341 + 1342 + </sect2> 1343 + 1344 + +<sect2 id="mutt-patches"> 1345 + +<title>Mutt Patches</title> 1346 + +<para> 1347 + +Mutt may also be <quote>patched</quote> to support smaller features. 1348 + +These patches should add a free-form string to the end Mutt's version string. 1349 + +Running <literal>mutt -v</literal> might show: 1350 + +<screen>patch-1.6.1.sidebar.20160502</screen> 1351 + +</para> 1352 + +</sect2> 1353 + + 1354 + <sect2 id="url-syntax"> 1355 + <title>URL Syntax</title> 1356 + 1357 + @@ -8081,6 +8719,469 @@ 1358 + 1359 + </sect1> 1360 + 1361 + +<sect1 id="sidebar"> 1362 + + <title>Sidebar Patch</title> 1363 + + <subtitle>Overview of mailboxes</subtitle> 1364 + + 1365 + + <sect2 id="sidebar-patch"> 1366 + + <title>Patch</title> 1367 + + 1368 + + <para> 1369 + + To check if Mutt supports <quote>Sidebar</quote>, look for 1370 + + <quote>+USE_SIDEBAR</quote> in the mutt version. 1371 + + See: <xref linkend="compile-time-features"/>. 1372 + + </para> 1373 + + 1374 + + <itemizedlist> 1375 + + <title>Dependencies:</title> 1376 + + <listitem><para>mutt-1.6.1</para></listitem> 1377 + + </itemizedlist> 1378 + + 1379 + + <para>This patch is part of the <ulink url="http://www.neomutt.org/">NeoMutt Project</ulink>.</para> 1380 + + </sect2> 1381 + + 1382 + + <sect2 id="sidebar-intro"> 1383 + + <title>Introduction</title> 1384 + + 1385 + + <para> 1386 + + The Sidebar shows a list of all your mailboxes. The list can be 1387 + + turned on and off, it can be themed and the list style can be 1388 + + configured. 1389 + + </para> 1390 + + 1391 + + <para> 1392 + + This part of the manual is a reference guide. 1393 + + If you want a simple introduction with examples see the 1394 + + <link linkend="intro-sidebar">Sidebar Howto</link>. 1395 + + If you just want to get started, you could use the sample 1396 + + <link linkend="sidebar-muttrc">Sidebar muttrc</link>. 1397 + + </para> 1398 + + 1399 + + <para> 1400 + + This version of Sidebar is based on Terry Chan's 1401 + + <ulink url="http://www.lunar-linux.org/mutt-sidebar/">2015-11-11 release</ulink>. 1402 + + It contains many 1403 + + <emphasis role="bold"><link linkend="intro-sidebar-features">new features</link></emphasis>, 1404 + + lots of 1405 + + <emphasis role="bold"><link linkend="intro-sidebar-bugfixes">bugfixes</link></emphasis>. 1406 + + </para> 1407 + + </sect2> 1408 + + 1409 + + <sect2 id="sidebar-variables"> 1410 + + <title>Variables</title> 1411 + + 1412 + + <table id="table-sidebar-variables"> 1413 + + <title>Sidebar Variables</title> 1414 + + <tgroup cols="3"> 1415 + + <thead> 1416 + + <row> 1417 + + <entry>Name</entry> 1418 + + <entry>Type</entry> 1419 + + <entry>Default</entry> 1420 + + </row> 1421 + + </thead> 1422 + + <tbody> 1423 + + <row> 1424 + + <entry><literal>sidebar_delim_chars</literal></entry> 1425 + + <entry>string</entry> 1426 + + <entry><literal>/.</literal></entry> 1427 + + </row> 1428 + + <row> 1429 + + <entry><literal>sidebar_divider_char</literal></entry> 1430 + + <entry>string</entry> 1431 + + <entry><literal>|</literal></entry> 1432 + + </row> 1433 + + <row> 1434 + + <entry><literal>sidebar_folder_indent</literal></entry> 1435 + + <entry>boolean</entry> 1436 + + <entry><literal>no</literal></entry> 1437 + + </row> 1438 + + <row> 1439 + + <entry><literal>sidebar_format</literal></entry> 1440 + + <entry>string</entry> 1441 + + <entry><literal>%B%?F? [%F]?%* %?N?%N/?%S</literal></entry> 1442 + + </row> 1443 + + <row> 1444 + + <entry><literal>sidebar_indent_string</literal></entry> 1445 + + <entry>string</entry> 1446 + + <entry><literal>&nbsp;&nbsp;</literal> (two spaces)</entry> 1447 + + </row> 1448 + + <row> 1449 + + <entry><literal>sidebar_new_mail_only</literal></entry> 1450 + + <entry>boolean</entry> 1451 + + <entry><literal>no</literal></entry> 1452 + + </row> 1453 + + <row> 1454 + + <entry><literal>sidebar_next_new_wrap</literal></entry> 1455 + + <entry>boolean</entry> 1456 + + <entry><literal>no</literal></entry> 1457 + + </row> 1458 + + <row> 1459 + + <entry><literal>sidebar_refresh_time</literal></entry> 1460 + + <entry>number</entry> 1461 + + <entry><literal>60</literal></entry> 1462 + + </row> 1463 + + <row> 1464 + + <entry><literal>sidebar_short_path</literal></entry> 1465 + + <entry>boolean</entry> 1466 + + <entry><literal>no</literal></entry> 1467 + + </row> 1468 + + <row> 1469 + + <entry><literal>sidebar_sort_method</literal></entry> 1470 + + <entry>enum</entry> 1471 + + <entry><literal>SORT_ORDER</literal></entry> 1472 + + </row> 1473 + + <row> 1474 + + <entry><literal>sidebar_visible</literal></entry> 1475 + + <entry>boolean</entry> 1476 + + <entry><literal>no</literal></entry> 1477 + + </row> 1478 + + <row> 1479 + + <entry><literal>sidebar_whitelist</literal></entry> 1480 + + <entry>list</entry> 1481 + + <entry>(empty)</entry> 1482 + + </row> 1483 + + <row> 1484 + + <entry><literal>sidebar_width</literal></entry> 1485 + + <entry>number</entry> 1486 + + <entry><literal>20</literal></entry> 1487 + + </row> 1488 + + </tbody> 1489 + + </tgroup> 1490 + + </table> 1491 + + </sect2> 1492 + + 1493 + + <sect2 id="sidebar-functions"> 1494 + + <title>Functions</title> 1495 + + 1496 + + <para> 1497 + + Sidebar adds the following functions to Mutt. 1498 + + By default, none of them are bound to keys. 1499 + + </para> 1500 + + 1501 + + <table id="table-sidebar-functions"> 1502 + + <title>Sidebar Functions</title> 1503 + + <tgroup cols="3"> 1504 + + <thead> 1505 + + <row> 1506 + + <entry>Menus</entry> 1507 + + <entry>Function</entry> 1508 + + <entry>Description</entry> 1509 + + </row> 1510 + + </thead> 1511 + + <tbody> 1512 + + <row> 1513 + + <entry>index,pager</entry> 1514 + + <entry><literal>&lt;sidebar-next&gt;</literal></entry> 1515 + + <entry>Move the highlight to next mailbox</entry> 1516 + + </row> 1517 + + <row> 1518 + + <entry>index,pager</entry> 1519 + + <entry><literal>&lt;sidebar-next-new&gt;</literal></entry> 1520 + + <entry>Move the highlight to next mailbox with new mail</entry> 1521 + + </row> 1522 + + <row> 1523 + + <entry>index,pager</entry> 1524 + + <entry><literal>&lt;sidebar-open&gt;</literal></entry> 1525 + + <entry>Open highlighted mailbox</entry> 1526 + + </row> 1527 + + <row> 1528 + + <entry>index,pager</entry> 1529 + + <entry><literal>&lt;sidebar-page-down&gt;</literal></entry> 1530 + + <entry>Scroll the Sidebar down 1 page</entry> 1531 + + </row> 1532 + + <row> 1533 + + <entry>index,pager</entry> 1534 + + <entry><literal>&lt;sidebar-page-up&gt;</literal></entry> 1535 + + <entry>Scroll the Sidebar up 1 page</entry> 1536 + + </row> 1537 + + <row> 1538 + + <entry>index,pager</entry> 1539 + + <entry><literal>&lt;sidebar-prev&gt;</literal></entry> 1540 + + <entry>Move the highlight to previous mailbox</entry> 1541 + + </row> 1542 + + <row> 1543 + + <entry>index,pager</entry> 1544 + + <entry><literal>&lt;sidebar-prev-new&gt;</literal></entry> 1545 + + <entry>Move the highlight to previous mailbox with new mail</entry> 1546 + + </row> 1547 + + <row> 1548 + + <entry>index,pager</entry> 1549 + + <entry><literal>&lt;sidebar-toggle-visible&gt;</literal></entry> 1550 + + <entry>Make the Sidebar (in)visible</entry> 1551 + + </row> 1552 + + </tbody> 1553 + + </tgroup> 1554 + + </table> 1555 + + </sect2> 1556 + + 1557 + + <sect2 id="sidebar-commands"> 1558 + + <title>Commands</title> 1559 + + <cmdsynopsis> 1560 + + <command>sidebar_whitelist</command> 1561 + + <arg choice="plain"> 1562 + + <replaceable class="parameter">mailbox</replaceable> 1563 + + </arg> 1564 + + <arg choice="opt" rep="repeat"> 1565 + + <replaceable class="parameter">mailbox</replaceable> 1566 + + </arg> 1567 + + </cmdsynopsis> 1568 + + </sect2> 1569 + + 1570 + + <sect2 id="sidebar-colors"> 1571 + + <title>Colors</title> 1572 + + 1573 + + <table id="table-sidebar-colors"> 1574 + + <title>Sidebar Colors</title> 1575 + + <tgroup cols="3"> 1576 + + <thead> 1577 + + <row> 1578 + + <entry>Name</entry> 1579 + + <entry>Default Color</entry> 1580 + + <entry>Description</entry> 1581 + + </row> 1582 + + </thead> 1583 + + <tbody> 1584 + + <row> 1585 + + <entry><literal>sidebar_divider</literal></entry> 1586 + + <entry>default</entry> 1587 + + <entry>The dividing line between the Sidebar and the Index/Pager panels</entry> 1588 + + </row> 1589 + + <row> 1590 + + <entry><literal>sidebar_flagged</literal></entry> 1591 + + <entry>default</entry> 1592 + + <entry>Mailboxes containing flagged mail</entry> 1593 + + </row> 1594 + + <row> 1595 + + <entry><literal>sidebar_highlight</literal></entry> 1596 + + <entry>underline</entry> 1597 + + <entry>Cursor to select a mailbox</entry> 1598 + + </row> 1599 + + <row> 1600 + + <entry><literal>sidebar_indicator</literal></entry> 1601 + + <entry>mutt <literal>indicator</literal></entry> 1602 + + <entry>The mailbox open in the Index panel</entry> 1603 + + </row> 1604 + + <row> 1605 + + <entry><literal>sidebar_new</literal></entry> 1606 + + <entry>default</entry> 1607 + + <entry>Mailboxes containing new mail</entry> 1608 + + </row> 1609 + + <row> 1610 + + <entry><literal>sidebar_spoolfile</literal></entry> 1611 + + <entry>default</entry> 1612 + + <entry>Mailbox that receives incoming mail</entry> 1613 + + </row> 1614 + + </tbody> 1615 + + </tgroup> 1616 + + </table> 1617 + + 1618 + + If the <literal>sidebar_indicator</literal> color isn't set, then the default Mutt 1619 + + indicator color will be used (the color used in the index panel). 1620 + + </sect2> 1621 + + 1622 + + <sect2 id="sidebar-sort"> 1623 + + <title>Sort</title> 1624 + + 1625 + + <table id="table-sidebar-sort"> 1626 + + <title>Sidebar Sort</title> 1627 + + <tgroup cols="2"> 1628 + + <thead> 1629 + + <row> 1630 + + <entry>Sort</entry> 1631 + + <entry>Description</entry> 1632 + + </row> 1633 + + </thead> 1634 + + <tbody> 1635 + + <row> 1636 + + <entry><literal>alpha</literal></entry> 1637 + + <entry>Alphabetically by path</entry> 1638 + + </row> 1639 + + <row> 1640 + + <entry><literal>count</literal></entry> 1641 + + <entry>Total number of messages</entry> 1642 + + </row> 1643 + + <row> 1644 + + <entry><literal>flagged</literal></entry> 1645 + + <entry>Number of flagged messages</entry> 1646 + + </row> 1647 + + <row> 1648 + + <entry><literal>name</literal></entry> 1649 + + <entry>Alphabetically by path</entry> 1650 + + </row> 1651 + + <row> 1652 + + <entry><literal>new</literal></entry> 1653 + + <entry>Number of new messages</entry> 1654 + + </row> 1655 + + <row> 1656 + + <entry><literal>path</literal></entry> 1657 + + <entry>Alphabetically by path</entry> 1658 + + </row> 1659 + + <row> 1660 + + <entry><literal>unsorted</literal></entry> 1661 + + <entry>Do not resort the paths</entry> 1662 + + </row> 1663 + + </tbody> 1664 + + </tgroup> 1665 + + </table> 1666 + + </sect2> 1667 + + 1668 + + <sect2 id="sidebar-muttrc"> 1669 + + <title>Muttrc</title> 1670 + +<screen> 1671 + +<emphasis role="comment"># This is a complete list of sidebar-related configuration. 1672 + + 1673 + +# -------------------------------------------------------------------------- 1674 + +# VARIABLES - shown with their default values 1675 + +# -------------------------------------------------------------------------- 1676 + + 1677 + +# Should the Sidebar be shown?</emphasis> 1678 + +set sidebar_visible = no 1679 + + 1680 + +<emphasis role="comment"># How wide should the Sidebar be in screen columns? 1681 + +# Note: Some characters, e.g. Chinese, take up two columns each.</emphasis> 1682 + +set sidebar_width = 20 1683 + + 1684 + +<emphasis role="comment"># Should the mailbox paths be abbreviated?</emphasis> 1685 + +set sidebar_short_path = no 1686 + + 1687 + +<emphasis role="comment"># When abbreviating mailbox path names, use any of these characters as path 1688 + +# separators. Only the part after the last separators will be shown. 1689 + +# For file folders '/' is good. For IMAP folders, often '.' is useful.</emphasis> 1690 + +set sidebar_delim_chars = '/.' 1691 + + 1692 + +<emphasis role="comment"># If the mailbox path is abbreviated, should it be indented?</emphasis> 1693 + +set sidebar_folder_indent = no 1694 + + 1695 + +<emphasis role="comment"># Indent mailbox paths with this string.</emphasis> 1696 + +set sidebar_indent_string = ' ' 1697 + + 1698 + +<emphasis role="comment"># Make the Sidebar only display mailboxes that contain new, or flagged, 1699 + +# mail.</emphasis> 1700 + +set sidebar_new_mail_only = no 1701 + + 1702 + +<emphasis role="comment"># Any mailboxes that are whitelisted will always be visible, even if the 1703 + +# sidebar_new_mail_only option is enabled.</emphasis> 1704 + +sidebar_whitelist '/home/user/mailbox1' 1705 + +sidebar_whitelist '/home/user/mailbox2' 1706 + + 1707 + +<emphasis role="comment"># When searching for mailboxes containing new mail, should the search wrap 1708 + +# around when it reaches the end of the list?</emphasis> 1709 + +set sidebar_next_new_wrap = no 1710 + + 1711 + +<emphasis role="comment"># The character to use as the divider between the Sidebar and the other Mutt 1712 + +# panels. 1713 + +# Note: Only the first character of this string is used.</emphasis> 1714 + +set sidebar_divider_char = '|' 1715 + + 1716 + +<emphasis role="comment"># Display the Sidebar mailboxes using this format string.</emphasis> 1717 + +set sidebar_format = '%B%?F? [%F]?%* %?N?%N/?%S' 1718 + + 1719 + +<emphasis role="comment"># Sidebar will not refresh its list of mailboxes any more frequently than 1720 + +# this number of seconds. This will help reduce disk/network traffic.</emphasis> 1721 + +set sidebar_refresh_time = 60 1722 + + 1723 + +<emphasis role="comment"># Sort the mailboxes in the Sidebar using this method: 1724 + +# count - total number of messages 1725 + +# flagged - number of flagged messages 1726 + +# new - number of new messages 1727 + +# path - mailbox path 1728 + +# unsorted - do not sort the mailboxes</emphasis> 1729 + +set sidebar_sort_method = 'unsorted' 1730 + + 1731 + +<emphasis role="comment"># -------------------------------------------------------------------------- 1732 + +# FUNCTIONS - shown with an example mapping 1733 + +# -------------------------------------------------------------------------- 1734 + + 1735 + +# Move the highlight to the previous mailbox</emphasis> 1736 + +bind index,pager \Cp sidebar-prev 1737 + + 1738 + +<emphasis role="comment"># Move the highlight to the next mailbox</emphasis> 1739 + +bind index,pager \Cn sidebar-next 1740 + + 1741 + +<emphasis role="comment"># Open the highlighted mailbox</emphasis> 1742 + +bind index,pager \Co sidebar-open 1743 + + 1744 + +<emphasis role="comment"># Move the highlight to the previous page 1745 + +# This is useful if you have a LOT of mailboxes.</emphasis> 1746 + +bind index,pager &lt;F3&gt; sidebar-page-up 1747 + + 1748 + +<emphasis role="comment"># Move the highlight to the next page 1749 + +# This is useful if you have a LOT of mailboxes.</emphasis> 1750 + +bind index,pager &lt;F4&gt; sidebar-page-down 1751 + + 1752 + +<emphasis role="comment"># Move the highlight to the previous mailbox containing new, or flagged, 1753 + +# mail.</emphasis> 1754 + +bind index,pager &lt;F5&gt; sidebar-prev-new 1755 + + 1756 + +<emphasis role="comment"># Move the highlight to the next mailbox containing new, or flagged, mail.</emphasis> 1757 + +bind index,pager &lt;F6&gt; sidebar-next-new 1758 + + 1759 + +<emphasis role="comment"># Toggle the visibility of the Sidebar.</emphasis> 1760 + +bind index,pager B sidebar-toggle-visible 1761 + + 1762 + +<emphasis role="comment"># -------------------------------------------------------------------------- 1763 + +# COLORS - some unpleasant examples are given 1764 + +# -------------------------------------------------------------------------- 1765 + +# Note: All color operations are of the form: 1766 + +# color OBJECT FOREGROUND BACKGROUND 1767 + + 1768 + +# Color of the current, open, mailbox 1769 + +# Note: This is a general Mutt option which colors all selected items.</emphasis> 1770 + +color indicator cyan black 1771 + + 1772 + +<emphasis role="comment"># Color of the highlighted, but not open, mailbox.</emphasis> 1773 + +color sidebar_highlight black color8 1774 + + 1775 + +<emphasis role="comment"># Color of the divider separating the Sidebar from Mutt panels</emphasis> 1776 + +color sidebar_divider color8 black 1777 + + 1778 + +<emphasis role="comment"># Color to give mailboxes containing flagged mail</emphasis> 1779 + +color sidebar_flagged red black 1780 + + 1781 + +<emphasis role="comment"># Color to give mailboxes containing new mail</emphasis> 1782 + +color sidebar_new green black 1783 + + 1784 + +<emphasis role="comment"># -------------------------------------------------------------------------- 1785 + + 1786 + +# vim: syntax=muttrc</emphasis> 1787 + +</screen> 1788 + + </sect2> 1789 + + 1790 + + <sect2 id="sidebar-see-also"> 1791 + + <title>See Also</title> 1792 + + 1793 + + <itemizedlist> 1794 + + <listitem><para><link linkend="regexp">Regular Expressions</link></para></listitem> 1795 + + <listitem><para><link linkend="patterns">Patterns</link></para></listitem> 1796 + + <listitem><para><link linkend="color">Color command</link></para></listitem> 1797 + + <listitem><para><link linkend="notmuch">notmuch patch</link></para></listitem> 1798 + + </itemizedlist> 1799 + + </sect2> 1800 + + 1801 + + <sect2 id="sidebar-known-bugs"> 1802 + + <title>Known Bugs</title> 1803 + + Unsorted isn't 1804 + + </sect2> 1805 + + 1806 + + <sect2 id="sidebar-credits"> 1807 + + <title>Credits</title> 1808 + + <itemizedlist> 1809 + + <listitem><para>Justin Hibbits <email>jrh29@po.cwru.edu</email></para></listitem> 1810 + + <listitem><para>Thomer M. Gil <email>mutt@thomer.com</email></para></listitem> 1811 + + <listitem><para>David Sterba <email>dsterba@suse.cz</email></para></listitem> 1812 + + <listitem><para>Evgeni Golov <email>evgeni@debian.org</email></para></listitem> 1813 + + <listitem><para>Fabian Groffen <email>grobian@gentoo.org</email></para></listitem> 1814 + + <listitem><para>Jason DeTiberus <email>jdetiber@redhat.com</email></para></listitem> 1815 + + <listitem><para>Stefan Assmann <email>sassmann@kpanic.de</email></para></listitem> 1816 + + <listitem><para>Steve Kemp <email>steve@steve.org.uk</email></para></listitem> 1817 + + <listitem><para>Terry Chan <email>tchan@lunar-linux.org</email></para></listitem> 1818 + + <listitem><para>Tyler Earnest <email>tylere@rne.st</email></para></listitem> 1819 + + <listitem><para>Richard Russon <email>rich@flatcap.org</email></para></listitem> 1820 + + </itemizedlist> 1821 + + </sect2> 1822 + +</sect1> 1823 + + 1824 + </chapter> 1825 + 1826 + <chapter id="security"> 1827 + @@ -9237,6 +10338,17 @@ 1828 + 1829 + <listitem> 1830 + <cmdsynopsis> 1831 + +<command><link linkend="sidebar-whitelist">sidebar_whitelist</link></command> 1832 + +<arg choice="plain"> 1833 + +<replaceable class="parameter">item</replaceable> 1834 + +</arg> 1835 + +<arg choice="plain"> 1836 + +<replaceable class="parameter">command</replaceable> 1837 + +</arg> 1838 + +</cmdsynopsis> 1839 + +</listitem> 1840 + +<listitem> 1841 + +<cmdsynopsis> 1842 + <command><link linkend="source">source</link></command> 1843 + <arg choice="plain"> 1844 + <replaceable class="parameter">filename</replaceable> 1845 + diff -urN mutt-1.6.1/doc/mutt.css mutt-1.6.1-sidebar/doc/mutt.css 1846 + --- mutt-1.6.1/doc/mutt.css 2016-06-12 18:43:00.402447590 +0100 1847 + +++ mutt-1.6.1-sidebar/doc/mutt.css 2016-06-12 18:43:03.811500752 +0100 1848 + @@ -9,17 +9,24 @@ 1849 + div.table-contents table th, div.informaltable table th { 1850 + font-family:sans-serif; 1851 + background:#d0d0d0; 1852 + - font-weight:normal; 1853 + + font-weight:bold; 1854 + vertical-align:top; 1855 + } 1856 + -div.cmdsynopsis { border-left:1px solid #707070; padding-left:5px; } 1857 + +div.cmdsynopsis { border-left:1px solid #707070; padding-left: 1em; } 1858 + li div.cmdsynopsis { border-left:none; padding-left:0px; } 1859 + -pre.screen, div.note { background:#f0f0f0; border:1px solid #c0c0c0; padding:5px; margin-left:2%; margin-right:2%; } 1860 + +li p { margin: 0; } 1861 + +pre.screen, div.note { border:1px solid #c0c0c0; margin-left:2%; margin-right:2%; } 1862 + +pre.screen { color: #ffffff; background:#000000; padding: 0.5em; } 1863 + +div.note { background:#ffff80; padding: 0.5em; } 1864 + div.example p.title { margin-left:2%; } 1865 + div.note h3 { font-size:small; font-style:italic; font-variant: small-caps; } 1866 + div.note h3:after { content: ":" } 1867 + div.note { margin-bottom: 5px; } 1868 + -.command { font-family: monospace; font-weight: normal; } 1869 + +div.literallayout, .command { font-family: monospace; font-weight: normal; } 1870 + .command strong { font-weight: normal; } 1871 + tr { vertical-align: top; } 1872 + -.comment { color:#707070; } 1873 + +.comment { color:#00c000; } 1874 + +code.literal { background: #f0f0f0; color: #000000; } 1875 + +span.indicator { background: #000060; color: #ffffff; } 1876 + +span.highlight { background: #404040; color: #ffffff; } 1877 + +span.reverse { background: #ffffff; color: #000000; } 1878 + diff -urN mutt-1.6.1/doc/muttrc.sidebar mutt-1.6.1-sidebar/doc/muttrc.sidebar 1879 + --- mutt-1.6.1/doc/muttrc.sidebar 1970-01-01 01:00:00.000000000 +0100 1880 + +++ mutt-1.6.1-sidebar/doc/muttrc.sidebar 2016-06-12 18:43:03.812500768 +0100 1881 + @@ -0,0 +1,116 @@ 1882 + +# This is a complete list of sidebar-related configuration. 1883 + + 1884 + +# -------------------------------------------------------------------------- 1885 + +# VARIABLES - shown with their default values 1886 + +# -------------------------------------------------------------------------- 1887 + + 1888 + +# Should the Sidebar be shown? 1889 + +set sidebar_visible = no 1890 + + 1891 + +# How wide should the Sidebar be in screen columns? 1892 + +# Note: Some characters, e.g. Chinese, take up two columns each. 1893 + +set sidebar_width = 20 1894 + + 1895 + +# Should the mailbox paths be abbreviated? 1896 + +set sidebar_short_path = no 1897 + + 1898 + +# When abbreviating mailbox path names, use any of these characters as path 1899 + +# separators. Only the part after the last separators will be shown. 1900 + +# For file folders '/' is good. For IMAP folders, often '.' is useful. 1901 + +set sidebar_delim_chars = '/.' 1902 + + 1903 + +# If the mailbox path is abbreviated, should it be indented? 1904 + +set sidebar_folder_indent = no 1905 + + 1906 + +# Indent mailbox paths with this string. 1907 + +set sidebar_indent_string = ' ' 1908 + + 1909 + +# Make the Sidebar only display mailboxes that contain new, or flagged, 1910 + +# mail. 1911 + +set sidebar_new_mail_only = no 1912 + + 1913 + +# Any mailboxes that are whitelisted will always be visible, even if the 1914 + +# sidebar_new_mail_only option is enabled. 1915 + +sidebar_whitelist '/home/user/mailbox1' 1916 + +sidebar_whitelist '/home/user/mailbox2' 1917 + + 1918 + +# When searching for mailboxes containing new mail, should the search wrap 1919 + +# around when it reaches the end of the list? 1920 + +set sidebar_next_new_wrap = no 1921 + + 1922 + +# The character to use as the divider between the Sidebar and the other Mutt 1923 + +# panels. 1924 + +# Note: Only the first character of this string is used. 1925 + +set sidebar_divider_char = '|' 1926 + + 1927 + +# Display the Sidebar mailboxes using this format string. 1928 + +set sidebar_format = '%B%?F? [%F]?%* %?N?%N/?%S' 1929 + + 1930 + +# Sidebar will not refresh its list of mailboxes any more frequently than 1931 + +# this number of seconds. This will help reduce disk/network traffic. 1932 + +set sidebar_refresh_time = 60 1933 + + 1934 + +# Sort the mailboxes in the Sidebar using this method: 1935 + +# count - total number of messages 1936 + +# flagged - number of flagged messages 1937 + +# new - number of new messages 1938 + +# path - mailbox path 1939 + +# unsorted - do not sort the mailboxes 1940 + +set sidebar_sort_method = 'unsorted' 1941 + + 1942 + +# -------------------------------------------------------------------------- 1943 + +# FUNCTIONS - shown with an example mapping 1944 + +# -------------------------------------------------------------------------- 1945 + + 1946 + +# Move the highlight to the previous mailbox 1947 + +bind index,pager \Cp sidebar-prev 1948 + + 1949 + +# Move the highlight to the next mailbox 1950 + +bind index,pager \Cn sidebar-next 1951 + + 1952 + +# Open the highlighted mailbox 1953 + +bind index,pager \Co sidebar-open 1954 + + 1955 + +# Move the highlight to the previous page 1956 + +# This is useful if you have a LOT of mailboxes. 1957 + +bind index,pager <F3> sidebar-page-up 1958 + + 1959 + +# Move the highlight to the next page 1960 + +# This is useful if you have a LOT of mailboxes. 1961 + +bind index,pager <F4> sidebar-page-down 1962 + + 1963 + +# Move the highlight to the previous mailbox containing new, or flagged, 1964 + +# mail. 1965 + +bind index,pager <F5> sidebar-prev-new 1966 + + 1967 + +# Move the highlight to the next mailbox containing new, or flagged, mail. 1968 + +bind index,pager <F6> sidebar-next-new 1969 + + 1970 + +# Toggle the visibility of the Sidebar. 1971 + +bind index,pager B sidebar-toggle-visible 1972 + + 1973 + +# -------------------------------------------------------------------------- 1974 + +# COLORS - some unpleasant examples are given 1975 + +# -------------------------------------------------------------------------- 1976 + +# Note: All color operations are of the form: 1977 + +# color OBJECT FOREGROUND BACKGROUND 1978 + + 1979 + +# Color of the current, open, mailbox 1980 + +# Note: This is a general Mutt option which colors all selected items. 1981 + +color indicator cyan black 1982 + + 1983 + +# Color of the highlighted, but not open, mailbox. 1984 + +color sidebar_highlight black color8 1985 + + 1986 + +# Color of the divider separating the Sidebar from Mutt panels 1987 + +color sidebar_divider color8 black 1988 + + 1989 + +# Color to give mailboxes containing flagged mail 1990 + +color sidebar_flagged red black 1991 + + 1992 + +# Color to give mailboxes containing new mail 1993 + +color sidebar_new green black 1994 + + 1995 + +# -------------------------------------------------------------------------- 1996 + + 1997 + +# vim: syntax=muttrc 1998 + diff -urN mutt-1.6.1/doc/vimrc.sidebar mutt-1.6.1-sidebar/doc/vimrc.sidebar 1999 + --- mutt-1.6.1/doc/vimrc.sidebar 1970-01-01 01:00:00.000000000 +0100 2000 + +++ mutt-1.6.1-sidebar/doc/vimrc.sidebar 2016-06-12 18:43:03.813500783 +0100 2001 + @@ -0,0 +1,35 @@ 2002 + +" Vim syntax file for the mutt sidebar patch 2003 + + 2004 + +syntax keyword muttrcVarBool skipwhite contained sidebar_folder_indent nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2005 + +syntax keyword muttrcVarBool skipwhite contained sidebar_new_mail_only nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2006 + +syntax keyword muttrcVarBool skipwhite contained sidebar_next_new_wrap nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2007 + +syntax keyword muttrcVarBool skipwhite contained sidebar_short_path nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2008 + +syntax keyword muttrcVarBool skipwhite contained sidebar_visible nextgroup=muttrcSetBoolAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2009 + + 2010 + +syntax keyword muttrcVarNum skipwhite contained sidebar_refresh_time nextgroup=muttrcSetNumAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2011 + +syntax keyword muttrcVarNum skipwhite contained sidebar_width nextgroup=muttrcSetNumAssignment,muttrcVPrefix,muttrcVarBool,muttrcVarQuad,muttrcVarNum,muttrcVarStr 2012 + + 2013 + +syntax keyword muttrcVarStr contained skipwhite sidebar_divider_char nextgroup=muttrcVarEqualsIdxFmt 2014 + +syntax keyword muttrcVarStr contained skipwhite sidebar_delim_chars nextgroup=muttrcVarEqualsIdxFmt 2015 + +syntax keyword muttrcVarStr contained skipwhite sidebar_format nextgroup=muttrcVarEqualsIdxFmt 2016 + +syntax keyword muttrcVarStr contained skipwhite sidebar_indent_string nextgroup=muttrcVarEqualsIdxFmt 2017 + +syntax keyword muttrcVarStr contained skipwhite sidebar_sort_method nextgroup=muttrcVarEqualsIdxFmt 2018 + + 2019 + +syntax keyword muttrcCommand sidebar_whitelist 2020 + + 2021 + +syntax match muttrcFunction contained "\<sidebar-next\>" 2022 + +syntax match muttrcFunction contained "\<sidebar-next-new\>" 2023 + +syntax match muttrcFunction contained "\<sidebar-open\>" 2024 + +syntax match muttrcFunction contained "\<sidebar-page-down\>" 2025 + +syntax match muttrcFunction contained "\<sidebar-page-up\>" 2026 + +syntax match muttrcFunction contained "\<sidebar-prev\>" 2027 + +syntax match muttrcFunction contained "\<sidebar-prev-new\>" 2028 + +syntax match muttrcFunction contained "\<sidebar-toggle-visible\>" 2029 + + 2030 + +syntax keyword muttrcColorField contained sidebar_divider 2031 + +syntax keyword muttrcColorField contained sidebar_flagged 2032 + +syntax keyword muttrcColorField contained sidebar_highlight 2033 + +syntax keyword muttrcColorField contained sidebar_indicator 2034 + +syntax keyword muttrcColorField contained sidebar_new 2035 + + 2036 + +" vim: syntax=vim 2037 + diff -urN mutt-1.6.1/filter.c mutt-1.6.1-sidebar/filter.c 2038 + --- mutt-1.6.1/filter.c 2016-06-12 18:43:00.403447606 +0100 2039 + +++ mutt-1.6.1-sidebar/filter.c 2016-06-12 18:43:03.835501127 +0100 2040 + @@ -21,6 +21,7 @@ 2041 + #endif 521 2042 522 2043 #include "mutt.h" 523 - #include "mutt_curses.h" 524 - +#include "mutt_menu.h" 2044 + +#include "mutt_curses.h" 2045 + 2046 + #include <unistd.h> 2047 + #include <stdlib.h> 2048 + @@ -34,6 +35,7 @@ 2049 + int fdin, int fdout, int fderr) 2050 + { 2051 + int pin[2], pout[2], perr[2], thepid; 2052 + + char columns[11]; 2053 + 2054 + if (in) 2055 + { 2056 + @@ -117,6 +119,9 @@ 2057 + close (fderr); 2058 + } 2059 + 2060 + + snprintf (columns, sizeof (columns), "%d", COLS - SidebarWidth); 2061 + + setenv ("COLUMNS", columns, 1); 2062 + + 2063 + execl (EXECSHELL, "sh", "-c", cmd, NULL); 2064 + _exit (127); 2065 + } 2066 + diff -urN mutt-1.6.1/flags.c mutt-1.6.1-sidebar/flags.c 2067 + --- mutt-1.6.1/flags.c 2016-06-12 18:43:00.403447606 +0100 2068 + +++ mutt-1.6.1-sidebar/flags.c 2016-06-12 18:43:03.956503013 +0100 2069 + @@ -25,6 +25,10 @@ 525 2070 #include "sort.h" 526 2071 #include "mx.h" 2072 + 2073 + +#ifdef USE_SIDEBAR 527 2074 +#include "sidebar.h" 528 - 2075 + +#endif 2076 + + 529 2077 void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 530 2078 { 531 - @@ -290,6 +292,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 2079 + int changed = h->changed; 2080 + @@ -263,6 +267,9 @@ 532 2081 */ 533 2082 if (h->searched && (changed != h->changed || deleted != ctx->deleted || tagged != ctx->tagged || flagged != ctx->flagged)) 534 2083 h->searched = 0; 535 - + draw_sidebar(0); 2084 + +#ifdef USE_SIDEBAR 2085 + + mutt_sb_draw(); 2086 + +#endif 536 2087 } 537 2088 538 2089 void mutt_tag_set_flag (int flag, int bf) 539 - diff --git a/functions.h b/functions.h 540 - index 26171a0..ef8937a 100644 541 - --- a/functions.h 542 - +++ b/functions.h 543 - @@ -170,6 +170,11 @@ const struct binding_t OpMain[] = { /* map: index */ 2090 + diff -urN mutt-1.6.1/functions.h mutt-1.6.1-sidebar/functions.h 2091 + --- mutt-1.6.1/functions.h 2016-06-12 18:43:00.403447606 +0100 2092 + +++ mutt-1.6.1-sidebar/functions.h 2016-06-12 18:43:03.956503013 +0100 2093 + @@ -168,6 +168,16 @@ 2094 + { "decrypt-copy", OP_DECRYPT_COPY, NULL }, 544 2095 { "decrypt-save", OP_DECRYPT_SAVE, NULL }, 545 2096 2097 + +#ifdef USE_SIDEBAR 2098 + + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 2099 + + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL }, 2100 + + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 2101 + + { "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN, NULL }, 2102 + + { "sidebar-page-up", OP_SIDEBAR_PAGE_UP, NULL }, 2103 + + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 2104 + + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL }, 2105 + + { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE, NULL }, 2106 + +#endif 546 2107 547 - + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, 548 - + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, 549 - + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 550 - + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 551 - + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 552 2108 { NULL, 0, NULL } 553 2109 }; 554 - 555 - @@ -274,6 +279,11 @@ const struct binding_t OpPager[] = { /* map: pager */ 2110 + @@ -272,6 +282,17 @@ 556 2111 557 2112 { "what-key", OP_WHAT_KEY, NULL }, 558 2113 559 - + { "sidebar-scroll-up", OP_SIDEBAR_SCROLL_UP, NULL }, 560 - + { "sidebar-scroll-down", OP_SIDEBAR_SCROLL_DOWN, NULL }, 561 - + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 562 - + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 563 - + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 2114 + +#ifdef USE_SIDEBAR 2115 + + { "sidebar-next", OP_SIDEBAR_NEXT, NULL }, 2116 + + { "sidebar-next-new", OP_SIDEBAR_NEXT_NEW, NULL }, 2117 + + { "sidebar-open", OP_SIDEBAR_OPEN, NULL }, 2118 + + { "sidebar-page-down", OP_SIDEBAR_PAGE_DOWN, NULL }, 2119 + + { "sidebar-page-up", OP_SIDEBAR_PAGE_UP, NULL }, 2120 + + { "sidebar-prev", OP_SIDEBAR_PREV, NULL }, 2121 + + { "sidebar-prev-new", OP_SIDEBAR_PREV_NEW, NULL }, 2122 + + { "sidebar-toggle-visible", OP_SIDEBAR_TOGGLE_VISIBLE, NULL }, 2123 + +#endif 2124 + + 564 2125 { NULL, 0, NULL } 565 2126 }; 566 2127 567 - diff --git a/globals.h b/globals.h 568 - index 282fde3..004c795 100644 569 - --- a/globals.h 570 - +++ b/globals.h 571 - @@ -118,6 +118,7 @@ WHERE short SearchContext; 2128 + diff -urN mutt-1.6.1/globals.h mutt-1.6.1-sidebar/globals.h 2129 + --- mutt-1.6.1/globals.h 2016-06-12 18:43:00.403447606 +0100 2130 + +++ mutt-1.6.1-sidebar/globals.h 2016-06-12 18:43:03.956503013 +0100 2131 + @@ -118,6 +118,12 @@ 572 2132 WHERE char *SendCharset; 573 2133 WHERE char *Sendmail; 574 2134 WHERE char *Shell; 575 - +WHERE char *SidebarDelim; 2135 + +#ifdef USE_SIDEBAR 2136 + +WHERE char *SidebarDelimChars; 2137 + +WHERE char *SidebarDividerChar; 2138 + +WHERE char *SidebarFormat; 2139 + +WHERE char *SidebarIndentString; 2140 + +#endif 576 2141 WHERE char *Signature; 577 2142 WHERE char *SimpleSearch; 578 2143 #if USE_SMTP 579 - @@ -214,6 +215,9 @@ WHERE short ScoreThresholdDelete; 2144 + @@ -214,6 +220,14 @@ 580 2145 WHERE short ScoreThresholdRead; 581 2146 WHERE short ScoreThresholdFlag; 582 2147 583 - +WHERE struct buffy_t *CurBuffy INITVAL(0); 584 - +WHERE short DrawFullLine INITVAL(0); 2148 + +/* This isn't excluded from the build because it's too entwined in the code. 2149 + + * For now. */ 585 2150 +WHERE short SidebarWidth; 2151 + +#ifdef USE_SIDEBAR 2152 + +WHERE short SidebarRefreshTime; 2153 + +WHERE LIST *SidebarWhitelist INITVAL(0); 2154 + +#endif 2155 + + 586 2156 #ifdef USE_IMAP 587 2157 WHERE short ImapKeepalive; 588 2158 WHERE short ImapPipelineDepth; 589 - diff --git a/imap/command.c b/imap/command.c 590 - index 32f8417..d68e3ab 100644 591 - --- a/imap/command.c 592 - +++ b/imap/command.c 593 - @@ -1012,6 +1012,13 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s) 2159 + diff -urN mutt-1.6.1/imap/command.c mutt-1.6.1-sidebar/imap/command.c 2160 + --- mutt-1.6.1/imap/command.c 2016-06-12 18:43:00.405447637 +0100 2161 + +++ mutt-1.6.1-sidebar/imap/command.c 2016-06-12 18:43:03.839501189 +0100 2162 + @@ -1016,6 +1016,14 @@ 594 2163 opened */ 595 2164 status->uidnext = oldun; 596 2165 597 - + /* Added to make the sidebar show the correct numbers */ 598 - + if (status->messages) 599 - + { 600 - + inc->msgcount = status->messages; 601 - + inc->msg_unread = status->unseen; 602 - + } 2166 + +#ifdef USE_SIDEBAR 2167 + + /* Make the sidebar show the correct numbers */ 2168 + + if (status->messages) { 2169 + + inc->msg_count = status->messages; 2170 + + inc->msg_unread = status->unseen; 2171 + + } 2172 + +#endif 603 2173 + 604 2174 FREE (&value); 605 2175 return; 606 2176 } 607 - diff --git a/imap/imap.c b/imap/imap.c 608 - index f476873..af3ac3d 100644 609 - --- a/imap/imap.c 610 - +++ b/imap/imap.c 611 - @@ -1529,7 +1529,7 @@ int imap_buffy_check (int force) 2177 + diff -urN mutt-1.6.1/imap/imap.c mutt-1.6.1-sidebar/imap/imap.c 2178 + --- mutt-1.6.1/imap/imap.c 2016-06-12 18:43:00.405447637 +0100 2179 + +++ mutt-1.6.1-sidebar/imap/imap.c 2016-06-12 18:43:03.958503044 +0100 2180 + @@ -1535,7 +1535,11 @@ 612 2181 613 - imap_munge_mbox_name (munged, sizeof (munged), name); 2182 + imap_munge_mbox_name (idata, munged, sizeof (munged), name); 614 2183 snprintf (command, sizeof (command), 615 - - "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); 2184 + +#ifdef USE_SIDEBAR 616 2185 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT MESSAGES)", munged); 2186 + +#else 2187 + "STATUS %s (UIDNEXT UIDVALIDITY UNSEEN RECENT)", munged); 2188 + +#endif 617 2189 618 2190 if (imap_exec (idata, command, IMAP_CMD_QUEUE) < 0) 619 2191 { 620 - diff --git a/init.h b/init.h 621 - index 35224c1..c664e5f 100644 622 - --- a/init.h 623 - +++ b/init.h 624 - @@ -2030,6 +2030,27 @@ struct option_t MuttVars[] = { 625 - ** not used. 626 - ** (PGP only) 2192 + diff -urN mutt-1.6.1/init.c mutt-1.6.1-sidebar/init.c 2193 + --- mutt-1.6.1/init.c 2016-06-12 18:43:00.406447652 +0100 2194 + +++ mutt-1.6.1-sidebar/init.c 2016-06-12 18:43:03.959503060 +0100 2195 + @@ -2173,6 +2173,9 @@ 2196 + case DT_SORT_AUX: 2197 + map = SortAuxMethods; 2198 + break; 2199 + + case DT_SORT_SIDEBAR: 2200 + + map = SortSidebarMethods; 2201 + + break; 2202 + default: 2203 + map = SortMethods; 2204 + break; 2205 + diff -urN mutt-1.6.1/init.h mutt-1.6.1-sidebar/init.h 2206 + --- mutt-1.6.1/init.h 2016-06-12 18:43:00.408447684 +0100 2207 + +++ mutt-1.6.1-sidebar/init.h 2016-06-12 18:43:03.960503075 +0100 2208 + @@ -42,11 +42,12 @@ 2209 + #define DTYPE(x) ((x) & DT_MASK) 2210 + 2211 + /* subtypes */ 2212 + -#define DT_SUBTYPE_MASK 0xf0 2213 + +#define DT_SUBTYPE_MASK 0xff0 2214 + #define DT_SORT_ALIAS 0x10 2215 + #define DT_SORT_BROWSER 0x20 2216 + #define DT_SORT_KEYS 0x40 2217 + #define DT_SORT_AUX 0x80 2218 + +#define DT_SORT_SIDEBAR 0x100 2219 + 2220 + /* flags to parse_set() */ 2221 + #define M_SET_INV (1<<0) /* default is to invert all vars */ 2222 + @@ -2665,6 +2666,147 @@ 2223 + ** Command to use when spawning a subshell. By default, the user's login 2224 + ** shell from \fC/etc/passwd\fP is used. 627 2225 */ 628 - + {"sidebar_delim", DT_STR, R_BOTH, UL &SidebarDelim, "|"}, 2226 + +#ifdef USE_SIDEBAR 2227 + + { "sidebar_divider_char", DT_STR, R_BOTH, UL &SidebarDividerChar, UL "|" }, 2228 + + /* 2229 + + ** .pp 2230 + + ** This specifies the characters to be drawn between the sidebar (when 2231 + + ** visible) and the other Mutt panels. ASCII and Unicode line-drawing 2232 + + ** characters are supported. 2233 + + */ 2234 + + { "sidebar_delim_chars", DT_STR, R_NONE, UL &SidebarDelimChars, UL "/." }, 2235 + + /* 2236 + + ** .pp 2237 + + ** This contains the list of characters which you would like to treat 2238 + + ** as folder separators for displaying paths in the sidebar. 2239 + + ** .pp 2240 + + ** Local mail is often arranged in directories: `dir1/dir2/mailbox'. 2241 + + ** .ts 2242 + + ** set sidebar_delim_chars='/' 2243 + + ** .te 2244 + + ** .pp 2245 + + ** IMAP mailboxes are often named: `folder1.folder2.mailbox'. 2246 + + ** .ts 2247 + + ** set sidebar_delim_chars='.' 2248 + + ** .te 2249 + + ** .pp 2250 + + ** \fBSee also:\fP $$sidebar_short_path, $$sidebar_folder_indent, $$sidebar_indent_string. 2251 + + */ 2252 + + { "sidebar_folder_indent", DT_BOOL, R_BOTH, OPTSIDEBARFOLDERINDENT, 0 }, 2253 + + /* 2254 + + ** .pp 2255 + + ** Set this to indent mailboxes in the sidebar. 2256 + + ** .pp 2257 + + ** \fBSee also:\fP $$sidebar_short_path, $$sidebar_indent_string, $$sidebar_delim_chars. 2258 + + */ 2259 + + { "sidebar_format", DT_STR, R_NONE, UL &SidebarFormat, UL "%B%?F? [%F]?%* %?N?%N/?%S" }, 2260 + + /* 2261 + + ** .pp 2262 + + ** This variable allows you to customize the sidebar display. This string is 2263 + + ** similar to $$index_format, but has its own set of \fCprintf(3)\fP-like 2264 + + ** sequences: 2265 + + ** .dl 2266 + + ** .dt %B .dd Name of the mailbox 2267 + + ** .dt %S .dd * Size of mailbox (total number of messages) 2268 + + ** .dt %N .dd * Number of New messages in the mailbox 2269 + + ** .dt %F .dd * Number of Flagged messages in the mailbox 2270 + + ** .dt %! .dd ``!'' : one flagged message; 2271 + + ** ``!!'' : two flagged messages; 2272 + + ** ``n!'' : n flagged messages (for n > 2). 2273 + + ** Otherwise prints nothing. 2274 + + ** .dt %d .dd * @ Number of deleted messages 2275 + + ** .dt %L .dd * @ Number of messages after limiting 2276 + + ** .dt %t .dd * @ Number of tagged messages 2277 + + ** .dt %>X .dd right justify the rest of the string and pad with ``X'' 2278 + + ** .dt %|X .dd pad to the end of the line with ``X'' 2279 + + ** .dt %*X .dd soft-fill with character ``X'' as pad 2280 + + ** .de 2281 + + ** .pp 2282 + + ** * = Can be optionally printed if nonzero 2283 + + ** @ = Only applicable to the current folder 2284 + + */ 2285 + + { "sidebar_indent_string", DT_STR, R_BOTH, UL &SidebarIndentString, UL " " }, 629 2286 + /* 630 2287 + ** .pp 631 - + ** This specifies the delimiter between the sidebar (if visible) and 632 - + ** other screens. 2288 + + ** This specifies the string that is used to indent mailboxes in the sidebar. 2289 + + ** It defaults to two spaces. 2290 + + ** .pp 2291 + + ** \fBSee also:\fP $$sidebar_short_path, $$sidebar_folder_indent, $$sidebar_delim_chars. 633 2292 + */ 634 - + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, 2293 + + { "sidebar_new_mail_only", DT_BOOL, R_BOTH, OPTSIDEBARNEWMAILONLY, 0 }, 635 2294 + /* 636 2295 + ** .pp 637 - + ** This specifies whether or not to show sidebar (left-side list of folders). 2296 + + ** When set, the sidebar will only display mailboxes containing new, or 2297 + + ** flagged, mail. 2298 + + ** .pp 2299 + + ** \fBSee also:\fP $sidebar_whitelist. 638 2300 + */ 639 - + { "sidebar_sort", DT_BOOL, R_BOTH, OPTSIDEBARSORT, 0 }, 2301 + + { "sidebar_next_new_wrap", DT_BOOL, R_BOTH, UL OPTSIDEBARNEXTNEWWRAP, 0 }, 640 2302 + /* 641 2303 + ** .pp 642 - + ** This specifies whether or not to sort the sidebar alphabetically. 2304 + + ** When set, the \fC<sidebar-next-new>\fP command will not stop and the end of 2305 + + ** the list of mailboxes, but wrap around to the beginning. The 2306 + + ** \fC<sidebar-prev-new>\fP command is similarly affected, wrapping around to 2307 + + ** the end of the list. 2308 + + */ 2309 + + { "sidebar_refresh_time", DT_NUM, R_BOTH, UL &SidebarRefreshTime, 60 }, 2310 + + /* 2311 + + ** .pp 2312 + + ** Set sidebar_refresh_time to the minimum number of seconds between refreshes. 2313 + + ** This will reduce network traffic. 2314 + + ** .pp 2315 + + ** \fBNote:\fP Set to 0 to disable refreshing. 2316 + + */ 2317 + + { "sidebar_short_path", DT_BOOL, R_BOTH, OPTSIDEBARSHORTPATH, 0 }, 2318 + + /* 2319 + + ** .pp 2320 + + ** By default the sidebar will show the mailbox's path, relative to the 2321 + + ** $$folder variable. Setting \fCsidebar_shortpath=yes\fP will shorten the 2322 + + ** names relative to the previous name. Here's an example: 2323 + + ** .dl 2324 + + ** .dt \fBshortpath=no\fP .dd \fBshortpath=yes\fP .dd \fBshortpath=yes, folderindent=yes, indentstr=".."\fP 2325 + + ** .dt \fCfruit\fP .dd \fCfruit\fP .dd \fCfruit\fP 2326 + + ** .dt \fCfruit.apple\fP .dd \fCapple\fP .dd \fC..apple\fP 2327 + + ** .dt \fCfruit.banana\fP .dd \fCbanana\fP .dd \fC..banana\fP 2328 + + ** .dt \fCfruit.cherry\fP .dd \fCcherry\fP .dd \fC..cherry\fP 2329 + + ** .de 2330 + + ** .pp 2331 + + ** \fBSee also:\fP $$sidebar_delim_chars, $$sidebar_folder_indent, $$sidebar_indent_string. 2332 + + */ 2333 + + { "sidebar_sort_method", DT_SORT|DT_SORT_SIDEBAR, R_NONE, UL &SidebarSortMethod, SORT_ORDER }, 2334 + + /* 2335 + + ** .pp 2336 + + ** Specifies how to sort entries in the file browser. By default, the 2337 + + ** entries are sorted alphabetically. Valid values: 2338 + + ** .il 2339 + + ** .dd alpha (alphabetically) 2340 + + ** .dd count (all message count) 2341 + + ** .dd date 2342 + + ** .dd desc (description) 2343 + + ** .dd new (new message count) 2344 + + ** .dd size 2345 + + ** .dd unsorted 2346 + + ** .ie 2347 + + ** .pp 2348 + + ** You may optionally use the ``reverse-'' prefix to specify reverse sorting 2349 + + ** order (example: ``\fCset sort_browser=reverse-date\fP''). 2350 + + */ 2351 + + { "sidebar_visible", DT_BOOL, R_BOTH, OPTSIDEBAR, 0 }, 2352 + + /* 2353 + + ** .pp 2354 + + ** This specifies whether or not to show sidebar. The sidebar shows a list of 2355 + + ** all your mailboxes. 2356 + + ** .pp 2357 + + ** \fBSee also:\fP $$sidebar_format, $$sidebar_width 643 2358 + */ 644 2359 + { "sidebar_width", DT_NUM, R_BOTH, UL &SidebarWidth, 0 }, 645 2360 + /* 646 2361 + ** .pp 647 - + ** The width of the sidebar. 2362 + + ** This controls the width of the sidebar. It is measured in screen columns. 2363 + + ** For example: sidebar_width=20 could display 20 ASCII characters, or 10 2364 + + ** Chinese characters. 648 2365 + */ 649 - { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0}, 2366 + +#endif 2367 + { "sig_dashes", DT_BOOL, R_NONE, OPTSIGDASHES, 1 }, 650 2368 /* 651 2369 ** .pp 652 - diff --git a/mailbox.h b/mailbox.h 653 - index 2b2c9a1..000503d 100644 654 - --- a/mailbox.h 655 - +++ b/mailbox.h 656 - @@ -27,6 +27,7 @@ 2370 + @@ -3652,6 +3794,19 @@ 2371 + { NULL, 0 } 2372 + }; 2373 + 2374 + +const struct mapping_t SortSidebarMethods[] = { 2375 + + { "alpha", SORT_PATH }, 2376 + + { "count", SORT_COUNT }, 2377 + + { "desc", SORT_DESC }, 2378 + + { "flagged", SORT_FLAGGED }, 2379 + + { "mailbox-order", SORT_ORDER }, 2380 + + { "name", SORT_PATH }, 2381 + + { "new", SORT_COUNT_NEW }, 2382 + + { "path", SORT_PATH }, 2383 + + { "unsorted", SORT_ORDER }, 2384 + + { NULL, 0 } 2385 + +}; 2386 + + 2387 + 2388 + /* functions used to parse commands in a rc file */ 2389 + 2390 + @@ -3741,6 +3896,9 @@ 2391 + { "send-hook", mutt_parse_hook, M_SENDHOOK }, 2392 + { "send2-hook", mutt_parse_hook, M_SEND2HOOK }, 2393 + { "set", parse_set, 0 }, 2394 + +#ifdef USE_SIDEBAR 2395 + + { "sidebar_whitelist",parse_list, UL &SidebarWhitelist }, 2396 + +#endif 2397 + { "source", parse_source, 0 }, 2398 + { "spam", parse_spam_list, M_SPAM }, 2399 + { "nospam", parse_spam_list, M_NOSPAM }, 2400 + diff -urN mutt-1.6.1/keymap.c mutt-1.6.1-sidebar/keymap.c 2401 + --- mutt-1.6.1/keymap.c 2016-06-12 18:43:00.408447684 +0100 2402 + +++ mutt-1.6.1-sidebar/keymap.c 2016-06-12 18:43:03.960503075 +0100 2403 + @@ -453,6 +453,9 @@ 2404 + } 2405 + #endif 2406 + 2407 + + /* update sidebar stats */ 2408 + + mutt_buffy_check(0); 2409 + + 2410 + timeout (i * 1000); 2411 + tmp = mutt_getch(); 2412 + timeout (-1); 2413 + diff -urN mutt-1.6.1/mailbox.h mutt-1.6.1-sidebar/mailbox.h 2414 + --- mutt-1.6.1/mailbox.h 2016-06-12 18:43:00.408447684 +0100 2415 + +++ mutt-1.6.1-sidebar/mailbox.h 2016-06-12 18:43:03.960503075 +0100 2416 + @@ -27,6 +27,9 @@ 657 2417 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses 658 2418 * safe_fopen() for mbox-style folders. 659 2419 */ 2420 + +#ifdef USE_SIDEBAR 660 2421 +#define M_PEEK (1<<5) /* revert atime back after taking a look (if applicable) */ 2422 + +#endif 661 2423 662 2424 /* mx_open_new_message() */ 663 2425 #define M_ADD_FROM (1<<0) /* add a From_ line */ 664 - diff --git a/mbox.c b/mbox.c 665 - index 6d3b6bd..fa82eb3 100644 666 - --- a/mbox.c 667 - +++ b/mbox.c 668 - @@ -104,6 +104,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) 2426 + diff -urN mutt-1.6.1/main.c mutt-1.6.1-sidebar/main.c 2427 + --- mutt-1.6.1/main.c 2016-06-12 18:43:00.409447699 +0100 2428 + +++ mutt-1.6.1-sidebar/main.c 2016-06-12 18:43:03.961503091 +0100 2429 + @@ -31,6 +31,9 @@ 2430 + #include "url.h" 2431 + #include "mutt_crypt.h" 2432 + #include "mutt_idna.h" 2433 + +#ifdef USE_SIDEBAR 2434 + +#include "sidebar.h" 2435 + +#endif 2436 + 2437 + #ifdef USE_SASL 2438 + #include "mutt_sasl.h" 2439 + @@ -485,6 +488,12 @@ 2440 + "-USE_HCACHE " 2441 + #endif 2442 + 2443 + +#ifdef USE_SIDEBAR 2444 + + "+USE_SIDEBAR " 2445 + +#else 2446 + + "-USE_SIDEBAR " 2447 + +#endif 2448 + + 2449 + ); 2450 + 2451 + #ifdef ISPELL 2452 + @@ -557,7 +566,11 @@ 2453 + 2454 + int main (int argc, char **argv) 2455 + { 2456 + +#ifdef USE_SIDEBAR 2457 + + char folder[PATH_MAX] = ""; 2458 + +#else 2459 + char folder[_POSIX_PATH_MAX] = ""; 2460 + +#endif 2461 + char *subject = NULL; 2462 + char *includeFile = NULL; 2463 + char *draftFile = NULL; 2464 + @@ -828,6 +841,9 @@ 2465 + clear (); 2466 + mutt_error = mutt_curses_error; 2467 + mutt_message = mutt_curses_message; 2468 + +#ifdef USE_SIDEBAR 2469 + + mutt_sb_init(); 2470 + +#endif 2471 + } 2472 + 2473 + /* Create the Maildir directory if it doesn't exist. */ 2474 + @@ -1184,6 +1200,15 @@ 2475 + strfcpy (folder, NONULL(Spoolfile), sizeof (folder)); 2476 + mutt_expand_path (folder, sizeof (folder)); 2477 + 2478 + +#ifdef USE_SIDEBAR 2479 + + { 2480 + + char tmpfolder[PATH_MAX] = ""; 2481 + + strfcpy (tmpfolder, folder, sizeof (tmpfolder)); 2482 + + if (!realpath (tmpfolder, folder)) 2483 + + strfcpy (folder, tmpfolder, sizeof (tmpfolder)); 2484 + + } 2485 + +#endif 2486 + + 2487 + mutt_str_replace (&CurrentFolder, folder); 2488 + mutt_str_replace (&LastFolder, folder); 2489 + 2490 + @@ -1206,6 +1231,9 @@ 2491 + if((Context = mx_open_mailbox (folder, ((flags & M_RO) || option (OPTREADONLY)) ? M_READONLY : 0, NULL)) 2492 + || !explicit_folder) 2493 + { 2494 + +#ifdef USE_SIDEBAR 2495 + + mutt_sb_set_open_buffy (folder); 2496 + +#endif 2497 + mutt_index_menu (); 2498 + if (Context) 2499 + FREE (&Context); 2500 + diff -urN mutt-1.6.1/Makefile.am mutt-1.6.1-sidebar/Makefile.am 2501 + --- mutt-1.6.1/Makefile.am 2016-06-12 18:43:00.389447388 +0100 2502 + +++ mutt-1.6.1-sidebar/Makefile.am 2016-06-12 18:43:03.944502826 +0100 2503 + @@ -56,7 +56,7 @@ 2504 + mutt_idna.c mutt_sasl.c mutt_socket.c mutt_ssl.c mutt_ssl_gnutls.c \ 2505 + mutt_tunnel.c pgp.c pgpinvoke.c pgpkey.c pgplib.c pgpmicalg.c \ 2506 + pgppacket.c pop.c pop_auth.c pop_lib.c remailer.c resize.c sha1.c \ 2507 + - smime.c smtp.c utf8.c wcwidth.c \ 2508 + + sidebar.c smime.c smtp.c utf8.c wcwidth.c \ 2509 + bcache.h browser.h hcache.h mbyte.h mutt_idna.h remailer.h url.h 2510 + 2511 + EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO UPDATING \ 2512 + @@ -71,7 +71,7 @@ 2513 + mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h \ 2514 + README.SSL smime.h group.h \ 2515 + muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \ 2516 + - ChangeLog mkchangelog.sh mutt_idna.h \ 2517 + + ChangeLog mkchangelog.sh mutt_idna.h sidebar.h OPS.sidebar \ 2518 + snprintf.c regex.c crypt-gpgme.h hcachever.sh.in sys_socket.h \ 2519 + txt2c.c txt2c.sh version.sh check_sec.sh 2520 + 2521 + @@ -129,9 +129,9 @@ 2522 + keymap_defs.h: $(OPS) $(srcdir)/gen_defs 2523 + $(srcdir)/gen_defs $(OPS) > keymap_defs.h 2524 + 2525 + -keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs 2526 + +keymap_alldefs.h: $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME $(srcdir)/gen_defs 2527 + rm -f $@ 2528 + - $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.PGP \ 2529 + + $(srcdir)/gen_defs $(srcdir)/OPS $(srcdir)/OPS.SIDEBAR $(srcdir)/OPS.PGP \ 2530 + $(srcdir)/OPS.MIX $(srcdir)/OPS.CRYPT $(srcdir)/OPS.SMIME \ 2531 + > keymap_alldefs.h 2532 + 2533 + diff -urN mutt-1.6.1/mbox.c mutt-1.6.1-sidebar/mbox.c 2534 + --- mutt-1.6.1/mbox.c 2016-06-12 18:43:00.409447699 +0100 2535 + +++ mutt-1.6.1-sidebar/mbox.c 2016-06-12 18:43:03.961503091 +0100 2536 + @@ -100,6 +100,9 @@ 669 2537 mutt_perror (ctx->path); 670 2538 return (-1); 671 2539 } 2540 + +#ifdef USE_SIDEBAR 672 2541 + ctx->atime = sb.st_atime; 2542 + +#endif 673 2543 ctx->mtime = sb.st_mtime; 674 2544 ctx->size = sb.st_size; 675 2545 676 - @@ -255,6 +256,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) 2546 + @@ -251,6 +254,9 @@ 677 2547 678 2548 ctx->size = sb.st_size; 679 2549 ctx->mtime = sb.st_mtime; 2550 + +#ifdef USE_SIDEBAR 680 2551 + ctx->atime = sb.st_atime; 2552 + +#endif 681 2553 682 2554 #ifdef NFS_ATTRIBUTE_HACK 683 2555 if (sb.st_mtime > sb.st_atime) 684 - diff --git a/menu.c b/menu.c 685 - index 27b5f8e..bc3a02f 100644 686 - --- a/menu.c 687 - +++ b/menu.c 688 - @@ -24,6 +24,7 @@ 2556 + diff -urN mutt-1.6.1/menu.c mutt-1.6.1-sidebar/menu.c 2557 + --- mutt-1.6.1/menu.c 2016-06-12 18:43:00.409447699 +0100 2558 + +++ mutt-1.6.1-sidebar/menu.c 2016-06-12 18:43:03.961503091 +0100 2559 + @@ -24,6 +24,9 @@ 689 2560 #include "mutt_curses.h" 690 2561 #include "mutt_menu.h" 691 2562 #include "mbyte.h" 2563 + +#ifdef USE_SIDEBAR 692 2564 +#include "sidebar.h" 2565 + +#endif 693 2566 694 - extern size_t UngetCount; 2567 + char* SearchBuffers[MENU_MAX]; 695 2568 696 - @@ -186,7 +187,7 @@ static void menu_pad_string (char *s, size_t n) 2569 + @@ -184,7 +187,7 @@ 697 2570 { 698 2571 char *scratch = safe_strdup (s); 699 2572 int shift = option (OPTARROWCURSOR) ? 3 : 0; ··· 702 2575 703 2576 mutt_format_string (s, n, cols, cols, FMT_LEFT, ' ', scratch, mutt_strlen (scratch), 1); 704 2577 s[n - 1] = 0; 705 - @@ -239,6 +240,7 @@ void menu_redraw_index (MUTTMENU *menu) 2578 + @@ -237,6 +240,9 @@ 706 2579 int do_color; 707 2580 int attr; 708 2581 709 - + draw_sidebar(1); 2582 + +#ifdef USE_SIDEBAR 2583 + + mutt_sb_draw(); 2584 + +#endif 710 2585 for (i = menu->top; i < menu->top + menu->pagelen; i++) 711 2586 { 712 2587 if (i < menu->max) 713 - @@ -249,7 +251,7 @@ void menu_redraw_index (MUTTMENU *menu) 2588 + @@ -247,7 +253,7 @@ 714 2589 menu_pad_string (buf, sizeof (buf)); 715 2590 716 2591 ATTRSET(attr); ··· 719 2594 do_color = 1; 720 2595 721 2596 if (i == menu->current) 722 - @@ -272,7 +274,7 @@ void menu_redraw_index (MUTTMENU *menu) 2597 + @@ -270,7 +276,11 @@ 723 2598 else 724 2599 { 725 2600 NORMAL_COLOR; 726 - - CLEARLINE(i - menu->top + menu->offset); 2601 + +#ifdef USE_SIDEBAR 727 2602 + CLEARLINE_WIN(i - menu->top + menu->offset); 2603 + +#else 2604 + CLEARLINE(i - menu->top + menu->offset); 2605 + +#endif 728 2606 } 729 2607 } 730 2608 NORMAL_COLOR; 731 - @@ -289,7 +291,7 @@ void menu_redraw_motion (MUTTMENU *menu) 2609 + @@ -287,7 +297,7 @@ 732 2610 return; 733 2611 } 734 2612 ··· 737 2615 ATTRSET(menu->color (menu->oldcurrent)); 738 2616 739 2617 if (option (OPTARROWCURSOR)) 740 - @@ -301,13 +303,13 @@ void menu_redraw_motion (MUTTMENU *menu) 2618 + @@ -299,13 +309,13 @@ 741 2619 { 742 2620 menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); 743 2621 menu_pad_string (buf, sizeof (buf)); ··· 753 2631 } 754 2632 else 755 2633 { 756 - @@ -320,7 +322,7 @@ void menu_redraw_motion (MUTTMENU *menu) 2634 + @@ -318,7 +328,7 @@ 757 2635 menu_make_entry (buf, sizeof (buf), menu, menu->current); 758 2636 menu_pad_string (buf, sizeof (buf)); 759 2637 SETCOLOR(MT_COLOR_INDICATOR); ··· 762 2640 print_enriched_string (menu->color(menu->current), (unsigned char *) buf, 0); 763 2641 } 764 2642 menu->redraw &= REDRAW_STATUS; 765 - @@ -332,7 +334,7 @@ void menu_redraw_current (MUTTMENU *menu) 2643 + @@ -330,7 +340,7 @@ 766 2644 char buf[LONG_STRING]; 767 2645 int attr = menu->color (menu->current); 768 2646 ··· 771 2649 menu_make_entry (buf, sizeof (buf), menu, menu->current); 772 2650 menu_pad_string (buf, sizeof (buf)); 773 2651 774 - @@ -881,7 +883,7 @@ int mutt_menuLoop (MUTTMENU *menu) 2652 + @@ -873,7 +883,7 @@ 775 2653 776 2654 777 2655 if (option (OPTARROWCURSOR)) ··· 780 2658 else if (option (OPTBRAILLEFRIENDLY)) 781 2659 move (menu->current - menu->top + menu->offset, 0); 782 2660 else 783 - diff --git a/mh.c b/mh.c 784 - index 63e12d2..4a84a99 100644 785 - --- a/mh.c 786 - +++ b/mh.c 787 - @@ -295,6 +295,28 @@ void mh_buffy(BUFFY *b) 2661 + diff -urN mutt-1.6.1/mh.c mutt-1.6.1-sidebar/mh.c 2662 + --- mutt-1.6.1/mh.c 2016-06-12 18:43:00.410447715 +0100 2663 + +++ mutt-1.6.1-sidebar/mh.c 2016-06-12 18:43:03.962503107 +0100 2664 + @@ -295,6 +295,48 @@ 788 2665 mhs_free_sequences (&mhs); 789 2666 } 790 2667 791 - +void mh_buffy_update (const char *path, int *msgcount, int *msg_unread, int *msg_flagged) 2668 + +#ifdef USE_SIDEBAR 2669 + +/** 2670 + + * mh_buffy_update - Update messages counts for an mh mailbox 2671 + + * @mailbox: BUFFY representing a maildir mailbox 2672 + + * 2673 + + * Read through an mh mailbox and count messages. Save the number of new, 2674 + + * flagged messages and a timestamp for now. 2675 + + */ 2676 + +void 2677 + +mh_buffy_update (BUFFY *mailbox) 792 2678 +{ 793 2679 + int i; 794 2680 + struct mh_sequences mhs; 2681 + + 2682 + + if (!mailbox) 2683 + + return; 2684 + + 2685 + + if (!option (OPTSIDEBAR)) 2686 + + return; 2687 + + 795 2688 + memset (&mhs, 0, sizeof (mhs)); 796 2689 + 797 - + if (mh_read_sequences (&mhs, path) < 0) 2690 + + if (mh_read_sequences (&mhs, mailbox->path) < 0) 798 2691 + return; 799 2692 + 800 - + msgcount = 0; 801 - + msg_unread = 0; 802 - + msg_flagged = 0; 2693 + + mailbox->msg_count = 0; 2694 + + mailbox->msg_unread = 0; 2695 + + mailbox->msg_flagged = 0; 2696 + + 803 2697 + for (i = 0; i <= mhs.max; i++) 804 - + msgcount++; 805 - + if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { 806 - + msg_unread++; 2698 + + { 2699 + + mailbox->msg_count++; 2700 + + if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) 2701 + + mailbox->msg_unread++; 2702 + + if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) 2703 + + mailbox->msg_flagged++; 807 2704 + } 808 - + if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) 809 - + msg_flagged++; 810 2705 + mhs_free_sequences (&mhs); 2706 + + mailbox->sb_last_checked = time (NULL); 811 2707 +} 2708 + +#endif 812 2709 + 813 2710 static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) 814 2711 { 815 2712 int fd; 816 - diff --git a/mutt.h b/mutt.h 817 - index 01d47de..5f25406 100644 818 - --- a/mutt.h 819 - +++ b/mutt.h 820 - @@ -435,6 +435,8 @@ enum 2713 + diff -urN mutt-1.6.1/mutt_curses.h mutt-1.6.1-sidebar/mutt_curses.h 2714 + --- mutt-1.6.1/mutt_curses.h 2016-06-12 18:43:00.410447715 +0100 2715 + +++ mutt-1.6.1-sidebar/mutt_curses.h 2016-06-12 18:43:03.962503107 +0100 2716 + @@ -64,6 +64,9 @@ 2717 + #undef lines 2718 + #endif /* lines */ 2719 + 2720 + +#ifdef USE_SIDEBAR 2721 + +#define CLEARLINE_WIN(x) move (x,SidebarWidth), clrtoeol() 2722 + +#endif 2723 + #define CLEARLINE(x) move(x,0), clrtoeol() 2724 + #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) 2725 + #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) 2726 + @@ -124,6 +127,14 @@ 2727 + MT_COLOR_UNDERLINE, 2728 + MT_COLOR_INDEX, 2729 + MT_COLOR_PROMPT, 2730 + +#ifdef USE_SIDEBAR 2731 + + MT_COLOR_DIVIDER, 2732 + + MT_COLOR_FLAGGED, 2733 + + MT_COLOR_HIGHLIGHT, 2734 + + MT_COLOR_NEW, 2735 + + MT_COLOR_SB_INDICATOR, 2736 + + MT_COLOR_SB_SPOOLFILE, 2737 + +#endif 2738 + MT_COLOR_MAX 2739 + }; 2740 + 2741 + @@ -163,12 +174,16 @@ 2742 + 2743 + static inline int mutt_term_width(short wrap) 2744 + { 2745 + + int cols = COLS; 2746 + +#ifdef USE_SIDEBAR 2747 + + cols -= SidebarWidth; 2748 + +#endif 2749 + if (wrap < 0) 2750 + - return COLS > -wrap ? COLS + wrap : COLS; 2751 + + return cols > -wrap ? cols + wrap : cols; 2752 + else if (wrap) 2753 + - return wrap < COLS ? wrap : COLS; 2754 + + return wrap < cols ? wrap : cols; 2755 + else 2756 + - return COLS; 2757 + + return cols; 2758 + } 2759 + 2760 + extern int *ColorQuote; 2761 + diff -urN mutt-1.6.1/mutt.h mutt-1.6.1-sidebar/mutt.h 2762 + --- mutt-1.6.1/mutt.h 2016-06-12 18:43:00.410447715 +0100 2763 + +++ mutt-1.6.1-sidebar/mutt.h 2016-06-12 18:43:03.962503107 +0100 2764 + @@ -428,6 +428,13 @@ 821 2765 OPTSAVEEMPTY, 822 2766 OPTSAVENAME, 823 2767 OPTSCORE, 2768 + +#ifdef USE_SIDEBAR 824 2769 + OPTSIDEBAR, 825 - + OPTSIDEBARSORT, 2770 + + OPTSIDEBARFOLDERINDENT, 2771 + + OPTSIDEBARNEWMAILONLY, 2772 + + OPTSIDEBARNEXTNEWWRAP, 2773 + + OPTSIDEBARSHORTPATH, 2774 + +#endif 826 2775 OPTSIGDASHES, 827 2776 OPTSIGONTOP, 828 2777 OPTSORTRE, 829 - @@ -880,6 +882,7 @@ typedef struct _context 2778 + @@ -872,6 +879,9 @@ 830 2779 { 831 2780 char *path; 832 2781 FILE *fp; 2782 + +#ifdef USE_SIDEBAR 833 2783 + time_t atime; 2784 + +#endif 834 2785 time_t mtime; 835 2786 off_t size; 836 2787 off_t vsize; 837 - @@ -920,6 +923,7 @@ typedef struct _context 2788 + @@ -906,6 +916,9 @@ 838 2789 unsigned int quiet : 1; /* inhibit status messages? */ 839 2790 unsigned int collapsed : 1; /* are all threads collapsed? */ 840 2791 unsigned int closing : 1; /* mailbox is being closed */ 2792 + +#ifdef USE_SIDEBAR 841 2793 + unsigned int peekonly : 1; /* just taking a glance, revert atime */ 2794 + +#endif 842 2795 843 2796 /* driver hooks */ 844 2797 void *data; /* driver specific data */ 845 - diff --git a/mutt_curses.h b/mutt_curses.h 846 - index f8bc47c..ef9884e 100644 847 - --- a/mutt_curses.h 848 - +++ b/mutt_curses.h 849 - @@ -64,6 +64,7 @@ 850 - #undef lines 851 - #endif /* lines */ 852 - 853 - +#define CLEARLINE_WIN(x) move(x,SidebarWidth), clrtoeol() 854 - #define CLEARLINE(x) move(x,0), clrtoeol() 855 - #define CENTERLINE(x,y) move(y, (COLS-strlen(x))/2), addstr(x) 856 - #define BEEP() do { if (option (OPTBEEP)) beep(); } while (0) 857 - @@ -121,6 +122,8 @@ enum 858 - MT_COLOR_UNDERLINE, 859 - MT_COLOR_INDEX, 860 - MT_COLOR_PROMPT, 861 - + MT_COLOR_NEW, 862 - + MT_COLOR_FLAGGED, 863 - MT_COLOR_MAX 864 - }; 865 - 866 - diff --git a/muttlib.c b/muttlib.c 867 - index c1d565f..039e7c3 100644 868 - --- a/muttlib.c 869 - +++ b/muttlib.c 870 - @@ -1279,6 +1279,8 @@ void mutt_FormatString (char *dest, /* output buffer */ 2798 + diff -urN mutt-1.6.1/muttlib.c mutt-1.6.1-sidebar/muttlib.c 2799 + --- mutt-1.6.1/muttlib.c 2016-06-12 18:43:00.411447731 +0100 2800 + +++ mutt-1.6.1-sidebar/muttlib.c 2016-06-12 18:43:03.963503122 +0100 2801 + @@ -1282,7 +1282,7 @@ 871 2802 pl = pw = 1; 872 2803 873 2804 /* see if there's room to add content, else ignore */ 874 - + if ( DrawFullLine ) 875 - + { 876 - if ((col < COLS && wlen < destlen) || soft) 2805 + - if ((col < COLS && wlen < destlen) || soft) 2806 + + if ((col < (COLS - SidebarWidth) && (wlen < destlen)) || soft) 877 2807 { 878 2808 int pad; 879 - @@ -1322,6 +1324,52 @@ void mutt_FormatString (char *dest, /* output buffer */ 880 - col += wid; 881 - src += pl; 882 - } 883 - + } 884 - + else 885 - + { 886 - + if ((col < COLS-SidebarWidth && wlen < destlen) || soft) 887 - + { 888 - + int pad; 889 - + 890 - + /* get contents after padding */ 891 - + mutt_FormatString (buf, sizeof (buf), 0, src + pl, callback, data, flags); 892 - + len = mutt_strlen (buf); 893 - + wid = mutt_strwidth (buf); 894 - + 895 - + /* try to consume as many columns as we can, if we don't have 896 - + * memory for that, use as much memory as possible */ 2809 + 2810 + @@ -1293,7 +1293,7 @@ 2811 + 2812 + /* try to consume as many columns as we can, if we don't have 2813 + * memory for that, use as much memory as possible */ 2814 + - pad = (COLS - col - wid) / pw; 897 2815 + pad = (COLS - SidebarWidth - col - wid) / pw; 898 - + if (pad > 0 && wlen + (pad * pl) + len > destlen) 899 - + pad = ((signed)(destlen - wlen - len)) / pl; 900 - + if (pad > 0) 901 - + { 902 - + while (pad--) 903 - + { 904 - + memcpy (wptr, src, pl); 905 - + wptr += pl; 906 - + wlen += pl; 907 - + col += pw; 908 - + } 909 - + } 910 - + else if (soft && pad < 0) 911 - + { 912 - + /* \0-terminate dest for length computation in mutt_wstr_trunc() */ 913 - + *wptr = 0; 914 - + /* make sure right part is at most as wide as display */ 915 - + len = mutt_wstr_trunc (buf, destlen, COLS, &wid); 916 - + /* truncate left so that right part fits completely in */ 917 - + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad, &col); 918 - + wptr = dest + wlen; 919 - + } 920 - + if (len + wlen > destlen) 2816 + if (pad > 0 && wlen + (pad * pl) + len > destlen) 2817 + pad = ((signed)(destlen - wlen - len)) / pl; 2818 + if (pad > 0) 2819 + @@ -1312,13 +1312,13 @@ 2820 + /* \0-terminate dest for length computation in mutt_wstr_trunc() */ 2821 + *wptr = 0; 2822 + /* make sure right part is at most as wide as display */ 2823 + - len = mutt_wstr_trunc (buf, destlen, COLS-offset, &wid); 2824 + + len = mutt_wstr_trunc (buf, destlen, COLS - offset - SidebarWidth, &wid); 2825 + /* truncate left so that right part fits completely in */ 2826 + wlen = mutt_wstr_trunc (dest, destlen - len, col + pad*pw -offset, &col); 2827 + wptr = dest + wlen; 2828 + } 2829 + if (len + wlen > destlen) 2830 + - len = mutt_wstr_trunc (buf, destlen - wlen, COLS - col, NULL); 921 2831 + len = mutt_wstr_trunc (buf, destlen - wlen, COLS - SidebarWidth - col, NULL); 922 - + memcpy (wptr, buf, len); 923 - + wptr += len; 924 - + wlen += len; 925 - + col += wid; 926 - + src += pl; 927 - + } 928 - + } 929 - break; /* skip rest of input */ 930 - } 931 - else if (ch == '|') 932 - diff --git a/mx.c b/mx.c 933 - index 0a1a80e..e80b8ff 100644 934 - --- a/mx.c 935 - +++ b/mx.c 936 - @@ -595,6 +595,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags) 2832 + memcpy (wptr, buf, len); 2833 + wptr += len; 2834 + wlen += len; 2835 + diff -urN mutt-1.6.1/mutt_menu.h mutt-1.6.1-sidebar/mutt_menu.h 2836 + --- mutt-1.6.1/mutt_menu.h 2016-06-12 18:43:00.410447715 +0100 2837 + +++ mutt-1.6.1-sidebar/mutt_menu.h 2016-06-12 18:43:03.962503107 +0100 2838 + @@ -34,6 +34,9 @@ 2839 + #define REDRAW_FULL (1<<5) 2840 + #define REDRAW_BODY (1<<6) 2841 + #define REDRAW_SIGWINCH (1<<7) 2842 + +#ifdef USE_SIDEBAR 2843 + +#define REDRAW_SIDEBAR (1<<8) 2844 + +#endif 2845 + 2846 + #define M_MODEFMT "-- Mutt: %s" 2847 + 2848 + diff -urN mutt-1.6.1/mx.c mutt-1.6.1-sidebar/mx.c 2849 + --- mutt-1.6.1/mx.c 2016-06-12 18:43:00.411447731 +0100 2850 + +++ mutt-1.6.1-sidebar/mx.c 2016-06-12 18:43:03.963503122 +0100 2851 + @@ -29,6 +29,9 @@ 2852 + #include "copy.h" 2853 + #include "keymap.h" 2854 + #include "url.h" 2855 + +#ifdef USE_SIDEBAR 2856 + +#include "sidebar.h" 2857 + +#endif 2858 + 2859 + #ifdef USE_IMAP 2860 + #include "imap.h" 2861 + @@ -580,6 +583,7 @@ 937 2862 * M_APPEND open mailbox for appending 938 2863 * M_READONLY open mailbox in read-only mode 939 2864 * M_QUIET only print error messages ··· 941 2866 * ctx if non-null, context struct to use 942 2867 */ 943 2868 CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) 944 - @@ -617,6 +618,8 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) 2869 + @@ -602,6 +606,10 @@ 945 2870 ctx->quiet = 1; 946 2871 if (flags & M_READONLY) 947 2872 ctx->readonly = 1; 2873 + +#ifdef USE_SIDEBAR 948 2874 + if (flags & M_PEEK) 949 2875 + ctx->peekonly = 1; 2876 + +#endif 950 2877 951 2878 if (flags & (M_APPEND|M_NEWFOLDER)) 952 2879 { 953 - @@ -721,9 +724,21 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx) 954 - void mx_fastclose_mailbox (CONTEXT *ctx) 955 - { 956 - int i; 957 - +#ifndef BUFFY_SIZE 958 - + struct utimbuf ut; 959 - +#endif 960 - 2880 + @@ -705,8 +713,21 @@ 961 2881 if(!ctx) 962 2882 return; 963 - +#ifndef BUFFY_SIZE 2883 + 2884 + +#ifdef USE_SIDEBAR 964 2885 + /* fix up the times so buffy won't get confused */ 965 - + if (ctx->peekonly && ctx->path && ctx->mtime > ctx->atime) 966 - + { 967 - + ut.actime = ctx->atime; 2886 + + struct utimbuf ut; 2887 + + if (ctx->peekonly && ctx->path && (ctx->mtime > ctx->atime)) { 2888 + + ut.actime = ctx->atime; 968 2889 + ut.modtime = ctx->mtime; 969 - + utime (ctx->path, &ut); 2890 + + utime (ctx->path, &ut); 970 2891 + } 971 2892 +#endif 972 - 2893 + + 973 2894 /* never announce that a mailbox we've just left has new mail. #3290 974 2895 * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ 975 - diff --git a/mx.h b/mx.h 976 - index 2ef4ec7..4aabadf 100644 977 - --- a/mx.h 978 - +++ b/mx.h 979 - @@ -60,6 +60,7 @@ void mbox_reset_atime (CONTEXT *, struct stat *); 2896 + +#ifdef USE_SIDEBAR 2897 + + if (!ctx->peekonly) 2898 + +#endif 2899 + mutt_buffy_setnotified(ctx->path); 2900 + 2901 + if (ctx->mx_close) 2902 + @@ -812,6 +833,12 @@ 2903 + if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read 2904 + && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) 2905 + read_msgs++; 2906 + +#ifdef USE_SIDEBAR 2907 + + if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read) 2908 + + ctx->unread--; 2909 + + if (ctx->hdrs[i]->deleted && ctx->hdrs[i]->flagged) 2910 + + ctx->flagged--; 2911 + +#endif 2912 + } 2913 + 2914 + if (read_msgs && quadoption (OPT_MOVE) != M_NO) 2915 + @@ -981,6 +1008,11 @@ 2916 + !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) 2917 + mx_unlink_empty (ctx->path); 2918 + 2919 + +#ifdef USE_SIDEBAR 2920 + + ctx->msgcount -= ctx->deleted; 2921 + + mutt_sb_set_buffystats (ctx); 2922 + +#endif 2923 + + 2924 + mx_fastclose_mailbox (ctx); 2925 + 2926 + return 0; 2927 + diff -urN mutt-1.6.1/mx.h mutt-1.6.1-sidebar/mx.h 2928 + --- mutt-1.6.1/mx.h 2016-06-12 18:43:00.411447731 +0100 2929 + +++ mutt-1.6.1-sidebar/mx.h 2016-06-12 18:43:03.963503122 +0100 2930 + @@ -26,6 +26,7 @@ 2931 + #define _MX_H 2932 + 2933 + #include "mailbox.h" 2934 + +#include "buffy.h" 2935 + 2936 + /* supported mailbox formats */ 2937 + enum 2938 + @@ -57,6 +58,9 @@ 980 2939 int mh_read_dir (CONTEXT *, const char *); 981 2940 int mh_sync_mailbox (CONTEXT *, int *); 982 2941 int mh_check_mailbox (CONTEXT *, int *); 983 - +void mh_buffy_update (const char *, int *, int *, int *); 2942 + +#ifdef USE_SIDEBAR 2943 + +void mh_buffy_update (BUFFY *mailbox); 2944 + +#endif 984 2945 int mh_check_empty (const char *); 985 2946 986 2947 int maildir_read_dir (CONTEXT *); 987 - diff --git a/pager.c b/pager.c 988 - index c99f1e4..5cfcb75 100644 989 - --- a/pager.c 990 - +++ b/pager.c 991 - @@ -29,6 +29,7 @@ 2948 + diff -urN mutt-1.6.1/OPS.SIDEBAR mutt-1.6.1-sidebar/OPS.SIDEBAR 2949 + --- mutt-1.6.1/OPS.SIDEBAR 1970-01-01 01:00:00.000000000 +0100 2950 + +++ mutt-1.6.1-sidebar/OPS.SIDEBAR 2016-06-12 18:43:03.944502826 +0100 2951 + @@ -0,0 +1,8 @@ 2952 + +OP_SIDEBAR_NEXT "Move the highlight to next mailbox" 2953 + +OP_SIDEBAR_NEXT_NEW "Move the highlight to next mailbox with new mail" 2954 + +OP_SIDEBAR_OPEN "Open highlighted mailbox" 2955 + +OP_SIDEBAR_PAGE_DOWN "Scroll the Sidebar down 1 page" 2956 + +OP_SIDEBAR_PAGE_UP "Scroll the Sidebar up 1 page" 2957 + +OP_SIDEBAR_PREV "Move the highlight to previous mailbox" 2958 + +OP_SIDEBAR_PREV_NEW "Move the highlight to previous mailbox with new mail" 2959 + +OP_SIDEBAR_TOGGLE_VISIBLE "Make the Sidebar (in)visible" 2960 + diff -urN mutt-1.6.1/pager.c mutt-1.6.1-sidebar/pager.c 2961 + --- mutt-1.6.1/pager.c 2016-06-12 18:43:00.412447746 +0100 2962 + +++ mutt-1.6.1-sidebar/pager.c 2016-06-12 18:43:03.964503138 +0100 2963 + @@ -29,6 +29,9 @@ 992 2964 #include "pager.h" 993 2965 #include "attach.h" 994 2966 #include "mbyte.h" 2967 + +#ifdef USE_SIDEBAR 995 2968 +#include "sidebar.h" 2969 + +#endif 996 2970 997 2971 #include "mutt_crypt.h" 998 2972 999 - @@ -1095,6 +1096,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf, 1000 - wchar_t wc; 1001 - mbstate_t mbstate; 1002 - int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); 1003 - + wrap_cols -= SidebarWidth; 2973 + @@ -1491,7 +1494,7 @@ 2974 + * a newline (grr!). 2975 + */ 2976 + #ifndef USE_SLANG_CURSES 2977 + - if (col < COLS) 2978 + + if (col < (COLS - SidebarWidth)) 2979 + #endif 2980 + addch ('\n'); 1004 2981 1005 - if (check_attachment_marker ((char *)buf) == 0) 1006 - wrap_cols = COLS; 1007 - @@ -1746,7 +1748,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) 2982 + @@ -1573,6 +1576,7 @@ 2983 + 2984 + int bodyoffset = 1; /* offset of first line of real text */ 2985 + int statusoffset = 0; /* offset for the status bar */ 2986 + + int statuswidth = COLS; 2987 + int helpoffset = LINES - 2; /* offset for the help bar. */ 2988 + int bodylen = LINES - 2 - bodyoffset; /* length of displayable area */ 2989 + 2990 + @@ -1747,7 +1751,7 @@ 1008 2991 if ((redraw & REDRAW_BODY) || topline != oldtopline) 1009 2992 { 1010 2993 do { ··· 1013 2996 curline = oldtopline = topline; 1014 2997 lines = 0; 1015 2998 force_redraw = 0; 1016 - @@ -1759,6 +1761,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) 2999 + @@ -1760,6 +1764,9 @@ 1017 3000 &QuoteList, &q_level, &force_redraw, &SearchRE) > 0) 1018 3001 lines++; 1019 3002 curline++; 1020 - + move(lines + bodyoffset, SidebarWidth); 3003 + +#ifdef USE_SIDEBAR 3004 + + move (lines + bodyoffset, SidebarWidth); 3005 + +#endif 1021 3006 } 1022 3007 last_offset = lineInfo[curline].offset; 1023 3008 } while (force_redraw); 1024 - @@ -1771,6 +1774,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) 3009 + @@ -1772,6 +1779,9 @@ 1025 3010 addch ('~'); 1026 3011 addch ('\n'); 1027 3012 lines++; 1028 - + move(lines + bodyoffset, SidebarWidth); 3013 + +#ifdef USE_SIDEBAR 3014 + + move (lines + bodyoffset, SidebarWidth); 3015 + +#endif 1029 3016 } 1030 3017 NORMAL_COLOR; 1031 3018 1032 - @@ -1794,22 +1798,22 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) 3019 + @@ -1789,29 +1799,49 @@ 3020 + hfi.ctx = Context; 3021 + hfi.pager_progress = pager_progress_str; 3022 + 3023 + +#ifdef USE_SIDEBAR 3024 + + statuswidth = COLS; 3025 + + if (option (OPTSTATUSONTOP) && (PagerIndexLines > 0)) 3026 + + statuswidth -= SidebarWidth; 3027 + +#endif 3028 + + 3029 + if (last_pos < sb.st_size - 1) 3030 + snprintf(pager_progress_str, sizeof(pager_progress_str), OFF_T_FMT "%%", (100 * last_offset / sb.st_size)); 3031 + else 1033 3032 strfcpy(pager_progress_str, (topline == 0) ? "all" : "end", sizeof(pager_progress_str)); 1034 3033 1035 3034 /* print out the pager status bar */ 1036 3035 - move (statusoffset, 0); 1037 3036 + move (statusoffset, SidebarWidth); 1038 3037 SETCOLOR (MT_COLOR_STATUS); 3038 + +#ifdef USE_SIDEBAR 3039 + + short sw = SidebarWidth; 3040 + + if (option (OPTSTATUSONTOP) && PagerIndexLines > 0) { 3041 + + CLEARLINE_WIN (statusoffset); 3042 + + } else { 3043 + + CLEARLINE (statusoffset); 3044 + + /* Temporarily lie about the sidebar width */ 3045 + + SidebarWidth = 0; 3046 + + } 3047 + +#endif 1039 3048 1040 3049 if (IsHeader (extra) || IsMsgAttach (extra)) 1041 3050 { 1042 3051 - size_t l1 = COLS * MB_LEN_MAX; 1043 - + size_t l1 = (COLS-SidebarWidth) * MB_LEN_MAX; 3052 + + size_t l1 = statuswidth * MB_LEN_MAX; 1044 3053 size_t l2 = sizeof (buffer); 1045 3054 hfi.hdr = (IsHeader (extra)) ? extra->hdr : extra->bdy->hdr; 1046 3055 mutt_make_string_info (buffer, l1 < l2 ? l1 : l2, NONULL (PagerFmt), &hfi, M_FORMAT_MAKEPRINT); 1047 3056 - mutt_paddstr (COLS, buffer); 1048 - + mutt_paddstr (COLS-SidebarWidth, buffer); 3057 + + mutt_paddstr (statuswidth, buffer); 1049 3058 } 1050 3059 else 1051 3060 { 1052 3061 char bn[STRING]; 1053 3062 snprintf (bn, sizeof (bn), "%s (%s)", banner, pager_progress_str); 1054 3063 - mutt_paddstr (COLS, bn); 1055 - + mutt_paddstr (COLS-SidebarWidth, bn); 3064 + + mutt_paddstr (statuswidth, bn); 1056 3065 } 3066 + +#ifdef USE_SIDEBAR 3067 + + if (!option (OPTSTATUSONTOP) || PagerIndexLines == 0) 3068 + + SidebarWidth = sw; /* Restore the sidebar width */ 3069 + +#endif 1057 3070 NORMAL_COLOR; 1058 3071 if (option(OPTTSENABLED) && TSSupported) 1059 - @@ -1826,16 +1830,21 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) 3072 + { 3073 + @@ -1827,16 +1857,26 @@ 1060 3074 /* redraw the pager_index indicator, because the 1061 3075 * flags for this message might have changed. */ 1062 3076 menu_redraw_current (index); 1063 - + draw_sidebar(MENU_PAGER); 3077 + +#ifdef USE_SIDEBAR 3078 + + mutt_sb_draw(); 3079 + +#endif 1064 3080 1065 3081 /* print out the index status bar */ 1066 3082 menu_status_line (buffer, sizeof (buffer), index, NONULL(Status)); 1067 3083 1068 3084 - move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 0); 1069 - + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), SidebarWidth); 3085 + + move (indexoffset + (option (OPTSTATUSONTOP) ? 0 : (indexlen - 1)), 3086 + + (option(OPTSTATUSONTOP) ? 0: SidebarWidth)); 1070 3087 SETCOLOR (MT_COLOR_STATUS); 1071 3088 - mutt_paddstr (COLS, buffer); 1072 - + mutt_paddstr (COLS-SidebarWidth, buffer); 3089 + + mutt_paddstr (COLS - (option(OPTSTATUSONTOP) ? 0 : SidebarWidth), buffer); 1073 3090 NORMAL_COLOR; 1074 3091 } 1075 3092 3093 + +#ifdef USE_SIDEBAR 1076 3094 + /* if we're not using the index, update every time */ 1077 - + if ( index == 0 ) 1078 - + draw_sidebar(MENU_PAGER); 3095 + + if (index == 0) 3096 + + mutt_sb_draw(); 3097 + +#endif 1079 3098 + 1080 3099 redraw = 0; 1081 3100 1082 3101 if (option(OPTBRAILLEFRIENDLY)) { 1083 - @@ -2776,6 +2785,13 @@ search_next: 3102 + @@ -2498,8 +2538,12 @@ 3103 + ch = 0; 3104 + } 3105 + 3106 + - if (option (OPTFORCEREDRAWPAGER)) 3107 + + if (option (OPTFORCEREDRAWPAGER)) { 3108 + redraw = REDRAW_FULL; 3109 + +#ifdef USE_SIDEBAR 3110 + + mutt_sb_draw(); 3111 + +#endif 3112 + + } 3113 + unset_option (OPTFORCEREDRAWINDEX); 3114 + unset_option (OPTFORCEREDRAWPAGER); 3115 + break; 3116 + @@ -2777,6 +2821,22 @@ 1084 3117 mutt_what_key (); 1085 3118 break; 1086 3119 1087 - + case OP_SIDEBAR_SCROLL_UP: 1088 - + case OP_SIDEBAR_SCROLL_DOWN: 3120 + +#ifdef USE_SIDEBAR 1089 3121 + case OP_SIDEBAR_NEXT: 3122 + + case OP_SIDEBAR_NEXT_NEW: 3123 + + case OP_SIDEBAR_PAGE_DOWN: 3124 + + case OP_SIDEBAR_PAGE_UP: 1090 3125 + case OP_SIDEBAR_PREV: 1091 - + scroll_sidebar(ch, MENU_PAGER); 1092 - + break; 3126 + + case OP_SIDEBAR_PREV_NEW: 3127 + + mutt_sb_change_mailbox (ch); 3128 + + break; 3129 + + 3130 + + case OP_SIDEBAR_TOGGLE_VISIBLE: 3131 + + toggle_option (OPTSIDEBAR); 3132 + + redraw = REDRAW_FULL; 3133 + + break; 3134 + +#endif 1093 3135 + 1094 3136 default: 1095 3137 ch = -1; 1096 3138 break; 1097 - diff --git a/sidebar.c b/sidebar.c 1098 - new file mode 100644 1099 - index 0000000..6098c2a 1100 - --- /dev/null 1101 - +++ b/sidebar.c 1102 - @@ -0,0 +1,333 @@ 1103 - +/* 1104 - + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> 3139 + diff -urN mutt-1.6.1/PATCHES mutt-1.6.1-sidebar/PATCHES 3140 + --- mutt-1.6.1/PATCHES 2016-06-12 18:43:00.395447481 +0100 3141 + +++ mutt-1.6.1-sidebar/PATCHES 2016-06-12 18:43:03.949502904 +0100 3142 + @@ -0,0 +1 @@ 3143 + +patch-sidebar-neo-20160612 3144 + diff -urN mutt-1.6.1/README.sidebar mutt-1.6.1-sidebar/README.sidebar 3145 + --- mutt-1.6.1/README.sidebar 1970-01-01 01:00:00.000000000 +0100 3146 + +++ mutt-1.6.1-sidebar/README.sidebar 2016-06-12 18:43:03.792500456 +0100 3147 + @@ -0,0 +1,145 @@ 3148 + +Sidebar Patch 3149 + +============= 3150 + + 3151 + + Overview of mailboxes 3152 + + 3153 + + NOTES: 3154 + + 3155 + + If you haven't used the sidebar before, you might like to read the 3156 + + Sidebar Introduction: 3157 + + 3158 + + http://www.neomutt.org/sidebar-intro.html 3159 + + 3160 + + If you have used an older version of the Sidebar, please note that some 3161 + + of the configuration has changed. 3162 + + 3163 + + http://www.neomutt.org/sidebar-intro.html#intro-sidebar-config-changes 3164 + + 3165 + +Patch 3166 + +----- 3167 + + 3168 + + To check if Mutt supports "Sidebar", look for "+USE_SIDEBAR" in the mutt 3169 + + version. 3170 + + 3171 + + Dependencies 3172 + + * mutt-1.6.1 3173 + + 3174 + +Introduction 3175 + +------------ 3176 + + 3177 + + The Sidebar shows a list of all your mailboxes. The list can be turned on 3178 + + and off, it can be themed and the list style can be configured. 3179 + + 3180 + + This part of the manual is a reference guide. If you want a simple 3181 + + introduction with examples see the Sidebar Howto. If you just want to get 3182 + + started, you could use the sample Sidebar muttrc. 3183 + + 3184 + + This version of Sidebar is based on Terry Chan's [2015-11-11 3185 + + release](http://www.lunar-linux.org/mutt-sidebar/). It contains many new 3186 + + features, lots of bugfixes. 3187 + + 3188 + +Variables 3189 + +--------- 3190 + + 3191 + + Sidebar Variables 3192 + + 3193 + + | Name | Type | Default | 3194 + + |-------------------------|---------|-----------------------------| 3195 + + | 'sidebar_delim_chars' | string | '/.' | 3196 + + | 'sidebar_divider_char' | string | '|' | 3197 + + | 'sidebar_folder_indent' | boolean | 'no' | 3198 + + | 'sidebar_format' | string | '%B%?F? [%F]?%* %?N?%N/?%S' | 3199 + + | 'sidebar_indent_string' | string | '  ' (two spaces) | 3200 + + | 'sidebar_new_mail_only' | boolean | 'no' | 3201 + + | 'sidebar_next_new_wrap' | boolean | 'no' | 3202 + + | 'sidebar_refresh_time' | number | '60' | 3203 + + | 'sidebar_short_path' | boolean | 'no' | 3204 + + | 'sidebar_sort_method' | enum | 'SORT_ORDER' | 3205 + + | 'sidebar_visible' | boolean | 'no' | 3206 + + | 'sidebar_whitelist' | list | (empty) | 3207 + + | 'sidebar_width' | number | '20' | 3208 + + 3209 + +Functions 3210 + +--------- 3211 + + 3212 + + Sidebar Functions 3213 + + 3214 + + Sidebar adds the following functions to Mutt. By default, none of them are 3215 + + bound to keys. 3216 + + 3217 + + | Menus | Function | Description | 3218 + + |-------------|----------------------------|------------------------------------------------------| 3219 + + | index,pager | '<sidebar-next>' | Move the highlight to next mailbox | 3220 + + | index,pager | '<sidebar-next-new>' | Move the highlight to next mailbox with new mail | 3221 + + | index,pager | '<sidebar-open>' | Open highlighted mailbox | 3222 + + | index,pager | '<sidebar-page-down>' | Scroll the Sidebar down 1 page | 3223 + + | index,pager | '<sidebar-page-up>' | Scroll the Sidebar up 1 page | 3224 + + | index,pager | '<sidebar-prev>' | Move the highlight to previous mailbox | 3225 + + | index,pager | '<sidebar-prev-new>' | Move the highlight to previous mailbox with new mail | 3226 + + | index,pager | '<sidebar-toggle-visible>' | Make the Sidebar (in)visible | 3227 + + 3228 + +Commands 3229 + +-------- 3230 + + 3231 + + sidebar_whitelist mailbox [ mailbox... ] 3232 + + 3233 + +Colors 3234 + +------ 3235 + + 3236 + + Sidebar Colors 3237 + + 3238 + + | Name | Default Color | Description | 3239 + + |---------------------|------------------|------------------------------------------------------------------| 3240 + + | 'sidebar_divider' | default | The dividing line between the Sidebar and the Index/Pager panels | 3241 + + | 'sidebar_flagged' | default | Mailboxes containing flagged mail | 3242 + + | 'sidebar_highlight' | underline | Cursor to select a mailbox | 3243 + + | 'sidebar_indicator' | mutt 'indicator' | The mailbox open in the Index panel | 3244 + + | 'sidebar_new' | default | Mailboxes containing new mail | 3245 + + | 'sidebar_spoolfile' | default | Mailbox that receives incoming mail | 3246 + + 3247 + + If the sidebar_indicator color isn't set, then the default Mutt indicator 3248 + + color will be used (the color used in the index panel). 3249 + + 3250 + +Sort 3251 + +---- 3252 + + 3253 + + Sidebar Sort 3254 + + 3255 + + | Sort | Description | 3256 + + |------------|----------------------------| 3257 + + | 'alpha' | Alphabetically by path | 3258 + + | 'count' | Total number of messages | 3259 + + | 'flagged' | Number of flagged messages | 3260 + + | 'name' | Alphabetically by path | 3261 + + | 'new' | Number of new messages | 3262 + + | 'path' | Alphabetically by path | 3263 + + | 'unsorted' | Do not resort the paths | 3264 + + 3265 + +See Also 3266 + +-------- 3267 + + 3268 + + * Regular Expressions 3269 + + * Patterns 3270 + + * Color command 3271 + + * notmuch patch 3272 + + 3273 + +Known Bugs 3274 + +---------- 3275 + + 3276 + + Unsorted isn't 3277 + + 3278 + +Credits 3279 + +------- 3280 + + 3281 + + * Justin Hibbits <jrh29@po.cwru.edu> 3282 + + * Thomer M. Gil <mutt@thomer.com> 3283 + + * David Sterba <dsterba@suse.cz> 3284 + + * Evgeni Golov <evgeni@debian.org> 3285 + + * Fabian Groffen <grobian@gentoo.org> 3286 + + * Jason DeTiberus <jdetiber@redhat.com> 3287 + + * Stefan Assmann <sassmann@kpanic.de> 3288 + + * Steve Kemp <steve@steve.org.uk> 3289 + + * Terry Chan <tchan@lunar-linux.org> 3290 + + * Tyler Earnest <tylere@rne.st> 3291 + + * Richard Russon <rich@flatcap.org> 3292 + + 3293 + diff -urN mutt-1.6.1/sidebar.c mutt-1.6.1-sidebar/sidebar.c 3294 + --- mutt-1.6.1/sidebar.c 1970-01-01 01:00:00.000000000 +0100 3295 + +++ mutt-1.6.1-sidebar/sidebar.c 2016-06-14 18:46:00.000000000 +0100 3296 + @@ -0,0 +1,1090 @@ 3297 + +/* Copyright (C) 2004 Justin Hibbits <jrh29@po.cwru.edu> 1105 3298 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> 1106 - + * 3299 + + * Copyright (C) 2015-2016 Richard Russon <rich@flatcap.org> 3300 + + * 1107 3301 + * This program is free software; you can redistribute it and/or modify 1108 3302 + * it under the terms of the GNU General Public License as published by 1109 3303 + * the Free Software Foundation; either version 2 of the License, or 1110 3304 + * (at your option) any later version. 1111 - + * 3305 + + * 1112 3306 + * This program is distributed in the hope that it will be useful, 1113 3307 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 1114 3308 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1115 3309 + * GNU General Public License for more details. 1116 - + * 3310 + + * 1117 3311 + * You should have received a copy of the GNU General Public License 1118 3312 + * along with this program; if not, write to the Free Software 1119 3313 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 1120 - + */ 1121 - + 3314 + + */ 1122 3315 + 1123 3316 +#if HAVE_CONFIG_H 1124 3317 +# include "config.h" 1125 3318 +#endif 1126 3319 + 1127 3320 +#include "mutt.h" 1128 - +#include "mutt_menu.h" 1129 - +#include "mutt_curses.h" 1130 - +#include "sidebar.h" 1131 3321 +#include "buffy.h" 1132 - +#include <libgen.h> 1133 3322 +#include "keymap.h" 1134 - +#include <stdbool.h> 3323 + +#include "mutt_curses.h" 3324 + +#include "mutt_menu.h" 3325 + +#include "sort.h" 1135 3326 + 1136 - +/*BUFFY *CurBuffy = 0;*/ 1137 - +static BUFFY *TopBuffy = 0; 1138 - +static BUFFY *BottomBuffy = 0; 1139 - +static int known_lines = 0; 3327 + +/* Previous values for some sidebar config */ 3328 + +static short OldVisible; /* sidebar_visible */ 3329 + +static short OldWidth; /* sidebar_width */ 3330 + +static short PreviousSort; /* sidebar_sort_method */ 3331 + +static time_t LastRefresh; /* Time of last refresh */ 3332 + + 3333 + +/* Keep track of various BUFFYs */ 3334 + +static BUFFY *TopBuffy; /* First mailbox visible in sidebar */ 3335 + +static BUFFY *OpnBuffy; /* Current (open) mailbox */ 3336 + +static BUFFY *HilBuffy; /* Highlighted mailbox */ 3337 + +static BUFFY *BotBuffy; /* Last mailbox visible in sidebar */ 3338 + +static BUFFY *Outgoing; /* Last mailbox in the linked list */ 3339 + + 3340 + +/** 3341 + + * struct sidebar_entry - Info about folders in the sidebar 3342 + + * 3343 + + * Used in the mutt_FormatString callback 3344 + + */ 3345 + +struct sidebar_entry 3346 + +{ 3347 + + char box[STRING]; 3348 + + BUFFY *buffy; 3349 + +}; 3350 + + 1140 3351 + 1141 - +static int quick_log10(int n) 3352 + +/** 3353 + + * find_next_new - Find the next folder that contains new mail 3354 + + * @wrap: Wrap around to the beginning if the end is reached 3355 + + * 3356 + + * Search down the list of mail folders for one containing new mail. 3357 + + * 3358 + + * Returns: 3359 + + * BUFFY*: Success 3360 + + * NULL: Failure 3361 + + */ 3362 + +static BUFFY *find_next_new (int wrap) 1142 3363 +{ 1143 - + char string[32]; 1144 - + sprintf(string, "%d", n); 1145 - + return strlen(string); 3364 + + BUFFY *b = HilBuffy; 3365 + + if (!b) 3366 + + return NULL; 3367 + + 3368 + + do 3369 + + { 3370 + + b = b->next; 3371 + + if (!b && wrap) 3372 + + b = Incoming; 3373 + + if (!b || (b == HilBuffy)) 3374 + + break; 3375 + + if (b->msg_unread > 0) 3376 + + return b; 3377 + + } while (b); 3378 + + 3379 + + return NULL; 1146 3380 +} 1147 3381 + 1148 - +void calc_boundaries (int menu) 3382 + +/** 3383 + + * find_prev_new - Find the previous folder that contains new mail 3384 + + * @wrap: Wrap around to the beginning if the end is reached 3385 + + * 3386 + + * Search up the list of mail folders for one containing new mail. 3387 + + * 3388 + + * Returns: 3389 + + * BUFFY*: Success 3390 + + * NULL: Failure 3391 + + */ 3392 + +static BUFFY *find_prev_new (int wrap) 1149 3393 +{ 1150 - + BUFFY *tmp = Incoming; 3394 + + BUFFY *b = HilBuffy; 3395 + + if (!b) 3396 + + return NULL; 1151 3397 + 1152 - + if ( known_lines != LINES ) { 1153 - + TopBuffy = BottomBuffy = 0; 1154 - + known_lines = LINES; 1155 - + } 1156 - + for ( ; tmp->next != 0; tmp = tmp->next ) 1157 - + tmp->next->prev = tmp; 3398 + + do 3399 + + { 3400 + + b = b->prev; 3401 + + if (!b && wrap) 3402 + + b = Outgoing; 3403 + + if (!b || (b == HilBuffy)) 3404 + + break; 3405 + + if (b->msg_unread > 0) 3406 + + return b; 3407 + + } while (b); 1158 3408 + 1159 - + if ( TopBuffy == 0 && BottomBuffy == 0 ) 1160 - + TopBuffy = Incoming; 1161 - + if ( BottomBuffy == 0 ) { 1162 - + int count = LINES - 2 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); 1163 - + BottomBuffy = TopBuffy; 1164 - + while ( --count && BottomBuffy->next ) 1165 - + BottomBuffy = BottomBuffy->next; 1166 - + } 1167 - + else if ( TopBuffy == CurBuffy->next ) { 1168 - + int count = LINES - 2 - (menu != MENU_PAGER); 1169 - + BottomBuffy = CurBuffy; 1170 - + tmp = BottomBuffy; 1171 - + while ( --count && tmp->prev) 1172 - + tmp = tmp->prev; 1173 - + TopBuffy = tmp; 1174 - + } 1175 - + else if ( BottomBuffy == CurBuffy->prev ) { 1176 - + int count = LINES - 2 - (menu != MENU_PAGER); 1177 - + TopBuffy = CurBuffy; 1178 - + tmp = TopBuffy; 1179 - + while ( --count && tmp->next ) 1180 - + tmp = tmp->next; 1181 - + BottomBuffy = tmp; 1182 - + } 3409 + + return NULL; 1183 3410 +} 1184 3411 + 1185 - +char *make_sidebar_entry(char *box, int size, int new, int flagged) 3412 + +/** 3413 + + * cb_format_str - Create the string to show in the sidebar 3414 + + * @dest: Buffer in which to save string 3415 + + * @destlen: Buffer length 3416 + + * @col: Starting column, UNUSED 3417 + + * @op: printf-like operator, e.g. 'B' 3418 + + * @src: printf-like format string 3419 + + * @prefix: Field formatting string, UNUSED 3420 + + * @ifstring: If condition is met, display this string 3421 + + * @elsestring: Otherwise, display this string 3422 + + * @data: Pointer to our sidebar_entry 3423 + + * @flags: Format flags, e.g. M_FORMAT_OPTIONAL 3424 + + * 3425 + + * cb_format_str is a callback function for mutt_FormatString. It understands 3426 + + * five operators. '%B' : Mailbox name, '%F' : Number of flagged messages, 3427 + + * '%N' : Number of new messages, '%S' : Size (total number of messages), 3428 + + * '%!' : Icon denoting number of flagged messages. 3429 + + * 3430 + + * Returns: src (unchanged) 3431 + + */ 3432 + +static const char *cb_format_str(char *dest, size_t destlen, size_t col, char op, 3433 + + const char *src, const char *prefix, const char *ifstring, 3434 + + const char *elsestring, unsigned long data, format_flag flags) 1186 3435 +{ 1187 - + static char *entry = 0; 1188 - + char *c; 1189 - + int i = 0; 1190 - + int delim_len = strlen(SidebarDelim); 3436 + + struct sidebar_entry *sbe = (struct sidebar_entry *) data; 3437 + + unsigned int optional; 3438 + + char fmt[STRING]; 3439 + + 3440 + + if (!sbe || !dest) 3441 + + return src; 3442 + + 3443 + + dest[0] = 0; /* Just in case there's nothing to do */ 3444 + + 3445 + + BUFFY *b = sbe->buffy; 3446 + + if (!b) 3447 + + return src; 3448 + + 3449 + + int c = Context && (mutt_strcmp (Context->path, b->path) == 0); 3450 + + 3451 + + optional = flags & M_FORMAT_OPTIONAL; 3452 + + 3453 + + switch (op) 3454 + + { 3455 + + case 'B': 3456 + + mutt_format_s (dest, destlen, prefix, sbe->box); 3457 + + break; 3458 + + 3459 + + case 'd': 3460 + + if (!optional) 3461 + + { 3462 + + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 3463 + + snprintf (dest, destlen, fmt, c ? Context->deleted : 0); 3464 + + } 3465 + + else if ((c && Context->deleted == 0) || !c) 3466 + + optional = 0; 3467 + + break; 1191 3468 + 1192 - + c = realloc(entry, SidebarWidth - delim_len + 2); 1193 - + if ( c ) entry = c; 1194 - + entry[SidebarWidth - delim_len + 1] = 0; 1195 - + for (; i < SidebarWidth - delim_len + 1; entry[i++] = ' ' ); 1196 - + i = strlen(box); 1197 - + strncpy( entry, box, i < (SidebarWidth - delim_len + 1) ? i : (SidebarWidth - delim_len + 1) ); 3469 + + case 'F': 3470 + + if (!optional) 3471 + + { 3472 + + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 3473 + + snprintf (dest, destlen, fmt, b->msg_flagged); 3474 + + } 3475 + + else if (b->msg_flagged == 0) 3476 + + optional = 0; 3477 + + break; 1198 3478 + 1199 - + if (size == -1) 1200 - + sprintf(entry + SidebarWidth - delim_len - 3, "?"); 1201 - + else if ( new ) { 1202 - + if (flagged > 0) { 1203 - + sprintf( 1204 - + entry + SidebarWidth - delim_len - 5 - quick_log10(size) - quick_log10(new) - quick_log10(flagged), 1205 - + "% d(%d)[%d]", size, new, flagged); 1206 - + } else { 1207 - + sprintf( 1208 - + entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(new), 1209 - + "% d(%d)", size, new); 1210 - + } 1211 - + } else if (flagged > 0) { 1212 - + sprintf( entry + SidebarWidth - delim_len - 3 - quick_log10(size) - quick_log10(flagged), "% d[%d]", size, flagged); 1213 - + } else { 1214 - + sprintf( entry + SidebarWidth - delim_len - 1 - quick_log10(size), "% d", size); 1215 - + } 1216 - + return entry; 3479 + + case 'L': 3480 + + if (!optional) 3481 + + { 3482 + + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 3483 + + snprintf (dest, destlen, fmt, c ? Context->vcount : b->msg_count); 3484 + + } 3485 + + else if ((c && Context->vcount == b->msg_count) || !c) 3486 + + optional = 0; 3487 + + break; 3488 + + 3489 + + case 'N': 3490 + + if (!optional) 3491 + + { 3492 + + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 3493 + + snprintf (dest, destlen, fmt, b->msg_unread); 3494 + + } 3495 + + else if (b->msg_unread == 0) 3496 + + optional = 0; 3497 + + break; 3498 + + 3499 + + case 'S': 3500 + + if (!optional) 3501 + + { 3502 + + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 3503 + + snprintf (dest, destlen, fmt, b->msg_count); 3504 + + } 3505 + + else if (b->msg_count == 0) 3506 + + optional = 0; 3507 + + break; 3508 + + 3509 + + case 't': 3510 + + if (!optional) 3511 + + { 3512 + + snprintf (fmt, sizeof (fmt), "%%%sd", prefix); 3513 + + snprintf (dest, destlen, fmt, c ? Context->tagged : 0); 3514 + + } 3515 + + else if ((c && Context->tagged == 0) || !c) 3516 + + optional = 0; 3517 + + break; 3518 + + 3519 + + case '!': 3520 + + if (b->msg_flagged == 0) 3521 + + mutt_format_s (dest, destlen, prefix, ""); 3522 + + else if (b->msg_flagged == 1) 3523 + + mutt_format_s (dest, destlen, prefix, "!"); 3524 + + else if (b->msg_flagged == 2) 3525 + + mutt_format_s (dest, destlen, prefix, "!!"); 3526 + + else 3527 + + { 3528 + + snprintf (fmt, sizeof (fmt), "%d!", b->msg_flagged); 3529 + + mutt_format_s (dest, destlen, prefix, fmt); 3530 + + } 3531 + + break; 3532 + + } 3533 + + 3534 + + if (optional) 3535 + + mutt_FormatString (dest, destlen, col, ifstring, cb_format_str, (unsigned long) sbe, flags); 3536 + + else if (flags & M_FORMAT_OPTIONAL) 3537 + + mutt_FormatString (dest, destlen, col, elsestring, cb_format_str, (unsigned long) sbe, flags); 3538 + + 3539 + + /* We return the format string, unchanged */ 3540 + + return src; 1217 3541 +} 1218 3542 + 1219 - +void set_curbuffy(char buf[LONG_STRING]) 3543 + +/** 3544 + + * make_sidebar_entry - Turn mailbox data into a sidebar string 3545 + + * @buf: Buffer in which to save string 3546 + + * @buflen: Buffer length 3547 + + * @width: Desired width in screen cells 3548 + + * @box: Mailbox name 3549 + + * @size: Size (total number of messages) 3550 + + * @new: Number of new messages 3551 + + * @flagged: Number of flagged messages 3552 + + * 3553 + + * Take all the relevant mailbox data and the desired screen width and then get 3554 + + * mutt_FormatString to do the actual work. mutt_FormatString will callback to 3555 + + * us using cb_format_str() for the sidebar specific formatting characters. 3556 + + */ 3557 + +static void make_sidebar_entry (char *buf, unsigned int buflen, int width, char *box, 3558 + + BUFFY *b) 1220 3559 +{ 1221 - + BUFFY* tmp = CurBuffy = Incoming; 3560 + + struct sidebar_entry sbe; 1222 3561 + 1223 - + if (!Incoming) 3562 + + if (!buf || !box || !b) 1224 3563 + return; 1225 3564 + 1226 - + while(1) { 1227 - + if(!strcmp(tmp->path, buf)) { 1228 - + CurBuffy = tmp; 3565 + + sbe.buffy = b; 3566 + + strfcpy (sbe.box, box, sizeof (sbe.box)); 3567 + + 3568 + + /* Temporarily lie about the screen width */ 3569 + + int oc = COLS; 3570 + + COLS = width + SidebarWidth; 3571 + + mutt_FormatString (buf, buflen, 0, NONULL(SidebarFormat), cb_format_str, (unsigned long) &sbe, 0); 3572 + + COLS = oc; 3573 + + 3574 + + /* Force string to be exactly the right width */ 3575 + + int w = mutt_strwidth (buf); 3576 + + int s = strlen (buf); 3577 + + width = MIN(buflen, width); 3578 + + if (w < width) 3579 + + { 3580 + + /* Pad with spaces */ 3581 + + memset (buf + s, ' ', width - w); 3582 + + buf[s + width - w] = 0; 3583 + + } 3584 + + else if (w > width) 3585 + + { 3586 + + /* Truncate to fit */ 3587 + + int len = mutt_wstr_trunc (buf, buflen, width, NULL); 3588 + + buf[len] = 0; 3589 + + } 3590 + +} 3591 + + 3592 + +/** 3593 + + * cb_qsort_buffy - qsort callback to sort BUFFYs 3594 + + * @a: First BUFFY to compare 3595 + + * @b: Second BUFFY to compare 3596 + + * 3597 + + * Compare the paths of two BUFFYs taking the locale into account. 3598 + + * 3599 + + * Returns: 3600 + + * -1: a precedes b 3601 + + * 0: a and b are identical 3602 + + * 1: b precedes a 3603 + + */ 3604 + +static int cb_qsort_buffy (const void *a, const void *b) 3605 + +{ 3606 + + const BUFFY *b1 = *(const BUFFY **) a; 3607 + + const BUFFY *b2 = *(const BUFFY **) b; 3608 + + 3609 + + /* Special case -- move hidden BUFFYs to the end */ 3610 + + if (b1->is_hidden != b2->is_hidden) 3611 + + { 3612 + + if (b1->is_hidden) 3613 + + return 1; 3614 + + else 3615 + + return -1; 3616 + + } 3617 + + 3618 + + int result = 0; 3619 + + 3620 + + switch ((SidebarSortMethod & SORT_MASK)) 3621 + + { 3622 + + case SORT_COUNT: 3623 + + result = (b2->msg_count - b1->msg_count); 1229 3624 + break; 3625 + + case SORT_COUNT_NEW: 3626 + + result = (b2->msg_unread - b1->msg_unread); 3627 + + break; 3628 + + case SORT_FLAGGED: 3629 + + result = (b2->msg_flagged - b1->msg_flagged); 3630 + + break; 3631 + + case SORT_PATH: 3632 + + result = mutt_strcasecmp (b1->path, b2->path); 3633 + + break; 3634 + + } 3635 + + 3636 + + if (SidebarSortMethod & SORT_REVERSE) 3637 + + result = -result; 3638 + + 3639 + + return result; 3640 + +} 3641 + + 3642 + +/** 3643 + + * buffy_going - Prevent our pointers becoming invalid 3644 + + * @b: BUFFY about to be deleted 3645 + + * 3646 + + * If we receive a delete-notification for a BUFFY, we need to change any 3647 + + * pointers we have to reference a different BUFFY, or set them to NULL. 3648 + + * 3649 + + * We don't update the prev/next pointers, they'll be fixed on the next 3650 + + * call to prepare_sidebar(). 3651 + + * 3652 + + * Returns: 3653 + + * A valid alternative BUFFY, or NULL 3654 + + */ 3655 + +static BUFFY *buffy_going (const BUFFY *b) 3656 + +{ 3657 + + if (!b) 3658 + + return NULL; 3659 + + 3660 + + if (b->prev) 3661 + + { 3662 + + b->prev->next = NULL; 3663 + + } 3664 + + 3665 + + if (b->next) 3666 + + { 3667 + + b->next->prev = NULL; 3668 + + return b->next; 3669 + + } 3670 + + 3671 + + return b->prev; 3672 + +} 3673 + + 3674 + +/** 3675 + + * update_buffy_visibility - Should a BUFFY be displayed in the sidebar 3676 + + * @arr: array of BUFFYs 3677 + + * @arr_len: number of BUFFYs in array 3678 + + * 3679 + + * For each BUFFY in the array, check whether we should display it. 3680 + + * This is determined by several criteria. If the BUFFY: 3681 + + * is the currently open mailbox 3682 + + * is the currently highlighted mailbox 3683 + + * has unread messages 3684 + + * has flagged messages 3685 + + * is whitelisted 3686 + + */ 3687 + +static void update_buffy_visibility (BUFFY **arr, int arr_len) 3688 + +{ 3689 + + if (!arr) 3690 + + return; 3691 + + 3692 + + short new_only = option (OPTSIDEBARNEWMAILONLY); 3693 + + 3694 + + BUFFY *b; 3695 + + int i; 3696 + + for (i = 0; i < arr_len; i++) 3697 + + { 3698 + + b = arr[i]; 3699 + + 3700 + + b->is_hidden = 0; 3701 + + 3702 + + if (!new_only) 3703 + + continue; 3704 + + 3705 + + if ((b == OpnBuffy) || (b->msg_unread > 0) || 3706 + + (b == HilBuffy) || (b->msg_flagged > 0)) 3707 + + continue; 3708 + + 3709 + + if (Context && (strcmp (b->path, Context->path) == 0)) 3710 + + /* Spool directory */ 3711 + + continue; 3712 + + 3713 + + if (mutt_find_list (SidebarWhitelist, b->path)) 3714 + + /* Explicitly asked to be visible */ 3715 + + continue; 3716 + + 3717 + + b->is_hidden = 1; 3718 + + } 3719 + +} 3720 + + 3721 + +/** 3722 + + * sort_buffy_array - Sort an array of BUFFY pointers 3723 + + * @arr: array of BUFFYs 3724 + + * @arr_len: number of BUFFYs in array 3725 + + * 3726 + + * Sort an array of BUFFY pointers according to the current sort config 3727 + + * option "sidebar_sort_method". This calls qsort to do the work which calls our 3728 + + * callback function "cb_qsort_buffy". 3729 + + * 3730 + + * Once sorted, the prev/next links will be reconstructed. 3731 + + */ 3732 + +static void sort_buffy_array (BUFFY **arr, int arr_len) 3733 + +{ 3734 + + if (!arr) 3735 + + return; 3736 + + 3737 + + /* These are the only sort methods we understand */ 3738 + + short ssm = (SidebarSortMethod & SORT_MASK); 3739 + + if ((ssm == SORT_COUNT) || 3740 + + (ssm == SORT_COUNT_NEW) || 3741 + + (ssm == SORT_DESC) || 3742 + + (ssm == SORT_FLAGGED) || 3743 + + (ssm == SORT_PATH)) 3744 + + qsort (arr, arr_len, sizeof (*arr), cb_qsort_buffy); 3745 + + 3746 + + int i; 3747 + + for (i = 0; i < (arr_len - 1); i++) 3748 + + arr[i]->next = arr[i + 1]; 3749 + + arr[arr_len - 1]->next = NULL; 3750 + + 3751 + + for (i = 1; i < arr_len; i++) 3752 + + arr[i]->prev = arr[i - 1]; 3753 + + arr[0]->prev = NULL; 3754 + +} 3755 + + 3756 + +/** 3757 + + * prepare_sidebar - Prepare the list of BUFFYs for the sidebar display 3758 + + * @page_size: The number of lines on a page 3759 + + * 3760 + + * Before painting the sidebar, we count the BUFFYs, determine which are 3761 + + * visible, sort them and set up our page pointers. 3762 + + * 3763 + + * This is a lot of work to do each refresh, but there are many things that 3764 + + * can change outside of the sidebar that we don't hear about. 3765 + + * 3766 + + * Returns: 3767 + + * 0: No, don't draw the sidebar 3768 + + * 1: Yes, draw the sidebar 3769 + + */ 3770 + +static int prepare_sidebar (int page_size) 3771 + +{ 3772 + + BUFFY *b = Incoming; 3773 + + if (!b) 3774 + + return 0; 3775 + + 3776 + + int count = 0; 3777 + + for (; b; b = b->next) 3778 + + count++; 3779 + + 3780 + + BUFFY **arr = safe_malloc (count * sizeof (*arr)); 3781 + + 3782 + + int i = 0; 3783 + + for (b = Incoming; b; b = b->next, i++) 3784 + + arr[i] = b; 3785 + + 3786 + + update_buffy_visibility (arr, count); 3787 + + sort_buffy_array (arr, count); 3788 + + 3789 + + Incoming = arr[0]; 3790 + + 3791 + + int top_index = 0; 3792 + + int opn_index = -1; 3793 + + int hil_index = -1; 3794 + + int bot_index = -1; 3795 + + 3796 + + for (i = 0; i < count; i++) 3797 + + { 3798 + + if (OpnBuffy == arr[i]) 3799 + + opn_index = i; 3800 + + if (HilBuffy == arr[i]) 3801 + + hil_index = i; 3802 + + } 3803 + + 3804 + + if (!HilBuffy || (SidebarSortMethod != PreviousSort)) 3805 + + { 3806 + + if (OpnBuffy) 3807 + + { 3808 + + HilBuffy = OpnBuffy; 3809 + + hil_index = opn_index; 1230 3810 + } 3811 + + else 3812 + + { 3813 + + HilBuffy = arr[0]; 3814 + + hil_index = 0; 3815 + + } 3816 + + } 3817 + + if (TopBuffy) 3818 + + top_index = (hil_index / page_size) * page_size; 3819 + + else 3820 + + top_index = hil_index; 3821 + + TopBuffy = arr[top_index]; 1231 3822 + 1232 - + if(tmp->next) 1233 - + tmp = tmp->next; 3823 + + bot_index = top_index + page_size - 1; 3824 + + if (bot_index > (count - 1)) 3825 + + bot_index = count - 1; 3826 + + BotBuffy = arr[bot_index]; 3827 + + 3828 + + Outgoing = arr[count - 1]; 3829 + + 3830 + + PreviousSort = SidebarSortMethod; 3831 + + FREE (&arr); 3832 + + return 1; 3833 + +} 3834 + + 3835 + +/** 3836 + + * visible - Should we display the sidebar? 3837 + + * 3838 + + * After validating the config options "sidebar_visible" and "sidebar_width", 3839 + + * determine whether we should should display the sidebar. 3840 + + * 3841 + + * When not visible, set the global SidebarWidth to 0. 3842 + + * 3843 + + * Returns: 3844 + + * Boolean 3845 + + */ 3846 + +static short 3847 + +visible (void) 3848 + +{ 3849 + + short new_visible = option (OPTSIDEBAR); 3850 + + short new_width = SidebarWidth; 3851 + + 3852 + + if (OldWidth != new_width) 3853 + + { 3854 + + if (new_width > 0) 3855 + + { 3856 + + OldWidth = new_width; 3857 + + } 3858 + + } 3859 + + 3860 + + if (OldVisible != new_visible) 3861 + + { 3862 + + if (new_visible) 3863 + + { 3864 + + set_option (OPTSIDEBAR); 3865 + + } 1234 3866 + else 1235 - + break; 3867 + + { 3868 + + unset_option (OPTSIDEBAR); 3869 + + } 3870 + + OldVisible = new_visible; 3871 + + } 3872 + + else if (new_width == 0) 3873 + + { 3874 + + unset_option (OPTSIDEBAR); 3875 + + OldVisible = 0; 3876 + + } 3877 + + 3878 + + if (!option (OPTSIDEBAR)) 3879 + + { 3880 + + SidebarWidth = 0; 3881 + + } 3882 + + else if (new_width == 0) 3883 + + { 3884 + + SidebarWidth = OldWidth; 3885 + + } 3886 + + else 3887 + + { 3888 + + SidebarWidth = new_width; 1236 3889 + } 3890 + + 3891 + + return new_visible; 1237 3892 +} 1238 3893 + 1239 - +int draw_sidebar(int menu) { 3894 + +/** 3895 + + * draw_divider - Draw a line between the sidebar and the rest of mutt 3896 + + * @first_row: Screen line to start (0-based) 3897 + + * @num_rows: Number of rows to fill 3898 + + * 3899 + + * Draw a divider using characters from the config option "sidebar_divider_char". 3900 + + * This can be an ASCII or Unicode character. First we calculate this 3901 + + * characters' width in screen columns, then subtract that from the config 3902 + + * option "sidebar_width". 3903 + + * 3904 + + * Returns: 3905 + + * -1: Error: bad character, etc 3906 + + * 0: Error: 0 width character 3907 + + * n: Success: character occupies n screen columns 3908 + + */ 3909 + +static int draw_divider (int first_row, int num_rows) 3910 + +{ 3911 + + /* Calculate the width of the delimiter in screen cells */ 3912 + + int delim_len = mutt_strwidth (SidebarDividerChar); 3913 + + 3914 + + if (delim_len < 1) 3915 + + return delim_len; 3916 + + 3917 + + if ((SidebarWidth + delim_len) > (COLS + 1)) 3918 + + return 0; 3919 + + 3920 + + if (delim_len > SidebarWidth) 3921 + + return -1; 3922 + + 3923 + + SETCOLOR(MT_COLOR_DIVIDER); 3924 + + 3925 + + int i; 3926 + + for (i = 0; i < num_rows; i++) 3927 + + { 3928 + + move (first_row + i, SidebarWidth - delim_len); 3929 + + addstr (NONULL(SidebarDividerChar)); 3930 + + } 3931 + + 3932 + + return delim_len; 3933 + +} 3934 + + 3935 + +/** 3936 + + * fill_empty_space - Wipe the remaining Sidebar space 3937 + + * @first_row: Screen line to start (0-based) 3938 + + * @num_rows: Number of rows to fill 3939 + + * @width: Width of the Sidebar (minus the divider) 3940 + + * 3941 + + * Write spaces over the area the sidebar isn't using. 3942 + + */ 3943 + +static void fill_empty_space (int first_row, int num_rows, int width) 3944 + +{ 3945 + + /* Fill the remaining rows with blank space */ 3946 + + SETCOLOR(MT_COLOR_NORMAL); 1240 3947 + 1241 - + int lines = option(OPTHELP) ? 1 : 0; 1242 - + BUFFY *tmp; 1243 - +#ifndef USE_SLANG_CURSES 1244 - + attr_t attrs; 1245 - +#endif 1246 - + short delim_len = strlen(SidebarDelim); 1247 - + short color_pair; 3948 + + int r; 3949 + + for (r = 0; r < num_rows; r++) 3950 + + { 3951 + + int i = 0; 3952 + + move (first_row + r, 0); 3953 + + for (; i < width; i++) 3954 + + addch (' '); 3955 + + } 3956 + +} 3957 + + 3958 + +/** 3959 + + * draw_sidebar - Write out a list of mailboxes, on the left 3960 + + * @first_row: Screen line to start (0-based) 3961 + + * @num_rows: Number of rows to fill 3962 + + * @div_width: Width in screen characters taken by the divider 3963 + + * 3964 + + * Display a list of mailboxes in a panel on the left. What's displayed will 3965 + + * depend on our index markers: TopBuffy, OpnBuffy, HilBuffy, BotBuffy. 3966 + + * On the first run they'll be NULL, so we display the top of Mutt's list 3967 + + * (Incoming). 3968 + + * 3969 + + * TopBuffy - first visible mailbox 3970 + + * BotBuffy - last visible mailbox 3971 + + * OpnBuffy - mailbox shown in Mutt's Index Panel 3972 + + * HilBuffy - Unselected mailbox (the paging follows this) 3973 + + * 3974 + + * The entries are formatted using "sidebar_format" and may be abbreviated: 3975 + + * "sidebar_short_path", indented: "sidebar_folder_indent", 3976 + + * "sidebar_indent_string" and sorted: "sidebar_sort_method". Finally, they're 3977 + + * trimmed to fit the available space. 3978 + + */ 3979 + +static void draw_sidebar (int first_row, int num_rows, int div_width) 3980 + +{ 3981 + + BUFFY *b = TopBuffy; 3982 + + if (!b) 3983 + + return; 1248 3984 + 1249 - + static bool initialized = false; 1250 - + static int prev_show_value; 1251 - + static short saveSidebarWidth; 3985 + + int w = MIN(COLS, (SidebarWidth - div_width)); 3986 + + int row = 0; 3987 + + for (b = TopBuffy; b && (row < num_rows); b = b->next) 3988 + + { 3989 + + if (b->is_hidden) 3990 + + continue; 1252 3991 + 1253 - + /* initialize first time */ 1254 - + if(!initialized) { 1255 - + prev_show_value = option(OPTSIDEBAR); 1256 - + saveSidebarWidth = SidebarWidth; 1257 - + if(!option(OPTSIDEBAR)) SidebarWidth = 0; 1258 - + initialized = true; 3992 + + if (b == OpnBuffy) 3993 + + { 3994 + + if ((ColorDefs[MT_COLOR_SB_INDICATOR] != 0)) 3995 + + SETCOLOR(MT_COLOR_SB_INDICATOR); 3996 + + else 3997 + + SETCOLOR(MT_COLOR_INDICATOR); 3998 + + } 3999 + + else if (b == HilBuffy) 4000 + + SETCOLOR(MT_COLOR_HIGHLIGHT); 4001 + + else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) && 4002 + + (mutt_strcmp (b->path, Spoolfile) == 0)) 4003 + + SETCOLOR(MT_COLOR_SB_SPOOLFILE); 4004 + + else if (b->msg_unread > 0) 4005 + + SETCOLOR(MT_COLOR_NEW); 4006 + + else if (b->msg_flagged > 0) 4007 + + SETCOLOR(MT_COLOR_FLAGGED); 4008 + + else 4009 + + SETCOLOR(MT_COLOR_NORMAL); 4010 + + 4011 + + move (first_row + row, 0); 4012 + + if (Context && Context->path && 4013 + + (!strcmp (b->path, Context->path)|| 4014 + + !strcmp (b->realpath, Context->path))) 4015 + + { 4016 + + b->msg_unread = Context->unread; 4017 + + b->msg_count = Context->msgcount; 4018 + + b->msg_flagged = Context->flagged; 4019 + + } 4020 + + 4021 + + /* compute length of Maildir without trailing separator */ 4022 + + size_t maildirlen = strlen (Maildir); 4023 + + if (SidebarDelimChars && strchr (SidebarDelimChars, Maildir[maildirlen - 1])) 4024 + + maildirlen--; 4025 + + 4026 + + /* check whether Maildir is a prefix of the current folder's path */ 4027 + + short maildir_is_prefix = 0; 4028 + + if ((strlen (b->path) > maildirlen) && (strncmp (Maildir, b->path, maildirlen) == 0)) 4029 + + maildir_is_prefix = 1; 4030 + + 4031 + + /* calculate depth of current folder and generate its display name with indented spaces */ 4032 + + int sidebar_folder_depth = 0; 4033 + + char *sidebar_folder_name; 4034 + + int i; 4035 + + if (option (OPTSIDEBARSHORTPATH)) 4036 + + { 4037 + + /* disregard a trailing separator, so strlen() - 2 */ 4038 + + sidebar_folder_name = b->path; 4039 + + for (i = strlen (sidebar_folder_name) - 2; i >= 0; i--) 4040 + + { 4041 + + if (SidebarDelimChars && 4042 + + strchr (SidebarDelimChars, sidebar_folder_name[i])) 4043 + + { 4044 + + sidebar_folder_name += (i + 1); 4045 + + break; 1259 4046 + } 4047 + + } 4048 + + } 4049 + + else 4050 + + sidebar_folder_name = b->path + maildir_is_prefix * (maildirlen + 1); 1260 4051 + 1261 - + /* save or restore the value SidebarWidth */ 1262 - + if(prev_show_value != option(OPTSIDEBAR)) { 1263 - + if(prev_show_value && !option(OPTSIDEBAR)) { 1264 - + saveSidebarWidth = SidebarWidth; 1265 - + SidebarWidth = 0; 1266 - + } else if(!prev_show_value && option(OPTSIDEBAR)) { 1267 - + SidebarWidth = saveSidebarWidth; 1268 - + } 1269 - + prev_show_value = option(OPTSIDEBAR); 4052 + + if (maildir_is_prefix && option (OPTSIDEBARFOLDERINDENT)) 4053 + + { 4054 + + const char *tmp_folder_name; 4055 + + int lastsep = 0; 4056 + + tmp_folder_name = b->path + maildirlen + 1; 4057 + + int tmplen = (int) strlen (tmp_folder_name) - 1; 4058 + + for (i = 0; i < tmplen; i++) 4059 + + { 4060 + + if (SidebarDelimChars && strchr (SidebarDelimChars, tmp_folder_name[i])) 4061 + + { 4062 + + sidebar_folder_depth++; 4063 + + lastsep = i + 1; 1270 4064 + } 4065 + + } 4066 + + if (sidebar_folder_depth > 0) 4067 + + { 4068 + + if (option (OPTSIDEBARSHORTPATH)) 4069 + + tmp_folder_name += lastsep; /* basename */ 4070 + + sidebar_folder_name = malloc (strlen (tmp_folder_name) + sidebar_folder_depth*strlen (NONULL(SidebarIndentString)) + 1); 4071 + + sidebar_folder_name[0]=0; 4072 + + for (i=0; i < sidebar_folder_depth; i++) 4073 + + strncat (sidebar_folder_name, NONULL(SidebarIndentString), strlen (NONULL(SidebarIndentString))); 4074 + + strncat (sidebar_folder_name, tmp_folder_name, strlen (tmp_folder_name)); 4075 + + } 4076 + + } 4077 + + char str[STRING]; 4078 + + make_sidebar_entry (str, sizeof (str), w, sidebar_folder_name, b); 4079 + + printw ("%s", str); 4080 + + if (sidebar_folder_depth > 0) 4081 + + FREE (&sidebar_folder_name); 4082 + + row++; 4083 + + } 1271 4084 + 4085 + + fill_empty_space (first_row + row, num_rows - row, w); 4086 + +} 1272 4087 + 1273 - +// if ( SidebarWidth == 0 ) return 0; 1274 - + if (SidebarWidth > 0 && option (OPTSIDEBAR) 1275 - + && delim_len >= SidebarWidth) { 1276 - + unset_option (OPTSIDEBAR); 1277 - + /* saveSidebarWidth = SidebarWidth; */ 1278 - + if (saveSidebarWidth > delim_len) { 1279 - + SidebarWidth = saveSidebarWidth; 1280 - + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar.")); 1281 - + sleep (2); 1282 - + } else { 1283 - + SidebarWidth = 0; 1284 - + mutt_error (_("Value for sidebar_delim is too long. Disabling sidebar. Please set your sidebar_width to a sane value.")); 1285 - + sleep (4); /* the advise to set a sane value should be seen long enough */ 1286 - + } 1287 - + saveSidebarWidth = 0; 1288 - + return (0); 1289 - + } 1290 4088 + 1291 - + if ( SidebarWidth == 0 || !option(OPTSIDEBAR)) { 1292 - + if (SidebarWidth > 0) { 1293 - + saveSidebarWidth = SidebarWidth; 1294 - + SidebarWidth = 0; 1295 - + } 1296 - + unset_option(OPTSIDEBAR); 1297 - + return 0; 4089 + +/** 4090 + + * mutt_sb_init - Set some default values for the sidebar. 4091 + + */ 4092 + +void 4093 + +mutt_sb_init (void) 4094 + +{ 4095 + + OldVisible = option (OPTSIDEBAR); 4096 + + if (SidebarWidth > 0) 4097 + + { 4098 + + OldWidth = SidebarWidth; 4099 + + } 4100 + + else 4101 + + { 4102 + + OldWidth = 20; 4103 + + if (OldVisible) 4104 + + { 4105 + + SidebarWidth = OldWidth; 1298 4106 + } 4107 + + } 4108 + +} 1299 4109 + 1300 - + /* get attributes for divider */ 1301 - + SETCOLOR(MT_COLOR_STATUS); 1302 - +#ifndef USE_SLANG_CURSES 1303 - + attr_get(&attrs, &color_pair, 0); 1304 - +#else 1305 - + color_pair = attr_get(); 1306 - +#endif 1307 - + SETCOLOR(MT_COLOR_NORMAL); 4110 + +/** 4111 + + * mutt_sb_draw - Completely redraw the sidebar 4112 + + * 4113 + + * Completely refresh the sidebar region. First draw the divider; then, for 4114 + + * each BUFFY, call make_sidebar_entry; finally blank out any remaining space. 4115 + + */ 4116 + +void mutt_sb_draw (void) 4117 + +{ 4118 + + if (!visible()) 4119 + + return; 1308 4120 + 1309 - + /* draw the divider */ 4121 + + /* XXX - if transitioning from invisible to visible */ 4122 + + /* if (OldVisible == 0) */ 4123 + + /* mutt_buffy_check (1); we probably have bad or no numbers */ 1310 4124 + 1311 - + for ( ; lines < LINES-1-(menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { 1312 - + move(lines, SidebarWidth - delim_len); 1313 - + addstr(NONULL(SidebarDelim)); 1314 - +#ifndef USE_SLANG_CURSES 1315 - + mvchgat(lines, SidebarWidth - delim_len, delim_len, 0, color_pair, NULL); 1316 - +#endif 1317 - + } 4125 + + int x = getcurx (stdscr); 4126 + + int y = getcury (stdscr); 1318 4127 + 1319 - + if ( Incoming == 0 ) return 0; 1320 - + lines = option(OPTHELP) ? 1 : 0; /* go back to the top */ 4128 + + int first_row = 0; 4129 + + int num_rows = LINES - 2; 1321 4130 + 1322 - + if ( known_lines != LINES || TopBuffy == 0 || BottomBuffy == 0 ) 1323 - + calc_boundaries(menu); 1324 - + if ( CurBuffy == 0 ) CurBuffy = Incoming; 4131 + + if (option (OPTHELP) || option (OPTSTATUSONTOP)) 4132 + + first_row++; 1325 4133 + 1326 - + tmp = TopBuffy; 4134 + + if (option (OPTHELP)) 4135 + + num_rows--; 4136 + + 4137 + + int div_width = draw_divider (first_row, num_rows); 4138 + + if (div_width < 0) 4139 + + return; 1327 4140 + 1328 - + SETCOLOR(MT_COLOR_NORMAL); 4141 + + if (!Incoming) 4142 + + { 4143 + + int w = MIN(COLS, (SidebarWidth - div_width)); 4144 + + fill_empty_space (first_row, num_rows, w); 4145 + + return; 4146 + + } 4147 + + 4148 + + if (!prepare_sidebar (num_rows)) 4149 + + return; 4150 + + 4151 + + draw_sidebar (first_row, num_rows, div_width); 4152 + + move (y, x); 4153 + +} 4154 + + 4155 + +/** 4156 + + * mutt_sb_should_refresh - Check if the sidebar is due to be refreshed 4157 + + * 4158 + + * The "sidebar_refresh_time" config option allows the user to limit the frequency 4159 + + * with which the sidebar is refreshed. 4160 + + * 4161 + + * Returns: 4162 + + * 1 Yes, refresh is due 4163 + + * 0 No, refresh happened recently 4164 + + */ 4165 + +int mutt_sb_should_refresh (void) 4166 + +{ 4167 + + if (!option (OPTSIDEBAR)) 4168 + + return 0; 4169 + + 4170 + + if (SidebarRefreshTime == 0) 4171 + + return 0; 4172 + + 4173 + + time_t diff = (time (NULL) - LastRefresh); 4174 + + 4175 + + return (diff >= SidebarRefreshTime); 4176 + +} 1329 4177 + 1330 - + for ( ; tmp && lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); tmp = tmp->next ) { 1331 - + if ( tmp == CurBuffy ) 1332 - + SETCOLOR(MT_COLOR_INDICATOR); 1333 - + else if ( tmp->msg_unread > 0 ) 1334 - + SETCOLOR(MT_COLOR_NEW); 1335 - + else if ( tmp->msg_flagged > 0 ) 1336 - + SETCOLOR(MT_COLOR_FLAGGED); 1337 - + else 1338 - + SETCOLOR(MT_COLOR_NORMAL); 4178 + +/** 4179 + + * mutt_sb_change_mailbox - Change the selected mailbox 4180 + + * @op: Operation code 4181 + + * 4182 + + * Change the selected mailbox, e.g. "Next mailbox", "Previous Mailbox 4183 + + * with new mail". The operations are listed OPS.SIDEBAR which is built 4184 + + * into an enum in keymap_defs.h. 4185 + + * 4186 + + * If the operation is successful, HilBuffy will be set to the new mailbox. 4187 + + * This function only *selects* the mailbox, doesn't *open* it. 4188 + + * 4189 + + * Allowed values are: OP_SIDEBAR_NEXT, OP_SIDEBAR_NEXT_NEW, 4190 + + * OP_SIDEBAR_PAGE_DOWN, OP_SIDEBAR_PAGE_UP, OP_SIDEBAR_PREV, 4191 + + * OP_SIDEBAR_PREV_NEW. 4192 + + */ 4193 + +void mutt_sb_change_mailbox (int op) 4194 + +{ 4195 + + BUFFY *b; 4196 + + if (!HilBuffy) /* It'll get reset on the next draw */ 4197 + + return; 4198 + + 4199 + + switch (op) 4200 + + { 4201 + + case OP_SIDEBAR_NEXT: 4202 + + if (!HilBuffy->next) 4203 + + return; 4204 + + if (HilBuffy->next->is_hidden) 4205 + + return; 4206 + + HilBuffy = HilBuffy->next; 4207 + + break; 4208 + + case OP_SIDEBAR_NEXT_NEW: 4209 + + b = find_next_new (option (OPTSIDEBARNEXTNEWWRAP)); 4210 + + if (!b) 4211 + + return; 4212 + + else 4213 + + HilBuffy = b; 4214 + + break; 4215 + + case OP_SIDEBAR_PAGE_DOWN: 4216 + + HilBuffy = BotBuffy; 4217 + + if (HilBuffy->next) 4218 + + HilBuffy = HilBuffy->next; 4219 + + break; 4220 + + case OP_SIDEBAR_PAGE_UP: 4221 + + HilBuffy = TopBuffy; 4222 + + if (HilBuffy != Incoming) 4223 + + HilBuffy = HilBuffy->prev; 4224 + + break; 4225 + + case OP_SIDEBAR_PREV: 4226 + + if (!HilBuffy->prev) 4227 + + return; 4228 + + if (HilBuffy->prev->is_hidden) /* Can't happen, we've sorted the hidden to the end */ 4229 + + return; 4230 + + HilBuffy = HilBuffy->prev; 4231 + + break; 4232 + + case OP_SIDEBAR_PREV_NEW: 4233 + + b = find_prev_new (option (OPTSIDEBARNEXTNEWWRAP)); 4234 + + if (!b) 4235 + + return; 4236 + + else 4237 + + HilBuffy = b; 4238 + + break; 4239 + + default: 4240 + + return; 4241 + + } 4242 + + 4243 + + /* We can change folder even if the sidebar is hidden */ 4244 + + if (option (OPTSIDEBAR)) 4245 + + mutt_sb_draw(); 4246 + +} 4247 + + 4248 + +/** 4249 + + * mutt_sb_set_buffystats - Update the BUFFY's message counts from the CONTEXT 4250 + + * @ctx: A mailbox CONTEXT 4251 + + * 4252 + + * Given a mailbox CONTEXT, find a matching mailbox BUFFY and copy the message 4253 + + * counts into it. 4254 + + */ 4255 + +void mutt_sb_set_buffystats (const CONTEXT *ctx) 4256 + +{ 4257 + + /* Even if the sidebar's hidden, 4258 + + * we should take note of the new data. */ 4259 + + BUFFY *b = Incoming; 4260 + + if (!ctx || !b) 4261 + + return; 1339 4262 + 1340 - + move( lines, 0 ); 1341 - + if ( Context && !strcmp( tmp->path, Context->path ) ) { 1342 - + tmp->msg_unread = Context->unread; 1343 - + tmp->msgcount = Context->msgcount; 1344 - + tmp->msg_flagged = Context->flagged; 1345 - + } 1346 - + // check whether Maildir is a prefix of the current folder's path 1347 - + short maildir_is_prefix = 0; 1348 - + if ( (strlen(tmp->path) > strlen(Maildir)) && 1349 - + (strncmp(Maildir, tmp->path, strlen(Maildir)) == 0) ) 1350 - + maildir_is_prefix = 1; 1351 - + // calculate depth of current folder and generate its display name with indented spaces 1352 - + int sidebar_folder_depth = 0; 1353 - + char *sidebar_folder_name; 1354 - + sidebar_folder_name = basename(tmp->path); 1355 - + if ( maildir_is_prefix ) { 1356 - + char *tmp_folder_name; 1357 - + int i; 1358 - + tmp_folder_name = tmp->path + strlen(Maildir); 1359 - + for (i = 0; i < strlen(tmp->path) - strlen(Maildir); i++) { 1360 - + if (tmp_folder_name[i] == '/') sidebar_folder_depth++; 1361 - + } 1362 - + if (sidebar_folder_depth > 0) { 1363 - + sidebar_folder_name = malloc(strlen(basename(tmp->path)) + sidebar_folder_depth + 1); 1364 - + for (i=0; i < sidebar_folder_depth; i++) 1365 - + sidebar_folder_name[i]=' '; 1366 - + sidebar_folder_name[i]=0; 1367 - + strncat(sidebar_folder_name, basename(tmp->path), strlen(basename(tmp->path)) + sidebar_folder_depth); 1368 - + } 1369 - + } 1370 - + printw( "%.*s", SidebarWidth - delim_len + 1, 1371 - + make_sidebar_entry(sidebar_folder_name, tmp->msgcount, 1372 - + tmp->msg_unread, tmp->msg_flagged)); 1373 - + if (sidebar_folder_depth > 0) 1374 - + free(sidebar_folder_name); 1375 - + lines++; 1376 - + } 1377 - + SETCOLOR(MT_COLOR_NORMAL); 1378 - + for ( ; lines < LINES-1 - (menu != MENU_PAGER || option(OPTSTATUSONTOP)); lines++ ) { 1379 - + int i = 0; 1380 - + move( lines, 0 ); 1381 - + for ( ; i < SidebarWidth - delim_len; i++ ) 1382 - + addch(' '); 1383 - + } 1384 - + return 0; 4263 + + for (; b; b = b->next) 4264 + + { 4265 + + if (!strcmp (b->path, ctx->path) || 4266 + + !strcmp (b->realpath, ctx->path)) 4267 + + { 4268 + + b->msg_unread = ctx->unread; 4269 + + b->msg_count = ctx->msgcount; 4270 + + b->msg_flagged = ctx->flagged; 4271 + + break; 4272 + + } 4273 + + } 1385 4274 +} 1386 4275 + 4276 + +/** 4277 + + * mutt_sb_get_highlight - Get the BUFFY that's highlighted in the sidebar 4278 + + * 4279 + + * Get the path of the mailbox that's highlighted in the sidebar. 4280 + + * 4281 + + * Returns: 4282 + + * Mailbox path 4283 + + */ 4284 + +const char *mutt_sb_get_highlight (void) 4285 + +{ 4286 + + if (!HilBuffy) 4287 + + return NULL; 1387 4288 + 1388 - +void set_buffystats(CONTEXT* Context) 4289 + + return HilBuffy->path; 4290 + +} 4291 + + 4292 + +/** 4293 + + * mutt_sb_set_open_buffy - Set the OpnBuffy based on a mailbox path 4294 + + * @path: Mailbox path 4295 + + * 4296 + + * Search through the list of mailboxes. If a BUFFY has a matching path, set 4297 + + * OpnBuffy to it. 4298 + + */ 4299 + +BUFFY *mutt_sb_set_open_buffy (const char *path) 1389 4300 +{ 1390 - + BUFFY *tmp = Incoming; 1391 - + while(tmp) { 1392 - + if(Context && !strcmp(tmp->path, Context->path)) { 1393 - + tmp->msg_unread = Context->unread; 1394 - + tmp->msgcount = Context->msgcount; 1395 - + break; 1396 - + } 1397 - + tmp = tmp->next; 1398 - + } 4301 + + /* Even if the sidebar is hidden */ 4302 + + 4303 + + BUFFY *b = Incoming; 4304 + + 4305 + + if (!path || !b) 4306 + + return NULL; 4307 + + 4308 + + OpnBuffy = NULL; 4309 + + 4310 + + for (; b; b = b->next) 4311 + + { 4312 + + if (!strcmp (b->path, path) || 4313 + + !strcmp (b->realpath, path)) 4314 + + { 4315 + + OpnBuffy = b; 4316 + + HilBuffy = b; 4317 + + break; 4318 + + } 4319 + + } 4320 + + 4321 + + return OpnBuffy; 1399 4322 +} 1400 4323 + 1401 - +void scroll_sidebar(int op, int menu) 4324 + +/** 4325 + + * mutt_sb_set_update_time - Note the time that the sidebar was updated 4326 + + * 4327 + + * Update the timestamp representing the last sidebar update. If the user 4328 + + * configures "sidebar_refresh_time", this will help to reduce traffic. 4329 + + */ 4330 + +void mutt_sb_set_update_time (void) 1402 4331 +{ 1403 - + if(!SidebarWidth) return; 1404 - + if(!CurBuffy) return; 4332 + + /* XXX - should this be public? */ 1405 4333 + 1406 - + switch (op) { 1407 - + case OP_SIDEBAR_NEXT: 1408 - + if ( CurBuffy->next == NULL ) return; 1409 - + CurBuffy = CurBuffy->next; 1410 - + break; 1411 - + case OP_SIDEBAR_PREV: 1412 - + if ( CurBuffy->prev == NULL ) return; 1413 - + CurBuffy = CurBuffy->prev; 1414 - + break; 1415 - + case OP_SIDEBAR_SCROLL_UP: 1416 - + CurBuffy = TopBuffy; 1417 - + if ( CurBuffy != Incoming ) { 1418 - + calc_boundaries(menu); 1419 - + CurBuffy = CurBuffy->prev; 1420 - + } 1421 - + break; 1422 - + case OP_SIDEBAR_SCROLL_DOWN: 1423 - + CurBuffy = BottomBuffy; 1424 - + if ( CurBuffy->next ) { 1425 - + calc_boundaries(menu); 1426 - + CurBuffy = CurBuffy->next; 1427 - + } 1428 - + break; 1429 - + default: 1430 - + return; 1431 - + } 1432 - + calc_boundaries(menu); 1433 - + draw_sidebar(menu); 4334 + + LastRefresh = time (NULL); 1434 4335 +} 1435 4336 + 1436 - diff --git a/sidebar.h b/sidebar.h 1437 - new file mode 100644 1438 - index 0000000..d195f11 1439 - --- /dev/null 1440 - +++ b/sidebar.h 4337 + +/** 4338 + + * mutt_sb_notify_mailbox - The state of a BUFFY is about to change 4339 + + * 4340 + + * We receive a notification: 4341 + + * After a new BUFFY has been created 4342 + + * Before a BUFFY is deleted 4343 + + * 4344 + + * Before a deletion, check that our pointers won't be invalidated. 4345 + + */ 4346 + +void mutt_sb_notify_mailbox (BUFFY *b, int created) 4347 + +{ 4348 + + if (!b) 4349 + + return; 4350 + + 4351 + + /* Any new/deleted mailboxes will cause a refresh. As long as 4352 + + * they're valid, our pointers will be updated in prepare_sidebar() */ 4353 + + 4354 + + if (created) 4355 + + { 4356 + + if (!TopBuffy) 4357 + + TopBuffy = b; 4358 + + if (!HilBuffy) 4359 + + HilBuffy = b; 4360 + + if (!BotBuffy) 4361 + + BotBuffy = b; 4362 + + if (!Outgoing) 4363 + + Outgoing = b; 4364 + + if (!OpnBuffy && Context) 4365 + + { 4366 + + /* This might happen if the user "unmailboxes *", then 4367 + + * "mailboxes" our current mailbox back again */ 4368 + + if (mutt_strcmp (b->path, Context->path) == 0) 4369 + + OpnBuffy = b; 4370 + + } 4371 + + } 4372 + + else 4373 + + { 4374 + + BUFFY *replacement = buffy_going (b); 4375 + + if (TopBuffy == b) 4376 + + TopBuffy = replacement; 4377 + + if (OpnBuffy == b) 4378 + + OpnBuffy = NULL; 4379 + + if (HilBuffy == b) 4380 + + HilBuffy = replacement; 4381 + + if (BotBuffy == b) 4382 + + BotBuffy = replacement; 4383 + + if (Outgoing == b) 4384 + + Outgoing = replacement; 4385 + + } 4386 + +} 4387 + diff -urN mutt-1.6.1/sidebar.h mutt-1.6.1-sidebar/sidebar.h 4388 + --- mutt-1.6.1/sidebar.h 1970-01-01 01:00:00.000000000 +0100 4389 + +++ mutt-1.6.1-sidebar/sidebar.h 2016-06-12 18:43:03.967503185 +0100 1441 4390 @@ -0,0 +1,36 @@ 1442 - +/* 1443 - + * Copyright (C) ????-2004 Justin Hibbits <jrh29@po.cwru.edu> 4391 + +/* Copyright (C) 2004 Justin Hibbits <jrh29@po.cwru.edu> 1444 4392 + * Copyright (C) 2004 Thomer M. Gil <mutt@thomer.com> 1445 - + * 4393 + + * Copyright (C) 2015-2016 Richard Russon <rich@flatcap.org> 4394 + + * 1446 4395 + * This program is free software; you can redistribute it and/or modify 1447 4396 + * it under the terms of the GNU General Public License as published by 1448 4397 + * the Free Software Foundation; either version 2 of the License, or 1449 4398 + * (at your option) any later version. 1450 - + * 4399 + + * 1451 4400 + * This program is distributed in the hope that it will be useful, 1452 4401 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 1453 4402 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1454 4403 + * GNU General Public License for more details. 1455 - + * 4404 + + * 1456 4405 + * You should have received a copy of the GNU General Public License 1457 4406 + * along with this program; if not, write to the Free Software 1458 4407 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 1459 - + */ 4408 + + */ 1460 4409 + 1461 4410 +#ifndef SIDEBAR_H 1462 4411 +#define SIDEBAR_H 1463 4412 + 1464 - +struct MBOX_LIST { 1465 - + char *path; 1466 - + int msgcount; 1467 - + int new; 1468 - +} MBLIST; 4413 + +#include "mutt.h" 4414 + +#include "buffy.h" 1469 4415 + 1470 - +/* parameter is whether or not to go to the status line */ 1471 - +/* used for omitting the last | that covers up the status bar in the index */ 1472 - +int draw_sidebar(int); 1473 - +void scroll_sidebar(int, int); 1474 - +void set_curbuffy(char*); 1475 - +void set_buffystats(CONTEXT*); 4416 + +void mutt_sb_change_mailbox (int op); 4417 + +void mutt_sb_draw (void); 4418 + +const char * mutt_sb_get_highlight (void); 4419 + +void mutt_sb_init (void); 4420 + +void mutt_sb_notify_mailbox (BUFFY *b, int created); 4421 + +void mutt_sb_set_buffystats (const CONTEXT *ctx); 4422 + +BUFFY * mutt_sb_set_open_buffy (const char *path); 4423 + +void mutt_sb_set_update_time (void); 4424 + +int mutt_sb_should_refresh (void); 1476 4425 + 1477 4426 +#endif /* SIDEBAR_H */ 4427 + diff -urN mutt-1.6.1/sort.h mutt-1.6.1-sidebar/sort.h 4428 + --- mutt-1.6.1/sort.h 2016-06-12 18:43:00.415447793 +0100 4429 + +++ mutt-1.6.1-sidebar/sort.h 2016-06-12 18:43:03.968503200 +0100 4430 + @@ -31,6 +31,12 @@ 4431 + #define SORT_KEYID 12 4432 + #define SORT_TRUST 13 4433 + #define SORT_SPAM 14 4434 + +#define SORT_COUNT 15 4435 + +#define SORT_COUNT_NEW 16 4436 + +#define SORT_DESC 17 4437 + +#define SORT_FLAGGED 18 4438 + +#define SORT_PATH 19 4439 + + 4440 + /* dgc: Sort & SortAux are shorts, so I'm bumping these bitflags up from 4441 + * bits 4 & 5 to bits 8 & 9 to make room for more sort keys in the future. */ 4442 + #define SORT_MASK 0xff 4443 + @@ -50,6 +56,7 @@ 4444 + WHERE short Sort INITVAL (SORT_DATE); 4445 + WHERE short SortAux INITVAL (SORT_DATE); /* auxiliary sorting method */ 4446 + WHERE short SortAlias INITVAL (SORT_ALIAS); 4447 + +WHERE short SidebarSortMethod INITVAL (SORT_ORDER); 4448 + 4449 + /* FIXME: This one does not belong to here */ 4450 + WHERE short PgpSortKeys INITVAL (SORT_ADDRESS);
-316
pkgs/applications/networking/mailreaders/mutt/trash-folder.patch
··· 1 - From: Cedric Duval <cedricduval@free.fr> 2 - Date: Thu, 27 Feb 2014 12:27:41 +0100 3 - Subject: trash-folder 4 - 5 - With this patch, if the trash variable is set to a path (unset by default), the 6 - deleted mails will be moved to a trash folder instead of being irremediably 7 - purged when syncing the mailbox. 8 - 9 - For instance, set trash="~/Mail/trash" will cause every deleted mail to go to 10 - this folder. 11 - 12 - Note that the append to the trash folder doesn't occur until the resync is 13 - done. This allows you to change your mind and undo deletes, and thus the moves 14 - to the trash folder are unnecessary. 15 - 16 - Notes 17 - 18 - * You might also want to have a look at the purge message feature below 19 - which is related to this patch. 20 - * IMAP is now supported. To retain the previous behavior, add this to your 21 - muttrc: 22 - folder-hook ^imap:// 'unset trash' 23 - 24 - FAQ 25 - 26 - Every once in a while, someone asks what are the advantages of this patch over 27 - a macro based solution. Here's an attempt to answer this question: 28 - 29 - * The folder history doesn't clutter up with unwanted trash entries. 30 - * Delayed move to the trash allows to change one's mind. 31 - * No need to treat the case of "normal folders" and trash folders 32 - separately with folder-hooks, and to create two sets of macros (one for 33 - the index, one for the pager). 34 - * Works not only with delete-message, but also with every deletion 35 - functions like delete-pattern, delete-thread or delete-subthread. 36 - 37 - To sum up, it's more integrated and transparent to the user. 38 - 39 - * Patch last synced with upstream: 40 - - Date: 2007-02-15 41 - - File: http://cedricduval.free.fr/mutt/patches/download/patch-1.5.5.1.cd.trash_folder.3.4 42 - 43 - * Changes made: 44 - - Updated to 1.5.13: 45 - - structure of _mutt_save_message changed (commands.c) 46 - - context of option (OPTCONFIRMAPPEND) changed (muttlib.c) 47 - - Fixed indentation of "appended" in mutt.h. 48 - 49 - Signed-off-by: Matteo F. Vescovi <mfvescovi@gmail.com> 50 - 51 - Gbp-Pq: Topic features 52 - --- 53 - commands.c | 1 + 54 - flags.c | 19 +++++++++++++++++- 55 - globals.h | 1 + 56 - imap/message.c | 2 ++ 57 - init.h | 10 ++++++++++ 58 - mutt.h | 3 +++ 59 - muttlib.c | 4 +++- 60 - mx.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 61 - postpone.c | 3 +++ 62 - 9 files changed, 103 insertions(+), 2 deletions(-) 63 - 64 - diff --git a/commands.c b/commands.c 65 - index 5dbd100..7fd014b 100644 66 - --- a/commands.c 67 - +++ b/commands.c 68 - @@ -720,6 +720,7 @@ int _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int dec 69 - if (option (OPTDELETEUNTAG)) 70 - mutt_set_flag (Context, h, M_TAG, 0); 71 - } 72 - + mutt_set_flag (Context, h, M_APPENDED, 1); 73 - 74 - return 0; 75 - } 76 - diff --git a/flags.c b/flags.c 77 - index f0f3d81..dfa6a50 100644 78 - --- a/flags.c 79 - +++ b/flags.c 80 - @@ -65,7 +65,13 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 81 - { 82 - h->deleted = 0; 83 - update = 1; 84 - - if (upd_ctx) ctx->deleted--; 85 - + if (upd_ctx) 86 - + { 87 - + ctx->deleted--; 88 - + if (h->appended) 89 - + ctx->appended--; 90 - + } 91 - + h->appended = 0; /* when undeleting, also reset the appended flag */ 92 - #ifdef USE_IMAP 93 - /* see my comment above */ 94 - if (ctx->magic == M_IMAP) 95 - @@ -87,6 +93,17 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) 96 - } 97 - break; 98 - 99 - + case M_APPENDED: 100 - + if (bf) 101 - + { 102 - + if (!h->appended) 103 - + { 104 - + h->appended = 1; 105 - + if (upd_ctx) ctx->appended++; 106 - + } 107 - + } 108 - + break; 109 - + 110 - case M_NEW: 111 - 112 - if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN)) 113 - diff --git a/globals.h b/globals.h 114 - index e77030c..6a1b8da 100644 115 - --- a/globals.h 116 - +++ b/globals.h 117 - @@ -144,6 +144,7 @@ WHERE char *Tochars; 118 - WHERE char *TSStatusFormat; 119 - WHERE char *TSIconFormat; 120 - WHERE short TSSupported; 121 - +WHERE char *TrashPath; 122 - WHERE char *Username; 123 - WHERE char *Visual; 124 - 125 - diff --git a/imap/message.c b/imap/message.c 126 - index 3877381..039fda6 100644 127 - --- a/imap/message.c 128 - +++ b/imap/message.c 129 - @@ -884,6 +884,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) 130 - if (ctx->hdrs[n]->tagged) 131 - { 132 - mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1); 133 - + mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1); 134 - if (option (OPTDELETEUNTAG)) 135 - mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0); 136 - } 137 - @@ -891,6 +892,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) 138 - else 139 - { 140 - mutt_set_flag (ctx, h, M_DELETE, 1); 141 - + mutt_set_flag (ctx, h, M_APPENDED, 1); 142 - if (option (OPTDELETEUNTAG)) 143 - mutt_set_flag (ctx, h, M_TAG, 0); 144 - } 145 - diff --git a/init.h b/init.h 146 - index 6b49341..d3206f9 100644 147 - --- a/init.h 148 - +++ b/init.h 149 - @@ -3341,6 +3341,16 @@ struct option_t MuttVars[] = { 150 - ** provided that ``$$ts_enabled'' has been set. This string is identical in 151 - ** formatting to the one used by ``$$status_format''. 152 - */ 153 - + { "trash", DT_PATH, R_NONE, UL &TrashPath, 0 }, 154 - + /* 155 - + ** .pp 156 - + ** If set, this variable specifies the path of the trash folder where the 157 - + ** mails marked for deletion will be moved, instead of being irremediably 158 - + ** purged. 159 - + ** .pp 160 - + ** NOTE: When you delete a message in the trash folder, it is really 161 - + ** deleted, so that you have a way to clean the trash. 162 - + */ 163 - #ifdef USE_SOCKET 164 - { "tunnel", DT_STR, R_NONE, UL &Tunnel, UL 0 }, 165 - /* 166 - diff --git a/mutt.h b/mutt.h 167 - index f8565fa..29bb6c2 100644 168 - --- a/mutt.h 169 - +++ b/mutt.h 170 - @@ -185,6 +185,7 @@ enum 171 - M_DELETE, 172 - M_UNDELETE, 173 - M_DELETED, 174 - + M_APPENDED, 175 - M_FLAG, 176 - M_TAG, 177 - M_UNTAG, 178 - @@ -713,6 +714,7 @@ typedef struct header 179 - unsigned int mime : 1; /* has a MIME-Version header? */ 180 - unsigned int flagged : 1; /* marked important? */ 181 - unsigned int tagged : 1; 182 - + unsigned int appended : 1; /* has been saved */ 183 - unsigned int deleted : 1; 184 - unsigned int changed : 1; 185 - unsigned int attach_del : 1; /* has an attachment marked for deletion */ 186 - @@ -885,6 +887,7 @@ typedef struct _context 187 - int new; /* how many new messages? */ 188 - int unread; /* how many unread messages? */ 189 - int deleted; /* how many deleted messages */ 190 - + int appended; /* how many saved messages? */ 191 - int flagged; /* how many flagged messages */ 192 - int msgnotreadyet; /* which msg "new" in pager, -1 if none */ 193 - 194 - diff --git a/muttlib.c b/muttlib.c 195 - index 02067cc..0fd9766 100644 196 - --- a/muttlib.c 197 - +++ b/muttlib.c 198 - @@ -1505,7 +1505,9 @@ int mutt_save_confirm (const char *s, struct stat *st) 199 - 200 - if (magic > 0 && !mx_access (s, W_OK)) 201 - { 202 - - if (option (OPTCONFIRMAPPEND)) 203 - + if (option (OPTCONFIRMAPPEND) && 204 - + (!TrashPath || (mutt_strcmp (s, TrashPath) != 0))) 205 - + /* if we're appending to the trash, there's no point in asking */ 206 - { 207 - snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s); 208 - if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO) 209 - diff --git a/mx.c b/mx.c 210 - index 4c5cb07..c0a6d30 100644 211 - --- a/mx.c 212 - +++ b/mx.c 213 - @@ -776,6 +776,53 @@ static int sync_mailbox (CONTEXT *ctx, int *index_hint) 214 - return rc; 215 - } 216 - 217 - +/* move deleted mails to the trash folder */ 218 - +static int trash_append (CONTEXT *ctx) 219 - +{ 220 - + CONTEXT *ctx_trash; 221 - + int i = 0; 222 - + struct stat st, stc; 223 - + 224 - + if (!TrashPath || !ctx->deleted || 225 - + (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) 226 - + return 0; 227 - + 228 - + for (;i < ctx->msgcount && (!ctx->hdrs[i]->deleted || 229 - + ctx->hdrs[i]->appended); i++); 230 - + if (i == ctx->msgcount) 231 - + return 0; /* nothing to be done */ 232 - + 233 - + if (mutt_save_confirm (TrashPath, &st) != 0) 234 - + { 235 - + mutt_error _("message(s) not deleted"); 236 - + return -1; 237 - + } 238 - + 239 - + if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino 240 - + && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev) 241 - + return 0; /* we are in the trash folder: simple sync */ 242 - + 243 - + if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) 244 - + { 245 - + for (i = 0 ; i < ctx->msgcount ; i++) 246 - + if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended 247 - + && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1) 248 - + { 249 - + mx_close_mailbox (ctx_trash, NULL); 250 - + return -1; 251 - + } 252 - + 253 - + mx_close_mailbox (ctx_trash, NULL); 254 - + } 255 - + else 256 - + { 257 - + mutt_error _("Can't open trash folder"); 258 - + return -1; 259 - + } 260 - + 261 - + return 0; 262 - +} 263 - + 264 - /* save changes and close mailbox */ 265 - int mx_close_mailbox (CONTEXT *ctx, int *index_hint) 266 - { 267 - @@ -912,6 +959,7 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) 268 - if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0) 269 - { 270 - mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1); 271 - + mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1); 272 - } 273 - else 274 - { 275 - @@ -936,6 +984,14 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) 276 - return 0; 277 - } 278 - 279 - + /* copy mails to the trash before expunging */ 280 - + if (purge && ctx->deleted && mutt_strcmp(ctx->path, TrashPath)) 281 - + if (trash_append (ctx) != 0) 282 - + { 283 - + ctx->closing = 0; 284 - + return -1; 285 - + } 286 - + 287 - #ifdef USE_IMAP 288 - /* allow IMAP to preserve the deleted flag across sessions */ 289 - if (ctx->magic == M_IMAP) 290 - @@ -1133,6 +1189,12 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) 291 - msgcount = ctx->msgcount; 292 - deleted = ctx->deleted; 293 - 294 - + if (purge && ctx->deleted && mutt_strcmp(ctx->path, TrashPath)) 295 - + { 296 - + if (trash_append (ctx) == -1) 297 - + return -1; 298 - + } 299 - + 300 - #ifdef USE_IMAP 301 - if (ctx->magic == M_IMAP) 302 - rc = imap_sync_mailbox (ctx, purge, index_hint); 303 - diff --git a/postpone.c b/postpone.c 304 - index a703161..7a4cbb1 100644 305 - --- a/postpone.c 306 - +++ b/postpone.c 307 - @@ -277,6 +277,9 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size 308 - /* finished with this message, so delete it. */ 309 - mutt_set_flag (PostContext, h, M_DELETE, 1); 310 - 311 - + /* and consider it saved, so that it won't be moved to the trash folder */ 312 - + mutt_set_flag (PostContext, h, M_APPENDED, 1); 313 - + 314 - /* update the count for the status display */ 315 - PostCount = PostContext->msgcount - PostContext->deleted; 316 -
+797
pkgs/applications/networking/mailreaders/mutt/trash.patch
··· 1 + diff -urN mutt-1.6.1/commands.c mutt-1.6.1-trash/commands.c 2 + --- mutt-1.6.1/commands.c 2016-06-12 18:43:00.397447512 +0100 3 + +++ mutt-1.6.1-trash/commands.c 2016-06-12 18:43:04.892517610 +0100 4 + @@ -720,6 +720,7 @@ 5 + if (option (OPTDELETEUNTAG)) 6 + mutt_set_flag (Context, h, M_TAG, 0); 7 + } 8 + + mutt_set_flag (Context, h, M_APPENDED, 1); 9 + 10 + return 0; 11 + } 12 + diff -urN mutt-1.6.1/curs_main.c mutt-1.6.1-trash/curs_main.c 13 + --- mutt-1.6.1/curs_main.c 2016-06-12 18:43:00.399447544 +0100 14 + +++ mutt-1.6.1-trash/curs_main.c 2016-06-12 18:43:04.895517656 +0100 15 + @@ -1919,6 +1919,7 @@ 16 + MAYBE_REDRAW (menu->redraw); 17 + break; 18 + 19 + + case OP_PURGE_MESSAGE: 20 + case OP_DELETE: 21 + 22 + CHECK_MSGCOUNT; 23 + @@ -1930,6 +1931,7 @@ 24 + if (tag) 25 + { 26 + mutt_tag_set_flag (M_DELETE, 1); 27 + + mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1); 28 + if (option (OPTDELETEUNTAG)) 29 + mutt_tag_set_flag (M_TAG, 0); 30 + menu->redraw = REDRAW_INDEX; 31 + @@ -1937,6 +1939,8 @@ 32 + else 33 + { 34 + mutt_set_flag (Context, CURHDR, M_DELETE, 1); 35 + + mutt_set_flag (Context, CURHDR, M_PURGED, 36 + + (op != OP_PURGE_MESSAGE) ? 0 : 1); 37 + if (option (OPTDELETEUNTAG)) 38 + mutt_set_flag (Context, CURHDR, M_TAG, 0); 39 + if (option (OPTRESOLVE)) 40 + @@ -2242,11 +2246,13 @@ 41 + if (tag) 42 + { 43 + mutt_tag_set_flag (M_DELETE, 0); 44 + + mutt_tag_set_flag (M_PURGED, 0); 45 + menu->redraw = REDRAW_INDEX; 46 + } 47 + else 48 + { 49 + mutt_set_flag (Context, CURHDR, M_DELETE, 0); 50 + + mutt_set_flag (Context, CURHDR, M_PURGED, 0); 51 + if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) 52 + { 53 + menu->current++; 54 + @@ -2268,9 +2274,11 @@ 55 + CHECK_ACL(M_ACL_DELETE, _("Cannot undelete message(s)")); 56 + 57 + rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0, 58 + - op == OP_UNDELETE_THREAD ? 0 : 1); 59 + + op == OP_UNDELETE_THREAD ? 0 : 1) 60 + + + mutt_thread_set_flag (CURHDR, M_PURGED, 0, 61 + + (op == OP_UNDELETE_THREAD) ? 0 : 1); 62 + 63 + - if (rc != -1) 64 + + if (rc > -1) 65 + { 66 + if (option (OPTRESOLVE)) 67 + { 68 + diff -urN mutt-1.6.1/doc/manual.xml.head mutt-1.6.1-trash/doc/manual.xml.head 69 + --- mutt-1.6.1/doc/manual.xml.head 2016-06-12 18:43:00.402447590 +0100 70 + +++ mutt-1.6.1-trash/doc/manual.xml.head 2016-06-12 18:43:04.901517750 +0100 71 + @@ -7467,6 +7467,16 @@ 72 + 73 + </sect2> 74 + 75 + +<sect2 id="mutt-patches"> 76 + +<title>Mutt Patches</title> 77 + +<para> 78 + +Mutt may also be <quote>patched</quote> to support smaller features. 79 + +These patches should add a free-form string to the end Mutt's version string. 80 + +Running <literal>mutt -v</literal> might show: 81 + +<screen>patch-1.6.1.sidebar.20160502</screen> 82 + +</para> 83 + +</sect2> 84 + + 85 + <sect2 id="url-syntax"> 86 + <title>URL Syntax</title> 87 + 88 + @@ -8081,6 +8091,175 @@ 89 + 90 + </sect1> 91 + 92 + +<sect1 id="trash-folder"> 93 + + <title>Trash Folder Patch</title> 94 + + <subtitle>Automatically move "deleted" emails to a trash bin</subtitle> 95 + + 96 + + <sect2 id="trash-folder-patch"> 97 + + <title>Patch</title> 98 + + 99 + + <para> 100 + + To check if Mutt supports <quote>Trash Folder</quote>, look for 101 + + <quote>patch-trash</quote> in the mutt version. 102 + + See: <xref linkend="mutt-patches"/>. 103 + + </para> 104 + + 105 + + If IMAP is enabled, this patch will use it 106 + + 107 + + <itemizedlist> 108 + + <title>Dependencies:</title> 109 + + <listitem><para>mutt-1.6.1</para></listitem> 110 + + <listitem><para>IMAP support</para></listitem> 111 + + </itemizedlist> 112 + + 113 + + <para>This patch is part of the <ulink url="http://www.neomutt.org/">NeoMutt Project</ulink>.</para> 114 + + </sect2> 115 + + 116 + + <sect2 id="trash-folder-intro"> 117 + + <title>Introduction</title> 118 + + 119 + + <para> 120 + + In Mutt, when you <quote>delete</quote> an email it is first marked 121 + + deleted. The email isn't really gone until 122 + + <link linkend="index-map">&lt;sync-mailbox&gt;</link> is called. 123 + + This happens when the user leaves the folder, or the function is called 124 + + manually. 125 + + </para> 126 + + 127 + + <para> 128 + + After <literal>&lt;sync-mailbox&gt;</literal> has been called the email is gone forever. 129 + + </para> 130 + + 131 + + <para> 132 + + The <link linkend="trash">$trash</link> variable defines a folder in 133 + + which to keep old emails. As before, first you mark emails for 134 + + deletion. When &lt;sync-mailbox&gt; is called the emails are moved to 135 + + the trash folder. 136 + + </para> 137 + + 138 + + <para> 139 + + The <literal>$trash</literal> path can be either a full directory, 140 + + or be relative to the <link linkend="folder">$folder</link> 141 + + variable, like the <literal>mailboxes</literal> command. 142 + + </para> 143 + + 144 + + <note> 145 + + Emails deleted from the trash folder are gone forever. 146 + + </note> 147 + + </sect2> 148 + + 149 + + <sect2 id="trash-folder-variables"> 150 + + <title>Variables</title> 151 + + <table id="table-trash-variables"> 152 + + <title>Trash Variables</title> 153 + + <tgroup cols="3"> 154 + + <thead> 155 + + <row> 156 + + <entry>Name</entry> 157 + + <entry>Type</entry> 158 + + <entry>Default</entry> 159 + + </row> 160 + + </thead> 161 + + <tbody> 162 + + <row> 163 + + <entry>trash</entry> 164 + + <entry>string</entry> 165 + + <entry>(none)</entry> 166 + + </row> 167 + + </tbody> 168 + + </tgroup> 169 + + </table> 170 + + </sect2> 171 + + 172 + + <sect2 id="trash-folder-functions"> 173 + + <title>Functions</title> 174 + + <table id="table-trash-functions"> 175 + + <title>Trash Functions</title> 176 + + <tgroup cols="4"> 177 + + <thead> 178 + + <row> 179 + + <entry>Menus</entry> 180 + + <entry>Default Key</entry> 181 + + <entry>Function</entry> 182 + + <entry>Description</entry> 183 + + </row> 184 + + </thead> 185 + + <tbody> 186 + + <row> 187 + + <entry>index,pager</entry> 188 + + <entry>(none)</entry> 189 + + <entry><literal>&lt;purge-message&gt;</literal></entry> 190 + + <entry>really delete the current entry, bypassing the trash folder</entry> 191 + + </row> 192 + + </tbody> 193 + + </tgroup> 194 + + </table> 195 + + </sect2> 196 + + 197 + +<!-- 198 + + <sect2 id="trash-folder-commands"> 199 + + <title>Commands</title> 200 + + <para>None</para> 201 + + </sect2> 202 + + 203 + + <sect2 id="trash-folder-colors"> 204 + + <title>Colors</title> 205 + + <para>None</para> 206 + + </sect2> 207 + + 208 + + <sect2 id="trash-folder-sort"> 209 + + <title>Sort</title> 210 + + <para>None</para> 211 + + </sect2> 212 + +--> 213 + + 214 + + <sect2 id="trash-folder-muttrc"> 215 + + <title>Muttrc</title> 216 + +<screen> 217 + +<emphasis role="comment"># Example Mutt config file for the 'trash' feature. 218 + + 219 + +# This feature defines a new 'trash' folder. 220 + +# When mail is deleted it will be moved to this folder. 221 + + 222 + +# Folder in which to put deleted emails</emphasis> 223 + +set trash='+Trash' 224 + +set trash='/home/flatcap/Mail/Trash' 225 + + 226 + +<emphasis role="comment"># The default delete key 'd' will move an email to the 'trash' folder 227 + +# Bind 'D' to REALLY delete an email</emphasis> 228 + +bind index D purge-message 229 + + 230 + +<emphasis role="comment"># Note: Deleting emails from the 'trash' folder will REALLY delete them. 231 + + 232 + +# vim: syntax=muttrc</emphasis> 233 + +</screen> 234 + + </sect2> 235 + + 236 + + <sect2 id="trash-folder-see-also"> 237 + + <title>See Also</title> 238 + + 239 + + <itemizedlist> 240 + + <listitem><para><ulink url="http://www.neomutt.org/">NeoMutt Project</ulink></para></listitem> 241 + + <listitem><para><link linkend="folder-hook">folder-hook</link></para></listitem> 242 + + </itemizedlist> 243 + + </sect2> 244 + + 245 + + <sect2 id="trash-folder-known-bugs"> 246 + + <title>Known Bugs</title> 247 + + <para>None</para> 248 + + </sect2> 249 + + 250 + + <sect2 id="trash-folder-credits"> 251 + + <title>Credits</title> 252 + + <itemizedlist> 253 + + <listitem><para>Cedric Duval <email>cedricduval@free.fr</email></para></listitem> 254 + + <listitem><para>Benjamin Kuperman <email>kuperman@acm.org</email></para></listitem> 255 + + <listitem><para>Paul Miller <email>paul@voltar.org</email></para></listitem> 256 + + <listitem><para>Richard Russon <email>rich@flatcap.org</email></para></listitem> 257 + + </itemizedlist> 258 + + </sect2> 259 + +</sect1> 260 + + 261 + </chapter> 262 + 263 + <chapter id="security"> 264 + diff -urN mutt-1.6.1/doc/muttrc.trash mutt-1.6.1-trash/doc/muttrc.trash 265 + --- mutt-1.6.1/doc/muttrc.trash 1970-01-01 01:00:00.000000000 +0100 266 + +++ mutt-1.6.1-trash/doc/muttrc.trash 2016-06-12 18:43:04.768515676 +0100 267 + @@ -0,0 +1,16 @@ 268 + +# Example Mutt config file for the 'trash' feature. 269 + + 270 + +# This feature defines a new 'trash' folder. 271 + +# When mail is deleted it will be moved to this folder. 272 + + 273 + +# Folder in which to put deleted emails 274 + +set trash='+Trash' 275 + +set trash='/home/flatcap/Mail/Trash' 276 + + 277 + +# The default delete key 'd' will move an email to the 'trash' folder 278 + +# Bind 'D' to REALLY delete an email 279 + +bind index D purge-message 280 + + 281 + +# Note: Deleting emails from the 'trash' folder will REALLY delete them. 282 + + 283 + +# vim: syntax=muttrc 284 + diff -urN mutt-1.6.1/doc/vimrc.trash mutt-1.6.1-trash/doc/vimrc.trash 285 + --- mutt-1.6.1/doc/vimrc.trash 1970-01-01 01:00:00.000000000 +0100 286 + +++ mutt-1.6.1-trash/doc/vimrc.trash 2016-06-12 18:43:04.769515692 +0100 287 + @@ -0,0 +1,7 @@ 288 + +" Vim syntax file for the mutt trash patch 289 + + 290 + +syntax keyword muttrcVarStr contained skipwhite trash nextgroup=muttrcVarEqualsIdxFmt 291 + + 292 + +syntax match muttrcFunction contained "\<purge-message\>" 293 + + 294 + +" vim: syntax=vim 295 + diff -urN mutt-1.6.1/flags.c mutt-1.6.1-trash/flags.c 296 + --- mutt-1.6.1/flags.c 2016-06-12 18:43:00.403447606 +0100 297 + +++ mutt-1.6.1-trash/flags.c 2016-06-12 18:43:04.902517766 +0100 298 + @@ -65,7 +65,13 @@ 299 + { 300 + h->deleted = 0; 301 + update = 1; 302 + - if (upd_ctx) ctx->deleted--; 303 + + if (upd_ctx) { 304 + + ctx->deleted--; 305 + + if (h->appended) { 306 + + ctx->appended--; 307 + + } 308 + + } 309 + + h->appended = 0; /* when undeleting, also reset the appended flag */ 310 + #ifdef USE_IMAP 311 + /* see my comment above */ 312 + if (ctx->magic == M_IMAP) 313 + @@ -87,6 +93,27 @@ 314 + } 315 + break; 316 + 317 + + case M_APPENDED: 318 + + if (bf) { 319 + + if (!h->appended) { 320 + + h->appended = 1; 321 + + if (upd_ctx) { 322 + + ctx->appended++; 323 + + } 324 + + } 325 + + } 326 + + break; 327 + + 328 + + case M_PURGED: 329 + + if (bf) { 330 + + if (!h->purged) { 331 + + h->purged = 1; 332 + + } 333 + + } else if (h->purged) { 334 + + h->purged = 0; 335 + + } 336 + + break; 337 + + 338 + case M_NEW: 339 + 340 + if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN)) 341 + diff -urN mutt-1.6.1/functions.h mutt-1.6.1-trash/functions.h 342 + --- mutt-1.6.1/functions.h 2016-06-12 18:43:00.403447606 +0100 343 + +++ mutt-1.6.1-trash/functions.h 2016-06-12 18:43:04.902517766 +0100 344 + @@ -121,6 +121,7 @@ 345 + { "toggle-write", OP_TOGGLE_WRITE, "%" }, 346 + { "next-thread", OP_MAIN_NEXT_THREAD, "\016" }, 347 + { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" }, 348 + + { "purge-message", OP_PURGE_MESSAGE, NULL }, 349 + { "query", OP_QUERY, "Q" }, 350 + { "quit", OP_QUIT, "q" }, 351 + { "reply", OP_REPLY, "r" }, 352 + @@ -213,6 +214,7 @@ 353 + { "print-message", OP_PRINT, "p" }, 354 + { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, 355 + { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" }, 356 + + { "purge-message", OP_PURGE_MESSAGE, NULL }, 357 + { "quit", OP_QUIT, "Q" }, 358 + { "exit", OP_EXIT, "q" }, 359 + { "reply", OP_REPLY, "r" }, 360 + diff -urN mutt-1.6.1/globals.h mutt-1.6.1-trash/globals.h 361 + --- mutt-1.6.1/globals.h 2016-06-12 18:43:00.403447606 +0100 362 + +++ mutt-1.6.1-trash/globals.h 2016-06-12 18:43:04.903517781 +0100 363 + @@ -141,6 +141,7 @@ 364 + WHERE char *Status; 365 + WHERE char *Tempdir; 366 + WHERE char *Tochars; 367 + +WHERE char *TrashPath; 368 + WHERE char *TSStatusFormat; 369 + WHERE char *TSIconFormat; 370 + WHERE short TSSupported; 371 + diff -urN mutt-1.6.1/imap/imap.c mutt-1.6.1-trash/imap/imap.c 372 + --- mutt-1.6.1/imap/imap.c 2016-06-12 18:43:00.405447637 +0100 373 + +++ mutt-1.6.1-trash/imap/imap.c 2016-06-12 18:43:04.905517812 +0100 374 + @@ -888,6 +888,12 @@ 375 + if (hdrs[n]->deleted != HEADER_DATA(hdrs[n])->deleted) 376 + match = invert ^ hdrs[n]->deleted; 377 + break; 378 + + case M_EXPIRED: /* imap_fast_trash version of M_DELETED */ 379 + + if (hdrs[n]->purged) 380 + + break; 381 + + if (hdrs[n]->deleted != HEADER_DATA(hdrs[n])->deleted) 382 + + match = invert ^ (hdrs[n]->deleted && !hdrs[n]->appended); 383 + + break; 384 + case M_FLAG: 385 + if (hdrs[n]->flagged != HEADER_DATA(hdrs[n])->flagged) 386 + match = invert ^ hdrs[n]->flagged; 387 + @@ -2038,3 +2044,53 @@ 388 + 389 + return -1; 390 + } 391 + + 392 + +/** 393 + + * imap_fast_trash - XXX 394 + + */ 395 + +int 396 + +imap_fast_trash (void) 397 + +{ 398 + + if ((Context->magic == M_IMAP) && mx_is_imap (TrashPath)) { 399 + + IMAP_MBOX mx; 400 + + IMAP_DATA *idata = (IMAP_DATA *) Context->data; 401 + + char mbox[LONG_STRING]; 402 + + char mmbox[LONG_STRING]; 403 + + int rc; 404 + + dprint (1, (debugfile, "[itf] trashcan seems to be on imap.\n")); 405 + + 406 + + if (imap_parse_path (TrashPath, &mx) == 0) { 407 + + if (mutt_account_match (&(idata->conn->account), &(mx.account))) { 408 + + dprint (1, (debugfile, "[itf] trashcan seems to be on the same account.\n")); 409 + + 410 + + imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox)); 411 + + if (!*mbox) 412 + + strfcpy (mbox, "INBOX", sizeof (mbox)); 413 + + imap_munge_mbox_name (idata, mmbox, sizeof (mmbox), mbox); 414 + + 415 + + rc = imap_exec_msgset (idata, "UID COPY", mmbox, M_EXPIRED, 0, 0); 416 + + if (rc == 0) { 417 + + dprint (1, (debugfile, "imap_copy_messages: No messages del-tagged\n")); 418 + + rc = -1; 419 + + goto old_way; 420 + + } else if (rc < 0) { 421 + + dprint (1, (debugfile, "could not queue copy\n")); 422 + + goto old_way; 423 + + } else { 424 + + mutt_message (_("Copying %d messages to %s..."), rc, mbox); 425 + + return 0; 426 + + } 427 + + } else { 428 + + dprint (1, (debugfile, "[itf] trashcan seems to be on a different account.\n")); 429 + + } 430 + +old_way: 431 + + FREE(&mx.mbox); /* we probably only need to free this when the parse works */ 432 + + } else { 433 + + dprint (1, (debugfile, "[itf] failed to parse TrashPath.\n")); 434 + + } 435 + + 436 + + dprint (1, (debugfile, "[itf] giving up and trying old fasioned way.\n")); 437 + + } 438 + + 439 + + return 1; 440 + +} 441 + diff -urN mutt-1.6.1/imap/imap.h mutt-1.6.1-trash/imap/imap.h 442 + --- mutt-1.6.1/imap/imap.h 2016-06-12 18:43:00.405447637 +0100 443 + +++ mutt-1.6.1-trash/imap/imap.h 2016-06-12 18:43:04.774515769 +0100 444 + @@ -72,4 +72,7 @@ 445 + 446 + int imap_account_match (const ACCOUNT* a1, const ACCOUNT* a2); 447 + 448 + +/* trash */ 449 + +int imap_fast_trash (void); 450 + + 451 + #endif 452 + diff -urN mutt-1.6.1/imap/message.c mutt-1.6.1-trash/imap/message.c 453 + --- mutt-1.6.1/imap/message.c 2016-06-12 18:43:00.406447652 +0100 454 + +++ mutt-1.6.1-trash/imap/message.c 2016-06-12 18:43:04.906517828 +0100 455 + @@ -886,6 +886,7 @@ 456 + if (ctx->hdrs[n]->tagged) 457 + { 458 + mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1); 459 + + mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1); 460 + if (option (OPTDELETEUNTAG)) 461 + mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0); 462 + } 463 + @@ -893,6 +894,7 @@ 464 + else 465 + { 466 + mutt_set_flag (ctx, h, M_DELETE, 1); 467 + + mutt_set_flag (ctx, h, M_APPENDED, 1); 468 + if (option (OPTDELETEUNTAG)) 469 + mutt_set_flag (ctx, h, M_TAG, 0); 470 + } 471 + diff -urN mutt-1.6.1/init.h mutt-1.6.1-trash/init.h 472 + --- mutt-1.6.1/init.h 2016-06-12 18:43:00.408447684 +0100 473 + +++ mutt-1.6.1-trash/init.h 2016-06-12 18:43:04.909517875 +0100 474 + @@ -3419,6 +3419,16 @@ 475 + ** provided that ``$$ts_enabled'' has been set. This string is identical in 476 + ** formatting to the one used by ``$$status_format''. 477 + */ 478 + + { "trash", DT_PATH, R_NONE, UL &TrashPath, 0 }, 479 + + /* 480 + + ** .pp 481 + + ** If set, this variable specifies the path of the trash folder where the 482 + + ** mails marked for deletion will be moved, instead of being irremediably 483 + + ** purged. 484 + + ** .pp 485 + + ** NOTE: When you delete a message in the trash folder, it is really 486 + + ** deleted, so that you have a way to clean the trash. 487 + + */ 488 + #ifdef USE_SOCKET 489 + { "tunnel", DT_STR, R_NONE, UL &Tunnel, UL 0 }, 490 + /* 491 + diff -urN mutt-1.6.1/mutt.h mutt-1.6.1-trash/mutt.h 492 + --- mutt-1.6.1/mutt.h 2016-06-12 18:43:00.410447715 +0100 493 + +++ mutt-1.6.1-trash/mutt.h 2016-06-12 18:43:04.912517922 +0100 494 + @@ -182,6 +182,8 @@ 495 + M_DELETE, 496 + M_UNDELETE, 497 + M_DELETED, 498 + + M_APPENDED, 499 + + M_PURGED, 500 + M_FLAG, 501 + M_TAG, 502 + M_UNTAG, 503 + @@ -719,6 +721,8 @@ 504 + unsigned int mime : 1; /* has a MIME-Version header? */ 505 + unsigned int flagged : 1; /* marked important? */ 506 + unsigned int tagged : 1; 507 + + unsigned int appended : 1; /* has been saved */ 508 + + unsigned int purged : 1; /* bypassing the trash folder */ 509 + unsigned int deleted : 1; 510 + unsigned int changed : 1; 511 + unsigned int attach_del : 1; /* has an attachment marked for deletion */ 512 + @@ -891,6 +895,7 @@ 513 + int new; /* how many new messages? */ 514 + int unread; /* how many unread messages? */ 515 + int deleted; /* how many deleted messages */ 516 + + int appended; /* how many saved messages? */ 517 + int flagged; /* how many flagged messages */ 518 + int msgnotreadyet; /* which msg "new" in pager, -1 if none */ 519 + 520 + diff -urN mutt-1.6.1/muttlib.c mutt-1.6.1-trash/muttlib.c 521 + --- mutt-1.6.1/muttlib.c 2016-06-12 18:43:00.411447731 +0100 522 + +++ mutt-1.6.1-trash/muttlib.c 2016-06-12 18:43:04.913517937 +0100 523 + @@ -1511,7 +1511,9 @@ 524 + 525 + if (magic > 0 && !mx_access (s, W_OK)) 526 + { 527 + - if (option (OPTCONFIRMAPPEND)) 528 + + if (option (OPTCONFIRMAPPEND) && 529 + + (!TrashPath || (mutt_strcmp (s, TrashPath) != 0))) 530 + + /* if we're appending to the trash, there's no point in asking */ 531 + { 532 + snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s); 533 + if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO) 534 + diff -urN mutt-1.6.1/mx.c mutt-1.6.1-trash/mx.c 535 + --- mutt-1.6.1/mx.c 2016-06-12 18:43:00.411447731 +0100 536 + +++ mutt-1.6.1-trash/mx.c 2016-06-12 18:43:04.914517953 +0100 537 + @@ -776,6 +776,62 @@ 538 + return rc; 539 + } 540 + 541 + +/** 542 + + * trash_append - XXX 543 + + * 544 + + * move deleted mails to the trash folder 545 + + */ 546 + +static int trash_append (CONTEXT *ctx) 547 + +{ 548 + + CONTEXT *ctx_trash; 549 + + int i = 0; 550 + + struct stat st, stc; 551 + + 552 + + if (!TrashPath || !ctx->deleted || 553 + + ((ctx->magic == M_MAILDIR) && option (OPTMAILDIRTRASH))) { 554 + + return 0; 555 + + } 556 + + 557 + + for (; i < ctx->msgcount && (!ctx->hdrs[i]->deleted || ctx->hdrs[i]->appended); i++); 558 + + /* nothing */ 559 + + 560 + + if (i == ctx->msgcount) 561 + + return 0; /* nothing to be done */ 562 + + 563 + + if (mutt_save_confirm (TrashPath, &st) != 0) { 564 + + mutt_error _("message(s) not deleted"); 565 + + return -1; 566 + + } 567 + + 568 + + if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino 569 + + && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev) { 570 + + return 0; /* we are in the trash folder: simple sync */ 571 + + } 572 + + 573 + +#ifdef USE_IMAP 574 + + if (!imap_fast_trash()) 575 + + return 0; 576 + +#endif 577 + + 578 + + if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) { 579 + + for (i = 0 ; i < ctx->msgcount ; i++) { 580 + + if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended 581 + + && !ctx->hdrs[i]->purged 582 + + && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1) { 583 + + mx_close_mailbox (ctx_trash, NULL); 584 + + return -1; 585 + + } 586 + + } 587 + + 588 + + mx_close_mailbox (ctx_trash, NULL); 589 + + } else { 590 + + mutt_error _("Can't open trash folder"); 591 + + return -1; 592 + + } 593 + + 594 + + return 0; 595 + +} 596 + + 597 + /* save changes and close mailbox */ 598 + int mx_close_mailbox (CONTEXT *ctx, int *index_hint) 599 + { 600 + @@ -912,6 +968,7 @@ 601 + if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0) 602 + { 603 + mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1); 604 + + mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1); 605 + } 606 + else 607 + { 608 + @@ -936,6 +993,14 @@ 609 + return 0; 610 + } 611 + 612 + + /* copy mails to the trash before expunging */ 613 + + if (purge && ctx->deleted && mutt_strcmp (ctx->path, TrashPath)) { 614 + + if (trash_append (ctx) != 0) { 615 + + ctx->closing = 0; 616 + + return -1; 617 + + } 618 + + } 619 + + 620 + #ifdef USE_IMAP 621 + /* allow IMAP to preserve the deleted flag across sessions */ 622 + if (ctx->magic == M_IMAP) 623 + @@ -1140,6 +1205,12 @@ 624 + msgcount = ctx->msgcount; 625 + deleted = ctx->deleted; 626 + 627 + + if (purge && ctx->deleted && mutt_strcmp (ctx->path, TrashPath)) { 628 + + if (trash_append (ctx) == -1) { 629 + + return -1; 630 + + } 631 + + } 632 + + 633 + #ifdef USE_IMAP 634 + if (ctx->magic == M_IMAP) 635 + rc = imap_sync_mailbox (ctx, purge, index_hint); 636 + diff -urN mutt-1.6.1/OPS mutt-1.6.1-trash/OPS 637 + --- mutt-1.6.1/OPS 2016-06-12 18:43:00.389447388 +0100 638 + +++ mutt-1.6.1-trash/OPS 2016-06-12 18:43:04.883517469 +0100 639 + @@ -142,6 +142,7 @@ 640 + OP_PREV_LINE "scroll up one line" 641 + OP_PREV_PAGE "move to the previous page" 642 + OP_PRINT "print the current entry" 643 + +OP_PURGE_MESSAGE "really delete the current entry, bypassing the trash folder" 644 + OP_QUERY "query external program for addresses" 645 + OP_QUERY_APPEND "append new query results to current results" 646 + OP_QUIT "save changes to mailbox and quit" 647 + diff -urN mutt-1.6.1/pager.c mutt-1.6.1-trash/pager.c 648 + --- mutt-1.6.1/pager.c 2016-06-12 18:43:00.412447746 +0100 649 + +++ mutt-1.6.1-trash/pager.c 2016-06-12 18:43:04.915517968 +0100 650 + @@ -2351,6 +2351,7 @@ 651 + MAYBE_REDRAW (redraw); 652 + break; 653 + 654 + + case OP_PURGE_MESSAGE: 655 + case OP_DELETE: 656 + CHECK_MODE(IsHeader (extra)); 657 + CHECK_READONLY; 658 + @@ -2358,6 +2359,8 @@ 659 + CHECK_ACL(M_ACL_DELETE, _("Cannot delete message")); 660 + 661 + mutt_set_flag (Context, extra->hdr, M_DELETE, 1); 662 + + mutt_set_flag (Context, extra->hdr, M_PURGED, 663 + + ch != OP_PURGE_MESSAGE ? 0 : 1); 664 + if (option (OPTDELETEUNTAG)) 665 + mutt_set_flag (Context, extra->hdr, M_TAG, 0); 666 + redraw = REDRAW_STATUS | REDRAW_INDEX; 667 + @@ -2688,6 +2691,7 @@ 668 + CHECK_ACL(M_ACL_DELETE, _("Cannot undelete message")); 669 + 670 + mutt_set_flag (Context, extra->hdr, M_DELETE, 0); 671 + + mutt_set_flag (Context, extra->hdr, M_PURGED, 0); 672 + redraw = REDRAW_STATUS | REDRAW_INDEX; 673 + if (option (OPTRESOLVE)) 674 + { 675 + @@ -2704,9 +2708,11 @@ 676 + CHECK_ACL(M_ACL_DELETE, _("Cannot undelete message(s)")); 677 + 678 + r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0, 679 + + ch == OP_UNDELETE_THREAD ? 0 : 1) 680 + + + mutt_thread_set_flag (extra->hdr, M_PURGED, 0, 681 + ch == OP_UNDELETE_THREAD ? 0 : 1); 682 + 683 + - if (r != -1) 684 + + if (r > -1) 685 + { 686 + if (option (OPTRESOLVE)) 687 + { 688 + diff -urN mutt-1.6.1/PATCHES mutt-1.6.1-trash/PATCHES 689 + --- mutt-1.6.1/PATCHES 2016-06-12 18:43:00.395447481 +0100 690 + +++ mutt-1.6.1-trash/PATCHES 2016-06-12 18:43:04.889517563 +0100 691 + @@ -0,0 +1 @@ 692 + +patch-trash-neo-20160612 693 + diff -urN mutt-1.6.1/pattern.c mutt-1.6.1-trash/pattern.c 694 + --- mutt-1.6.1/pattern.c 2016-06-12 18:43:00.413447762 +0100 695 + +++ mutt-1.6.1-trash/pattern.c 2016-06-12 18:43:04.916517984 +0100 696 + @@ -1367,8 +1367,9 @@ 697 + { 698 + switch (op) 699 + { 700 + - case M_DELETE: 701 + case M_UNDELETE: 702 + + mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED, 0); 703 + + case M_DELETE: 704 + mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, 705 + (op == M_DELETE)); 706 + break; 707 + diff -urN mutt-1.6.1/postpone.c mutt-1.6.1-trash/postpone.c 708 + --- mutt-1.6.1/postpone.c 2016-06-12 18:43:00.414447777 +0100 709 + +++ mutt-1.6.1-trash/postpone.c 2016-06-12 18:43:04.917518000 +0100 710 + @@ -277,6 +277,9 @@ 711 + /* finished with this message, so delete it. */ 712 + mutt_set_flag (PostContext, h, M_DELETE, 1); 713 + 714 + + /* and consider it saved, so that it won't be moved to the trash folder */ 715 + + mutt_set_flag (PostContext, h, M_APPENDED, 1); 716 + + 717 + /* update the count for the status display */ 718 + PostCount = PostContext->msgcount - PostContext->deleted; 719 + 720 + diff -urN mutt-1.6.1/README.trash mutt-1.6.1-trash/README.trash 721 + --- mutt-1.6.1/README.trash 1970-01-01 01:00:00.000000000 +0100 722 + +++ mutt-1.6.1-trash/README.trash 2016-06-12 18:43:04.748515364 +0100 723 + @@ -0,0 +1,74 @@ 724 + +Trash Folder Patch 725 + +================== 726 + + 727 + + Automatically move "deleted" emails to a trash bin 728 + + 729 + +Patch 730 + +----- 731 + + 732 + + To check if Mutt supports "Trash Folder", look for "patch-trash" in the 733 + + mutt version. 734 + + 735 + + If IMAP is enabled, this patch will use it 736 + + 737 + + Dependencies 738 + + * mutt-1.6.1 739 + + * IMAP support 740 + + 741 + +Introduction 742 + +------------ 743 + + 744 + + In Mutt, when you "delete" an email it is first marked deleted. The email 745 + + isn't really gone until <sync-mailbox> is called. This happens when the 746 + + user leaves the folder, or the function is called manually. 747 + + 748 + + After '<sync-mailbox>' has been called the email is gone forever. 749 + + 750 + + The $trash variable defines a folder in which to keep old emails. As 751 + + before, first you mark emails for deletion. When <sync-mailbox> is called 752 + + the emails are moved to the trash folder. 753 + + 754 + + The '$trash' path can be either a full directory, or be relative to the 755 + + $folder variable, like the 'mailboxes' command. 756 + + 757 + + > Note 758 + + > 759 + + > Emails deleted from the trash folder are gone forever. 760 + + 761 + +Variables 762 + +--------- 763 + + 764 + + Trash Variables 765 + + 766 + + | Name | Type | Default | 767 + + |-------|--------|---------| 768 + + | trash | string | (none) | 769 + + 770 + +Functions 771 + +--------- 772 + + 773 + + Trash Functions 774 + + 775 + + | Menus | Default Key | Function | Description | 776 + + |-------------|-------------|-------------------|-------------------------------------------------------------| 777 + + | index,pager | (none) | '<purge-message>' | really delete the current entry, bypassing the trash folder | 778 + + 779 + +See Also 780 + +-------- 781 + + 782 + + * NeoMutt project 783 + + * folder-hook 784 + + 785 + +Known Bugs 786 + +---------- 787 + + 788 + + None 789 + + 790 + +Credits 791 + +------- 792 + + 793 + + * Cedric Duval <cedricduval@free.fr> 794 + + * Benjamin Kuperman <kuperman@acm.org> 795 + + * Paul Miller <paul@voltar.org> 796 + + * Richard Russon <rich@flatcap.org> 797 + +