int alias_search (MUTTMENU *m, regex_t *re, int n)
{
- int i, match = 0;
char s[LONG_STRING];
int slen = sizeof(s);
- for (i=0; i < m->max; i++)
- {
- mutt_FormatString (s, slen, NONULL (AliasFmt), alias_format_str,
- (unsigned long) ((ALIAS **) m->data)[n], 0);
- if ((match = regexec (re, s, 0, NULL, 0))) return match;
- }
- return (0);
+ mutt_FormatString (s, slen, NONULL (AliasFmt), alias_format_str,
+ (unsigned long) ((ALIAS **) m->data)[n], 0);
+ return regexec (re, s, 0, NULL, 0);
}
MUTTMENU *menu;
int i, done=0, r=-1;
char helpstr[SHORT_STRING];
- char title[SHORT_STRING];
+ char title[SHORT_STRING], from_folder[SHORT_STRING];
- snprintf(title, sizeof (title), "Messages to attach from folder %s",
- ctx->path);
+ strfcpy(from_folder, ctx->path, sizeof (from_folder));
+ mutt_pretty_mailbox (from_folder);
+ snprintf(title, sizeof (title), "Attach messages from folder: %s",
+ from_folder);
menu = mutt_new_menu ();
menu->make_entry = attach_msg_make_entry;
menu->max = ctx->msgcount;
menu->title = title;
menu->data = ctx;
+ menu->search = (int (*)(MUTTMENU *, regex_t *, int)) -1;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_GENERIC,
AttachMsgHelp);
case OP_SEARCH_OPPOSITE:
CHECK_MSGCOUNT;
- if ((menu->current = mutt_search_command (menu->current, op)) == -1)
+ if ((menu->current = mutt_search_command (Context, menu->current, op)) == -1)
menu->current = menu->oldcurrent;
else
menu->redraw = REDRAW_MOTION;
static int menu_search (MUTTMENU *menu, int op)
{
int r;
- int searchDir = (menu->searchDir == M_SEARCH_UP) ? -1 : 1;
+ int searchDir;
regex_t re;
char buf[SHORT_STRING];
+ /* Need to search the folder using the pattern matching language,
+ * not plain regexps. mutt_search_command() does just this */
+ if (menu->search == (int (*)(MUTTMENU *, regex_t *, int)) -1 )
+ return mutt_search_command (menu->data, menu->current, op);
+
if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
{
strfcpy (buf, menu->searchBuf ? menu->searchBuf : "", sizeof (buf));
- if (mutt_get_field ("Search for: ", buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
+ if (mutt_get_field ((op == OP_SEARCH) ? "Search for: " :
+ "Reverse search for: ",
+ buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
return (-1);
safe_free ((void **) &menu->searchBuf);
menu->searchBuf = safe_strdup (buf);
mutt_error ("No search pattern.");
return (-1);
}
-
- if (op == OP_SEARCH_OPPOSITE)
- searchDir = -searchDir;
}
+ searchDir = (menu->searchDir == M_SEARCH_UP) ? -1 : 1;
+ if (op == OP_SEARCH_OPPOSITE)
+ searchDir = -searchDir;
+
if ((r = REGCOMP (&re, menu->searchBuf, REG_NOSUB | mutt_which_case (menu->searchBuf))) != 0)
{
regerror (r, &re, buf, sizeof (buf));
return 0;
}
-int mutt_search_command (int cur, int op)
+int mutt_search_command (CONTEXT *ctx, int cur, int op)
{
int i, j;
char buf[STRING];
if (option (OPTSEARCHINVALID))
{
- for (i = 0; i < Context->msgcount; i++)
- Context->hdrs[i]->searched = 0;
+ for (i = 0; i < ctx->msgcount; i++)
+ ctx->hdrs[i]->searched = 0;
unset_option (OPTSEARCHINVALID);
}
if (op == OP_SEARCH_OPPOSITE)
incr = -incr;
- for (i = cur + incr, j = 0 ; j != Context->vcount; j++)
+ for (i = cur + incr, j = 0 ; j != ctx->vcount; j++)
{
- if (i > Context->vcount - 1)
+ if (i > ctx->vcount - 1)
{
i = 0;
if (option (OPTWRAPSEARCH))
}
else if (i < 0)
{
- i = Context->vcount - 1;
+ i = ctx->vcount - 1;
if (option (OPTWRAPSEARCH))
mutt_message ("Search wrapped to bottom.");
else
}
}
- h = Context->hdrs[Context->v2r[i]];
+ h = ctx->hdrs[ctx->v2r[i]];
if (h->searched)
{
/* if we've already evaulated this message, use the cached value */
{
/* remember that we've already searched this message */
h->searched = 1;
- if ((h->matched = (mutt_pattern_exec (SearchPattern, M_MATCH_FULL_ADDRESS, Context, h) > 0)))
+ if ((h->matched = (mutt_pattern_exec (SearchPattern, M_MATCH_FULL_ADDRESS, ctx, h) > 0)))
return i;
}
int mutt_query_complete (char *, size_t);
int mutt_save_attachment (FILE *, BODY *, char *, int);
int mutt_save_message (HEADER *, int, int, int *);
-int mutt_search_command (int, int);
+int mutt_search_command (CONTEXT *, int, int);
int mutt_send_menu (HEADER *, char *, size_t, HEADER *);
int mutt_send_message (HEADER *, const char *);
int mutt_strcmp (const char *, const char *);