<<< Date Index >>>     <<< Thread Index >>>

For 1.5.9: soft fill [patch-1.5.8.dgc.softfill.3]



The previous version, patch-1.5.8.dgc.softfill.2, is from Sept. 2003.
Thomas, we had a brief discussion about it then, but I was not sure
whether the patch was rejected or just lost. It came up again last month
in mutt-users, so here's an update in case it's suitable to commit.

The current patch rev is at
    http://home.uchicago.edu/~dgc/sw/mutt/patch-1.5.8.dgc.softfill.3

The older version is updated for 1.5.8:
    http://home.uchicago.edu/~dgc/sw/mutt/patch-1.5.8.dgc.softfill.2

I think my original description of this patch was a complete failure
to communicate, so I'm going to try again from scratch. Note that I've
changed the syntax since 1.5.6. It is now less weird, and it fits in
better with the other "special" expandos in mutt.

The softfill patch provides a "%*X" expando, similar to the existing
"%>X" and %|X". Like "%>X", it inserts padding to push a line of text
all the way to the right. Unlike "%>X", it gives fill precedence to the
right-hand side, not to the left. If there's more than enough space
for all the expandos to expand, the outcome is the same as with "%>X".
However, if there's not enough, "%*X" makes the formatting routines
chomp back to the left to guarantee enough space for whatever lies
to the right. "%>X" just fills out everything on the LHS, then shows
whatever from the RHS there's room for -- which could be nothing.

Here's an example.

Suppose I set my $index_format to "%4C %[%y%m%d] %s%>. [%F]". Here are
two messages from my imaginary inbox, as they might appear with that
setting. From is from "Verisign Corporation" and one is from "Angry
Man".

  34 030915 And now a word from your sponsor............. [Verisign Corporation]
  35 030915 Re: Re: Re: Verisign are idiots and will be first against the wall w

If I change %>. to %*., this becomes:

  34 030915 And now a word from your sponsor............. [Verisign Corporation]
  35 030915 Re: Re: Re: Verisign are idiots and will be first agains [Angry Man]

Note that %* has ensured that there's room for my [%F], cutting away at
the %s which comes before it to provide that room. The original softfill
patch used a %=XY notation, where X was the fill character and Y was the
expando that would be held in reserve for truncation. Now the entire
LHS is held in reserve. It's debatable whether this is better, but it's
definitely simpler.

This rev of the patch also modifies the basic expando modifier code,
adding cetering of fields in addition to left- and right-justification.
Whereas "%12.12F" right-justifies, and "%-12.12F" left-justifies,
"%=12.12s" centers.

The patch includes documentation for the new features, and also for
the existing format controls, which I found were not documented at all
in current mutt. The documentation, as always, is untested since I
cannot build sgml-tools. If someone wants to check it for me, I'd be
appreciative.


Here are some interesting examples of how one might use this in
$index_format. They're all variations on a theme.

set index_format="%5C %Z %4c %?y?%=10.10y&  %[%y%m%d]  ? %s %*. [%F"
set index_format="%5C %Z %4c %s %*  [%?y?:%=10.10y:&%.12F?"
set index_format="%5C %Z %[%y%m%d] %=15.15F %s%* %?y?% [%y?"
set index_format="%5C %Z %S %4c %d  %s  %* %14n"

-- 
 -D.    dgc@xxxxxxxxxxxx                                  NSIT::ENSS
 "So now, less than five years later, you can go up on a steep hill...
  and with the right kind of eyes you can almost see the high-water
  mark -- the place where the wave finally broke and rolled back." -HST