]> code.delx.au - gnu-emacs/blob - lispref/permute-index
Don't include coff.h unless HAVE_COFF_H is defined.
[gnu-emacs] / lispref / permute-index
1 #!/bin/csh -f
2 # Generate a permuted index of all names.
3 # The result is a file called index.fns.
4
5 # Copyright (C) 2001 Free Software Foundation, Inc.
6 #
7 # This file is part of GNU Emacs.
8 #
9 # GNU Emacs is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13 #
14 # GNU Emacs is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Emacs; see the file COPYING. If not, write to the
21 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, USA.
23
24 # You will need to modify this for your needs.
25
26
27 set TEXINDEX=texindex # path to texindex command
28 #set EMACS=gnuemacs # your emacs command
29 #set TEX=tex # your tex command
30
31 set MANUAL=elisp # the base name of the manual
32
33 # goto 3
34
35 1:
36 echo "Extract raw index from texinfo fn index."
37 # Let texindex combine duplicate entries, later.
38 # But it wants to protect non-alphanumerics thus confusing ptx.
39 # Also change `\ ' to just a ` ', since texindex will fail. This is produced
40 # by `@findex two words' in an example environment (no doubt among others).
41 # delete wrapper parens
42 # change dots {} to dots{}
43 # change {-} to char form, so ptx wont ignore it.
44 # delete leading \entry {
45 # change '\ ' to ' '
46 # change lines with = < > since they mess up field extraction.
47 # separate into fields delimited by "
48 cat ${MANUAL}.fn | \
49 sed \
50 -e 's/(\([^)]*\))/\1/' \
51 -e 's/\\dots {}/(\\dots{})/' \
52 -e "s/{-}/{{\\tt\\char'055}}/" \
53 -e 's,^[^ ]* {,,' \
54 -e 's, },},' \
55 -e 's,\\ , ,g' \
56 -e 's/{\\tt\\char61}/=/' \
57 -e 's/{\\tt\\gtr}/>/' \
58 -e 's/{\\tt\\less}/</' \
59 -e 's/}{/"/g' \
60 | awk -F\" '{print $2, $1}' >! permuted.raw
61
62 2:
63 # Build break file for ptx.
64 cat <<EOF > permuted.break
65 -
66 :
67 EOF
68 # Build the ignore file for ptx.
69 # We would like to ignore "and", "or", and "for",
70 # but ptx ignores ignore words even if they stand alone.
71 cat <<EOF > permuted.ignore
72 the
73 in
74 to
75 as
76 a
77 an
78 of
79 on
80 them
81 how
82 from
83 by
84 EOF
85
86 echo "Make troff permuted index."
87 ptx -i permuted.ignore -b permuted.break -f -r -w 144 \
88 < permuted.raw >! permuted.t
89
90 3:
91 echo "Extract the desired fields."
92 awk -F\" '{printf "%s\"%s\"%s\n", $4,$6,$9}' permuted.t >! permuted.fields
93
94 4:
95 echo "Format for texindex."
96 # delete lines that start with "and ", "for "
97 sed < permuted.fields \
98 -e 's/=/{\\tt\\char61}/' \
99 -e 's/>/{\\tt\\gtr}/' \
100 -e 's/</{\\tt\\less}/' \
101 -e '/"and /d' \
102 -e '/"for /d' \
103 | awk -F\" 'NF>0 {if ($1=="") {\
104 print "\entry {" $2 "}{" 0+$3 "}{" $2 "}" }\
105 else {\
106 print "\entry {" $2 ", " $1 "}{" 0+$3 "}{" $2 ", " $1 "}"} }'\
107 > permuted.fn
108
109 5:
110 echo "Sort with texindex."
111 ${TEXINDEX} permuted.fn
112 #mv permuted.fns ${MANUAL}.fns
113
114 # The resulting permuted.fns will be read when we run TeX
115 # on the manual the second time. Or you can use permuted.texinfo here.
116 #${TEX} permuted.texinfo
117
118 6:
119 echo "Clean up."
120 rm -f permuted.fields permuted.t permuted.raw
121 rm -f permuted.break permuted.ignore permuted.fn