From fb0c46594a3e16a3a5ea06c0b21c487b8faab0e9 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Wed, 29 Sep 2010 10:26:07 -0700 Subject: [PATCH] fix handling of format=flowed when $wrap is 0. --- rfc3676.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/rfc3676.c b/rfc3676.c index aadda0f3..3dd7c742 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -96,13 +96,29 @@ static void flush_par (STATE *s, flowed_state_t *fst) fst->spaces = 0; } +/* Calculate the paragraph width based upon the current quote level. The start + * of a quoted line will be ">>> ", so we need to subtrace the space required + * for the prefix from the terminal width. */ static int quote_width (STATE *s, int ql) { - size_t width = (Wrap ? mutt_term_width (Wrap) : FLOWED_MAX) - 1; - if (s->flags & M_REPLYING && width > FLOWED_MAX) - width = FLOWED_MAX; - if (ql + 1 < width) - width -= ql + 1; + int width = mutt_term_width (Wrap); + if (option(OPTTEXTFLOWED) && (s->flags & M_REPLYING)) + { + /* When replying, force a wrap at FLOWED_MAX to comply with RFC3676 + * guidelines */ + if (width > FLOWED_MAX) + width = FLOWED_MAX; + ++ql; /* When replying, we will add an additional quote level */ + } + /* adjust the paragraph width subtracting the number of prefix chars */ + width -= ql; + /* When displaying (not replying), there will be a space between the prefix + * string and the paragraph */ + if ((s->flags & M_REPLYING) == 0 && ql > 0) + --width; + /* failsafe for really long quotes */ + if (width <= 0) + width = FLOWED_MAX; /* arbitrary, since the line will wrap */ return width; } -- 2.40.0