First, thanks for including sidebar in the official release. I find it
invaluable and allows me to use mutt in a work environment.

I do have a couple quibbles with the default behavior and have attached
two patches to tweak it. There are no configuration options for these
patches and they soft-fail in a couple side cases, so they are more
talking points at this time.

===== patch-1.6.2-sidebar-newonly_REALLY.diff =====

The first, patch-1.6.2-sidebar-newonly_REALLY.diff, modifies the check
within update_entries_visibility() to only check against
sbe->buffy->msg_unread. I know this includes old and new messages, but it
seems the best balance of usefulness to me. 

To me, the proper solution would be to ditch the entire
sidebar_new_mail_only variable and parse sidebar_format. If the user
specified %N then check against buffy->msg_unread. If the user specified
%n then check against buffy->new, etc.

If there is any interest in this let me know and I will see what I can
do. I feel like there should be some way to reuse/expand cb_format_str()
but I'm not seeing it right now.

===== patch-1.6.2-sidebar-nofollow.patch =====

The second, patch-1.6.2-sidebar-nofollow.patch, changes the behavior in
prepare_sidebar() where TopIndex gets set. If all of the non-hidden
mailboxes fit on screen then leave TopIndex at the top. If not all fit,
then it currently anchors at the last visible mailbox. BUG: this
soft-breaks if you have more than 2 pages of mailboxes in the sidebar.
BUG: it also, currently, completly ignores HilIndex. Again, let me
know if there is interest and I will work on cleaning it up.

The major question on this one would be: hardcode the behavior or
offer a config variable?

-- 
Mother is far too clever to understand anything she does not like.
diff -u --show-c-function mutt-1.6.2.orig/sidebar.c mutt-1.6.2-1-ow/sidebar.c
--- mutt-1.6.2.orig/sidebar.c	2016-08-01 17:22:46.000000000 -0700
+++ mutt-1.6.2-1-ow/sidebar.c	2016-08-02 16:58:18.920169504 -0700
@@ -341,8 +341,7 @@ static void update_entries_visibility (v
     if (!new_only)
       continue;
 
-    if ((i == OpnIndex) || (sbe->buffy->msg_unread  > 0) || sbe->buffy->new ||
-        (i == HilIndex) || (sbe->buffy->msg_flagged > 0))
+    if ((i == OpnIndex) || (i == HilIndex) || (sbe->buffy->msg_unread > 0))
       continue;
 
     if (Context && (mutt_strcmp (sbe->buffy->realpath, Context->realpath) == 0))
diff -u --show-c-function mutt-1.6.2.orig/sidebar.c mutt-1.6.2-1-ow/sidebar.c
--- mutt-1.6.2.orig/sidebar.c	2016-08-01 17:22:46.000000000 -0700
+++ mutt-1.6.2-1-ow/sidebar.c	2016-08-02 16:58:18.920169504 -0700
@@ -428,6 +427,8 @@ static int prepare_sidebar (int page_siz
 {
   int i;
   SBENTRY *opn_entry = NULL, *hil_entry = NULL;
+  int not_hidden = 0;
+  int NthIndex = -1;    /* Last entry that is not hidden when paged */
 
   if (!EntryCount)
     return 0;
@@ -440,12 +441,17 @@ static int prepare_sidebar (int page_siz
   update_entries_visibility ();
   sort_entries ();
 
-  for (i = 0; i < EntryCount; i++)
+  for (i = EntryCount-1; i >= 0; i--)
   {
     if (opn_entry == Entries[i])
       OpnIndex = i;
     if (hil_entry == Entries[i])
       HilIndex = i;
+    if (! Entries[i]->is_hidden) {
+        not_hidden++;
+        if (not_hidden >= page_size && NthIndex == -1)
+            NthIndex = i;
+    }
   }
 
   if ((HilIndex < 0) || (SidebarSortMethod != PreviousSort))
@@ -455,10 +461,11 @@ static int prepare_sidebar (int page_siz
     else
       HilIndex  = 0;
   }
-  if (TopIndex >= 0)
-    TopIndex = (HilIndex / page_size) * page_size;
+
+  if (NthIndex > 0) 
+      TopIndex = NthIndex;
   else
-    TopIndex = HilIndex;
+      TopIndex = 0;
 
   BotIndex = TopIndex + page_size - 1;
   if (BotIndex > (EntryCount - 1))

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to