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
24 (*tmp)->newly_created = 0;
27 /* for check_mbox_size, it is important that if the folder is new (tested by
28 * reading it), the size is set to 0 so that later when we check we see
36 char path[_POSIX_PATH_MAX];
38 if (tmp->magic != M_IMAP)
44 if (tmp->magic != M_IMAP)
46 if (*de->d_name != '.' &&
47 (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
49 - /* one new and undeleted message is enough */
55 + /* one new and undeleted message is enough */
59 + if (! option (OPTMAILDIRMTIME)) /* prevent stat calls */
62 + snprintf (path, sizeof (path), "%s/new/%s", tmp->path, de->d_name);
63 + if (!stat (path, &smd) && smd.st_mtime > tmp->mtime)
65 + tmp->mtime = smd.st_mtime;
72 @@ -1185,6 +1185,16 @@
73 ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE
76 + { "maildir_mtime", DT_BOOL, R_NONE, OPTMAILDIRMTIME, 0 },
79 + ** If set, the sort-by-date option in the browser will sort maildirs
80 + ** smartly, not using the mtime of the maildir itself but that of the
81 + ** newest message in the new subdirectory, making the sorting by
82 + ** reverse date much more useful. People with maildirs over NFS may
83 + ** wish to leave this option unset.
87 { "header_cache", DT_PATH, R_NONE, UL &HeaderCache, 0 },
112 static void add_folder (MUTTMENU *m, struct browser_state *state,
113 - const char *name, const struct stat *s, int new)
114 + const char *name, /*DEB const IAN*/ struct stat *s, BUFFY *mbuf)
116 + int new = (mbuf) ? mbuf->new : 0;
118 if (state->entrylen == state->entrymax)
120 /* need to allocate more space */
122 m->data = state->entry;
125 + if (mbuf && mbuf->magic == M_MAILDIR && mbuf->mtime)
126 + s->st_mtime = mbuf->mtime;
130 (state->entry)[state->entrylen].mode = s->st_mode;
133 while (tmp && mutt_strcmp (buffer, tmp->path))
135 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
136 + add_folder (menu, state, de->d_name, &s, tmp);
139 browser_sort (state);
140 @@ -443,14 +449,15 @@
141 if (mx_is_imap (tmp->path))
143 imap_mailbox_state (tmp->path, &mbox);
144 - add_folder (menu, state, tmp->path, NULL, mbox.new);
145 + tmp->new = mbox.new;
146 + add_folder (menu, state, tmp->path, NULL, tmp);
151 if (mx_is_pop (tmp->path))
153 - add_folder (menu, state, tmp->path, NULL, tmp->new);
154 + add_folder (menu, state, tmp->path, NULL, tmp);
159 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
160 mutt_pretty_mailbox (buffer, sizeof (buffer));
162 - add_folder (menu, state, buffer, &s, tmp->new);
163 + add_folder (menu, state, buffer, &s, tmp);
165 while ((tmp = tmp->next));
166 browser_sort (state);
172 struct buffy_t *next;
173 + time_t mtime; /* for maildirs...time of newest entry */
174 short new; /* mailbox has new mail */
175 short notified; /* user has been notified */
176 short magic; /* mailbox type */