<<< Date Index >>>     <<< Thread Index >>>

Re: list-new



On Sat, Nov 15 2003 at 11:53:04PM BRST, corey@xxxxxxxxxxxxxx wrote:
> On Sun, Nov 16, 2003 at 06:03:31PM -0200, Rodrigo Bernardo Pimentel wrote:

> >         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. 
> >
> <snippity-snip>
> > (perhaps even get it > incorporated into mainstream). 
> <snip>
> 
> 
>   I would simply like to give a patch along these lines being included into
>   mutt a very strong +1.

        Thanks :)

        Please try it out and tell me how it works for you!

        BTW, I made a small change from the last version, I'm attaching the
latest one.

>   I'm very surprised that mutt doesn't already include such a feature - in
>   fact it can hardly be called a feature... if there's a 'list-reply' cmd,
>   it only makes sense that there be a 'list-mail'/'list-new' cmd as well.

        Yeah, and in fact (as can be seen from the patch) I barely had to
code at all, all the pieces were there, they just had to be connected
(though I'd still like to hear from more experienced mutt developers whether
I did it the right way).

>   Editing headers and/or creating custom hooks in order to provide such a 
>   common action seems kinda lame...

        True. I had to do that a couple of time, it got to the point when
writing a patch was easier :)

>   ( I'm not subscribed to mutt-dev, but I just had to respond in favor to
>     this patch )

        Thanks again :)



                rbp
-- 
 Rodrigo Bernardo Pimentel                         <rbp@xxxxxxxxxxxx>
 http://isnomore.net                          GPG KeyId: <0x0DB14978>

Nobody expects the spanish inquisition!
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 19:03:36.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 19:03:36.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 19:03:36.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" },
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 19:03:36.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 19:03:36.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 19:03:49.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);
@@ -1049,8 +1052,8 @@
 
   int rv = -1;
   
-  if (!flags && !msg && quadoption (OPT_RECALL) != M_NO &&
-      mutt_num_postponed (1))
+  if ((!flags || (flags == SENDLISTMAIL)) && !msg &&
+      quadoption (OPT_RECALL) != M_NO && mutt_num_postponed (1))
   {
     /* If the user is composing a new message, check to see if there
      * are any postponed messages first.
@@ -1059,7 +1062,7 @@
       return rv;
 
     if(i == M_YES)
-      flags |= SENDPOSTPONED;
+      flags = SENDPOSTPONED;
   }
   
   
@@ -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;