~kevin8t8/mutt

abfaa0e01e1c897e4171f49dbfdc457c002422ed — Kevin McCarthy 7 months ago ba1b595
Add $sidebar_use_mb_shortcuts to turn off shortcuts.

If unset, Mutt will revert to pre-1.13 display behavior, matching and
removing a literal $folder prefix, without using mailbox shortcuts.
3 files changed, 34 insertions(+), 3 deletions(-)

M init.h
M mutt.h
M sidebar.c
M init.h => init.h +9 -0
@@ 3272,6 3272,15 @@ struct option_t MuttVars[] = {
  ** \fC<sidebar-prev-new>\fP command is similarly affected, wrapping around to
  ** the end of the list.
  */
  { "sidebar_use_mb_shortcuts", DT_BOOL, R_SIDEBAR, {.l=OPTSIDEBARUSEMBSHORTCUTS}, {.l=1} },
  /*
  ** .pp
  ** When set, sidebar mailboxes will be displayed with mailbox shortcut prefixes
  ** "=" or "~".
  ** .pp
  ** When unset, the sidebar will use pre-1.13.0 behavior: trimming off a matching
  ** $$folder but otherwise not using mailbox shortcuts.
  */
  { "sidebar_short_path", DT_BOOL, R_SIDEBAR, {.l=OPTSIDEBARSHORTPATH}, {.l=0} },
  /*
  ** .pp

M mutt.h => mutt.h +1 -0
@@ 515,6 515,7 @@ enum
  OPTSIDEBARFOLDERINDENT,
  OPTSIDEBARNEWMAILONLY,
  OPTSIDEBARNEXTNEWWRAP,
  OPTSIDEBARUSEMBSHORTCUTS,
  OPTSIDEBARSHORTPATH,
#endif
  OPTSIGDASHES,

M sidebar.c => sidebar.c +24 -3
@@ 668,9 668,30 @@ static void draw_sidebar (int num_rows, int num_cols, int div_width)
      b->msg_flagged = Context->flagged;
    }

    mutt_buffer_strcpy (pretty_folder_name, mutt_b2s (b->pathbuf));
    mutt_buffer_pretty_mailbox (pretty_folder_name);
    sidebar_folder_name = mutt_b2s (pretty_folder_name);
    if (option (OPTSIDEBARUSEMBSHORTCUTS))
    {
      mutt_buffer_strcpy (pretty_folder_name, mutt_b2s (b->pathbuf));
      mutt_buffer_pretty_mailbox (pretty_folder_name);
      sidebar_folder_name = mutt_b2s (pretty_folder_name);
    }
    else
    {
      /* compute length of Maildir without trailing separator */
      size_t maildirlen = mutt_strlen (Maildir);
      if (maildirlen &&
          SidebarDelimChars &&
          strchr (SidebarDelimChars, Maildir[maildirlen - 1]))
        maildirlen--;

      /* check whether Maildir is a prefix of the current folder's path */
      if ((mutt_buffer_len (b->pathbuf) > maildirlen) &&
          (mutt_strncmp (Maildir, mutt_b2s (b->pathbuf), maildirlen) == 0) &&
          SidebarDelimChars &&
          strchr (SidebarDelimChars, mutt_b2s (b->pathbuf)[maildirlen]))
        sidebar_folder_name = mutt_b2s (b->pathbuf) + (maildirlen + 1);
      else
        sidebar_folder_name = mutt_b2s (b->pathbuf);
    }

    if (SidebarDelimChars)
    {