Ilya Zakharevich on Tue, 21 Apr 1998 08:29:25 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
make etags |
This makes make etags generate quite smart TAGS file. How smart: read below. Enjoy, Ilya --- ./src/make_tags~ Mon Apr 20 23:36:02 1998 +++ ./src/make_tags Tue Apr 21 01:12:14 1998 @@ -0,0 +1,67 @@ +#!/bin/sh + +# Generate a tags file which contains PARI functions, and allows going +# to help-message for a PARI functions and to a PARI function of C function +# by repeated C-u M-. + +# If you are reading this, you may enjoy imenu-go.el from +# ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs/ + +# Skip language/init.c, gp/gp_init.c and language/helpmessages.c: + +excluded=`perl -e 'print join "\n", + grep { $_ ne "language/init.c" + and $_ ne "language/helpmessages.c" + and $_ ne "gp/gp_init.c" } + <*/*.[chs]>, <*/*/*.[chs]>'` + +etags $excluded + +# Process declarations like + +# {"polredord",1,(void*)ordred,6,"Gp"}, + +# => an entry for polredord, and an entry for ordred as well +# (so that one may find which PARI function is implemented by the C one) + +re='[ \t]*{[ \t]*"\([a-zA-Z_0-9]+\)"[ \t]*,[ \t]*[0-9]+[ \t]*,[ \t]*([ \t]*void[ \t]*\*[ \t]*)[ \t]*\([a-zA-Z0-9+]+\)[ \t]*,' + +etags -a -l c -o TAGS.tmp -r "/$re/\\1/" -r "/$re/\\2/" language/init.c + +# Process helpmessages too: +# "printtex(a): outputs a in TeX format", + +helpre='[ \t]*"\([a-zA-Z_0-9]+\)[=(]' + +etags -a -l c -o TAGS.tmp -r "/$re/\\1/" -r "/$re/\\2/" \ + -r "/$helpre/\\1/" gp/gp_init.c + +etags -a -l c -o TAGS.tmp -r "/$helpre/\\1/" language/helpmessages.c + +# This would produces a wrong entry size - though AFAIK, nobody uses it +# uniq TAGS.tm >> TAGS + +perl -w014pe 'if (s/^(.*\n)\1+/$1/mg) { # Remove duplicate lines + $chars = chomp; + s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; + $_ .= ("\f" x $chars); + }' TAGS.tmp > TAGS.tm2 + +# Since we generate *specific* definitions for the functions in the table, +# they will be prefered by Emacs over non-specific ones for the code, so we +# convert non-specific definitions into specific ones (with \x1): + +perl -w014pe 'if (s/^( [^\n\x7F\x1]*\b # 1: TAG group + (\w+) # 2: word + [^\w\x7X\x1\n]* # Most anything + \x7F # End of description + ) + (\d+,\d+\n) # 3: TAGS Trail + /$1$2\x1$3/mgx) { # Add specific marking + $chars = chomp; + s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e; + $_ .= ("\f" x $chars); + }' TAGS > TAGS.tm1 && mv TAGS.tm1 TAGS + +cat TAGS.tm2 >> TAGS +rm TAGS.tm* --- ./config/TOP_Makefile.SH~ Sat Feb 7 11:15:26 1998 +++ ./config/TOP_Makefile.SH Tue Apr 21 00:12:36 1998 @@ -71,6 +71,9 @@ bigtar: tar tar:: rm -f $tarfile.gz + +etags: + cd src ; sh make_tags EOT case "`tar 2>&1`" in *"--help"*) cat >> $file << EOT