File mutt-1.5.20.sidebar-fix.dif of Package mutt.4421

--- buffy.c
+++ buffy.c	2009-06-26 13:09:04.609901395 +0200
@@ -334,7 +334,6 @@ int mutt_buffy_check (int force)
   char path[_POSIX_PATH_MAX];
   struct stat contex_sb;
   time_t t;
-  CONTEXT *ctx;
 
   sb.st_size=0;
   contex_sb.st_dev=0;
@@ -374,8 +373,6 @@ int mutt_buffy_check (int force)
   
   for (tmp = Incoming; tmp; tmp = tmp->next)
   {
-    if ( tmp->new == 1 )
-      tmp->has_new = 1;
 #ifdef USE_IMAP
     if (tmp->magic != M_IMAP)
 #endif
@@ -427,14 +424,18 @@ int mutt_buffy_check (int force)
 	)
 	
     {
+      int check;
+
       switch (tmp->magic)
       {
       case M_MBOX:
       case M_MMDF:
 
-        {
-	if (STAT_CHECK || tmp->msgcount == 0)
+	check = STAT_CHECK;
+
+	if (option(OPTSIDEBAR) && (check || tmp->msgcount == 0))
 	{
+	  CONTEXT *ctx;
 	  BUFFY b = *tmp;
  	  int msgcount = 0;
  	  int msg_unread = 0;
@@ -449,11 +450,12 @@ int mutt_buffy_check (int force)
  	  *tmp = b;
  	  tmp->msgcount = msgcount;
  	  tmp->msg_unread = msg_unread;
- 	  if(STAT_CHECK) {
- 	    tmp->has_new = tmp->new = 1;
-	    BuffyCount++;
-          }  
 	}
+ 	if(check)
+	{
+ 	  tmp->new = 1;
+	  BuffyCount++;
+        }  
 	else if (option(OPTCHECKMBOXSIZE))
 	{
 	  /* some other program has deleted mail from the folder */
@@ -462,7 +464,7 @@ int mutt_buffy_check (int force)
 	if (tmp->newly_created &&
 	    (sb.st_ctime != sb.st_mtime || sb.st_ctime != sb.st_atime))
 	  tmp->newly_created = 0;
-        }
+
 	break;
 
       case M_MAILDIR:
@@ -483,7 +485,13 @@ int mutt_buffy_check (int force)
 	  if (*de->d_name != '.' && 
 	      (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
 	  {
- 	    tmp->has_new = tmp->new = 1;
+	    if (!option(OPTSIDEBAR))
+	    {
+	      tmp->new = 1;	      
+	      BuffyCount++;
+	      break;
+	    }	
+ 	    tmp->new = 1;
             tmp->msgcount++;
             tmp->msg_unread++;
  	  }
@@ -493,6 +501,9 @@ int mutt_buffy_check (int force)
  
  	closedir (dirp);
  
+	if (!option(OPTSIDEBAR))
+	  break;
+
         /*
          * count read messages (for folderlist (sidebar) we also need to count
          * messages in cur so that we the total number of messages
@@ -523,25 +534,25 @@ int mutt_buffy_check (int force)
 	break;
 
       case M_MH:
-      {
-      DIR *dp;
-      struct dirent *de;
+
 	if ((tmp->new = mh_buffy (tmp->path)) > 0)
 	  BuffyCount++;
-    
-      if ((dp = opendir (path)) == NULL)
-        break;
-      tmp->msgcount = 0;
-      while ((de = readdir (dp)))
-      {
-        if (mh_valid_message (de->d_name))
-        {
-	  tmp->msgcount++;
- 	  tmp->has_new = tmp->new = 1;
-        }
-      }
-      closedir (dp);
-      }
+	if (!option(OPTSIDEBAR))
+	  break;  
+
+	if ((dirp = opendir (path)) == NULL)
+	  break;
+        tmp->msgcount = 0;
+	while ((de = readdir (dirp)))
+	{
+	  if (mh_valid_message (de->d_name))
+	  {
+	    tmp->msgcount++;
+	    tmp->new = 1;
+	  }
+	}
+	closedir (dirp);
+
 	break;
       }
     }
--- buffy.h
+++ buffy.h	2009-06-26 12:47:59.000000000 +0200
@@ -27,7 +27,6 @@ typedef struct buffy_t
   struct buffy_t *next;
   struct buffy_t *prev;
   short new;			/* mailbox has new mail */
-  short has_new;		/* set it new if new and not read */
   int msgcount;			/* total number of messages */
   int msg_unread;		/* number of unread messages */
   int msg_flagged;		/* number of flagged messages */
openSUSE Build Service is sponsored by