joel --
Some feedback would be nice. I like to think the script works. :)
it occurred to me yesterday that this script might be quite
useful (instead of just pretty :-) if it had one simple feature:
the ability to add each thread to a separate, temporary, mh
sequence ("t1", "t2", "t3", ...). the output would then include
a column for the sequence name (or number). then, you could run
your script:
$ spin unseen
to sort a bunch of unread messages into thread sequences, and then
either read all the threads with:
$ show t1 | more
$ show t2 | more
or any specific thread by spotting its number in the spin output.
this sort of assumes that the messages are in the right order in
the folder -- if they're not, then an initial "sortm unseen" would
fix that.
another useful feature (and i'm not sure how much harder this
would be) would be the ability to find the entire thread of which
a given message is a part -- i.e., if i view a message at random
in my scan listing, i'd like to be able to obtain a sequence
which identifies the thread containing it:
$ whichthread cur last:500
would search the most recent 500 messages for the thread containing
"cur", and emit the name of its sequence.
i started looking at adding these features myself, but quickly decided
you might rather do it. ;-)
paul
Cheers,
- Joel
part 2 text/plain 1325
===============
#!/bin/sh
AWK=/usr/bin/awk
SCANLINE_FORMAT=`cat /etc/nmh/scan.default`
TERMINAL_WIDTH=`echo "$TERMCAP" | $AWK 'BEGIN { RS=":"; FS="#" } "co"==$1 {
cols=$2 } END { print cols?cols:80 }'`
/usr/local/bin/scan $* -width 4096 -format "<fake-root-id> %{references}
%{in-reply-to} %{message-id}\n$SCANLINE_FORMAT\n" | $AWK '
function pruneshow(x, prefix, i) {
if(x in scanline) {
print prefix substr(scanline[x], 1, width-1-length(prefix))
prefix=prefix " "
}
for(i=0; i<lastkid[x]; i++)
if((x, i) in kids)
pruneshow(kids[x, i], prefix)
}
BEGIN {
scanline["<fake-root-id>"]="THIS SHOULD NOT APPEAR"
}
{
i=0
for(j=1; j<=NF; j++)
if("<"==substr($j, 1, 1) && ">"==substr($j, length($j),
length($j)))
$++i=$j
NF=i
for(midsuffix=""; ($NF midsuffix) in scanline; midsuffix++)
;
$NF=$NF midsuffix
if($NF in parent) {
delete kids[parent[$NF], kidnumber[$NF]]
delete parent[$NF]
}
for(i=1; i<NF; i++)
if(!($(i+1) in parent)) {
for(ancestor=$i; ancestor in parent;
ancestor=parent[ancestor])
;
if(ancestor==$(i+1))
$i="<fake-root-id>"
kids[parent[$(i+1)]=$i,
kidnumber[$(i+1)]=lastkid[$i]++]=$(i+1)
}
getline scanline[$NF]
}
END {
for(i=0; i<lastkid["<fake-root-id>"]; i++)
if(("<fake-root-id>", i) in kids)
pruneshow(kids["<fake-root-id>", i])
}
' width=$TERMINAL_WIDTH
part 3 text/plain 149
===============
_______________________________________________
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers
=---------------------
paul fox, pgf@foxharp.boston.ma.us (arlington, ma, where it's 30.4 degrees)
_______________________________________________
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers