]> granicus.if.org Git - mutt/commitdiff
Add the $print_decode option.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 16 Mar 2000 10:01:43 +0000 (10:01 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 16 Mar 2000 10:01:43 +0000 (10:01 +0000)
commands.c
init.h
mutt.h

index 8c50625920a9e7b23402c6b94623d184cc4608b4..1927690b6f23bb3c8b4f11692373e722366aed46 100644 (file)
@@ -232,22 +232,27 @@ void ci_bounce_message (HEADER *h, int *redraw)
   mutt_message (h ? _("Message bounced.") : _("Messages bounced."));
 }
 
-void mutt_pipe_message_to_state (HEADER *h, STATE *s)
+static void pipe_print_set_flags (int decode, int *cmflags, int *chflags)
 {
-  int cmflags = 0;
-  int chflags = CH_FROM;
-  
-  if (option (OPTPIPEDECODE))
+  if (decode)
   {
-    cmflags |= M_CM_DECODE | M_CM_CHARCONV;
-    chflags |= CH_DECODE | CH_REORDER;
+    *cmflags |= M_CM_DECODE | M_CM_CHARCONV;
+    *chflags |= CH_DECODE | CH_REORDER;
     
     if (option (OPTWEED))
     {
-      chflags |= CH_WEED;
-      cmflags |= M_CM_WEED;
+      *chflags |= CH_WEED;
+      *cmflags |= M_CM_WEED;
     }
   }
+}
+
+void mutt_pipe_message_to_state (HEADER *h, STATE *s)
+{
+  int cmflags = 0;
+  int chflags = CH_FROM;
+  
+  pipe_print_set_flags (option (OPTPIPEDECODE), &cmflags, &chflags);
   
   if (option (OPTPIPEDECODE))
     mutt_parse_mime_message (Context, h);
@@ -686,19 +691,17 @@ int mutt_save_message (HEADER *h, int delete,
   return -1;
 }
 
+/* XXX - merge this with mutt_pipe_message_to_state? */
+
 static void print_msg (FILE *fp, CONTEXT *ctx, HEADER *h)
 {
-  int cmflags = M_CM_DECODE | M_CM_CHARCONV;
-  int chflags = CH_DECODE | CH_REORDER;
+  int cmflags = 0;
+  int chflags = CH_FROM;
 
-  if (option (OPTWEED))
-  {
-    cmflags |= M_CM_WEED;
-    chflags |= CH_WEED;
-  }
+  pipe_print_set_flags (option (OPTPRINTDECODE), &cmflags, &chflags);
 
 #ifdef HAVE_PGP
-  if (h->pgp & PGPENCRYPT)
+  if (option (OPTPRINTDECODE) && (h->pgp & PGPENCRYPT))
   {
     if (!pgp_valid_passphrase ())
       return;
@@ -706,7 +709,9 @@ static void print_msg (FILE *fp, CONTEXT *ctx, HEADER *h)
   }
 #endif
 
-  mutt_parse_mime_message (ctx, h);
+  if (option (OPTPRINTDECODE))
+    mutt_parse_mime_message (ctx, h);
+
   mutt_copy_message (fp, ctx, h, cmflags, chflags);
 }
 
diff --git a/init.h b/init.h
index a7c4901ff0c3698105cead6fc6a9b62a035daba4..acb3697ed783e218a00fa0578fd798148c413380 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1462,6 +1462,17 @@ struct option_t MuttVars[] = {
   { "print_cmd",       DT_SYN,  R_NONE, UL "print_command", 0 },
   /*
   */
+  { "print_decode",    DT_BOOL, R_NONE, OPTPRINTDECODE, 1 },
+  /*
+  ** .pp
+  ** Used in connection with the print-message command.  If this
+  ** option is set, the message is decoded before it is passed to the
+  ** external command specified by $$print_command.  If this option
+  ** is unset, no processing will be applied to the message when
+  ** printing it.  The latter setting may be useful if you are using
+  ** some advanced printer filter which is able to properly format
+  ** e-mail messages for printing.
+  */
   { "prompt_after",    DT_BOOL, R_NONE, OPTPROMPTAFTER, 1 },
   /*
   ** .pp
diff --git a/mutt.h b/mutt.h
index da8bd2131c0f3513d5c58f16916e78d60ad17c89..48212dabf095e559cb15f0194057b7d583ac5280 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -321,6 +321,7 @@ enum
   OPTPIPESPLIT,
   OPTPOPDELETE,
   OPTPOPLAST,
+  OPTPRINTDECODE,
   OPTPROMPTAFTER,
   OPTREADONLY,
   OPTREPLYSELF,