Commit 22d028d7 authored by Thomas Roessler's avatar Thomas Roessler

Apply message-hook to more commands, and make it more useful by

permitting the "~h" and "~b" pattern specifiers.  Bad enough, this
removes message-hook abilities from the receive-attachment menu.
parent 77613b14
......@@ -73,7 +73,7 @@ int mutt_display_message (HEADER *cur)
cur->content->subtype);
mutt_parse_mime_message (Context, cur);
mutt_message_hook (Context, cur, M_MESSAGEHOOK);
#ifdef HAVE_PGP
/* see if PGP is needed for this message. if so, we should exit curses */
......@@ -113,8 +113,6 @@ int mutt_display_message (HEADER *cur)
return (0);
}
mutt_message_hook (cur, M_MESSAGEHOOK);
if (DisplayFilter && *DisplayFilter)
{
fpfilterout = fpout;
......@@ -305,7 +303,7 @@ int mutt_pipe_message (HEADER *h)
if (h)
{
mutt_message_hook (Context, h, M_MESSAGEHOOK);
#ifdef HAVE_PGP
if (option (OPTPIPEDECODE))
......@@ -336,6 +334,7 @@ int mutt_pipe_message (HEADER *h)
for (i = 0; i < Context->vcount; i++)
if(Context->hdrs[Context->v2r[i]]->tagged)
{
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
mutt_parse_mime_message(Context, Context->hdrs[Context->v2r[i]]);
if (Context->hdrs[Context->v2r[i]]->pgp & PGPENCRYPT &&
!pgp_valid_passphrase())
......@@ -352,6 +351,7 @@ int mutt_pipe_message (HEADER *h)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
endwin ();
thepid = mutt_create_filter (buffer, &(s.fpout), NULL, NULL);
mutt_pipe_message_to_state (Context->hdrs[Context->v2r[i]], &s);
......@@ -372,6 +372,7 @@ int mutt_pipe_message (HEADER *h)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
mutt_pipe_message_to_state (Context->hdrs[Context->v2r[i]], &s);
/* add the message separator */
if (PipeSep)
......@@ -582,6 +583,7 @@ int mutt_save_message (HEADER *h, int delete,
*redraw = 0;
snprintf (prompt, sizeof (prompt), _("%s%s to mailbox"),
decode ? (delete ? _("Decode-save") : _("Decode-copy")) :
(decrypt ? (delete ? _("Decrypt-save") : _("Decrypt-copy")):
......@@ -592,6 +594,7 @@ int mutt_save_message (HEADER *h, int delete,
#ifdef HAVE_PGP
need_passphrase = h->pgp & PGPENCRYPT;
#endif
mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h);
}
else
......@@ -609,6 +612,7 @@ int mutt_save_message (HEADER *h, int delete,
if (h)
{
mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h);
#ifdef HAVE_PGP
need_passphrase |= h->pgp & PGPENCRYPT;
......@@ -681,8 +685,11 @@ int mutt_save_message (HEADER *h, int delete,
for (i = 0; i < Context->vcount; i++)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
_mutt_save_message(Context->hdrs[Context->v2r[i]],
&ctx, delete, decode, decrypt);
}
}
}
......@@ -746,6 +753,7 @@ void mutt_print_message (HEADER *h)
pid_t thepid;
FILE *fp;
if (query_quadoption (OPT_PRINT,
h ? _("Print message?") : _("Print tagged messages?"))
!= M_YES)
......@@ -755,6 +763,7 @@ void mutt_print_message (HEADER *h)
return;
if (h)
{
mutt_message_hook (Context, h, M_MESSAGEHOOK);
print_msg (fp, Context, h);
count++;
}
......@@ -764,6 +773,7 @@ void mutt_print_message (HEADER *h)
{
if (Context->hdrs[Context->v2r[i]]->tagged)
{
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
print_msg (fp, Context, Context->hdrs[Context->v2r[i]]);
/* add a formfeed */
fputc ('\f', fp);
......
......@@ -147,7 +147,7 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
if (data & (M_SENDHOOK | M_SAVEHOOK | M_FCCHOOK | M_MESSAGEHOOK))
{
if ((pat = mutt_pattern_comp (pattern.data,
(data & (M_SENDHOOK | M_FCCHOOK | M_MESSAGEHOOK)) ? 0 : M_FULL_MSG,
(data & (M_SENDHOOK | M_FCCHOOK)) ? 0 : M_FULL_MSG,
err)) == NULL)
goto error;
}
......@@ -294,7 +294,7 @@ char *mutt_find_hook (int type, const char *pat)
return (NULL);
}
void mutt_message_hook (HEADER *hdr, int type)
void mutt_message_hook (CONTEXT *ctx, HEADER *hdr, int type)
{
BUFFER err, token;
HOOK *hook;
......@@ -309,7 +309,7 @@ void mutt_message_hook (HEADER *hdr, int type)
continue;
if (hook->type & type)
if ((mutt_pattern_exec (hook->pattern, 0, NULL, hdr) > 0) ^ hook->rx.not)
if ((mutt_pattern_exec (hook->pattern, 0, ctx, hdr) > 0) ^ hook->rx.not)
if (mutt_parse_rc_line (hook->command, &token, &err) != 0)
{
FREE (&token.data);
......
......@@ -197,7 +197,7 @@ void mutt_score_message (CONTEXT *, HEADER *, int);
void mutt_select_fcc (char *, size_t, HEADER *);
#define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,0,NULL,NULL)
void _mutt_select_file (char *, size_t, int, int, char ***, int *);
void mutt_message_hook (HEADER *, int);
void mutt_message_hook (CONTEXT *, HEADER *, int);
void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)
void mutt_set_followup_to (ENVELOPE *);
......
......@@ -795,6 +795,8 @@ void mutt_view_attachments (HEADER *hdr)
/* make sure we have parsed this message */
mutt_parse_mime_message (Context, hdr);
mutt_message_hook (Context, hdr, M_MESSAGEHOOK);
if ((msg = mx_open_message (Context, hdr->msgno)) == NULL)
return;
......
......@@ -566,7 +566,7 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
if (cur)
{
mutt_message_hook (cur->hdr, M_MESSAGEHOOK);
/* mutt_message_hook (cur->hdr, M_MESSAGEHOOK); */
mutt_forward_intro (tmpfp, cur->hdr);
_mutt_copy_message (tmpfp, fp, cur->hdr, cur->hdr->content, cmflags, chflags);
mutt_forward_trailer (tmpfp);
......@@ -577,7 +577,7 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
{
if (idx[i]->content->tagged)
{
mutt_message_hook (idx[i]->content->hdr, M_MESSAGEHOOK);
/* mutt_message_hook (idx[i]->content->hdr, M_MESSAGEHOOK); */
mutt_forward_intro (tmpfp, idx[i]->content->hdr);
_mutt_copy_message (tmpfp, fp, idx[i]->content->hdr,
idx[i]->content->hdr->content, cmflags, chflags);
......@@ -733,7 +733,7 @@ static void attach_include_reply (FILE *fp, FILE *tmpfp, HEADER *cur, int flags)
int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV;
int chflags = CH_DECODE;
mutt_message_hook (cur, M_MESSAGEHOOK);
/* mutt_message_hook (cur, M_MESSAGEHOOK); */
mutt_make_attribution (Context, cur, tmpfp);
......
......@@ -337,7 +337,8 @@ static int include_forward (CONTEXT *ctx, HEADER *cur, FILE *out)
{
int chflags = CH_DECODE, cmflags = 0;
mutt_message_hook (cur, M_MESSAGEHOOK);
mutt_parse_mime_message (ctx, cur);
mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
#ifdef HAVE_PGP
if ((cur->pgp & PGPENCRYPT) && option (OPTFORWDECODE))
......@@ -360,7 +361,7 @@ static int include_forward (CONTEXT *ctx, HEADER *cur, FILE *out)
}
if (option (OPTFORWQUOTE))
cmflags |= M_CM_PREFIX;
mutt_parse_mime_message (ctx, cur);
mutt_copy_message (out, ctx, cur, cmflags, chflags);
mutt_forward_trailer (out);
return 0;
......@@ -404,7 +405,8 @@ static int include_reply (CONTEXT *ctx, HEADER *cur, FILE *out)
}
#endif /* HAVE_PGP */
mutt_message_hook (cur, M_MESSAGEHOOK);
mutt_parse_mime_message (ctx, cur);
mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
mutt_make_attribution (ctx, cur, out);
......@@ -416,9 +418,8 @@ static int include_reply (CONTEXT *ctx, HEADER *cur, FILE *out)
cmflags |= M_CM_WEED;
}
mutt_parse_mime_message (ctx, cur);
mutt_copy_message (out, ctx, cur, cmflags, chflags);
mutt_make_post_indent (ctx, cur, out);
return 0;
......@@ -1152,7 +1153,7 @@ ci_send_message (int flags, /* send mode */
/* change settings based upon recipients */
mutt_message_hook (msg, M_SENDHOOK);
mutt_message_hook (NULL, msg, M_SENDHOOK);
if (killfrom)
{
......@@ -1165,6 +1166,20 @@ ci_send_message (int flags, /* send mode */
/* include replies/forwarded messages, unless we are given a template */
if (!tempfile && (ctx || !(flags & (SENDREPLY|SENDFORWARD)))
&& generate_body (tempfp, msg, flags, ctx, cur) == -1)
goto cleanup;
if (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0)
append_signature (tempfp);
/*
* this wants to be done _after_ generate_body, so message-hooks
* can take effect.
*/
#ifdef HAVE_PGP
if (! (flags & SENDMAILX))
{
......@@ -1183,13 +1198,6 @@ ci_send_message (int flags, /* send mode */
/* include replies/forwarded messages, unless we are given a template */
if (!tempfile && (ctx || !(flags & (SENDREPLY|SENDFORWARD)))
&& generate_body (tempfp, msg, flags, ctx, cur) == -1)
goto cleanup;
if (! (flags & (SENDMAILX | SENDKEY)) && Editor && mutt_strcmp (Editor, "builtin") != 0)
append_signature (tempfp);
}
/* wait until now to set the real name portion of our return address so
that $realname can be set in a send-hook */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment