Re: Replying to multiple mails
On Thu, 2008-10-09 at 17:22:02 +0200, Anders Helmersson wrote:
> On Thu, 2008-10-09 at 10:46:03 +0200, Rocco Rutte wrote:
> > Hmm, I think since mutt supports extracting several message-ids out of
> > In-Reply-To, it should also support writing them. So yes, this should
> > be fixed.
I have attached a new patch set according to Rocco's suggestions.
Regards Anders
--
Anders Helmersson phone: +46-13-157 888
Spångerumsgatan 33 mobile: +46-739 874 328
SE-587 25 Linköping email: anders.helmersson.utsikt@xxxxxxxxxxxx
Sweden PGP/GPG key: 1024D/2AD939A8
# HG changeset patch
# User Anders Helmersson <anders.helmersson.utsikt@xxxxxxxxxxxx>
# Date 1223626807 -7200
# Branch multiple-replies-2
# Node ID 2315a6258f4df98763027c8e7cae75cb130df2cc
# Parent 10a1f06bc8aa0233841682fad1a967fe2d0141b6
Replace trim with a flag for trimming and removing duplicates in
mutt_write_references
diff -r 10a1f06bc8aa -r 2315a6258f4d sendlib.c
--- a/sendlib.c Tue Oct 07 19:22:53 2008 -0700
+++ b/sendlib.c Fri Oct 10 10:20:07 2008 +0200
@@ -1520,19 +1520,36 @@
/* arbitrary number of elements to grow the array by */
#define REF_INC 16
+#define REF_TRIM_COUNT 10
+#define F_TRIM_REF (1<<0)
+#define F_TRIM_DUP (1<<1)
+
/* need to write the list in reverse because they are stored in reverse order
* when parsed to speed up threading
*/
-void mutt_write_references (LIST *r, FILE *f, int trim)
+void mutt_write_references (LIST *r, FILE *f, int flags)
{
+ int trim = (flags & F_TRIM_REF) ? REF_TRIM_COUNT : 0;
LIST **ref = NULL;
int refcnt = 0, refmax = 0;
+ int i;
for ( ; (trim == 0 || refcnt < trim) && r ; r = r->next)
{
if (refcnt == refmax)
safe_realloc (&ref, (refmax += REF_INC) * sizeof (LIST *));
- ref[refcnt++] = r;
+ if (flags & F_TRIM_DUP)
+ {
+ /* remove dupes */
+ /* check if ref is already in th list, then discard it */
+ for (i = 0; i < refcnt; i++)
+ {
+ if (mutt_strcmp (r->data, ref[i]->data) == 0) break;
+ }
+ if (i == refcnt) ref[refcnt++] = r;
+ }
+ else
+ ref[refcnt++] = r;
}
while (refcnt-- > 0)
@@ -1823,7 +1840,7 @@
if (env->references)
{
fputs ("References:", fp);
- mutt_write_references (env->references, fp, 10);
+ mutt_write_references (env->references, fp, F_TRIM_REF);
fputc('\n', fp);
}
@@ -1835,7 +1852,7 @@
if (env->in_reply_to)
{
fputs ("In-Reply-To:", fp);
- mutt_write_references (env->in_reply_to, fp, 1);
+ mutt_write_references (env->in_reply_to, fp, F_TRIM_REF);
fputc ('\n', fp);
}
# HG changeset patch
# User Anders Helmersson <anders.helmersson.utsikt@xxxxxxxxxxxx>
# Date 1223627226 -7200
# Branch multiple-replies-2
# Node ID bf4e0f5e8145df7ded6e8b6e61f785239dd390fe
# Parent 2315a6258f4df98763027c8e7cae75cb130df2cc
remove duplicates in In-Reply-To and References when replying
diff -r 2315a6258f4d -r bf4e0f5e8145 sendlib.c
--- a/sendlib.c Fri Oct 10 10:20:07 2008 +0200
+++ b/sendlib.c Fri Oct 10 10:27:06 2008 +0200
@@ -1840,7 +1840,7 @@
if (env->references)
{
fputs ("References:", fp);
- mutt_write_references (env->references, fp, F_TRIM_REF);
+ mutt_write_references (env->references, fp, F_TRIM_REF|F_TRIM_DUP);
fputc('\n', fp);
}
@@ -1852,7 +1852,7 @@
if (env->in_reply_to)
{
fputs ("In-Reply-To:", fp);
- mutt_write_references (env->in_reply_to, fp, F_TRIM_REF);
+ mutt_write_references (env->in_reply_to, fp, F_TRIM_REF|F_TRIM_DUP);
fputc ('\n', fp);
}
# HG changeset patch
# User Anders Helmersson <anders.helmersson.utsikt@xxxxxxxxxxxx>
# Date 1223627844 -7200
# Branch multiple-replies-2
# Node ID 1efcb45c3df60a7782d51cb7b0f069124353b519
# Parent bf4e0f5e8145df7ded6e8b6e61f785239dd390fe
move writing of newline into mutt_write_references
diff -r bf4e0f5e8145 -r 1efcb45c3df6 copy.c
--- a/copy.c Fri Oct 10 10:27:06 2008 +0200
+++ b/copy.c Fri Oct 10 10:37:24 2008 +0200
@@ -378,7 +378,6 @@
{
fputs ("References:", out);
mutt_write_references (h->env->references, out, 0);
- fputc ('\n', out);
}
if ((flags & CH_UPDATE) && (flags & CH_NOSTATUS) == 0)
diff -r bf4e0f5e8145 -r 1efcb45c3df6 sendlib.c
--- a/sendlib.c Fri Oct 10 10:27:06 2008 +0200
+++ b/sendlib.c Fri Oct 10 10:37:24 2008 +0200
@@ -1557,6 +1557,7 @@
fputc (' ', f);
fputs (ref[refcnt]->data, f);
}
+ fputc ('\n', f);
FREE (&ref);
}
@@ -1841,7 +1842,6 @@
{
fputs ("References:", fp);
mutt_write_references (env->references, fp, F_TRIM_REF|F_TRIM_DUP);
- fputc('\n', fp);
}
/* Add the MIME headers */
@@ -1853,7 +1853,6 @@
{
fputs ("In-Reply-To:", fp);
mutt_write_references (env->in_reply_to, fp, F_TRIM_REF|F_TRIM_DUP);
- fputc ('\n', fp);
}
/* Add any user defined headers */
# HG changeset patch
# User Anders Helmersson <anders.helmersson.utsikt@xxxxxxxxxxxx>
# Date 1223458596 -7200
# Branch multiple-replies-2
# Node ID 34a0d27a8efcb6d1fa1e5db14ddc0c10bbfb2f5b
# Parent 1efcb45c3df60a7782d51cb7b0f069124353b519
use mutt_write_references when copying In-reply-to list
diff -r 1efcb45c3df6 -r 34a0d27a8efc copy.c
--- a/copy.c Fri Oct 10 10:37:24 2008 +0200
+++ b/copy.c Wed Oct 08 11:36:36 2008 +0200
@@ -364,13 +364,8 @@
if ((flags & CH_UPDATE_IRT) && h->env->in_reply_to)
{
- LIST *listp = h->env->in_reply_to;
fputs ("In-Reply-To:", out);
- for (; listp; listp = listp->next)
- {
- fputc (' ', out);
- fputs (listp->data, out);
- }
+ mutt_write_references (h->env->in_reply_to, out, 0);
fputc ('\n', out);
}