From: Lars Ellenberg <Lars.Ellenberg@linbit.com>
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 23 Oct 2005 01:12:29 +0000 (01:12 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 23 Oct 2005 01:12:29 +0000 (01:12 +0000)
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
VERSION.svn
buffy.c
doc/manual.txt
imap/imap.c
init.h
sidebar.c

index 8296e4a..588f54b 100644 (file)
--- 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.
 
 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 <rebuild-cache> function has been added.
 2005-10-14:
 
   The generic <rebuild-cache> function has been added.
index 2e9c1e1..30ce115 100644 (file)
@@ -1 +1 @@
-558
+559
diff --git a/buffy.c b/buffy.c
index 28f88ac..126cf8c 100644 (file)
--- 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);
         /* 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++;
             BuffyCount++;
-            tmp->msg_unread = tmp->new; /* for sidebar; wtf? */
-          }
-          else {
+          else
             tmp->new = 0;
             tmp->new = 0;
+          if (tmp->msg_unread < 0)
             tmp->msg_unread = 0;
             tmp->msg_unread = 0;
-          }
         }
         else if (tmp->new > 0)
           /* keep current stats if !force and !$imap_mail_check reached */
         }
         else if (tmp->new > 0)
           /* keep current stats if !force and !$imap_mail_check reached */
index 79bf9eb..af554fc 100644 (file)
@@ -8526,6 +8526,9 @@ Chapter 7. Reference
    %t
           Number of tagged messages. 1)
 
    %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.
 
    1) These expandos only have a non-zero value for the current mailbox
    and will always be zero otherwise.
 
index 022415f..a59eb4b 100644 (file)
@@ -1136,9 +1136,12 @@ int imap_check_mailbox (CONTEXT * ctx, int *index_hint, int force)
   return result;
 }
 
   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
  */
  *   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,
   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.
   }
   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 (file)
--- 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 %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
    ** .de
    ** .pp
    ** 1) These expandos only have a non-zero value for the current mailbox and
index 4ea49d4..92a0d2a 100644 (file)
--- 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':
       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);
       if (!opt) {
         snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
         snprintf (dest, destlen, tmp, c ? Context->unread : b->msg_unread);