From: Kevin McCarthy Date: Tue, 10 May 2016 16:42:27 +0000 (-0700) Subject: Set COLUMNS to MuttIndexWindow->cols in mutt_create_filter_fd. (closes #3837) X-Git-Tag: neomutt-20160530~18^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1032f7922cd2e359fc5a47bb0612f52ca9b544d;p=neomutt Set COLUMNS to MuttIndexWindow->cols in mutt_create_filter_fd. (closes #3837) 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. --- diff --git a/doc/manual.xml.head b/doc/manual.xml.head index ebdddf161..8b7cc42a1 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -7389,6 +7389,17 @@ as text/plain and Mutt will use your standard pager to display the results. + +Mutt will set the COLUMNS 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: + + + +text/html; lynx -dump -width ${COLUMNS:-80} %s; copiousoutput + + Note that when using the built-in pager, only entries with this flag will be considered a handler for a MIME type diff --git a/filter.c b/filter.c index 91a4d7565..a8dc2f5a3 100644 --- a/filter.c +++ b/filter.c @@ -21,6 +21,7 @@ #endif #include "mutt.h" +#include "mutt_curses.h" #include #include @@ -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); }