From bbd5bbab3d4c6f705849fdaafbf06adeb2a3a936 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Tue, 15 Dec 2015 15:29:56 -0800 Subject: [PATCH] Add $reflow_space_quotes option. (closes #3309) When viewing and replying to a flowed email, add spacing between the quotes to improve readability and interoperability with non-flowed replies. Add a section to the documentation discussing support for viewing and non-flowed replies to flowed emails. --- doc/manual.xml.head | 38 ++++++++++++++++++++++++++ init.h | 11 ++++++++ mutt.h | 1 + rfc3676.c | 65 ++++++++++++++++++++++++++++++++++++++------- 4 files changed, 105 insertions(+), 10 deletions(-) diff --git a/doc/manual.xml.head b/doc/manual.xml.head index baeddac5..1fcc7905 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -1612,6 +1612,44 @@ fo-table for details. + +Support for viewing and non-flowed replies + + + Mutt has some support for viewing and replying to + format=flowed messages. In order to take advantage of these, + $reflow_text must be set. + + + + + + Paragraphs are automatically reflowed and wrapped at a width specified + by $reflow_wrap. + + + + + By default, the quoting style of format=flowed + messages can be difficult to read, and doesn't intermix well with + non-flowed replies. + Setting $reflow_space_quotes + adds spaces after each level of quoting when in the pager and + replying in a non-flowed format + (i.e. with $text_flowed unset). + + + + + If $reflow_space_quotes + is unset, mutt will still add one trailing space after all the + quotes in the pager (but not when replying). + + + + + + diff --git a/init.h b/init.h index b0402a1f..abe68a7d 100644 --- a/init.h +++ b/init.h @@ -2380,6 +2380,17 @@ struct option_t MuttVars[] = { ** The value of \fI$$record\fP is overridden by the $$force_name and ** $$save_name variables, and the ``$fcc-hook'' command. */ + { "reflow_space_quotes", DT_BOOL, R_NONE, OPTREFLOWSPACEQUOTES, 1 }, + /* + ** .pp + ** This option controls how quotes from format=flowed messages are displayed + ** in the pager and when replying (with $$text_flowed \fIunset\fP). + ** When set, this option adds spaces after each level of quote marks, turning + ** ">>>foo" into "> > > foo". + ** .pp + ** \fBNote:\fP If $$reflow_text is \fIunset\fP, this option has no effect. + ** Also, this option does not affect replies when $$text_flowed is \fIset\fP. + */ { "reflow_text", DT_BOOL, R_NONE, OPTREFLOWTEXT, 1 }, /* ** .pp diff --git a/mutt.h b/mutt.h index 20c0e408..a34e5f6d 100644 --- a/mutt.h +++ b/mutt.h @@ -409,6 +409,7 @@ enum OPTPRINTSPLIT, OPTPROMPTAFTER, OPTREADONLY, + OPTREFLOWSPACEQUOTES, OPTREFLOWTEXT, OPTREPLYSELF, OPTRESOLVE, diff --git a/rfc3676.c b/rfc3676.c index 10cf105c..94f41f04 100644 --- a/rfc3676.c +++ b/rfc3676.c @@ -61,7 +61,46 @@ static int get_quote_level (const char *line) return quoted; } -static size_t print_indent (int ql, STATE *s, int sp) +/* Determines whether to add spacing between/after each quote level: + * >>>foo + * becomes + * > > > foo + */ +static int space_quotes (STATE *s) +{ + /* Allow quote spacing in the pager even for OPTTEXTFLOWED, + * but obviously not when replying. + */ + if (option (OPTTEXTFLOWED) && (s->flags & M_REPLYING)) + return 0; + + return option (OPTREFLOWSPACEQUOTES); +} + +/* Determines whether to add a trailing space to quotes: + * >>> foo + * as opposed to + * >>>foo + */ +static int add_quote_suffix (STATE *s, int ql) +{ + if (s->flags & M_REPLYING) + return 0; + + if (space_quotes (s)) + return 0; + + if (!ql && !s->prefix) + return 0; + + /* The prefix will add its own space */ + if (!option (OPTTEXTFLOWED) && !ql && s->prefix) + return 0; + + return 1; +} + +static size_t print_indent (int ql, STATE *s, int add_suffix) { int i; size_t wid = 0; @@ -77,14 +116,21 @@ static size_t print_indent (int ql, STATE *s, int sp) { state_puts (s->prefix, s); wid = mutt_strwidth (s->prefix); - sp = 0; } } for (i = 0; i < ql; i++) + { state_putc ('>', s); - if (sp) + if (space_quotes (s) ) + state_putc (' ', s); + } + if (add_suffix) state_putc (' ', s); - return ql + sp + wid; + + if (space_quotes (s)) + ql *= 2; + + return ql + add_suffix + wid; } static void flush_par (STATE *s, flowed_state_t *fst) @@ -112,10 +158,10 @@ static int quote_width (STATE *s, int ql) ++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 + width -= space_quotes (s) ? ql*2 : ql; + /* When displaying (not replying), there may be a space between the prefix * string and the paragraph */ - if ((s->flags & M_REPLYING) == 0 && ql > 0) + if (add_quote_suffix (s, ql)) --width; /* failsafe for really long quotes */ if (width <= 0) @@ -183,8 +229,7 @@ static void print_flowed_line (char *line, STATE *s, int ql, } if (!words && !fst->width) - fst->width = print_indent (ql, s, !(s->flags & M_REPLYING) && - (ql > 0 || s->prefix)); + fst->width = print_indent (ql, s, add_quote_suffix (s, ql)); fst->width += w + fst->spaces; for ( ; fst->spaces; fst->spaces--) state_putc (' ', s); @@ -199,7 +244,7 @@ static void print_flowed_line (char *line, STATE *s, int ql, static void print_fixed_line (const char *line, STATE *s, int ql, flowed_state_t *fst) { - print_indent (ql, s, !(s->flags & M_REPLYING) && (ql > 0 || s->prefix)); + print_indent (ql, s, add_quote_suffix (s, ql)); if (line && *line) state_puts (line, s); state_putc ('\n', s); -- 2.40.0