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

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



On 2003-12-15, Allister MacLeod <amacleod@xxxxxxxx> wrote:
> On Mon, Dec 15, 2003 at 01:57:02PM +0200, Denis V. Lozko wrote:
> > Good day!
> > 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.  I
didn't investigate any further than to recognize the need to fix my
sed expressions.

> set display_filter="sed -e '/^\\[-- .* --\\]$/d'"
> 
> A brief test reveals that this doesn't actually delete the attachment
> lines (I'm not sure why).  However, it works just fine when you get
> rid of the end-of-line anchors.
> 
> set display_filter="sed -e '/\\[-- .* --\\]/d'"

If your pager includes that initial escape sequence too, then that
is the reason your expression doesn't work when you anchor the [ to
the beginning of the line.

HTH,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA