[mutt] 01/03: Backport three sidebar fixes

Faidon Liambotis paravoid at moszumanska.debian.org
Sun Aug 14 16:10:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

paravoid pushed a commit to branch master
in repository mutt.

commit 8d4a3640e9202e9e868943a8024c349cff934f3f
Author: Faidon Liambotis <paravoid at debian.org>
Date:   Sun Aug 14 18:38:24 2016 +0300

    Backport three sidebar fixes
    
    Courtesy of upstream vanilla mutt maintainer Kevin J. McCarthy.
---
 debian/changelog                                   |  2 +
 .../neomutt-devel/sidebar-fix-5fb53b95afa7.patch   | 83 ++++++++++++++++++++
 .../neomutt-devel/sidebar-fix-6f2fe8f32dab.patch   | 88 ++++++++++++++++++++++
 .../neomutt-devel/sidebar-fix-ec4c113a3d2b.patch   | 48 ++++++++++++
 debian/patches/series                              |  3 +
 5 files changed, 224 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 249f5aa..a617822 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ mutt (1.6.2-2) UNRELEASED; urgency=medium
     - Drop patch debian/patches/features/multiple-fcc.patch, merged upstream.
     - Drop patch imap-sidebar-update-bug.patch, was an upstream backport.
     - Refresh patch neomutt-devel/sensible-browser.patch.
+  * Backport three sidebar fixes, courtesy of upstream vanilla mutt maintainer
+    Kevin J. McCarthy.
   * Add a patch to avoid a warning message if getrandom() fails. This should
     help not scare off users that are running a jessie kernel, among others.
     Thanks to Adam Borowski for the fix. (Closes: #833593)
diff --git a/debian/patches/neomutt-devel/sidebar-fix-5fb53b95afa7.patch b/debian/patches/neomutt-devel/sidebar-fix-5fb53b95afa7.patch
new file mode 100644
index 0000000..350d646
--- /dev/null
+++ b/debian/patches/neomutt-devel/sidebar-fix-5fb53b95afa7.patch
@@ -0,0 +1,83 @@
+
+# HG changeset patch
+# User Kevin McCarthy <kevin at 8t8.us>
+# Date 1468029171 25200
+# Node ID 5fb53b95afa706be8f5a9f121ecf3668c047f164
+# Parent  4dc1831fd6d71a69cb1178938e04bec716a3a514
+Fix sidebar pagedown/up when mailboxes on the end are hidden.
+
+The pageup/pagedown code was setting the highlighted mailbox to the
+top and bottom index without checking if those were hidden.
+
+--- a/sidebar.c
++++ b/sidebar.c
+@@ -962,6 +962,52 @@ static int select_prev_new (void)
+ }
+ 
+ /**
++ * select_page_down - Selects the first entry in the next page of mailboxes
++ *
++ * Returns:
++ *      1: Success
++ *      0: Failure
++ */
++static int select_page_down (void)
++{
++  int orig_hil_index = HilIndex;
++
++  if (!EntryCount || BotIndex < 0)
++    return 0;
++
++  HilIndex = BotIndex;
++  select_next ();
++  /* If the rest of the entries are hidden, go up to the last unhidden one */
++  if (Entries[HilIndex]->is_hidden)
++    select_prev ();
++
++  return (orig_hil_index != HilIndex);
++}
++
++/**
++ * select_page_up - Selects the last entry in the previous page of mailboxes
++ *
++ * Returns:
++ *      1: Success
++ *      0: Failure
++ */
++static int select_page_up (void)
++{
++  int orig_hil_index = HilIndex;
++
++  if (!EntryCount || TopIndex < 0)
++    return 0;
++
++  HilIndex = TopIndex;
++  select_prev ();
++  /* If the rest of the entries are hidden, go down to the last unhidden one */
++  if (Entries[HilIndex]->is_hidden)
++    select_next ();
++
++  return (orig_hil_index != HilIndex);
++}
++
++/**
+  * mutt_sb_change_mailbox - Change the selected mailbox
+  * @op: Operation code
+  *
+@@ -995,12 +1041,12 @@ void mutt_sb_change_mailbox (int op)
+         return;
+       break;
+     case OP_SIDEBAR_PAGE_DOWN:
+-      HilIndex = BotIndex;
+-      select_next ();
++      if (! select_page_down ())
++        return;
+       break;
+     case OP_SIDEBAR_PAGE_UP:
+-      HilIndex = TopIndex;
+-      select_prev ();
++      if (! select_page_up ())
++        return;
+       break;
+     case OP_SIDEBAR_PREV:
+       if (! select_prev ())
diff --git a/debian/patches/neomutt-devel/sidebar-fix-6f2fe8f32dab.patch b/debian/patches/neomutt-devel/sidebar-fix-6f2fe8f32dab.patch
new file mode 100644
index 0000000..c74e54e
--- /dev/null
+++ b/debian/patches/neomutt-devel/sidebar-fix-6f2fe8f32dab.patch
@@ -0,0 +1,88 @@
+
+# HG changeset patch
+# User Kevin McCarthy <kevin at 8t8.us>
+# Date 1467918037 25200
+# Node ID 6f2fe8f32dabc5350920398af4595efeade27d1c
+# Parent  5229c7fbc37e4dd6b2715443dde39114cb7b1715
+Fix the sidebar TopIndex and BotIndex when $sidebar_new_mail_only is set.
+
+When set, some of the entries can be hidden, so a simple division by
+page_size to find the correct top/bottom isn't correct.
+
+Instead, manually partition into groups of page_size visible entries
+and set top and bottom based on the interval around the highlighted
+entry.
+
+--- a/sidebar.c
++++ b/sidebar.c
+@@ -35,6 +35,9 @@ static short  OldVisible;	/* sidebar_vis
+ static short  OldWidth;		/* sidebar_width */
+ static short PreviousSort = SORT_ORDER;  /* sidebar_sort_method */
+ 
++static int select_next (void);
++
++
+ /**
+  * struct sidebar_entry - Info about folders in the sidebar
+  */
+@@ -428,8 +431,9 @@ static int prepare_sidebar (int page_siz
+ {
+   int i;
+   SBENTRY *opn_entry = NULL, *hil_entry = NULL;
++  int page_entries;
+ 
+-  if (!EntryCount)
++  if (!EntryCount || (page_size <= 0))
+     return 0;
+ 
+   if (OpnIndex >= 0)
+@@ -451,16 +455,43 @@ static int prepare_sidebar (int page_siz
+   if ((HilIndex < 0) || (SidebarSortMethod != PreviousSort))
+   {
+     if (OpnIndex >= 0)
+-      HilIndex  = OpnIndex;
++      HilIndex = OpnIndex;
+     else
+-      HilIndex  = 0;
++    {
++      HilIndex = 0;
++      if (Entries[HilIndex]->is_hidden)
++        select_next ();
++    }
+   }
+-  if (TopIndex >= 0)
+-    TopIndex = (HilIndex / page_size) * page_size;
++
++  /* Set the Top and Bottom to frame the HilIndex in groups of page_size */
++
++  /* If OPTSIDEBARNEMAILONLY is set, some entries may be hidden so we
++   * need to scan for the framing interval */
++  if (option (OPTSIDEBARNEWMAILONLY))
++  {
++    TopIndex = BotIndex = -1;
++    while (BotIndex < HilIndex)
++    {
++      TopIndex = BotIndex + 1;
++      page_entries = 0;
++      while (page_entries < page_size)
++      {
++        BotIndex++;
++        if (BotIndex >= EntryCount)
++          break;
++        if (! Entries[BotIndex]->is_hidden)
++          page_entries++;
++      }
++    }
++  }
++  /* Otherwise we can just calculate the interval */
+   else
+-    TopIndex = HilIndex;
++  {
++    TopIndex = (HilIndex / page_size) * page_size;
++    BotIndex = TopIndex + page_size - 1;
++  }
+ 
+-  BotIndex = TopIndex + page_size - 1;
+   if (BotIndex > (EntryCount - 1))
+     BotIndex = EntryCount - 1;
+ 
diff --git a/debian/patches/neomutt-devel/sidebar-fix-ec4c113a3d2b.patch b/debian/patches/neomutt-devel/sidebar-fix-ec4c113a3d2b.patch
new file mode 100644
index 0000000..8de283c
--- /dev/null
+++ b/debian/patches/neomutt-devel/sidebar-fix-ec4c113a3d2b.patch
@@ -0,0 +1,48 @@
+
+# HG changeset patch
+# User Kevin McCarthy <kevin at 8t8.us>
+# Date 1468029176 25200
+# Node ID ec4c113a3d2b907c77ec49ee897427626eb0309f
+# Parent  5fb53b95afa706be8f5a9f121ecf3668c047f164
+Change sidebar highlighted mailbox behavior.
+
+Delay selecting the highlighted mailbox until prepare_mailbox(), to
+avoid a hidden mailbox being selected during the Buffy list population
+(in mutt_sb_notify_mailbox()).
+
+Change update_entries_visibility() to not automatically make the
+highlighted mailbox visible.
+
+Change prepare_sidebar() to (re)set the highlighted mailbox when the
+current highlighted mailbox is hidden.
+
+--- a/sidebar.c
++++ b/sidebar.c
+@@ -345,7 +345,7 @@ static void update_entries_visibility (v
+       continue;
+ 
+     if ((i == OpnIndex) || (sbe->buffy->msg_unread  > 0) || sbe->buffy->new ||
+-        (i == HilIndex) || (sbe->buffy->msg_flagged > 0))
++        (sbe->buffy->msg_flagged > 0))
+       continue;
+ 
+     if (Context && (mutt_strcmp (sbe->buffy->realpath, Context->realpath) == 0))
+@@ -452,7 +452,8 @@ static int prepare_sidebar (int page_siz
+       HilIndex = i;
+   }
+ 
+-  if ((HilIndex < 0) || (SidebarSortMethod != PreviousSort))
++  if ((HilIndex < 0) || Entries[HilIndex]->is_hidden ||
++      (SidebarSortMethod != PreviousSort))
+   {
+     if (OpnIndex >= 0)
+       HilIndex = OpnIndex;
+@@ -1168,8 +1169,6 @@ void mutt_sb_notify_mailbox (BUFFY *b, i
+ 
+     if (TopIndex < 0)
+       TopIndex = EntryCount;
+-    if (HilIndex < 0)
+-      HilIndex = EntryCount;
+     if (BotIndex < 0)
+       BotIndex = EntryCount;
+     if ((OpnIndex < 0) && Context &&
diff --git a/debian/patches/series b/debian/patches/series
index 77be3a2..091ddca 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,6 +1,9 @@
 neomutt-20160808.patch
 neomutt-devel/sensible-browser.patch
 neomutt-devel/dont-whine-if-getrandom-fails.patch
+neomutt-devel/sidebar-fix-6f2fe8f32dab.patch
+neomutt-devel/sidebar-fix-5fb53b95afa7.patch
+neomutt-devel/sidebar-fix-ec4c113a3d2b.patch
 debian-specific/Muttrc.patch
 debian-specific/Md.etc_mailname_gethostbyname.patch
 debian-specific/use_usr_bin_editor.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mutt/mutt.git



More information about the pkg-mutt-commits mailing list