~kevin8t8/mutt

d97bbddfeb0167fd0cf1ba5a20bd7913c6577ce6 — Kevin McCarthy 11 months ago d79cb6b
Create <group-chat-reply> function.

This function differs from <group-reply> only in that it preserves To
recipients in the original email as To recipients in the reply.

The merits of this function aren't without controversy; therefore it
is left unbound by default.  Those who care about such things are free
to bind it.

Combine reply operation handlers in the pager and curs_main, since the
code was the same with the exception of the flags used.
8 files changed, 61 insertions(+), 54 deletions(-)

M OPS
M curs_main.c
M doc/manual.xml.head
M functions.h
M mutt.h
M pager.c
M recvattach.c
M send.c
M OPS => OPS +1 -0
@@ 92,6 92,7 @@ OP_FIRST_ENTRY "move to the first entry"
OP_FLAG_MESSAGE "toggle a message's 'important' flag"
OP_FORWARD_MESSAGE "forward a message with comments"
OP_GENERIC_SELECT_ENTRY "select the current entry"
OP_GROUP_CHAT_REPLY "reply to all recipients preserving To/Cc"
OP_GROUP_REPLY "reply to all recipients"
OP_HALF_DOWN "scroll down 1/2 page"
OP_HALF_UP "scroll up 1/2 page"

M curs_main.c => curs_main.c +13 -23
@@ 2197,17 2197,6 @@ int mutt_index_menu (void)
	crypt_forget_passphrase ();
	break;

      case OP_GROUP_REPLY:

	CHECK_MSGCOUNT;
        CHECK_VISIBLE;
	CHECK_ATTACH;
	if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
	  mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
	ci_send_message (SENDREPLY|SENDGROUPREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
	menu->redraw = REDRAW_FULL;
	break;

      case OP_EDIT_LABEL:

	CHECK_MSGCOUNT;


@@ 2230,17 2219,6 @@ int mutt_index_menu (void)
	}
	break;

      case OP_LIST_REPLY:

	CHECK_ATTACH;
	CHECK_MSGCOUNT;
        CHECK_VISIBLE;
	if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
	  mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
	ci_send_message (SENDREPLY|SENDLISTREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
	menu->redraw = REDRAW_FULL;
	break;

      case OP_MAIL:

	CHECK_ATTACH;


@@ 2413,15 2391,27 @@ int mutt_index_menu (void)
        break;

      case OP_REPLY:
      case OP_GROUP_REPLY:
      case OP_GROUP_CHAT_REPLY:
      case OP_LIST_REPLY:
      {
        int replyflags;

	CHECK_ATTACH;
	CHECK_MSGCOUNT;
        CHECK_VISIBLE;

        replyflags = SENDREPLY |
	  (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
	  (op == OP_GROUP_CHAT_REPLY ? SENDGROUPCHATREPLY : 0) |
	  (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);

	if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
	  mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
	ci_send_message (SENDREPLY, NULL, NULL, Context, tag ? NULL : CURHDR);
	ci_send_message (replyflags, NULL, NULL, Context, tag ? NULL : CURHDR);
	menu->redraw = REDRAW_FULL;
	break;
      }

      case OP_SHELL_ESCAPE:


M doc/manual.xml.head => doc/manual.xml.head +15 -2
@@ 1233,6 1233,7 @@ new message.
<row><entry>m</entry><entry><literal>&lt;compose&gt;</literal></entry><entry>compose a new message</entry></row>
<row><entry>r</entry><entry><literal>&lt;reply&gt;</literal></entry><entry>reply to sender</entry></row>
<row><entry>g</entry><entry><literal>&lt;group-reply&gt;</literal></entry><entry>reply to all recipients</entry></row>
<row><entry></entry><entry><literal>&lt;group-chat-reply&gt;</literal></entry><entry>reply to all recipients preserving To/Cc</entry></row>
<row><entry>L</entry><entry><literal>&lt;list-reply&gt;</literal></entry><entry>reply to mailing list address</entry></row>
<row><entry>f</entry><entry><literal>&lt;forward&gt;</literal></entry><entry>forward message</entry></row>
<row><entry>b</entry><entry><literal>&lt;bounce&gt;</literal></entry><entry>bounce (remail) message</entry></row>


@@ 1283,8 1284,20 @@ Reply to the author directly.
<term>Group reply</term>
<listitem>
<para>
Reply to the author as well to all recipients except you; this consults
<link linkend="alternates"><command>alternates</command></link>.
Reply to the author; cc all other recipients; consults
<link linkend="alternates"><command>alternates</command></link>
and excludes you.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Group Chat reply</term>
<listitem>
<para>
Reply to the author and other recipients in the To list;
cc other recipients in the Cc list; consults
<link linkend="alternates"><command>alternates</command></link>
and excludes you.
</para>
</listitem>
</varlistentry>

M functions.h => functions.h +3 -0
@@ 106,6 106,7 @@ const struct binding_t OpMain[] = { /* map: index */
  { "edit-type",		OP_EDIT_TYPE,			"\005" },
  { "forward-message",		OP_FORWARD_MESSAGE,		"f" },
  { "flag-message",		OP_FLAG_MESSAGE,		"F" },
  { "group-chat-reply",		OP_GROUP_CHAT_REPLY,		NULL },
  { "group-reply",		OP_GROUP_REPLY,			"g" },
#ifdef USE_POP
  { "fetch-mail",		OP_MAIN_FETCH_MAIL,		"G" },


@@ 209,6 210,7 @@ const struct binding_t OpPager[] = { /* map: pager */
  { "edit-type",	OP_EDIT_TYPE,			"\005" },
  { "forward-message",	OP_FORWARD_MESSAGE,		"f" },
  { "flag-message",	OP_FLAG_MESSAGE,		"F" },
  { "group-chat-reply",	OP_GROUP_CHAT_REPLY,		NULL },
  { "group-reply",	OP_GROUP_REPLY,			"g" },
#ifdef USE_IMAP
  { "imap-fetch-mail",  OP_MAIN_IMAP_FETCH,		NULL },


@@ 320,6 322,7 @@ const struct binding_t OpAttach[] = { /* map: attachment */
  { "view-mailcap",	OP_ATTACH_VIEW_MAILCAP,		"m" },
  { "reply",		OP_REPLY,			"r" },
  { "resend-message",	OP_RESEND,			"\033e" },
  { "group-chat-reply",	OP_GROUP_CHAT_REPLY,		NULL },
  { "group-reply",	OP_GROUP_REPLY,			"g" },
  { "list-reply",	OP_LIST_REPLY,			"L" },
  { "forward-message",	OP_FORWARD_MESSAGE,		"f" },

M mutt.h => mutt.h +2 -1
@@ 346,7 346,8 @@ enum
#define SENDPOSTPONEDFCC	(1<<9) /* used by mutt_get_postponed() to signal that the x-mutt-fcc header field was present */
#define SENDNOFREEHEADER	(1<<10)   /* Used by the -E flag */
#define SENDDRAFTFILE		(1<<11)   /* Used by the -H flag */
#define SENDTOSENDER    (1<<12)
#define SENDTOSENDER            (1<<12)
#define SENDGROUPCHATREPLY      (1<<13)

/* flags for mutt_compose_menu() */
#define MUTT_COMPOSE_NOFREEHEADER (1<<0)

M pager.c => pager.c +15 -24
@@ 2652,15 2652,28 @@ search_next:
	break;

      case OP_REPLY:
      case OP_GROUP_REPLY:
      case OP_GROUP_CHAT_REPLY:
      case OP_LIST_REPLY:
      {
        int replyflags;

	CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
        CHECK_ATTACH;

        replyflags = SENDREPLY |
	  (ch == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
	  (ch == OP_GROUP_CHAT_REPLY ? SENDGROUPCHATREPLY : 0) |
	  (ch == OP_LIST_REPLY ? SENDLISTREPLY : 0);

        if (IsMsgAttach (extra))
	  mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
			     extra->bdy, SENDREPLY);
			     extra->bdy, replyflags);
	else
	  ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr);
	  ci_send_message (replyflags, NULL, NULL, extra->ctx, extra->hdr);
	pager_menu->redraw = REDRAW_FULL;
	break;
      }

      case OP_RECALL_MESSAGE:
	CHECK_MODE(IsHeader (extra) && !IsAttach(extra));


@@ 2669,28 2682,6 @@ search_next:
	pager_menu->redraw = REDRAW_FULL;
	break;

      case OP_GROUP_REPLY:
	CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
        CHECK_ATTACH;
        if (IsMsgAttach (extra))
	  mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
			     extra->bdy, SENDREPLY|SENDGROUPREPLY);
        else
	  ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr);
	pager_menu->redraw = REDRAW_FULL;
	break;

      case OP_LIST_REPLY:
	CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
        CHECK_ATTACH;
        if (IsMsgAttach (extra))
	  mutt_attach_reply (extra->fp, extra->hdr, extra->actx,
			     extra->bdy, SENDREPLY|SENDLISTREPLY);
        else
	  ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr);
	pager_menu->redraw = REDRAW_FULL;
	break;

      case OP_FORWARD_MESSAGE:
	CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
        CHECK_ATTACH;

M recvattach.c => recvattach.c +2 -0
@@ 1333,12 1333,14 @@ void mutt_view_attachments (HEADER *hdr)

      case OP_REPLY:
      case OP_GROUP_REPLY:
      case OP_GROUP_CHAT_REPLY:
      case OP_LIST_REPLY:

        CHECK_ATTACH;

        flags = SENDREPLY |
	  (op == OP_GROUP_REPLY ? SENDGROUPREPLY : 0) |
	  (op == OP_GROUP_CHAT_REPLY ? SENDGROUPCHATREPLY : 0) |
	  (op == OP_LIST_REPLY ? SENDLISTREPLY : 0);
        mutt_attach_reply (CURATTACH->fp, hdr, actx,
			   menu->tagprefix ? NULL : CURATTACH->content, flags);

M send.c => send.c +10 -4
@@ 530,7 530,8 @@ int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags)
  ADDRESS *tmp;
  int hmfupto = -1;

  if ((flags & (SENDLISTREPLY|SENDGROUPREPLY)) && in->mail_followup_to)
  if ((flags & (SENDLISTREPLY|SENDGROUPREPLY|SENDGROUPCHATREPLY)) &&
      in->mail_followup_to)
  {
    snprintf (prompt, sizeof (prompt), _("Follow-up to %s%s?"),
	      in->mail_followup_to->mailbox,


@@ 554,13 555,18 @@ int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags)
    rfc822_append (&out->to, in->from, 0);
  else
  {
    if (default_to (&out->to, in, flags & SENDGROUPREPLY, hmfupto) == -1)
    if (default_to (&out->to, in, flags & (SENDGROUPREPLY|SENDGROUPCHATREPLY),
                    hmfupto) == -1)
      return (-1); /* abort */

    if ((flags & SENDGROUPREPLY) && (!in->mail_followup_to || hmfupto != MUTT_YES))
    if ((flags & (SENDGROUPREPLY|SENDGROUPCHATREPLY)) &&
        (!in->mail_followup_to || hmfupto != MUTT_YES))
    {
      /* if (!mutt_addr_is_user(in->to)) */
      rfc822_append (&out->cc, in->to, 1);
      if (flags & SENDGROUPREPLY)
        rfc822_append (&out->cc, in->to, 1);
      else
        rfc822_append (&out->to, in->to, 1);
      rfc822_append (&out->cc, in->cc, 1);
    }
  }