nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] showing the n messages 'around' a particular message


From: Joel Reicher
Subject: Re: [Nmh-workers] showing the n messages 'around' a particular message
Date: Wed, 18 Jan 2006 16:25:10 +1100

> A friend was trying to sort out a suitable shell alias/function for
> doing a scan of the N messages 'around' the current one, by which I
> mean something like "cur:-X cur:X" where X is N/2, except that if there
> aren't X messages after cur you show more of the messages from before
> cur, and vice-versa, and you don't give an error message if cur is
> off the end of the folder or off the start or points to a message
> you've just deleted. (The idea is that you want a "screenful" of
> scan output, say, with cur somewhere in the middle.)

Since pick and scan don't behave the way you want with respect to error
conditions, and they are the right tools for the job, I think the only
clean way is to do it with another tool, such as awk. I *think* the
following will work, but the boundary conditions are a little tricky,
and you might want to redirect stderr to /dev/null to get rid of a
harmless warning from scan under some conditions.

scan cur:-$n | awk '{ line[NR]=$0 } END { i=(2*NR)<n?n-NR:int(n/2); while("scan 
next:"i | getline line[++NR]) if(NR>n) start++; while(start<NR) print 
line[++start] }' n=$n

Cheers,

        - Joel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]