[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mutt-dev
Subject:    [patch] new "list-mail" function
From:       Rodrigo Bernardo Pimentel <rbp () isnomore ! net>
Date:       2003-11-20 3:05:00
[Download RAW message or body]

Hi!

        First of all, thanks to all developers for mutt. The more I use it,
the more I find new functionality in it :)

        I've somewhat recently started using the "lists" command and have
found it very useful. However, I couldn't find an easy (or clean) way to
compose a message to a list, but not in reply to any existing message (that
is, a "fresh" new message). Before I started using "lists", I had set
folder-hooks to a few of my most frequently posted to lists changing the
bindings of my "<mail>" key to a macro that called <mail> and filled in the
e-mail address for that particular list. However, that is clearly a very
ugly hack, specially after having used "lists" and "list-reply".

         So I put together a patch (attached) that creates a new function,
"list-mail" (in OpMain and OpPager binding_t structs, where it seemd to make
sense). 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 (not a
reply) to that list.

        I haven't bound it to any key, in my patch, but, if it's accepted, a
sensible default could be chosen. Additionally, it could be useful to rebind
the default mail key to "list-mail", when on lists folders:

folder-hook . bind index m mail
folder-hook '/lists/' bind index m list-mail

        I have already heard favourably from some people on mutt-users about
this patch (or at least the functionality it promises), so I think this
could prove to be really useful. I'd really like to hear
comments/suggestions/criticism on it.

        Thanks again,



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

Either this man is dead or my watch has stopped.
          -- Groucho Marx

["patch-1.5.4.rbp.list_mail.4" (text/plain)]

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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic