On Fri, Dec 11, 2015 at 02:22:47PM -0800, Kevin J. McCarthy wrote:
> After thinking about it, I'm leaning towards something like
> $reflow_space_quotes.  If set, and your $indent_string = "| ", ">>>Foo"
> would become "| > > > Foo".  If unset, it would become "| >>>Foo".
> (Keeping the weird spacing behavior for now.)

I'm attaching a very (very) raw patch, just to try out.  Obviously, I
need to test and document this better, but it's just something you can
take a look at and see how it feels.

Try setting/unsetting $reflow_space_quotes and see what you think.

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
http://www.8t8.us/configs/gpg-key-transition-statement.txt
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1449879056 28800
#      Fri Dec 11 16:10:56 2015 -0800
# Node ID 81beb8a86a45d5bf45b255d2baba32a3e46f2590
# Parent  02bc14ed15697cdc13f73f07f9be225226361f96
Add $reflow_space_quotes option for fixed replies to flowed emails. (closes 
#3309)

When replying to a flowed email, add spacing between the quotes to
improve readability.

diff --git a/init.h b/init.h
--- a/init.h
+++ b/init.h
@@ -2375,16 +2375,24 @@
   ** This specifies the file into which your outgoing messages should be
   ** appended.  (This is meant as the primary method for saving a copy of
   ** your messages, but another way to do this is using the ``$my_hdr''
   ** command to create a ``Bcc:'' field with your email address in it.)
   ** .pp
   ** 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, 0 },
+  /*
+  ** .pp
+  ** This option is used when replying to format=flowed parts with
+  ** $$text_flowed \fIunset\fP and $$reflow_text \fIset\fP.
+  ** Setting this option adds spaces after each level of quote marks, making
+  ** an unflowed reply more readable.
+  */
   { "reflow_text",     DT_BOOL, R_NONE, OPTREFLOWTEXT, 1 },
   /*
   ** .pp
   ** When \fIset\fP, Mutt will reformat paragraphs in text/plain
   ** parts marked format=flowed.  If \fIunset\fP, Mutt will display paragraphs
   ** unaltered from how they appear in the message body.  See RFC3676 for
   ** details on the \fIformat=flowed\fP format.
   ** .pp
diff --git a/mutt.h b/mutt.h
--- a/mutt.h
+++ b/mutt.h
@@ -404,16 +404,17 @@
   OPTPOPAUTHTRYALL,
   OPTPOPLAST,
 #endif
   OPTPOSTPONEENCRYPT,
   OPTPRINTDECODE,
   OPTPRINTSPLIT,
   OPTPROMPTAFTER,
   OPTREADONLY,
+  OPTREFLOWSPACEQUOTES,
   OPTREFLOWTEXT,
   OPTREPLYSELF,
   OPTRESOLVE,
   OPTREVALIAS,
   OPTREVNAME,
   OPTREVREAL,
   OPTRFC2047PARAMS,
   OPTSAVEADDRESS,
diff --git a/rfc3676.c b/rfc3676.c
--- a/rfc3676.c
+++ b/rfc3676.c
@@ -56,40 +56,83 @@
   {
     quoted++;
     p++;
   }
 
   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 (void)
+{
+  if (!option (OPTTEXTFLOWED) && option (OPTREFLOWSPACEQUOTES))
+    return 1;
+
+  return 0;
+}
+
+/* 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 ())
+    return 0;
+
+  if (!ql && !s->prefix)
+    return 0;
+
+  /* The prefix will add its own space */
+  if (!option (OPTTEXTFLOWED) && s->prefix)
+    return 0;
+
+  return 1;
+}
+
+static size_t print_indent (int ql, STATE *s, int add_suffix)
 {
   int i;
   size_t wid = 0;
 
   if (s->prefix)
   {
     /* use given prefix only for format=fixed replies to format=flowed,
      * for format=flowed replies to format=flowed, use '>' indentation
      */
     if (option (OPTTEXTFLOWED))
       ql++;
     else
     {
       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 () )
+      state_putc (' ', s);
+  }
+  if (add_suffix)
     state_putc (' ', s);
-  return ql + sp + wid;
+
+  if (space_quotes ())
+    ql *= 2;
+
+  return ql + add_suffix + wid;
 }
 
 static void flush_par (STATE *s, flowed_state_t *fst)
 {
   if (fst->width > 0)
   {
     state_putc ('\n', s);
     fst->width = 0;
@@ -107,20 +150,20 @@
   {
     /* 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
+  width -= space_quotes () ? 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)
     width = FLOWED_MAX; /* arbitrary, since the line will wrap */
   return width;
 }
 
 static void print_flowed_line (char *line, STATE *s, int ql,
@@ -178,33 +221,32 @@
          state_putc (' ', s);
       state_putc ('\n', s);
       fst->width = 0;
       fst->spaces = 0;
       words = 0;
     }
 
     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);
     state_puts (p, s);
     words++;
   }
 
   if (term)
     flush_par (s, fst);
 }
 
 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);
 
   fst->width = 0;
   fst->spaces = 0;
 }
 

Attachment: signature.asc
Description: PGP signature

Reply via email to