On 17 January 2006 at 22:36, [EMAIL PROTECTED] wrote:
> 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.)

I can't think of a non-ugly way to do this.  A semi-ugly ;-) way is:

- Get a list of messages from "mhpath all" or "mhpath cur:-N cur:N"

- Strip off the path, leave the number

- Use grep -CN to get N lines of context around the current message
  number.  Use start- and end-of-line anchors (^ and $) to be sure
  you don't match any other messages.

For example, if you want up to 5 messages surrounding message 4363:

        $ mhpath 4363:-5 4363:5 | sed '[EMAIL PROTECTED]/@@' | grep -C5 
"^4363\$"
        4359
        4360
        4361
        4362
        4363
        4364
        4365

The last message in the folder is 4365.

Jerry


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

Reply via email to