Hello, I've updated Stefan Zehl's reverse_reply patch. Comments welcome. Christoph PS: apparently the mutt lists were down from Mar 22 until yesterday; I don't know whether postings got lost and have to be resent. -- cb@xxxxxxxx | http://www.df7cb.de/
patch-1.5.6.cb.reverse_reply.2
===============================
This is the reverse_reply patch for mutt. It acts on the To: and Cc: headers of
reply mails like $reverse_alias does in the index. The patch was originally
written by Stefan Zehl for 1.3.25 [1]. I've introduced a new variable
$reverse_reply to separate the functionality from $reverse_alias and cleaned up
the code a bit.
[1] patch-1.3.25.sec.reverse_reply.1
The patch homepage is at
[2] http://www.df7cb.de/projects/mutt/
Changelog:
reverse_reply.2 (2004-03-26; cb):
* New option $reverse_reply.
* Code cleanup.
Wishlist:
* reverse_reply is applied before send- and reply-hooks, it would be nice
if "reply-hook ~l 'set reverse_reply'" worked. Applying it twice and/or
only later would break other things, though.
Christoph Berg <cb@xxxxxxxx>
diff -ur ../MUTT/mutt/PATCHES mutt/PATCHES
--- ../MUTT/mutt/PATCHES 2002-12-09 18:44:54.000000000 +0100
+++ mutt/PATCHES 2004-03-26 13:07:42.000000000 +0100
@@ -0,0 +1 @@
+patch-1.5.6.cb.reverse_reply.2
diff -ur ../MUTT/mutt/init.h mutt/init.h
--- ../MUTT/mutt/init.h 2004-02-13 16:08:31.000000000 +0100
+++ mutt/init.h 2004-03-26 13:19:20.000000000 +0100
@@ -2120,6 +2120,13 @@
** possibly including eventual real names. When it is unset, mutt will
** override any such real names with the setting of the $realname variable.
*/
+ { "reverse_reply", DT_BOOL, R_NONE, OPTREVREPLY, 0 },
+ /*
+ ** .pp
+ ** When set, this variable uses the name from your aliases in the To and Cc
+ ** headers of reply mails you send, like $reverse_alias does in the index.
+ ** When unset, the headers taken from the original mail are left unchanged.
+ */
{ "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0 },
/*
** .pp
diff -ur ../MUTT/mutt/mutt.h mutt/mutt.h
--- ../MUTT/mutt/mutt.h 2004-02-13 16:08:32.000000000 +0100
+++ mutt/mutt.h 2004-03-26 13:42:06.000000000 +0100
@@ -397,6 +397,7 @@
OPTREVALIAS,
OPTREVNAME,
OPTREVREAL,
+ OPTREVREPLY,
OPTRFC2047PARAMS,
OPTSAVEADDRESS,
OPTSAVEEMPTY,
diff -ur ../MUTT/mutt/protos.h mutt/protos.h
--- ../MUTT/mutt/protos.h 2004-02-13 16:08:32.000000000 +0100
+++ mutt/protos.h 2004-03-26 13:07:26.000000000 +0100
@@ -77,6 +77,7 @@
ADDRESS *mutt_get_address (ENVELOPE *, char **);
ADDRESS *mutt_lookup_alias (const char *s);
ADDRESS *mutt_remove_duplicates (ADDRESS *);
+ADDRESS *mutt_reverse_address (ADDRESS *);
ADDRESS *mutt_expand_aliases (ADDRESS *);
ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *);
diff -ur ../MUTT/mutt/send.c mutt/send.c
--- ../MUTT/mutt/send.c 2004-01-05 19:49:00.000000000 +0100
+++ mutt/send.c 2004-03-26 13:19:20.000000000 +0100
@@ -583,6 +583,10 @@
/* the CC field can get cluttered, especially with lists */
env->to = mutt_remove_duplicates (env->to);
env->cc = mutt_remove_duplicates (env->cc);
+ if (option (OPTREVREPLY)){
+ env->to = mutt_reverse_address (env->to);
+ env->cc = mutt_reverse_address (env->cc);
+ }
env->cc = mutt_remove_xrefs (env->to, env->cc);
}
diff -ur ../MUTT/mutt/sendlib.c mutt/sendlib.c
--- ../MUTT/mutt/sendlib.c 2003-09-19 15:03:26.000000000 +0200
+++ mutt/sendlib.c 2004-03-26 13:38:55.000000000 +0100
@@ -2330,6 +2330,35 @@
}
}
+/* given a list of addresses, return a list of reverse_alias'ed addresses */
+ADDRESS *mutt_reverse_address (ADDRESS *addr)
+{
+ ADDRESS *top,*tmp,*alias;
+
+ if (addr == NULL)
+ return NULL;
+
+ if ((alias = alias_reverse_lookup (addr)) && alias->personal) {
+ tmp = rfc822_cpy_adr_real(alias);
+ tmp->next = addr->next;
+ addr->next = NULL;
+ rfc822_free_address(&addr);
+ addr = tmp;
+ }
+
+ for (top = addr; top->next != NULL; top = tmp) {
+ tmp = top->next;
+ if ((alias = alias_reverse_lookup (tmp)) && alias->personal) {
+ top->next = rfc822_cpy_adr_real(alias);
+ top->next->next = tmp->next;
+ tmp->next = NULL;
+ rfc822_free_address(&tmp);
+ tmp = top->next;
+ }
+ }
+ return addr;
+}
+
int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int
post, char *fcc)
{
CONTEXT f;
Attachment:
signature.asc
Description: Digital signature