]> 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)
committerRichard Russon <rich@flatcap.org>
Sat, 21 May 2016 12:03:13 +0000 (13:03 +0100)
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 ebdddf161385f3536cf2d1e88d3166e0b919304c..8b7cc42a10ab4cdc58f0a45d0fb9e0868b207d43 100644 (file)
@@ -7389,6 +7389,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..a8dc2f5a3d6521c7c7b917a6cca4c5a109c9bd2a 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,9 @@ mutt_create_filter_fd (const char *cmd, FILE **in, FILE **out, FILE **err,
       close (fderr);
     }
 
+    snprintf (columns, sizeof (columns), "%d", COLS - SidebarWidth);
+    setenv ("COLUMNS", columns, 1);
+
     execl (EXECSHELL, "sh", "-c", cmd, NULL);
     _exit (127);
   }