numfiles = 0;
files = NULL;
- if (_mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 0, 1, &files, &numfiles) == -1 ||
+ if (_mutt_enter_fname (prompt, fname, sizeof (fname),
+ &menu->redraw, 0, 1, &files, &numfiles, 0) == -1 ||
*fname == '\0')
break;
#include <ctype.h>
#include <unistd.h> /* needed for SEEK_SET under SunOS 4.1.4 */
+#if USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
static int address_header_decode (char **str);
static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date);
{
MESSAGE *msg;
int r;
-
+
if ((msg = mx_open_message (src, hdr->msgno)) == NULL)
return -1;
if ((r = _mutt_copy_message (fpout, msg->fp, hdr, hdr->content, flags, chflags)) == 0
if (mx_commit_message (msg, dest) != 0)
r = -1;
+#ifdef USE_NOTMUCH
+ if (r != -1 && src->magic == M_NOTMUCH) {
+ char old[_POSIX_PATH_MAX];
+
+ if (nm_header_get_fullpath(hdr, old, sizeof(old)))
+ nm_update_filename(src, old, msg->commited_path);
+ }
+#endif
+
mx_close_message (&msg);
return r;
}
return rc;
}
-int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, int *redraw, int buffy, int multiple, char ***files, int *numfiles)
+int _mutt_enter_fname (const char *prompt, char *buf, size_t blen,
+ int *redraw, int buffy, int multiple,
+ char ***files, int *numfiles, int flags)
{
event_t ch;
{
mutt_refresh ();
buf[0] = 0;
- _mutt_select_file (buf, blen, M_SEL_FOLDER | (multiple ? M_SEL_MULTI : 0),
- files, numfiles);
+ if (!flags)
+ flags = M_SEL_FOLDER | (multiple ? M_SEL_MULTI : 0);
+
+ _mutt_select_file (buf, blen, flags, files, numfiles);
+ *redraw = REDRAW_FULL;
+ }
+ else if (flags & M_SEL_VFOLDER) {
+ _mutt_select_file (buf, blen, flags, files, numfiles);
*redraw = REDRAW_FULL;
}
else
#include "imap_private.h"
#endif
+#ifdef USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
#include "mutt_crypt.h"
safe_free (&lineInfo.syntax);
}
+static int main_change_folder(MUTTMENU *menu, int op, char *buf, size_t bufsz,
+ int *oldcount, int *index_hint)
+{
+ mutt_expand_path (buf, bufsz);
+#ifdef USE_SIDEBAR
+ if (sb_set_open_buffy (buf) == NULL)
+ break;
+#endif
+ if (mx_get_magic (buf) <= 0)
+ {
+ mutt_error (_("%s is not a mailbox."), buf);
+ return -1;
+ }
+ mutt_str_replace (&CurrentFolder, buf);
+
+ /* keepalive failure in mutt_enter_fname may kill connection. #3028 */
+ if (Context && !Context->path)
+ FREE (&Context);
+
+ if (Context)
+ {
+ int check;
+
+ mutt_str_replace (&LastFolder, Context->path);
+ *oldcount = Context ? Context->msgcount : 0;
+
+ if ((check = mx_close_mailbox (Context, index_hint)) != 0)
+ {
+ if (check == M_NEW_MAIL || check == M_REOPENED)
+ update_index (menu, Context, check, *oldcount, *index_hint);
+
+ set_option (OPTSEARCHINVALID);
+ menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
+ return 0;
+ }
+ FREE (&Context);
+ }
+
+ mutt_sleep (0);
+
+ /* Set CurrentMenu to MENU_MAIN before executing any folder
+ * hooks so that all the index menu functions are available to
+ * the exec command.
+ */
+
+ CurrentMenu = MENU_MAIN;
+ mutt_folder_hook (buf);
+
+ if ((Context = mx_open_mailbox (buf,
+ (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
+ M_READONLY : 0, NULL)) != NULL)
+ {
+ menu->current = ci_first_message ();
+ }
+ else
+ menu->current = 0;
+
+ mutt_clear_error ();
+ mutt_buffy_check(1); /* force the buffy check after we have changed the folder */
+ menu->redraw = REDRAW_FULL;
+ set_option (OPTSEARCHINVALID);
+
+ return 0;
+}
+
static const struct mapping_t IndexHelp[] = {
{ N_("Quit"), OP_QUIT },
{ N_("Del"), OP_DELETE },
}
break;
+#ifdef USE_NOTMUCH
+ case OP_MAIN_VFOLDER_FROM_QUERY:
+
+ buf[0] = '\0';
+ if (mutt_get_field ("Query: ", buf, sizeof (buf), 0) != 0 || !buf[0])
+ {
+ mutt_message _("No query, aborting.");
+ break;
+ }
+ if (!nm_uri_from_query(Context, buf, sizeof (buf)))
+ mutt_message _("Failed to create query, aborting.");
+ else
+ main_change_folder(menu, op, buf, sizeof (buf), &oldcount, &index_hint);
+ break;
+
+ case OP_MAIN_CHANGE_VFOLDER:
+#endif
#ifdef USE_SIDEBAR
case OP_SIDEBAR_OPEN:
#endif
if ((op == OP_MAIN_CHANGE_FOLDER_READONLY) || option (OPTREADONLY))
cp = _("Open mailbox in read-only mode");
- else
+#ifdef USE_NOTMUCH
+ else if (op == OP_MAIN_CHANGE_VFOLDER)
+ cp = _("Open virtual folder");
+#endif
+ else
cp = _("Open mailbox");
buf[0] = '\0';
break;
strncpy (buf, path, sizeof (buf));
} else
+#endif
+#ifdef USE_NOTMUCH
+ if (op == OP_MAIN_CHANGE_VFOLDER)
+ mutt_enter_vfolder (cp, buf, sizeof (buf), &menu->redraw, 1);
+ else
#endif
if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1)
{
}
}
- mutt_expand_path (buf, sizeof (buf));
-#ifdef USE_SIDEBAR
- if (sb_set_open_buffy (buf) == NULL)
- break;
-#endif
- if (mx_get_magic (buf) <= 0)
- {
- mutt_error (_("%s is not a mailbox."), buf);
- break;
- }
- mutt_str_replace (&CurrentFolder, buf);
-
- /* keepalive failure in mutt_enter_fname may kill connection. #3028 */
- if (Context && !Context->path)
- FREE (&Context);
-
- if (Context)
- {
- int check;
-
- mutt_str_replace (&LastFolder, Context->path);
- oldcount = Context ? Context->msgcount : 0;
-
- if ((check = mx_close_mailbox (Context, &index_hint)) != 0)
- {
- if (check == M_NEW_MAIL || check == M_REOPENED)
- update_index (menu, Context, check, oldcount, index_hint);
-
- set_option (OPTSEARCHINVALID);
- menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
- break;
- }
- FREE (&Context);
- }
-
- mutt_sleep (0);
-
- /* Set CurrentMenu to MENU_MAIN before executing any folder
- * hooks so that all the index menu functions are available to
- * the exec command.
- */
-
- CurrentMenu = MENU_MAIN;
- mutt_folder_hook (buf);
-
- if ((Context = mx_open_mailbox (buf,
- (option (OPTREADONLY) || op == OP_MAIN_CHANGE_FOLDER_READONLY) ?
- M_READONLY : 0, NULL)) != NULL)
- {
- menu->current = ci_first_message ();
- }
- else
- menu->current = 0;
-
- mutt_clear_error ();
- mutt_buffy_check(1); /* force the buffy check after we have changed
- the folder */
- menu->redraw = REDRAW_FULL;
- set_option (OPTSEARCHINVALID);
+ main_change_folder(menu, op, buf, sizeof (buf), &oldcount, &index_hint);
break;
case OP_DISPLAY_MESSAGE:
#include <alloca.h>
#endif
+#ifdef USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
int mutt_is_mail_list (ADDRESS *addr)
{
if (!mutt_match_rx_list (addr->mailbox, UnMailLists))
* %E = number of messages in current thread
* %f = entire from line
* %F = like %n, unless from self
+ * %g = message labes (e.g. notmuch tags)
* %i = message-id
* %l = number of lines in the message
* %L = like %F, except `lists' are displayed first
else if (mutt_addr_is_user (hdr->env->from))
optional = 0;
break;
-
+#ifdef USE_NOTMUCH
+ case 'g':
+ mutt_format_s (dest, destlen, prefix, nm_header_get_tags(hdr));
+ break;
+#endif
case 'H':
/* (Hormel) spam score */
if (optional)
int mutt_parent_message (CONTEXT *, HEADER *);
int mutt_prepare_template(FILE*, CONTEXT *, HEADER *, HEADER *, short);
int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
-#define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
-int _mutt_enter_fname (const char *, char *, size_t, int *, int, int, char ***, int *);
+#define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL,0)
+#define mutt_enter_vfolder(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL,M_SEL_VFOLDER)
+
+int _mutt_enter_fname (const char *, char *, size_t, int *, int, int, char ***, int *, int);
int mutt_enter_string (char *buf, size_t buflen, int y, int x, int flags);
int _mutt_enter_string (char *, size_t, int, int, int, int, char ***, int *, ENTER_STATE *);
#define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)