2 # Generate a permuted index of all names.
3 # The result is a file called index.fns.
5 # You will need to modify this for your needs.
8 set TEXINDEX=texindex # path to texindex command
9 #set EMACS=xemacs # your emacs command
10 #set TEX=tex # your tex command
12 set MANUAL=lispref # the base name of the manual
17 echo "Extract raw index from texinfo fn index."
18 # Let texindex combine duplicate entries, later.
19 # But it wants to protect non-alphanumerics thus confusing ptx.
20 # Also change `\ ' to just a ` ', since texindex will fail. This is produced
21 # by `@findex two words' in an example environment (no doubt among others).
22 # delete wrapper parens
23 # change dots {} to dots{}
24 # change {-} to char form, so ptx wont ignore it.
25 # delete leading \entry {
27 # change lines with = < > since they mess up field extraction.
28 # separate into fields delimited by "
31 -e 's/(\([^)]*\))/\1/' \
32 -e 's/\\dots {}/(\\dots{})/' \
33 -e "s/{-}/{{\\tt\\char'055}}/" \
37 -e 's/{\\tt\\char61}/=/' \
38 -e 's/{\\tt\\gtr}/>/' \
39 -e 's/{\\tt\\less}/</' \
41 | awk -F\" '{print $2, $1}' >! permuted.raw
44 # Build break file for ptx.
45 cat <<EOF > permuted.break
49 # Build the ignore file for ptx.
50 # We would like to ignore "and", "or", and "for",
51 # but ptx ignores ignore words even if they stand alone.
52 cat <<EOF > permuted.ignore
67 echo "Make troff permuted index."
68 ptx -i permuted.ignore -b permuted.break -f -r -w 144 \
69 < permuted.raw >! permuted.t
72 echo "Extract the desired fields."
73 awk -F\" '{printf "%s\"%s\"%s\n", $4,$6,$9}' permuted.t >! permuted.fields
76 echo "Format for texindex."
77 # delete lines that start with "and ", "for "
78 sed < permuted.fields \
79 -e 's/=/{\\tt\\char61}/' \
80 -e 's/>/{\\tt\\gtr}/' \
81 -e 's/</{\\tt\\less}/' \
84 | awk -F\" 'NF>0 {if ($1=="") {\
85 print "\entry {" $2 "}{" 0+$3 "}{" $2 "}" }\
87 print "\entry {" $2 ", " $1 "}{" 0+$3 "}{" $2 ", " $1 "}"} }'\
91 echo "Sort with texindex."
92 ${TEXINDEX} permuted.fn
93 #mv permuted.fns ${MANUAL}.fns
95 # The resulting permuted.fns will be read when we run TeX
96 # on the manual the second time. Or you can use permuted.texinfo here.
97 #${TEX} permuted.texinfo
101 rm -f permuted.fields permuted.t permuted.raw
102 rm -f permuted.break permuted.ignore permuted.fn