<<< Date Index >>>     <<< Thread Index >>>

Re: What should go into 1.5.7?



 On Wed, Jan 26, Thomas Roessler wrote:

> If there are any patches you want to see included with 1.5.7, please
> re-submit them to mutt-dev by Thursday evening.  1.5.7 due on Friday.

I'm using this hack to show if there are new mails in a maildir.
Currently only the main directory is used, but not the new/ dir where
new mails actually arrive.
Maybe someone can see the idea and clean it up for inclusion.


diff -purN -X mutt_excludes mutt-1.5.4.orig/browser.c mutt-1.5.4/browser.c
--- mutt-1.5.4.orig/browser.c   2003-01-21 13:25:21.000000000 +0100
+++ mutt-1.5.4/browser.c        2003-04-28 18:21:19.000000000 +0200
@@ -353,6 +353,8 @@ static int examine_directory (MUTTMENU *
   DIR *dp;
   struct dirent *de;
   char buffer[_POSIX_PATH_MAX + SHORT_STRING];
+  void *md_path;
+  char *tmp_path;
   BUFFY *tmp;
 
   while (stat (d, &s) == -1)
@@ -388,6 +390,8 @@ static int examine_directory (MUTTMENU *
 
   init_state (state, menu);
 
+  md_path = malloc(_POSIX_PATH_MAX);
+
   while ((de = readdir (dp)) != NULL)
   {
     if (mutt_strcmp (de->d_name, ".") == 0)
@@ -399,7 +403,14 @@ static int examine_directory (MUTTMENU *
       continue;
 
     mutt_concat_path (buffer, d, de->d_name, sizeof (buffer));
-    if (lstat (buffer, &s) == -1)
+    if (md_path && mx_is_maildir (buffer)) {
+           tmp_path = md_path;
+           *tmp_path = '\0';
+           snprintf (tmp_path, _POSIX_PATH_MAX, "%s/new", buffer);
+    }
+    else
+           tmp_path = buffer;
+    if (lstat (tmp_path, &s) == -1)
       continue;
     
     if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) &&
@@ -411,7 +422,9 @@ static int examine_directory (MUTTMENU *
       tmp = tmp->next;
     add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
   }
-  closedir (dp);  
+  closedir (dp);
+  if (md_path)
+         free (md_path);
   browser_sort (state);
   return 0;
 }
@@ -420,6 +433,8 @@ static int examine_mailboxes (MUTTMENU *
 {
   struct stat s;
   char buffer[LONG_STRING];
+  void *md_path;
+  char *tmp_path;
   BUFFY *tmp = Incoming;
 
   if (!Incoming)
@@ -428,6 +443,8 @@ static int examine_mailboxes (MUTTMENU *
 
   init_state (state, menu);
 
+  md_path = malloc(_POSIX_PATH_MAX);
+
   do
   {
 #ifdef USE_IMAP
@@ -444,7 +461,16 @@ static int examine_mailboxes (MUTTMENU *
       continue;
     }
 #endif
-    if (lstat (tmp->path, &s) == -1)
+    if (md_path && mx_is_maildir (tmp->path)) {
+           tmp_path = md_path;
+           *tmp_path = '\0';
+           snprintf (tmp_path, _POSIX_PATH_MAX, "%s/new", tmp->path);
+    }
+    else
+           tmp_path = tmp->path;
+
+
+    if (lstat (tmp_path, &s) == -1)
       continue;
 
     if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) &&
@@ -457,6 +483,10 @@ static int examine_mailboxes (MUTTMENU *
     add_folder (menu, state, buffer, &s, tmp->new);
   }
   while ((tmp = tmp->next));
+
+  if (md_path)
+         free(md_path);
+
   browser_sort (state);
   return 0;
 }
diff -purN -X mutt_excludes mutt-1.5.4.orig/mx.c mutt-1.5.4/mx.c
--- mutt-1.5.4.orig/mx.c        2003-02-25 22:39:14.000000000 +0100
+++ mutt-1.5.4/mx.c     2003-04-26 14:04:12.000000000 +0200
@@ -454,6 +454,13 @@ int mx_get_magic (const char *path)
 }
 
 /*
+ *
+ */
+int mx_is_maildir (const char *s)
+{
+       return !!(mx_get_magic(s) == M_MAILDIR);
+}
+/*
  * set DefaultMagic to the given value
  */
 int mx_set_magic (const char *s)