[Patch] Add ability to specify the column when to wrap long lines
Hi there,
- sorry, if this arrives a second time, but I sent this message quite
some time ago and didn't see it on the list yet, so I'm re-sending
it now.
I know mutt can be told to wrap long lines at screenwidth - $wrapmargin
columns, but sometimes one needs a wide window and the message should
still be wrapped properly, ie. at a particular column. This cannot be
done with the relative approach of $wrapmargin. I therefore created a
new variable $wrapcolumn which can be used to specify the column at
which lengthy lines should be wrapped.
The patch for this incl. the documentation is attached. I'd appreciate
if it can be approved and applied by someone.
Thx, cheers.
l8er
manfred
2005-05-02 19:58:30 Manfred Hollstein <mh@xxxxxxxxxx>
* globals.h (WrapColumn): Add new global variable.
* init.h (MuttVars): Likewise.
* handler.c (text_enriched_handler): Initialize .WrapMargin field
under consideration of the new variable WrapColumn.
(text_plain_flowed_handler): Likewise for flowed_max.
* pager.c (format_line): Likewise for wrap_cols.
* Muttrc, doc/manual.sgml: Add documentation for new variable.
* doc/manual*.html, doc/manual.txt: Regenerate.
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/Muttrc mutt-1.5.9/Muttrc
--- mutt-1.5.9.orig/Muttrc 2005-03-13 17:37:11.000000000 +0100
+++ mutt-1.5.9/Muttrc 2005-05-02 19:57:59.663233248 +0200
@@ -3963,6 +3963,18 @@ macro pager <f1> "!less /usr/local/doc
# unset, searches will not wrap.
#
#
+# set wrapcolumn=0
+#
+# Name: wrapcolumn
+# Type: number
+# Default: 0
+#
+#
+# Controls at which column mutt's pager does smart wrapping. If
+# set to 0, no smart wrapping is done. If set to a value larger
+# than what the current display can handle, this value is ignored.
+#
+#
# set wrapmargin=0
#
# Name: wrapmargin
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/doc/manual.sgml mutt-1.5.9/doc/manual.sgml
--- mutt-1.5.9.orig/doc/manual.sgml 2005-03-13 17:37:11.000000000 +0100
+++ mutt-1.5.9/doc/manual.sgml 2005-05-02 19:57:59.668231894 +0200
@@ -6916,6 +6916,17 @@ When set, searches will wrap around the
unset, searches will not wrap.
+<sect2>wrapcolumn<label id="wrapcolumn">
+<p>
+Type: number<newline>
+Default: 0
+
+<p>
+Controls at which column mutt's pager does smart wrapping. If
+set to 0, no smart wrapping is done. If set to a value larger
+than what the current display can handle, this value is ignored.
+
+
<sect2>wrapmargin<label id="wrapmargin">
<p>
Type: number<newline>
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/doc/manual-6.html
mutt-1.5.9/doc/manual-6.html
--- mutt-1.5.9.orig/doc/manual-6.html 2005-03-13 17:37:24.000000000 +0100
+++ mutt-1.5.9/doc/manual-6.html 2005-05-02 19:57:59.672230810 +0200
@@ -3680,6 +3680,16 @@ Default: yes</P>
unset, searches will not wrap.</P>
+<H3><A NAME="wrapcolumn"></A> wrapcolumn</H3>
+
+<P>Type: number<BR>
+Default: 0</P>
+
+<P>Controls at which column mutt's pager does smart wrapping. If
+set to 0, no smart wrapping is done. If set to a value larger
+than what the current display can handle, this value is ignored.</P>
+
+
<H3><A NAME="wrapmargin"></A> wrapmargin</H3>
<P>Type: number<BR>
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/doc/manual.txt mutt-1.5.9/doc/manual.txt
--- mutt-1.5.9.orig/doc/manual.txt 2005-03-13 17:37:17.000000000 +0100
+++ mutt-1.5.9/doc/manual.txt 2005-05-02 19:57:59.678229185 +0200
@@ -379,9 +379,10 @@
6.3.274 wait_key
6.3.275 weed
6.3.276 wrap_search
- 6.3.277 wrapmargin
- 6.3.278 write_inc
- 6.3.279 write_bcc
+ 6.3.277 wrapcolumn
+ 6.3.278 wrapmargin
+ 6.3.279 write_inc
+ 6.3.280 write_bcc
6.4 Functions
6.4.1 generic
6.4.2 index
@@ -6645,7 +6646,16 @@
When set, searches will wrap around the first (or last) message. When
unset, searches will not wrap.
- 66..33..227777.. wwrraappmmaarrggiinn
+ 66..33..227777.. wwrraappccoolluummnn
+
+ Type: number
+ Default: 0
+
+ Controls at which column mutt's pager does smart wrapping. If
+ set to 0, no smart wrapping is done. If set to a value larger
+ than what the current display can handle, this value is ignored.
+
+ 66..33..227788.. wwrraappmmaarrggiinn
Type: number
Default: 0
@@ -6653,7 +6663,7 @@
Controls the size of the margin remaining at the right side of the
terminal when mutt's pager does smart wrapping.
- 66..33..227788.. wwrriittee__iinncc
+ 66..33..227799.. wwrriittee__iinncc
Type: number
Default: 10
@@ -6664,7 +6674,7 @@
Also see the ````$read_inc'''' variable.
- 66..33..227799.. wwrriittee__bbcccc
+ 66..33..228800.. wwrriittee__bbcccc
Type: boolean
Default: yes
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/globals.h mutt-1.5.9/globals.h
--- mutt-1.5.9.orig/globals.h 2005-02-12 21:01:02.000000000 +0100
+++ mutt-1.5.9/globals.h 2005-05-02 19:57:59.679228915 +0200
@@ -172,6 +172,7 @@ WHERE short ReadInc;
WHERE short SendmailWait;
WHERE short SleepTime INITVAL (1);
WHERE short Timeout;
+WHERE short WrapColumn;
WHERE short WrapMargin;
WHERE short WriteInc;
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/handler.c mutt-1.5.9/handler.c
--- mutt-1.5.9.orig/handler.c 2005-02-03 19:47:52.000000000 +0100
+++ mutt-1.5.9/handler.c 2005-05-02 19:57:59.681228373 +0200
@@ -781,7 +781,10 @@ void text_enriched_handler (BODY *a, STA
memset (&stte, 0, sizeof (stte));
stte.s = s;
- stte.WrapMargin = ((s->flags & M_DISPLAY) ? (COLS-4) :
((COLS-4)<72)?(COLS-4):72);
+ if (WrapColumn > 0 && WrapColumn < COLS)
+ stte.WrapMargin = ((s->flags & M_DISPLAY) ? (WrapColumn-4) :
((WrapColumn-4)<72)?(WrapColumn-4):72);
+ else
+ stte.WrapMargin = ((s->flags & M_DISPLAY) ? (COLS-4) :
((COLS-4)<72)?(COLS-4):72);
stte.line_max = stte.WrapMargin * 4;
stte.line = (char *) safe_calloc (1, stte.line_max + 1);
stte.param = (char *) safe_calloc (1, STRING);
@@ -993,12 +996,16 @@ static void text_plain_flowed_handler (B
if (s->prefix)
add = 1;
- if ((flowed_max = FLOWED_MAX) > COLS - 3)
- flowed_max = COLS - 3;
- if (flowed_max > COLS - WrapMargin)
- flowed_max = COLS - WrapMargin;
+ if ((flowed_max = FLOWED_MAX) >
+ ((WrapColumn > 0 && WrapColumn < COLS) ? WrapColumn : COLS) - 3)
+ flowed_max = ((WrapColumn > 0 && WrapColumn < COLS)
+ ? WrapColumn : COLS) - 3;
+ if (flowed_max > ((WrapColumn > 0 && WrapColumn < COLS)
+ ? WrapColumn : COLS) - WrapMargin)
+ flowed_max = ((WrapColumn > 0 && WrapColumn < COLS)
+ ? WrapColumn : COLS) - WrapMargin;
if (flowed_max <= 0)
- flowed_max = COLS;
+ flowed_max = (WrapColumn > 0 && WrapColumn < COLS) ? WrapColumn : COLS;
while (bytes > 0 && fgets (line, sizeof (line), s->fpin))
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/init.h mutt-1.5.9/init.h
--- mutt-1.5.9.orig/init.h 2005-03-01 16:56:02.000000000 +0100
+++ mutt-1.5.9/init.h 2005-05-02 19:57:59.684227560 +0200
@@ -2798,6 +2798,13 @@ struct option_t MuttVars[] = {
** When set, searches will wrap around the first (or last) message. When
** unset, searches will not wrap.
*/
+ { "wrapcolumn", DT_NUM, R_PAGER, UL &WrapColumn, 0 },
+ /*
+ ** .pp
+ ** Controls at which column mutt's pager does smart wrapping. If
+ ** set to 0, no smart wrapping is done. If set to a value larger
+ ** than what the current display can handle, this value is ignored.
+ */
{ "wrapmargin", DT_NUM, R_PAGER, UL &WrapMargin, 0 },
/*
** .pp
diff -rup -x CVS -x RCS -x '*.o' -x '*.info*' -x '*.elc' -x '*.dvi' -x '*.orig'
-x '*~' -x version.el mutt-1.5.9.orig/pager.c mutt-1.5.9/pager.c
--- mutt-1.5.9.orig/pager.c 2005-02-12 20:30:16.000000000 +0100
+++ mutt-1.5.9/pager.c 2005-05-02 19:57:59.689226206 +0200
@@ -1036,7 +1036,8 @@ static int format_line (struct line_t **
wchar_t wc;
mbstate_t mbstate;
- int wrap_cols = COLS - WrapMargin;
+ int wrap_cols = ((WrapColumn > 0 && WrapColumn < COLS)
+ ? WrapColumn : COLS) - WrapMargin;
if (wrap_cols <= 0)
wrap_cols = COLS;