#ifdef USE_IMAP
#include "imap.h"
#endif
+#ifdef USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
#include <stdlib.h>
#include <dirent.h>
case 'f':
{
char *s;
+
+#ifdef USE_NOTMUCH
+ if (mx_is_notmuch(folder->ff->name))
+ s = NONULL (folder->ff->desc);
+ else
+#endif
#ifdef USE_IMAP
if (folder->ff->imap)
s = NONULL (folder->ff->desc);
optional = 0;
break;
}
+#endif
+#ifdef USE_NOTMUCH
+ if (mx_is_notmuch (folder->ff->name))
+ {
+ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
+ snprintf (dest, destlen, tmp, folder->ff->new);
+ break;
+ }
#endif
snprintf (tmp, sizeof (tmp), "%%%sc", fmt);
snprintf (dest, destlen, tmp, folder->ff->new ? 'N' : ' ');
return 0;
}
+#ifdef USE_NOTMUCH
+static int examine_vfolders (MUTTMENU *menu, struct browser_state *state)
+{
+ BUFFY *tmp = VirtIncoming;
+
+ if (!VirtIncoming)
+ return (-1);
+ mutt_buffy_check (0);
+
+ init_state (state, menu);
+
+ do
+ {
+ if (mx_is_notmuch (tmp->path))
+ {
+ unsigned new = 0, all = 0;
+ nm_get_count(tmp->path, &all, &new);
+ add_folder (menu, state, tmp->path, tmp->desc, NULL, new, all);
+ continue;
+ }
+ }
+ while ((tmp = tmp->next));
+ browser_sort (state);
+ return 0;
+}
+#endif
+
static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
{
struct stat s;
(unsigned long) &folder, M_FORMAT_ARROWCURSOR);
}
+#ifdef USE_NOTMUCH
+static void vfolder_entry (char *s, size_t slen, MUTTMENU *menu, int num)
+{
+ FOLDER folder;
+
+ folder.ff = &((struct folder_file *) menu->data)[num];
+ folder.num = num;
+
+ mutt_FormatString (s, slen, 0, NONULL(VirtFolderFormat), folder_format_str,
+ (unsigned long) &folder, M_FORMAT_ARROWCURSOR);
+}
+#endif
+
static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
size_t titlelen, int buffy)
{
int buffy = (flags & M_SEL_BUFFY) ? 1 : 0;
buffy = buffy && folder;
-
+
memset (&state, 0, sizeof (struct browser_state));
if (!folder)
}
#endif
}
- else
+#ifdef USE_NOTMUCH
+ else if (!(flags & M_SEL_VFOLDER))
+#else
+ else
+#endif
{
if (!folder)
getcwd (LastDir, sizeof (LastDir));
else if (!LastDir[0])
strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
-
+
#ifdef USE_IMAP
if (!buffy && mx_is_imap (LastDir))
{
*f = 0;
+#ifdef USE_NOTMUCH
+ if (flags & M_SEL_VFOLDER) {
+ if (examine_vfolders (NULL, &state) == -1)
+ goto bail;
+ } else
+#endif
if (buffy)
{
if (examine_mailboxes (NULL, &state) == -1)
#ifdef USE_IMAP
if (!state.imap_browse)
#endif
+ {
if (examine_directory (NULL, &state, LastDir, prefix) == -1)
goto bail;
-
+ }
menu = mutt_new_menu (MENU_FOLDER);
- menu->make_entry = folder_entry;
+#ifdef USE_NOTMUCH
+ if (flags & M_SEL_VFOLDER)
+ menu->make_entry = vfolder_entry;
+ else
+#endif
+ menu->make_entry = folder_entry;
+
menu->search = select_file_search;
menu->title = title;
menu->data = state.entry;
#ifdef USE_IMAP
else if (state.imap_browse)
strfcpy (f, state.entry[menu->current].name, flen);
+#endif
+#ifdef USE_NOTMUCH
+ else if (mx_is_notmuch(state.entry[menu->current].name))
+ strfcpy (f, state.entry[menu->current].name, flen);
#endif
else
mutt_concat_path (f, LastDir, state.entry[menu->current].name, flen);
}
break;
#endif
-
+
case OP_CHANGE_DIRECTORY:
strfcpy (buf, LastDir, sizeof (buf));