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
21 @@ -226,6 +226,7 @@ int mutt_parse_mailboxes (BUFFER *path,
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
29 @@ -254,6 +255,7 @@ int mutt_buffy_check (int force)
36 char path[_POSIX_PATH_MAX];
37 @@ -298,6 +300,7 @@ int mutt_buffy_check (int force)
38 if (tmp->magic != M_IMAP)
44 if (tmp->magic != M_IMAP)
45 @@ -380,10 +383,20 @@ int mutt_buffy_check (int force)
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 @@ -1086,6 +1086,16 @@ struct option_t MuttVars[] = {
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 },
91 @@ -395,6 +395,7 @@ enum
109 @@ -307,8 +308,10 @@ folder_format_str (char *dest, size_t de
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 */
121 @@ -320,6 +323,9 @@ static void add_folder (MUTTMENU *m, str
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;
131 @@ -414,7 +420,7 @@ static int examine_directory (MUTTMENU *
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 @@ -438,14 +444,15 @@ static int examine_mailboxes (MUTTMENU *
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);
158 @@ -459,7 +466,7 @@ static int examine_mailboxes (MUTTMENU *
159 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
160 mutt_pretty_mailbox (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);
169 @@ -25,6 +25,7 @@ typedef struct buffy_t
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 */
180 +patch-1.5.6.dw.maildir-mtime.1