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

Re: strip[p]ing attachment lines in the pager



On Mon, Dec 15, 2003 at 06:10:42PM -0800, Gary Johnson wrote:
> On 2003-12-15, Allister MacLeod <amacleod@xxxxxxxx> wrote:
> > On Mon, Dec 15, 2003 at 01:57:02PM +0200, Denis V. Lozko wrote:
> > > On Fri, 12/12/03, 16:50 -0800 Gary Johnson wrote:
> > > >On 2003-12-13, "Denis V. Lozko" <talmuth@xxxxxxxxxxxxx> wrote:

> > > >>Hi, mutters!
> > > >>is there the way to strip attachment lines in the pager view?
> > > >>I mean lines:
> > > >>[-- Attachment #1 --]
> > > >>any ideas?
> > > >Yes, use a 'display_filter', e.g.,
> > > >   set display_filter="sed '/^.*\\[-- .* --]$/d'"
> > > Mutt's gone crazy when i've try this option
> > > may be i don't understood coorectly
> > > but next line will be helpfull for advicers
> > > ed: 1: "/^^[.*^G\[-- .* --]$/d": RE error: invalid character range
> > 
> > Well.. if I understand my regexps correctly, sed/ed is interpreting
> > '[.*^G\[-- .* --]' as an attempt at a character range.. that is, any
> > of the characters in the midst of the []'s.  Probably it's taking
> > exception to the duplicated characters [.*- ].  I'm not sure what the
> > ^G part is for, but here's my attempt at a filter that would delete
> > only lines which begin with '[-- ' and end with ' --]' and have some
> > text in between:
> 
> I should have explained the contents of the sed expression I posted:
> 
>     set display_filter="sed '/^.*\\[-- .* --]$/d'"
> 
> First of all, what appear as ^[ and ^G are control characters,
> Escape and Ctrl-G, respectively.  So to use that sed expression, you
> need to either copy it using an editor, or enter those control
> characters explicitly--an X copy-and-paste using the mouse will copy
> the printable representation rather than the actual control
> characters.
> 
> So, there is no character range in that expression.
> 
> I don't really know what the ^[ and the ^G are for, but they
> appeared in those "[-- ... --]" lines when I changed from mutt-1.2i
> to mutt-1.4i, so I just added them to my sed expressions.  My guess
> is that they are someone's attempt to highlight those lines in the
> pager, but my terminal doesn't understand the escape sequence.

The ^[ blahblahblah ^G ANSI escape (^[ == ESC, as many VIers and some
EMACSers already know) sequence allows a program to change the terminal's
color.  Mutt uses it to change the colors of various things, including
its own messages.  You only need to include it in your regexps if you
have mutt color its own messages (which includes coloring PGP output,
attachments, autoview output, etc.).  I'm starting to think that coloring
messages should be done by a display_filter rather than Mutt itself, since
these types of filtering ops shouldn't really have to mess with control
characters ... I guess when you ask why I miss ELM, I have to answer that
it liked going to extremes to delegate functionality to separate programs,
whereas Mutt sometimes tries to do a tad too much all by itself, IMHO. . .

>  I
> didn't investigate any further than to recognize the need to fix my
> sed expressions.

Truth be told, that won't quite fix the issue once and for all, either.
In cases where only Mutt's message is colored but the rest isn't,
there will be an ANSI reset color change escape sequence at the end of
the line, so you'll need another ^[ blablablah ^G pattern at the end,
before the EOL marker.  However, Allister's version (getting rid of the
SOL and EOL markers altogether) solves both problems quite nicely, as
long as nobody tries to talk about the [-- blah --] stuff in his email ;-)

If you insist on solving the problem correctly, you need to figure out
the codes Mutt generates under your particular config, put them into the
regexp, and disable convert_meta in your config.  That way, your filter
will only kill [-- blah --] sequences generated by Mutt.

A shortcut way (if you don't mind losing [-- blah --] sequences in
email) is to make the ANSI sequences at the start and end optional in
your regexp.

HTH,
 - Dave

-- 
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

Attachment: pgpqAMTlWiZWz.pgp
Description: PGP signature