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
102 +patch-1.5.6.dw.maildir-mtime.1
103 patch-1.5.13.cd.ifdef.2
114 @@ -307,8 +308,10 @@ folder_format_str (char *dest, size_t de
117 static void add_folder (MUTTMENU *m, struct browser_state *state,
118 - const char *name, const struct stat *s, int new)
119 + const char *name, /*DEB const IAN*/ struct stat *s, BUFFY *mbuf)
121 + int new = (mbuf) ? mbuf->new : 0;
123 if (state->entrylen == state->entrymax)
125 /* need to allocate more space */
126 @@ -320,6 +323,9 @@ static void add_folder (MUTTMENU *m, str
127 m->data = state->entry;
130 + if (mbuf && mbuf->magic == M_MAILDIR && mbuf->mtime)
131 + s->st_mtime = mbuf->mtime;
135 (state->entry)[state->entrylen].mode = s->st_mode;
136 @@ -414,7 +420,7 @@ static int examine_directory (MUTTMENU *
138 while (tmp && mutt_strcmp (buffer, tmp->path))
140 - add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
141 + add_folder (menu, state, de->d_name, &s, tmp);
144 browser_sort (state);
145 @@ -438,14 +444,15 @@ static int examine_mailboxes (MUTTMENU *
147 if (mx_is_imap (tmp->path))
149 - add_folder (menu, state, tmp->path, NULL, tmp->new);
150 + tmp->new = mbox.new;
151 + add_folder (menu, state, tmp->path, NULL, tmp);
156 if (mx_is_pop (tmp->path))
158 - add_folder (menu, state, tmp->path, NULL, tmp->new);
159 + add_folder (menu, state, tmp->path, NULL, tmp);
163 @@ -459,7 +466,7 @@ static int examine_mailboxes (MUTTMENU *
164 strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
165 mutt_pretty_mailbox (buffer);
167 - add_folder (menu, state, buffer, &s, tmp->new);
168 + add_folder (menu, state, buffer, &s, tmp);
170 while ((tmp = tmp->next));
171 browser_sort (state);
174 @@ -25,6 +25,7 @@ typedef struct buffy_t
177 struct buffy_t *next;
178 + time_t mtime; /* for maildirs...time of newest entry */
179 short new; /* mailbox has new mail */
180 short notified; /* user has been notified */
181 short magic; /* mailbox type */