]> granicus.if.org Git - neomutt/commitdiff
Set COLUMNS to MuttIndexWindow->cols in mutt_create_filter_fd. (closes #3837)
authorKevin McCarthy <kevin@8t8.us>
Tue, 10 May 2016 16:42:27 +0000 (09:42 -0700)
committerKevin McCarthy <kevin@8t8.us>
Tue, 10 May 2016 16:42:27 +0000 (09:42 -0700)
This allows filters to automatically (or via a command line argument)
adjust to the width of the pager/index.  This is even more important
with the sidebar, since the width of the pager is smaller than the
terminal width.

Thanks to Vincent Lefèvre for his helpful information and suggestions,
and to Richard Russon for the initial patches.

doc/manual.xml.head
filter.c

index b90908f001610306861479d3bc7440f848d5e17c..a3711d093858eeeff9c54d90282d7b7661e50c90 100644 (file)
@@ -6772,6 +6772,17 @@ as <literal>text/plain</literal> and Mutt will use your standard pager
 to display the results.
 </para>
 
+<para>
+Mutt will set the <literal>COLUMNS</literal> environment variable to
+the width of the pager.  Some programs make use of this environment
+variable automatically.  Others provide a command line argument that
+can use this to set the output width:
+</para>
+
+<screen>
+text/html; lynx -dump -width ${COLUMNS:-80} %s; copiousoutput
+</screen>
+
 <para>
 Note that when using the built-in pager, <emphasis>only</emphasis>
 entries with this flag will be considered a handler for a MIME type
index 91a4d756567813198335f5d20d8b5ecbdb43359f..0e94d249fa84f57e76ece2e8d5a565e5dafc6e1b 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -21,6 +21,7 @@
 #endif
 
 #include "mutt.h"
+#include "mutt_curses.h"
 
 #include <unistd.h>
 #include <stdlib.h>
@@ -34,6 +35,7 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
                       int fdin, int fdout, int fderr)
 {
   int pin[2], pout[2], perr[2], thepid;
+  char columns[11];
 
   if (in)
   {
@@ -117,6 +119,12 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
       close (fderr);
     }
 
+    if (MuttIndexWindow && (MuttIndexWindow->cols > 0))
+    {
+      snprintf (columns, sizeof (columns), "%d", MuttIndexWindow->cols);
+      setenv ("COLUMNS", columns, 1);
+    }
+
     execl (EXECSHELL, "sh", "-c", cmd, NULL);
     _exit (127);
   }