The algorithm of classifying quotes in mutt's pager is really
interesting, but sometimes it gives an unexpected result (to those who
do not know the algorithm used ;).  For instance, if only second level
(or deeper) quotes are visible on screen initially, they are highlighted
like first level quotes.  After scrolling down they suddenly change
their color when lower level quotes become visible.  I had thought this
was a bug in mutt before I started studying the code.

There are also other questionable situations, like this:

    somebody wrote this:
    > me> said this
    > me> said this
    > yes, I agree

    another one wrote that:
    > > that
    > no, I don't agree

    third one wrote:
    > > > > > > > > send me money
    > me too!

Lines beginning with "> me>" and with "> >" are in the same level, but
they will be colored differently.  And the one "> > > ..." is quite
deeply nested, but, as there are not all possible prefixes, it will be
classified as level three (actually, four, because "> >" already got
level three as it is different from level-two prefix "> me>").

This behavior may be useful to some (even if not intuitive from the
description in the manual), but class shifting is disturbing (to say the
least).

An alternative approach would be to use quote_regexp to identify
individual quoting levels, like this:
    set quote_regexp = "[ ]?[a-zA-Z]{0,2}[ ]?[>]"
and determine the level of quoting by matching this pattern repeatedly
at the beginning of the line.

This way quoting levels can be specified strictly with an regexp and
there is no more need to store prefix trees in memory.

Are there important shortcomings of this approach?  Any clever
quote_regexp hacks that can be implemented with current algorithm but
not with the alternative?  Or maybe someone just loves the current
behavior and would hate to have another?

(Of course, there could be an option, e.g. smart_quote_parsing).

I think I'll try to implement this alternative unless someone more
familiar with the source likes this idea.  Or someone suggests of a way
to force mutt preparse the whole message (i.e. construct the full quote 
prefix tree) before displaying it, to avoid `class shifting' problem.

Maybe this should have been sent to mutt-dev?

Best Regards,
Marius Gedminas
-- 
Westheimer's Discovery:
        A couple of months in the laboratory can
        frequently save a couple of hours in the library.

Reply via email to