Mercurial > hg > xemacs-beta
comparison man/lispref/permute-index @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
| author | cvs |
|---|---|
| date | Mon, 13 Aug 2007 11:20:41 +0200 |
| parents | 376386a54a3c |
| children |
comparison
equal
deleted
inserted
replaced
| 411:12e008d41344 | 412:697ef44129c6 |
|---|---|
| 1 #!/bin/csh -f | |
| 2 # Generate a permuted index of all names. | |
| 3 # The result is a file called index.fns. | |
| 4 | |
| 5 # You will need to modify this for your needs. | |
| 6 | |
| 7 | |
| 8 set TEXINDEX=texindex # path to texindex command | |
| 9 #set EMACS=xemacs # your emacs command | |
| 10 #set TEX=tex # your tex command | |
| 11 | |
| 12 set MANUAL=lispref # the base name of the manual | |
| 13 | |
| 14 # goto 3 | |
| 15 | |
| 16 1: | |
| 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 { | |
| 26 # change '\ ' to ' ' | |
| 27 # change lines with = < > since they mess up field extraction. | |
| 28 # separate into fields delimited by " | |
| 29 cat ${MANUAL}.fn | \ | |
| 30 sed \ | |
| 31 -e 's/(\([^)]*\))/\1/' \ | |
| 32 -e 's/\\dots {}/(\\dots{})/' \ | |
| 33 -e "s/{-}/{{\\tt\\char'055}}/" \ | |
| 34 -e 's,^[^ ]* {,,' \ | |
| 35 -e 's, },},' \ | |
| 36 -e 's,\\ , ,g' \ | |
| 37 -e 's/{\\tt\\char61}/=/' \ | |
| 38 -e 's/{\\tt\\gtr}/>/' \ | |
| 39 -e 's/{\\tt\\less}/</' \ | |
| 40 -e 's/}{/"/g' \ | |
| 41 | awk -F\" '{print $2, $1}' >! permuted.raw | |
| 42 | |
| 43 2: | |
| 44 # Build break file for ptx. | |
| 45 cat <<EOF > permuted.break | |
| 46 - | |
| 47 : | |
| 48 EOF | |
| 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 | |
| 53 the | |
| 54 in | |
| 55 to | |
| 56 as | |
| 57 a | |
| 58 an | |
| 59 of | |
| 60 on | |
| 61 them | |
| 62 how | |
| 63 from | |
| 64 by | |
| 65 EOF | |
| 66 | |
| 67 echo "Make troff permuted index." | |
| 68 ptx -i permuted.ignore -b permuted.break -f -r -w 144 \ | |
| 69 < permuted.raw >! permuted.t | |
| 70 | |
| 71 3: | |
| 72 echo "Extract the desired fields." | |
| 73 awk -F\" '{printf "%s\"%s\"%s\n", $4,$6,$9}' permuted.t >! permuted.fields | |
| 74 | |
| 75 4: | |
| 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}/' \ | |
| 82 -e '/"and /d' \ | |
| 83 -e '/"for /d' \ | |
| 84 | awk -F\" 'NF>0 {if ($1=="") {\ | |
| 85 print "\entry {" $2 "}{" 0+$3 "}{" $2 "}" }\ | |
| 86 else {\ | |
| 87 print "\entry {" $2 ", " $1 "}{" 0+$3 "}{" $2 ", " $1 "}"} }'\ | |
| 88 > permuted.fn | |
| 89 | |
| 90 5: | |
| 91 echo "Sort with texindex." | |
| 92 ${TEXINDEX} permuted.fn | |
| 93 #mv permuted.fns ${MANUAL}.fns | |
| 94 | |
| 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 | |
| 98 | |
| 99 6: | |
| 100 echo "Clean up." | |
| 101 rm -f permuted.fields permuted.t permuted.raw | |
| 102 rm -f permuted.break permuted.ignore permuted.fn |
