2 This is the maildir mtime patch by Dale Woolridge.
4 The home page for this patch is:
6 http://www.mutt.ca/maildir-mtime.html
8 * Patch last synced with upstream:
10 - File: http://www.mutt.ca/patches/patch-1.5.6.dw.maildir-mtime.1
13 - removed a spurious const in add_folder() definition.
14 - added a $maildir_mtime option to allow this patch to be disabled at
15 runtime (see Bug#253261, comments from Zephaniah E. Hull).
16 - 2007-04-03 myon: resolved conflict in browser.c
19 Index: debian-mutt/buffy.c
20 ===================================================================
21 --- debian-mutt.orig/buffy.c 2007-04-03 19:17:22.000000000 +0200
22 +++ debian-mutt/buffy.c 2007-04-03 19:20:31.000000000 +0200
23 @@ -226,6 +226,7 @@ int mutt_parse_mailboxes (BUFFER *path,
26 (*tmp)->newly_created = 0;
29 /* for check_mbox_size, it is important that if the folder is new (tested by
30 * reading it), the size is set to 0 so that later when we check we see
31 @@ -254,6 +255,7 @@ int mutt_buffy_check (int force)
38 char path[_POSIX_PATH_MAX];
39 @@ -298,6 +300,7 @@ int mutt_buffy_check (int force)
40 if (tmp->magic != M_IMAP)
46 if (tmp->magic != M_IMAP)
47 @@ -380,10 +383,20 @@ int mutt_buffy_check (int force)
48 if (*de->d_name != '.' &&
49 (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
51 - /* one new and undeleted message is enough */
57 + /* one new and undeleted message is enough */
61 + if (! option (OPTMAILDIRMTIME)) /* prevent stat calls */
64 + snprintf (path, sizeof (path), "%s/new/%s", tmp->path, de->d_name);
65 + if (!stat (path, &smd) && smd.st_mtime > tmp->mtime)
67 + tmp->mtime = smd.st_mtime;
72 Index: debian-mutt/init.h
73 ===================================================================
74 --- debian-mutt.orig/init.h 2007-04-03 19:20:27.000000000 +0200
75 +++ debian-mutt/init.h 2007-04-03 19:20:31.000000000 +0200
76 @@ -1086,6 +1086,16 @@ struct option_t MuttVars[] = {
77 ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE
80 + { "maildir_mtime", DT_BOOL, R_NONE, OPTMAILDIRMTIME, 0 },
83 + ** If set, the sort-by-date option in the browser will sort maildirs
84 + ** smartly, not using the mtime of the maildir itself but that of the
85 + ** newest message in the new subdirectory, making the sorting by
86 + ** reverse date much more useful. People with maildirs over NFS may
87 + ** wish to leave this option unset.
91 { "header_cache", DT_PATH, R_NONE, UL &HeaderCache, 0 },
93 Index: debian-mutt/mutt.h
94 ===================================================================
95 --- debian-mutt.orig/mutt.h 2007-04-03 19:20:27.000000000 +0200
96 +++ debian-mutt/mutt.h 2007-04-03 19:20:31.000000000 +0200
97 @@ -400,6 +400,7 @@ enum
105 Index: debian-mutt/PATCHES
106 ===================================================================
107 --- debian-mutt.orig/PATCHES 2007-04-03 19:20:27.000000000 +0200
108 +++ debian-mutt/PATCHES 2007-04-03 19:20:31.000000000 +0200
110 +patch-1.5.6.dw.maildir-mtime.1
111 patch-1.5.13.cd.ifdef.2
112 patch-1.5.14.rr.compressed.1
113 Index: debian-mutt/browser.c
114 ===================================================================
115 --- debian-mutt.orig/browser.c 2007-04-03 19:20:17.000000000 +0200
116 +++ debian-mutt/browser.c 2007-04-03 19:24:32.000000000 +0200
125 @@ -307,8 +308,10 @@ folder_format_str (char *dest, size_t de
128 static void add_folder (MUTTMENU *m, struct browser_state *state,
129 - const char *name, const struct stat *s, int new)
130 + const char *name, /*DEB const IAN*/ struct stat *s, BUFFY *mbuf)
132 + int new = (mbuf) ? mbuf->new : 0;
134 if (state->entrylen == state->entrymax)
136 /* need to allocate more space */
137 @@ -320,6 +323,9 @@ static void add_folder (MUTTMENU *m, str
138 m->data = state->entry;
141 + if (mbuf && mbuf->magic == M_MAILDIR && mbuf->mtime)
142 + s->st_mtime = mbuf->mtime;
146 (state->entry)[state->entrylen].mode = s->st_mode;
147 @@ -414,7 +420,7 @@ static int examine_directory (MUTTMENU *
149 while (tmp && mutt_strcmp (buffer, tmp->path))
151 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
152 + add_folder (menu, state, de->d_name, &s, tmp);
155 browser_sort (state);
156 @@ -442,14 +448,15 @@ static int examine_mailboxes (MUTTMENU *
157 if (mx_is_imap (tmp->path))
159 imap_mailbox_state (tmp->path, &mbox);
160 - add_folder (menu, state, tmp->path, NULL, mbox.new);
161 + tmp->new = mbox.new;
162 + add_folder (menu, state, tmp->path, NULL, tmp);
167 if (mx_is_pop (tmp->path))
169 - add_folder (menu, state, tmp->path, NULL, tmp->new);
170 + add_folder (menu, state, tmp->path, NULL, tmp);
174 @@ -463,7 +469,7 @@ static int examine_mailboxes (MUTTMENU *
175 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
176 mutt_pretty_mailbox (buffer);
178 - add_folder (menu, state, buffer, &s, tmp->new);
179 + add_folder (menu, state, buffer, &s, tmp);
181 while ((tmp = tmp->next));
182 browser_sort (state);
183 Index: debian-mutt/buffy.h
184 ===================================================================
185 --- debian-mutt.orig/buffy.h 2007-04-03 19:17:22.000000000 +0200
186 +++ debian-mutt/buffy.h 2007-04-03 19:20:31.000000000 +0200
187 @@ -25,6 +25,7 @@ typedef struct buffy_t
190 struct buffy_t *next;
191 + time_t mtime; /* for maildirs...time of newest entry */
192 short new; /* mailbox has new mail */
193 short notified; /* user has been notified */
194 short magic; /* mailbox type */