From 5f6b586de5a46f2359a4fc392fd89f1716d847a3 Mon Sep 17 00:00:00 2001 From: pdmef Date: Sun, 23 Oct 2005 01:12:29 +0000 Subject: [PATCH] From: Lars Ellenberg Rocco Rutte: - add %u for unread messages to $sidebar_number_format git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@559 e385b8ad-14ed-0310-8656-cc95a2468c6d --- UPGRADING | 4 ++++ VERSION.svn | 2 +- buffy.c | 10 +++++----- doc/manual.txt | 3 +++ imap/imap.c | 11 +++++++---- init.h | 1 + sidebar.c | 8 ++++++++ 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/UPGRADING b/UPGRADING index 8296e4a..588f54b 100644 --- a/UPGRADING +++ b/UPGRADING @@ -10,6 +10,10 @@ This document is not the place for verbose documentation; it only offers the necessary keywords to look them up in the manual, ChangeLog or other sources of information. +2005-10-23: + + The %u expando for $sidebar_number_format has been added. + 2005-10-14: The generic function has been added. diff --git a/VERSION.svn b/VERSION.svn index 2e9c1e1..30ce115 100644 --- a/VERSION.svn +++ b/VERSION.svn @@ -1 +1 @@ -558 +559 diff --git a/buffy.c b/buffy.c index 28f88ac..126cf8c 100644 --- a/buffy.c +++ b/buffy.c @@ -463,14 +463,14 @@ int buffy_check (int force) /* only check on force or $imap_mail_check reached */ if (force != 0 || (now - last2 >= ImapBuffyTimeout)) { tmp->msgcount = imap_mailbox_check (tmp->path, 0); - if ((tmp->new = imap_mailbox_check (tmp->path, 1)) > 0) { + tmp->new = imap_mailbox_check (tmp->path, 1); + tmp->msg_unread = imap_mailbox_check (tmp->path, 2); + if (tmp->new > 0) BuffyCount++; - tmp->msg_unread = tmp->new; /* for sidebar; wtf? */ - } - else { + else tmp->new = 0; + if (tmp->msg_unread < 0) tmp->msg_unread = 0; - } } else if (tmp->new > 0) /* keep current stats if !force and !$imap_mail_check reached */ diff --git a/doc/manual.txt b/doc/manual.txt index 79bf9eb..af554fc 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -8526,6 +8526,9 @@ Chapter 7. Reference %t Number of tagged messages. 1) + %u + Number of unread messages. + 1) These expandos only have a non-zero value for the current mailbox and will always be zero otherwise. diff --git a/imap/imap.c b/imap/imap.c index 022415f..a59eb4b 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1136,9 +1136,12 @@ int imap_check_mailbox (CONTEXT * ctx, int *index_hint, int force) return result; } -/* returns count of recent messages if new = 1, else count of total messages. - * (useful for at least postponed function) - * Question of taste: use RECENT or UNSEEN for new? +/* + * count messages: + * new == 1: recent + * new == 2: unseen + * otherwise: total + * return: * 0+ number of messages in mailbox * -1 error while polling mailboxes */ @@ -1186,7 +1189,7 @@ int imap_mailbox_check (char *path, int new) else if (mutt_bit_isset (idata->capabilities, IMAP4REV1) || mutt_bit_isset (idata->capabilities, STATUS)) { snprintf (buf, sizeof (buf), "STATUS %s (%s)", mbox, - new ? "RECENT" : "MESSAGES"); + new == 1 ? "RECENT" : (new == 2 ? "UNSEEN" : "MESSAGES")); } else /* Server does not support STATUS, and this is not the current mailbox. diff --git a/init.h b/init.h index 0797555..fecccfc 100644 --- a/init.h +++ b/init.h @@ -1596,6 +1596,7 @@ struct option_t MuttVars[] = { ** .dt %M .dd Total number of messages shown, i.e. not hidden by a limit. 1) ** .dt %n .dd Number of new messages. ** .dt %t .dd Number of tagged messages. 1) + ** .dt %u .dd Number of unread messages. ** .de ** .pp ** 1) These expandos only have a non-zero value for the current mailbox and diff --git a/sidebar.c b/sidebar.c index 4ea49d4..92a0d2a 100644 --- a/sidebar.c +++ b/sidebar.c @@ -149,6 +149,14 @@ static const char* sidebar_number_format (char* dest, size_t destlen, char op, break; /* new */ case 'n': + if (!opt) { + snprintf (tmp, sizeof (tmp), "%%%sd", fmt); + snprintf (dest, destlen, tmp, c ? Context->new : b->new); + } else if ((c && Context->new == 0) || (!c && b->new == 0)) + opt = 0; + break; + /* unread */ + case 'u': if (!opt) { snprintf (tmp, sizeof (tmp), "%%%sd", fmt); snprintf (dest, destlen, tmp, c ? Context->unread : b->msg_unread); -- 2.20.1