Re: list-new
(I think this belongs in mutt-dev, but the question appeared on
mutt-users, hence the cross-posting; please continue the discussion in
mutt-dev).
On Sat, Nov 15 2003 at 01:57:01AM BRST, John Iverson <johni@xxxxxxxxx> wrote:
> On Fri 14 Nov 2003 at 06:51am +0000, corey@xxxxxxxxxxxxxx wrote:
>
> > Warning: potentialy brain dead question(s) following.
> >
> > Is there a "list-new" command? Similar to "list-reply"... only
> > instead of replying to a message, it uh, well, prepares a _new_
> > message to the specified list?
>
> If you mean you want to go to an existing list message and start a new
> thread to the list from it, there's not such a built-in command.
> However, as section 2.4.1 of the manual states,
>
> When replying to messages, if you remove the In-Reply-To: field from
> the header field, Mutt will not generate a References: field, which
> allows you to create a new message thread.
>
> So just remove the In-Reply-To: field in your editor.
That's not really a clean way to do it, is it?
I've wanted this kind of functionality for some time, now, I've even
done some folder-hooks to rebind the "mail" key to a macro, but it's a pain
having to do this for each list folder.
So I've just put together a patch (attached) that creates a new
function, "list-mail". It's (supposed to be) a merger of "mail" and
"list-reply": if called on a message recognized as a list message, it starts
a new mail to that list. I then put a folder-hook to rebind my "mail" key to
"list-mail" if I'm in a list folder, something like
folder-hook . bind index c mail
folder-hook '/lists/' bind index c list-mail
And so on. Yes, I use "c" for "mail". Hey, I came straight from
years of Pine, old habits are hard to let go!
Please note that I have barely tested this patch (I know it applies
to Debian mutt 1.5.4, and seems to work at first, but not much beyond that),
so any comments/suggestions/criticism are very much appreciated.
It's also my first attempt at actually writing anything for mutt, so
please let me know if I'm doing things "The Right Way"(TM) and if there are
any changes I need to make to improve the patch (perhaps even get it
incorporated into mainstream). I can try and make a patch for 1.5.x, if
it proves helpful.
(I just noticed it skips checking for postponed messages, I'll deal
with that later, just think of it as a known bug for now :)
Thanks.
rbp
--
Rodrigo Bernardo Pimentel <rbp@xxxxxxxxxxxx>
http://isnomore.net GPG KeyId: <0x0DB14978>
It's not a REAL sport unless you can die from massive internal trauma.
diff -Naur mutt-1.5.4.orig/OPS mutt-1.5.4/OPS
--- mutt-1.5.4.orig/OPS 2002-12-17 07:50:26.000000000 -0200
+++ mutt-1.5.4/OPS 2003-11-16 17:15:30.000000000 -0200
@@ -93,6 +93,7 @@
OP_JUMP "jump to an index number"
OP_LAST_ENTRY "move to the last entry"
OP_LIST_REPLY "reply to specified mailing list"
+OP_LIST_MAIL "compose a new mail message to specified mailing list"
OP_MACRO "execute a macro"
OP_MAIL "compose a new mail message"
OP_MAIN_CHANGE_FOLDER "open a different folder"
diff -Naur mutt-1.5.4.orig/curs_main.c mutt-1.5.4/curs_main.c
--- mutt-1.5.4.orig/curs_main.c 2003-01-23 20:04:28.000000000 -0200
+++ mutt-1.5.4/curs_main.c 2003-11-16 17:12:40.000000000 -0200
@@ -1801,6 +1801,15 @@
menu->redraw = REDRAW_FULL;
break;
+ case OP_LIST_MAIL:
+
+ CHECK_ATTACH;
+ CHECK_MSGCOUNT;
+ CHECK_VISIBLE;
+ ci_send_message (SENDLISTMAIL, NULL, NULL, Context, tag ? NULL :
CURHDR);
+ menu->redraw = REDRAW_FULL;
+ break;
+
case OP_MAIL:
CHECK_ATTACH;
diff -Naur mutt-1.5.4.orig/functions.h mutt-1.5.4/functions.h
--- mutt-1.5.4.orig/functions.h 2003-01-06 08:25:34.000000000 -0200
+++ mutt-1.5.4/functions.h 2003-11-16 17:14:04.000000000 -0200
@@ -94,6 +94,7 @@
{ "previous-undeleted", OP_MAIN_PREV_UNDELETED, "k" },
{ "limit", OP_MAIN_LIMIT, "l" },
{ "list-reply", OP_LIST_REPLY, "L" },
+ { "list-mail", OP_LIST_MAIL, NULL },
{ "mail", OP_MAIL, "m" },
{ "toggle-new", OP_TOGGLE_NEW, "N" },
{ "toggle-write", OP_TOGGLE_WRITE, "%" },
@@ -174,6 +175,7 @@
{ "previous-undeleted",OP_MAIN_PREV_UNDELETED, "k" },
{ "previous-entry", OP_PREV_ENTRY, "K" },
{ "list-reply", OP_LIST_REPLY, "L" },
+ { "list-mail", OP_LIST_MAIL, NULL },
{ "redraw-screen", OP_REDRAW, "\014" },
{ "mail", OP_MAIL, "m" },
{ "mark-as-new", OP_TOGGLE_NEW, "N" },
@@ -256,6 +258,7 @@
{ "resend-message", OP_RESEND, "\033e" },
{ "group-reply", OP_GROUP_REPLY, "g" },
{ "list-reply", OP_LIST_REPLY, "L" },
+ { "list-mail", OP_LIST_MAIL, NULL },
{ "forward-message", OP_FORWARD_MESSAGE, "f" },
{ "view-text", OP_ATTACH_VIEW_TEXT, "T" },
{ "view-attach", OP_VIEW_ATTACH, M_ENTER_S },
diff -Naur mutt-1.5.4.orig/mutt.h mutt-1.5.4/mutt.h
--- mutt-1.5.4.orig/mutt.h 2003-03-04 04:49:48.000000000 -0300
+++ mutt-1.5.4/mutt.h 2003-11-16 16:45:26.000000000 -0200
@@ -302,6 +302,7 @@
#define SENDMAILX (1<<6)
#define SENDKEY (1<<7)
#define SENDRESEND (1<<8)
+#define SENDLISTMAIL (1<<9)
/* flags to _mutt_select_file() */
#define M_SEL_BUFFY (1<<0)
diff -Naur mutt-1.5.4.orig/pager.c mutt-1.5.4/pager.c
--- mutt-1.5.4.orig/pager.c 2003-01-23 20:04:28.000000000 -0200
+++ mutt-1.5.4/pager.c 2003-11-16 17:18:37.000000000 -0200
@@ -2417,6 +2417,13 @@
redraw = REDRAW_FULL;
break;
+ case OP_LIST_MAIL:
+ CHECK_MODE(IsHeader (extra) && !IsAttach (extra));
+ CHECK_ATTACH;
+ ci_send_message (SENDLISTMAIL, NULL, NULL, extra->ctx, extra->hdr);
+ redraw = REDRAW_FULL;
+ break;
+
case OP_FORWARD_MESSAGE:
CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
CHECK_ATTACH;
diff -Naur mutt-1.5.4.orig/send.c mutt-1.5.4/send.c
--- mutt-1.5.4.orig/send.c 2003-03-06 18:21:32.000000000 -0300
+++ mutt-1.5.4/send.c 2003-11-16 17:04:44.000000000 -0200
@@ -456,7 +456,7 @@
/* Exit now if we're setting up the default Cc list for list-reply
* (only set if Mail-Followup-To is present and honoured).
*/
- if (flags & SENDLISTREPLY)
+ if (flags & (SENDLISTREPLY | SENDLISTMAIL))
return 0;
if (!option(OPTREPLYSELF) && mutt_addr_is_user (env->from))
@@ -520,14 +520,14 @@
int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags)
{
ADDRESS *tmp;
- if (flags & SENDLISTREPLY)
+ if (flags & (SENDLISTREPLY | SENDLISTMAIL))
{
tmp = find_mailing_lists (in->to, in->cc);
rfc822_append (&out->to, tmp);
rfc822_free_address (&tmp);
if (in->mail_followup_to &&
- default_to (&out->cc, in, flags & SENDLISTREPLY) == -1)
+ default_to (&out->cc, in, flags & (SENDLISTREPLY | SENDLISTMAIL)) ==
-1)
return (-1); /* abort */
}
else
@@ -684,7 +684,7 @@
else
curenv = cur->env;
- if (flags & SENDREPLY)
+ if (flags & (SENDREPLY | SENDLISTMAIL))
{
if (tag)
{
@@ -706,8 +706,11 @@
return (-1);
}
- mutt_make_misc_reply_headers (env, ctx, cur, curenv);
- mutt_make_reference_headers (tag ? NULL : curenv, env, ctx);
+ if (! (flags & SENDLISTMAIL))
+ {
+ mutt_make_misc_reply_headers (env, ctx, cur, curenv);
+ mutt_make_reference_headers (tag ? NULL : curenv, env, ctx);
+ }
}
else if (flags & SENDFORWARD)
mutt_make_forward_subject (env, ctx, cur);
@@ -1160,7 +1163,7 @@
}
else if (! (flags & (SENDPOSTPONED|SENDRESEND)))
{
- if ((flags & (SENDREPLY | SENDFORWARD)) && ctx &&
+ if ((flags & (SENDREPLY | SENDFORWARD | SENDLISTMAIL)) && ctx &&
envelope_defaults (msg->env, ctx, cur, flags) == -1)
goto cleanup;
@@ -1172,7 +1175,7 @@
if (! (flags & SENDMAILX) &&
! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
- ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
+ ! ((flags & (SENDREPLY | SENDLISTMAIL)) && option (OPTFASTREPLY)))
{
if (edit_envelope (msg->env) == -1)
goto cleanup;