permuted index
Luke Kendall
luke at research.canon.oz.au
Wed May 22 16:33:46 AEST 1991
The utility `ptx' which generates lines like:
.xx "" "permuted index generation by" "computer" ""
.xx "" "permuted index" "generation by computer" ""
.xx "" "permuted" "index generation by computer" ""
.xx "computer" "" "permuted index generation by" ""
expects you to have or write a suitable .xx macro for troff, which does
several fancy things, but the major one being that the third argument
(the one that the index is sorted on) aligns vertically.
None of the macro packages in /usr/lib/tmac contain definitions of an
xx macro (ie. grep "de *xx" ... finds none). I've written my own,
passable (but rather weak) macro, but was wondering if anyone has a
more polished one?
----
PS: in case you're interested, here is the shell script I've written
that wraps around `ptx':
----
#!/bin/sh
#
# Author: Luke Kendall
#
MYNAME=`basename $0`
usage="usage: $MYNAME [man-directory]
(generates permuted index of -man files in directory)"
md=/usr/man
#
if [ $# = 0 ]
then
echo "$MYNAME: no man directory specified: assuming $md"
elif [ $# != 1 ]
then
echo "$usage"
exit 1
elif [ -d $1 ]
then
md="$1"
else
echo "$usage"
exit 1
fi
echo "Permuted index of $md:"
out=ptx.tr
# ------ clumsy permuted index macros ------------
cat <<'EOF' > $out
.pn 1
.de xx
\\$1 \\$2 \\fB\\$3\\fR \\$4 \\s-1\\$5\\s0
..
.pl 10i
.de NP
.ev 1
.ft 1
.ps 10
.sp 0.75c
.tl '\s-2\\fIpermuted index\\fP\s0'\- \\n% \-'\s-2\\fIpermuted index\\fP\s0'
.pn +1
.bp
.ev
..
.wh 9i NP
.nf
.na
.ta 6.5i-1.1iR 6.5iR 6.51iR 6.52R
.ll 6.0i
.po 0i
.sp 0.25i
'\"
EOF
# ------ ------- ------- ------- ------- -------
find $md -type f -name "*.n" -print |
while read f
do
man=`basename $f`
man=`expr "$man" : "\(.*\)\.[^\.]*"`
echo $man:
#
# Use 1st non-"." and non-"'" started line as input to ptx (this
# should be the synopsis after the `.SH NAME');
# strip any "\-" from it (a silly sort key for ptx to avoid);
# insert a leading man page name for the -r option to find
#
sed -n '/^[^.]/s/\\-//gp;/^[^.]/q' $f | sed "s/^/($man) /"
done | ptx -t -f -r >> $out
#
# Turn the troff'able permuted index file into PostScript
#
psroff -t -rL10i $out > ptx.ps
echo "$out and ptx.ps produced from man directory $md."
--
Luke Kendall, Senior Software Engineer. | Net: luke at research.canon.oz.au
Canon Information Systems Research Australia | Phone: +61 2 805 2914
P.O. Box 313 North Ryde, NSW, Australia 2113 | Fax: +61 2 805 2929
More information about the Comp.unix.questions
mailing list