else
mutt_format_s (dest, destlen, fmt, "");
break;
-
- case 'N':
-#ifdef USE_IMAP
- if (mx_is_imap (folder->ff->desc))
+
+ case 'm':
+ if (!optional)
{
- if (!optional)
- {
- snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
- snprintf (dest, destlen, tmp, folder->ff->new);
- }
- else if (!folder->ff->new)
- optional = 0;
- break;
+ if (folder->ff->has_buffy)
+ {
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, folder->ff->msg_count);
+ }
+ else
+ mutt_format_s (dest, destlen, fmt, "");
}
-#endif
+ else if (!folder->ff->msg_count)
+ optional = 0;
+ break;
+
+ case 'N':
snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : ' ');
break;
-
+
+ case 'n':
+ if (!optional)
+ {
+ if (folder->ff->has_buffy)
+ {
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, folder->ff->msg_unread);
+ }
+ else
+ mutt_format_s (dest, destlen, fmt, "");
+ }
+ else if (!folder->ff->msg_unread)
+ optional = 0;
+ break;
+
case 's':
if (folder->ff->local)
{
}
static void add_folder (MUTTMENU *m, struct browser_state *state,
- const char *name, const struct stat *s, unsigned int new)
+ const char *name, const struct stat *s, BUFFY *b)
{
if (state->entrylen == state->entrymax)
{
(state->entry)[state->entrylen].local = 1;
}
- else
- (state->entry)[state->entrylen].local = 0;
- (state->entry)[state->entrylen].new = new;
+ if (b)
+ {
+ (state->entry)[state->entrylen].has_buffy = 1;
+ (state->entry)[state->entrylen].new = b->new;
+ (state->entry)[state->entrylen].msg_count = b->msg_count;
+ (state->entry)[state->entrylen].msg_unread = b->msg_unread;
+ }
+
(state->entry)[state->entrylen].name = safe_strdup (name);
(state->entry)[state->entrylen].desc = safe_strdup (name);
#ifdef USE_IMAP
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 (tmp && Context &&
+ !mutt_strcmp (tmp->realpath, Context->realpath))
+ {
+ tmp->msg_count = Context->msgcount;
+ tmp->msg_unread = Context->unread;
+ }
+ add_folder (menu, state, de->d_name, &s, tmp);
}
closedir (dp);
browser_sort (state);
struct stat s;
char buffer[LONG_STRING];
BUFFY *tmp = Incoming;
-#ifdef USE_IMAP
- struct mailbox_state mbox;
-#endif
if (!Incoming)
return (-1);
do
{
+ if (Context &&
+ !mutt_strcmp (tmp->realpath, Context->realpath))
+ {
+ tmp->msg_count = Context->msgcount;
+ tmp->msg_unread = Context->unread;
+ }
+
#ifdef USE_IMAP
if (mx_is_imap (tmp->path))
{
- imap_mailbox_state (tmp->path, &mbox);
- add_folder (menu, state, tmp->path, NULL, mbox.new);
+ add_folder (menu, state, tmp->path, NULL, tmp);
continue;
}
#endif
#ifdef USE_POP
if (mx_is_pop (tmp->path))
{
- add_folder (menu, state, tmp->path, NULL, tmp->new);
+ add_folder (menu, state, tmp->path, NULL, tmp);
continue;
}
#endif
if (st2.st_mtime > s.st_mtime)
s.st_mtime = st2.st_mtime;
}
-
+
strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
mutt_pretty_mailbox (buffer, sizeof (buffer));
- add_folder (menu, state, buffer, &s, tmp->new);
+ add_folder (menu, state, buffer, &s, tmp);
}
while ((tmp = tmp->next));
browser_sort (state);
if (nentry+1 < state.entrylen)
memmove (state.entry + nentry, state.entry + nentry + 1,
sizeof (struct folder_file) * (state.entrylen - (nentry+1)));
+ memset (&state.entry[state.entrylen - 1], 0,
+ sizeof (struct folder_file));
state.entrylen--;
mutt_message _("Mailbox deleted.");
init_menu (&state, menu, title, sizeof (title), buffy);
#include <ctype.h>
#include "mutt.h"
+#include "buffy.h"
#include "imap_private.h"
/* -- forward declarations -- */
return -1;
}
-int imap_mailbox_state (const char* path, struct mailbox_state* state)
-{
- IMAP_DATA* idata;
- IMAP_MBOX mx;
- IMAP_STATUS* status;
-
- memset (state, 0, sizeof (*state));
- if (imap_parse_path (path, &mx) < 0)
- {
- dprint (1, (debugfile, "imap_mailbox_state: bad path %s\n", path));
- return -1;
- }
- if (!(idata = imap_conn_find (&mx.account, MUTT_IMAP_CONN_NONEW)))
- {
- dprint (2, (debugfile, "imap_mailbox_state: no open connection for %s\n",
- path));
- FREE (&mx.mbox);
- return -1;
- }
-
- if (idata->ctx && !imap_mxcmp(mx.mbox, idata->mailbox))
- {
- state->new = idata->ctx->new;
- state->messages = idata->ctx->msgcount;
- }
- else if ((status = imap_mboxcache_get (idata, mx.mbox, 0)))
- {
- state->new = status->unseen;
- state->messages = status->messages;
- }
-
- FREE (&mx.mbox);
-
- return 0;
-}
-
/* imap_mailbox_create: Prompt for a new mailbox name, and try to create it */
int imap_mailbox_create (const char* folder)
{
char tmp[LONG_STRING];
char relpath[LONG_STRING];
IMAP_MBOX mx;
+ BUFFY *b;
if (imap_parse_path (state->folder, &mx))
return;
(state->entry)[state->entrylen].delim = delim;
(state->entry)[state->entrylen].selectable = !noselect;
(state->entry)[state->entrylen].inferiors = !noinferiors;
+
+ b = Incoming;
+ while (b && mutt_strcmp (tmp, b->path))
+ b = b->next;
+ if (b)
+ {
+ if (Context &&
+ !mutt_strcmp (b->realpath, Context->realpath))
+ {
+ b->msg_count = Context->msgcount;
+ b->msg_unread = Context->unread;
+ }
+ (state->entry)[state->entrylen].has_buffy = 1;
+ (state->entry)[state->entrylen].new = b->new;
+ (state->entry)[state->entrylen].msg_count = b->msg_count;
+ (state->entry)[state->entrylen].msg_unread = b->msg_unread;
+ }
+
(state->entrylen)++;
FREE (&mx.mbox);
** .dt %F .dd file permissions
** .dt %g .dd group name (or numeric gid, if missing)
** .dt %l .dd number of hard links
- ** .dt %N .dd N if folder has new mail, blank otherwise
+ ** .dt %m .dd number of messages in the mailbox *
+ ** .dt %n .dd number of unread messages in the mailbox *
+ ** .dt %N .dd N if mailbox has new mail, blank otherwise
** .dt %s .dd size in bytes
** .dt %t .dd ``*'' if the file is tagged, blank otherwise
** .dt %u .dd owner name (or numeric uid, if missing)
** .de
** .pp
** For an explanation of ``soft-fill'', see the $$index_format documentation.
+ ** .pp
+ ** * = can be optionally printed if nonzero
+ ** .pp
+ ** %m, %n, and %N only work for monitored mailboxes.
+ ** %m requires $$mail_check_stats to be set.
+ ** %n requires $$mail_check_stats to be set (except for IMAP mailboxes).
*/
{ "followup_to", DT_BOOL, R_NONE, OPTFOLLOWUPTO, 1 },
/*