changeset: 7095:c45291f87137
user:      Kevin McCarthy <[email protected]>
date:      Sat Jul 01 19:32:05 2017 -0700
link:      http://dev.mutt.org/hg/mutt/rev/c45291f87137

Add config vars for forwarded message attribution intro/trailer.

Add $forward_attribution_intro and $forward_attribution_trailer to
allow the default strings to be overridden.

diffs (163 lines):

diff -r 88602d33a49a -r c45291f87137 globals.h
--- a/globals.h Mon Jun 26 15:54:30 2017 -0700
+++ b/globals.h Sat Jul 01 19:32:05 2017 -0700
@@ -51,6 +51,8 @@
 WHERE char *Editor;
 WHERE char *EscChar;
 WHERE char *FolderFormat;
+WHERE char *ForwardAttrIntro;
+WHERE char *ForwardAttrTrailer;
 WHERE char *ForwFmt;
 WHERE char *Fqdn;
 WHERE char *HdrFmt;
diff -r 88602d33a49a -r c45291f87137 init.h
--- a/init.h    Mon Jun 26 15:54:30 2017 -0700
+++ b/init.h    Sat Jul 01 19:32:05 2017 -0700
@@ -888,6 +888,22 @@
   ** .pp
   ** Also see the $$record variable.
   */
+  { "forward_attribution_intro", DT_STR, R_NONE, UL &ForwardAttrIntro, UL 
"----- Forwarded message from %f -----" },
+  /*
+  ** .pp
+  ** This is the string that will precede a message which has been forwarded
+  ** in the main body of a message (when $$mime_forward is unset).
+  ** For a full listing of defined \fCprintf(3)\fP-like sequences see
+  ** the section on $$index_format.  See also $$attribution_locale.
+  */
+  { "forward_attribution_trailer", DT_STR, R_NONE, UL &ForwardAttrTrailer, UL 
"----- End forwarded message -----" },
+  /*
+  ** .pp
+  ** This is the string that will follow a message which has been forwarded
+  ** in the main body of a message (when $$mime_forward is unset).
+  ** For a full listing of defined \fCprintf(3)\fP-like sequences see
+  ** the section on $$index_format.  See also $$attribution_locale.
+  */
   { "forward_decode",  DT_BOOL, R_NONE, OPTFORWDECODE, 1 },
   /*
   ** .pp
diff -r 88602d33a49a -r c45291f87137 protos.h
--- a/protos.h  Mon Jun 26 15:54:30 2017 -0700
+++ b/protos.h  Sat Jul 01 19:32:05 2017 -0700
@@ -207,8 +207,8 @@
 void mutt_format_string (char *, size_t, int, int, int, char, const char *, 
size_t, int);
 void mutt_format_s (char *, size_t, const char *, const char *);
 void mutt_format_s_tree (char *, size_t, const char *, const char *);
-void mutt_forward_intro (FILE *fp, HEADER *cur);
-void mutt_forward_trailer (FILE *fp);
+void mutt_forward_intro (CONTEXT *ctx, HEADER *cur, FILE *fp);
+void mutt_forward_trailer (CONTEXT *ctx, HEADER *cur, FILE *fp);
 void mutt_free_alias (ALIAS **);
 void mutt_free_body (BODY **);
 void mutt_free_color (int fg, int bg);
diff -r 88602d33a49a -r c45291f87137 recvcmd.c
--- a/recvcmd.c Mon Jun 26 15:54:30 2017 -0700
+++ b/recvcmd.c Sat Jul 01 19:32:05 2017 -0700
@@ -442,7 +442,7 @@
     return;
   }
 
-  mutt_forward_intro (tmpfp, parent);
+  mutt_forward_intro (Context, parent, tmpfp);
 
   /* prepare the prefix here since we'll need it later. */
 
@@ -541,7 +541,7 @@
       goto bail;
   }
   
-  mutt_forward_trailer (tmpfp);
+  mutt_forward_trailer (Context, parent, tmpfp);
   
   safe_fclose (&tmpfp);
   tmpfp = NULL;
@@ -641,9 +641,9 @@
     if (cur)
     {
       /* mutt_message_hook (cur->hdr, MUTT_MESSAGEHOOK); */ 
-      mutt_forward_intro (tmpfp, cur->hdr);
+      mutt_forward_intro (Context, cur->hdr, tmpfp);
       _mutt_copy_message (tmpfp, fp, cur->hdr, cur->hdr->content, cmflags, 
chflags);
-      mutt_forward_trailer (tmpfp);
+      mutt_forward_trailer (Context, cur->hdr, tmpfp);
     }
     else
     {
@@ -652,10 +652,10 @@
        if (idx[i]->content->tagged)
        {
          /* mutt_message_hook (idx[i]->content->hdr, MUTT_MESSAGEHOOK); */ 
-         mutt_forward_intro (tmpfp, idx[i]->content->hdr);
+         mutt_forward_intro (Context, idx[i]->content->hdr, tmpfp);
          _mutt_copy_message (tmpfp, fp, idx[i]->content->hdr,
                              idx[i]->content->hdr->content, cmflags, chflags);
-         mutt_forward_trailer (tmpfp);
+         mutt_forward_trailer (Context, idx[i]->content->hdr, tmpfp);
        }
       }
     }
diff -r 88602d33a49a -r c45291f87137 send.c
--- a/send.c    Mon Jun 26 15:54:30 2017 -0700
+++ b/send.c    Sat Jul 01 19:32:05 2017 -0700
@@ -324,20 +324,33 @@
   }
 }
 
-void mutt_forward_intro (FILE *fp, HEADER *cur)
+void mutt_forward_intro (CONTEXT *ctx, HEADER *cur, FILE *fp)
 {
-  char buffer[STRING];
-  
-  fputs ("----- Forwarded message from ", fp);
-  buffer[0] = 0;
-  rfc822_write_address (buffer, sizeof (buffer), cur->env->from, 1);
-  fputs (buffer, fp);
-  fputs (" -----\n\n", fp);
+  char buffer[LONG_STRING];
+
+  if (ForwardAttrIntro)
+  {
+    setlocale (LC_TIME, NONULL (AttributionLocale));
+    mutt_make_string (buffer, sizeof (buffer), ForwardAttrIntro, ctx, cur);
+    setlocale (LC_TIME, "");
+    fputs (buffer, fp);
+    fputs ("\n\n", fp);
+  }
 }
 
-void mutt_forward_trailer (FILE *fp)
+void mutt_forward_trailer (CONTEXT *ctx, HEADER *cur, FILE *fp)
 {
-  fputs ("\n----- End forwarded message -----\n", fp);
+  char buffer[LONG_STRING];
+
+  if (ForwardAttrTrailer)
+  {
+    setlocale (LC_TIME, NONULL (AttributionLocale));
+    mutt_make_string (buffer, sizeof (buffer), ForwardAttrTrailer, ctx, cur);
+    setlocale (LC_TIME, "");
+    fputc ('\n', fp);
+    fputs (buffer, fp);
+    fputc ('\n', fp);
+  }
 }
 
 
@@ -354,7 +367,7 @@
     crypt_valid_passphrase (cur->security);
   }
 
-  mutt_forward_intro (out, cur);
+  mutt_forward_intro (ctx, cur, out);
 
   if (option (OPTFORWDECODE))
   {
@@ -373,7 +386,7 @@
   chflags |= CH_DISPLAY;
 
   mutt_copy_message (out, ctx, cur, cmflags, chflags);
-  mutt_forward_trailer (out);
+  mutt_forward_trailer (ctx, cur, out);
   return 0;
 }
 

Reply via email to