From: Richard Russon Date: Thu, 10 Jan 2019 13:44:17 +0000 (+0000) Subject: mutt_ev_message: factor out Context X-Git-Tag: 2019-10-25~373^2~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=197dc8490d8889077072b0d4ad9eb481c7a1235f;p=neomutt mutt_ev_message: factor out Context --- diff --git a/editmsg.c b/editmsg.c index a9781126a..9955fb5fe 100644 --- a/editmsg.c +++ b/editmsg.c @@ -244,24 +244,19 @@ bail: /** * mutt_ev_message - Edit or view a message - * @param ctx Mailbox Context - * @param e Email + * @param m Mailbox + * @param el List of Emails * @param action Action to perform, e.g. #EVM_EDIT * @retval 1 Message not modified * @retval 0 Message edited successfully * @retval -1 Error */ -int mutt_ev_message(struct Context *ctx, struct Email *e, enum EvMessage action) +int mutt_ev_message(struct Mailbox *m, struct EmailList *el, enum EvMessage action) { - if (e) - return ev_message(action, ctx->mailbox, e); - - for (int i = 0; i < ctx->mailbox->msg_count; i++) + struct EmailNode *en = NULL; + STAILQ_FOREACH(en, el, entries) { - if (!message_is_tagged(ctx, i)) - continue; - - if (ev_message(action, ctx->mailbox, ctx->mailbox->emails[i]) == -1) + if (ev_message(action, m, en->email) == -1) return -1; } diff --git a/index.c b/index.c index 3865ef30b..20cf45d64 100644 --- a/index.c +++ b/index.c @@ -3051,7 +3051,7 @@ int mutt_index_menu(void) case OP_EDIT_OR_VIEW_RAW_MESSAGE: case OP_EDIT_RAW_MESSAGE: case OP_VIEW_RAW_MESSAGE: - + { /* TODO split this into 3 cases? */ CHECK_MSGCOUNT; CHECK_VISIBLE; @@ -3074,10 +3074,14 @@ int mutt_index_menu(void) { mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw); } - mutt_ev_message(Context, tag ? NULL : CUR_EMAIL, edit ? EVM_EDIT : EVM_VIEW); + struct EmailList el = STAILQ_HEAD_INITIALIZER(el); + el_add_tagged(&el, Context, CUR_EMAIL, tag); + mutt_ev_message(Context->mailbox, &el, edit ? EVM_EDIT : EVM_VIEW); + el_free(&el); menu->redraw = REDRAW_FULL; break; + } case OP_FORWARD_MESSAGE: diff --git a/protos.h b/protos.h index 69ae8e053..b206b4a27 100644 --- a/protos.h +++ b/protos.h @@ -34,6 +34,7 @@ struct Context; struct EnterState; struct Envelope; struct Email; +struct EmailList; struct Mailbox; /** @@ -54,7 +55,7 @@ enum EvMessage EVM_EDIT, ///< Edit the message }; -int mutt_ev_message(struct Context *ctx, struct Email *e, enum EvMessage action); +int mutt_ev_message(struct Mailbox *m, struct EmailList *el, enum EvMessage action); int mutt_system(const char *cmd);