nmh-workers
[Top] [All Lists]

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

2006-01-17 22:26:31
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


_______________________________________________
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>