There is actually a patch 4 to this series, but I'm still working on it. This patch adds a new format string %n to the sidebar, so it can display 'N' for buffy->new.
-- Kevin J. McCarthy GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
# HG changeset patch # User Kevin McCarthy <[email protected]> # Date 1465417005 25200 # Wed Jun 08 13:16:45 2016 -0700 # Node ID 3af134a91dae2cf067e9f97870326758105f80b6 # Parent 1fad3bfd4aab7d2eb3f4ee8d99f7157579fb24d2 Add sidebar_format flag '%n' to display 'N' on new mail. diff --git a/init.h b/init.h --- a/init.h +++ b/init.h @@ -2705,16 +2705,17 @@ ** .pp ** This variable allows you to customize the sidebar display. This string is ** similar to $$index_format, but has its own set of \fCprintf(3)\fP-like ** sequences: ** .dl ** .dt %B .dd Name of the mailbox ** .dt %S .dd * Size of mailbox (total number of messages) ** .dt %N .dd * Number of New messages in the mailbox + ** .dt %n .dd N if mailbox has new mail, blank otherwise ** .dt %F .dd * Number of Flagged messages in the mailbox ** .dt %! .dd ``!'' : one flagged message; ** ``!!'' : two flagged messages; ** ``n!'' : n flagged messages (for n > 2). ** Otherwise prints nothing. ** .dt %d .dd * @ Number of deleted messages ** .dt %L .dd * @ Number of messages after limiting ** .dt %t .dd * @ Number of tagged messages diff --git a/sidebar.c b/sidebar.c --- a/sidebar.c +++ b/sidebar.c @@ -120,19 +120,20 @@ * @src: printf-like format string * @prefix: Field formatting string, UNUSED * @ifstring: If condition is met, display this string * @elsestring: Otherwise, display this string * @data: Pointer to our sidebar_entry * @flags: Format flags, e.g. MUTT_FORMAT_OPTIONAL * * cb_format_str is a callback function for mutt_FormatString. It understands - * five operators. '%B' : Mailbox name, '%F' : Number of flagged messages, + * six operators. '%B' : Mailbox name, '%F' : Number of flagged messages, * '%N' : Number of new messages, '%S' : Size (total number of messages), * '%!' : Icon denoting number of flagged messages. + * '%n' : N if folder has new mail, blank otherwise. * * Returns: src (unchanged) */ static const char *cb_format_str(char *dest, size_t destlen, size_t col, int cols, char op, const char *src, const char *prefix, const char *ifstring, const char *elsestring, unsigned long data, format_flag flags) { struct sidebar_entry *sbe = (struct sidebar_entry *) data; @@ -193,16 +194,26 @@ { snprintf (fmt, sizeof (fmt), "%%%sd", prefix); snprintf (dest, destlen, fmt, b->msg_unread); } else if (b->msg_unread == 0) optional = 0; break; + case 'n': + if (!optional) + { + snprintf (fmt, sizeof (fmt), "%%%sc", prefix); + snprintf (dest, destlen, fmt, b->new ? 'N' : ' '); + } + else if (b->new == 0) + optional = 0; + break; + case 'S': if (!optional) { snprintf (fmt, sizeof (fmt), "%%%sd", prefix); snprintf (dest, destlen, fmt, b->msg_count); } else if (b->msg_count == 0) optional = 0; @@ -625,17 +636,17 @@ else SETCOLOR(MT_COLOR_INDICATOR); } else if (b == HilBuffy) SETCOLOR(MT_COLOR_HIGHLIGHT); else if ((ColorDefs[MT_COLOR_SB_SPOOLFILE] != 0) && (mutt_strcmp (b->path, Spoolfile) == 0)) SETCOLOR(MT_COLOR_SB_SPOOLFILE); - else if (b->msg_unread > 0) + else if ((b->msg_unread > 0) || (b->new)) SETCOLOR(MT_COLOR_NEW); else if (b->msg_flagged > 0) SETCOLOR(MT_COLOR_FLAGGED); else SETCOLOR(MT_COLOR_NORMAL); mutt_window_move (MuttSidebarWindow, row, 0); if (Context && Context->path &&
signature.asc
Description: PGP signature
