* Brendan Cully on Thursday, February 22, 2007 at 09:30:33 -0800: > I intend to cut 1.5.14 this weekend. I'd like to make 1.5.15 the last > proper dev release for 1.6 - that is, feature-freeze after > 1.5.15. So, I'd like to hear once again which patches everyone would > like to see in 1.6 (and which patches people object to).
The maildir_indicator patch by Olaf Hering overcomes an annoying shortcoming when reading Maildir folders. I'm using it for quite some time now, and didn't have any problems with it. I attach a version against current tip. c -- _B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>
# HG changeset patch # User Christian Ebert <[EMAIL PROTECTED]> # Date 1172751178 -3600 # Node ID 819ef6a7be0672ac8461faea6e4a9e940b9c7427 # Parent 42595801073eb5bfca435a65de87162a1c2c0824 Maildir indicator patch by Olaf Hering Apply patch from Message-Id: <[EMAIL PROTECTED]> against 1.5.14. Original patch by: Olaf Hering <[EMAIL PROTECTED]> diff -r 42595801073e -r 819ef6a7be06 PATCHES --- a/PATCHES Thu Mar 01 06:05:39 2007 +0000 +++ b/PATCHES Thu Mar 01 13:12:58 2007 +0100 @@ -0,0 +1,1 @@ +patch-1.5.14.oh.maildir_indicator.1 diff -r 42595801073e -r 819ef6a7be06 browser.c --- a/browser.c Thu Mar 01 06:05:39 2007 +0000 +++ b/browser.c Thu Mar 01 13:12:58 2007 +0100 @@ -351,6 +351,22 @@ static void init_state (struct browser_s menu->data = state->entry; } +static unsigned short walk_maildir_new(const char *path) +{ + struct dirent *de; + DIR *d = opendir(path); + unsigned short count = 0; + if (d) { + while ((de = readdir(d))) { + if (de->d_name[0] == '.' && (!de->d_name[1] || (de->d_name[1] == '.' && !de->d_name[2]))) + continue; + count++; + } + closedir(d); + } + return count; +} + static int examine_directory (MUTTMENU *menu, struct browser_state *state, char *d, const char *prefix) { @@ -358,6 +374,8 @@ static int examine_directory (MUTTMENU * DIR *dp; struct dirent *de; char buffer[_POSIX_PATH_MAX + SHORT_STRING]; + char md_path[_POSIX_PATH_MAX]; + unsigned short new; BUFFY *tmp; while (stat (d, &s) == -1) @@ -404,17 +422,27 @@ static int examine_directory (MUTTMENU * continue; mutt_concat_path (buffer, d, de->d_name, sizeof (buffer)); - if (lstat (buffer, &s) == -1) - continue; - - if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) && - (! S_ISLNK (s.st_mode))) - continue; - - tmp = Incoming; - while (tmp && mutt_strcmp (buffer, tmp->path)) - tmp = tmp->next; - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0); + if (mx_is_maildir (buffer)) { + snprintf (md_path, sizeof(md_path), "%s/new", buffer); + if (lstat (md_path, &s) == -1) + continue; + s.st_size = new = walk_maildir_new(md_path); + } else { + if (lstat (buffer, &s) == -1) + continue; + + if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) && + (! S_ISLNK (s.st_mode))) + continue; + tmp = Incoming; + while (tmp && mutt_strcmp (buffer, tmp->path)) + tmp = tmp->next; + if (tmp) + new = tmp->new; + else + new = 0; + } + add_folder (menu, state, de->d_name, &s, new); } closedir (dp); browser_sort (state); @@ -425,6 +453,8 @@ static int examine_mailboxes (MUTTMENU * { struct stat s; char buffer[LONG_STRING]; + char md_path[_POSIX_PATH_MAX]; + unsigned short new; BUFFY *tmp = Incoming; if (!Incoming) @@ -449,17 +479,24 @@ static int examine_mailboxes (MUTTMENU * continue; } #endif - if (lstat (tmp->path, &s) == -1) - continue; - - if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) && - (! S_ISLNK (s.st_mode))) - continue; - + if (mx_is_maildir (tmp->path)) { + snprintf (md_path, sizeof(md_path), "%s/new", tmp->path); + if (lstat (md_path, &s) == -1) + continue; + s.st_size = new = walk_maildir_new(md_path); + } else { + new = tmp->new; + if (lstat (tmp->path, &s) == -1) + continue; + if ((! S_ISREG (s.st_mode)) && (! S_ISDIR (s.st_mode)) && + (! S_ISLNK (s.st_mode))) + continue; + } + strfcpy (buffer, NONULL(tmp->path), sizeof (buffer)); mutt_pretty_mailbox (buffer); - add_folder (menu, state, buffer, &s, tmp->new); + add_folder (menu, state, buffer, &s, new); } while ((tmp = tmp->next)); browser_sort (state); diff -r 42595801073e -r 819ef6a7be06 mailbox.h --- a/mailbox.h Thu Mar 01 06:05:39 2007 +0000 +++ b/mailbox.h Thu Mar 01 13:12:58 2007 +0100 @@ -74,6 +74,7 @@ int mx_is_imap (const char *); #ifdef USE_POP int mx_is_pop (const char *); #endif +int mx_is_maildir (const char *s); int mx_access (const char*, int); int mx_check_empty (const char *); diff -r 42595801073e -r 819ef6a7be06 mx.c --- a/mx.c Thu Mar 01 06:05:39 2007 +0000 +++ b/mx.c Thu Mar 01 13:12:58 2007 +0100 @@ -457,6 +457,13 @@ int mx_get_magic (const char *path) return (magic); } +/* + * + */ +int mx_is_maildir (const char *s) +{ + return mx_get_magic(s) == M_MAILDIR; +} /* * set DefaultMagic to the given value */