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

Re: colours and quotes and regex libs? (was: Re: colours and quotes)



On Fri, May 28, 2004 at 04:15:55PM EDT, Ronald J Kimball wrote:
> On Fri, May 28, 2004 at 04:03:06PM -0400, Ronald J Kimball wrote:

> > Here's a mutt-friendly regex, based on David's Perl regex, that seems to do
> > well:
> > 
> > color body brightblue default \
> >   '(https?|ftp|gopher|finger):\/\/([^"'"'"' \t\n)>.,!?&]|[.,!?][^"'"'"' 
> > \t\n)>.,!?&]|&([^g]|$)|&g([^t]|$)|&gt([^;]|$))+'
> > 
> 
> Woops!  There's a flaw in that command that became apparent when I received
> a URL containing the letter n!  :D  Apparently in mutt "\n" is a newline,
> but '\n' is an n.  Here's the command again, with proper quoting:
> 
> color body brightblue default \
>   "(https?|ftp|gopher|finger)://([^"'"'"' \t\r\n)>.,!?&]|[.,!?][^"'"'"' 
> \t\r\n)>.,!?&]|&([^g]|$)|&g([^t]|$)|&gt([^;]|$))+"

Okay, my new WHY_USE [1] is online :-)

I'm attaching a courtesy copy to this email, since it appears my Web
server is down for some odd reason.

 - Dave

[1]
http://www.bigfatdave.com/dave/mutt/muttdir/WHY_USE

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel
What Makes My Setup So Cool?

mailing lists:

There's extensive support for mailing lists using a simple data file
format.  Aliases for lists (in the ml_ namespace) are autogenerated.  If
you set a "subscribed:" field to "no," it'll generate a "lists" statement
instead of a "subscribed" statement.  Outgoing email automatically has the
From: name and address changed to match your preference (with a reasonable
default chosen for each list automatically).  If you find yourself
looking at a list post and you haven't added the list to your config
yet, there's a script you can pipe the mail into in order to add the
address to your lists (with some basic info that the script can extract
autonomously) automatically.  Of course, mail to mutt-users+blah@xxxxxxxx
will correctly be recognized if mutt-users@xxxxxxxx is in your list of
lists (but this only works for Mutt 1.5.6i or later - else, you'll need
to use the --compat option to force non-regexp list addys).  As an added
bonus, you can change your name and attribution depending on the list's
language (using the "speaks:" field).

colors:

The pager coloring is done by our $display_filter, so none of the
limitations of Mutt's coloring functionality affect us.  We can color
individual words, letters, etc., for instance (rather than simply whole
lines).  (The Mutt pager has certain bugs which cause it to screw up much
of the coloring config.  I've implemented a workaround for most of the
problems by coloring each letter individually, but Mutt's pager still
manages to screw up a lot of times.  I'm working on a solution that will
allow you to use an external pager as if it were Mutt's built-in one.
Stay tuned.)

Well, I'm informed by reputable sources that Mutt _can_ in fact handle
partial line coloring (as of 1.5.6i, probably even earlier in the 1.5
branch - always in the 1.4 branch, but my setup doesn't officially
support 1.4 at all).  In fact, Ronald J Kimball (who can be reached at
rjk-mutt followed by an at sign, and then tamias with a dot net) posted
(Message-id: <20040528201555.GA94669@xxxxxxxxxxxxxxx>) a regex for Mutt
that'll color URLs even better than my own:

color body brightblue default \
  "(https?|ftp|gopher|finger)://([^"'"'"' \t\r\n)>.,!?&]|[.,!?][^"'"'"' 
\t\r\n)>.,!?&]|&([^g]|$)|&g([^t]|$)|&gt([^;]|$))+"

However, that just underscores another advantage: you can use Perl regex
syntax, sed regex syntax, or any other regex syntax, since the pipelines
can be filled with any program/script you want.  Mine does a bit less,
but compare simplicity (and this is including Perl escaping for the s//
operator):

((https?|ftp|gopher|finger):\/\/(.+?))(?="|\s|&gt;|\))

Here's the full line in my displayfilterlist:
perl -npe 
's/((https?|ftp|gopher|finger):\/\/(.+?))(?="|\s|&gt;|\))/<green>$1<\/green>/g'

PGP output:

Another one of my filters changes the PGP output from Mutt to be a lot
more compact without introducing too many serious security considerations.
(The filter checks the approximate validity of the timestamp, and colors
appropriately.)  When I get the chance, I should probably make another
filter to simply verify the PGP signature all by itself and produce XML
to that effect.

custom headers:

Custom headers are managed in a separate file, with blanks and comments
allowed.  A "X-Mutt-Ignore-Me-Pattern:" header is automatically generated
to help others filter your custom headers easily.

aliases:

The address book is maintained in a separate file, with arbitrary fields
allowed.  There's built-in support for groups, including some with
special treatment.  Mutt's version is autogenerated from it.  Mutt's
create-alias function is accomodated with an alias queue that gets run
on config reload (^r by default), to add the entry to the real address
book with whatever info can be easily extracted from Mutt's version.
save-hooks are also autogenerated, so when you try to save a message,
it'll give you a reasonable default folder.  Of course, resources
(user+resource@xxxxxxxxxx) are handled automatically.

addresses:

Your alternates are automatically managed based on a single file listing
regexps.  (Support for both the old alternates variable and the new
alternates command is built-in - use the --compat flag to generate an
old RC file.)  Resources (+blahblahblah) are matched automatically, so
there's no need to include the optional plus patterns in every address.
(Try replying to a message sent to you+blah@xxxxxxxxxxxxxx, and you'll
notice the reply comes from you@xxxxxxxxxxxxxx, silently losing the
resource.  The only way to fix that in general is to tell mutt that
you([+].*)?@yourdomain\.com matches your addresses, and my config does
that automatically.)  The "From:" header is also managed based on this.
You can also use hooks/etc. to change your "From:" name and "From:"
address individually, without clobbering whichever one you didn't want
to change.

Attachment: pgp60cZVjqvFm.pgp
Description: PGP signature