[BACK]Return to make_emacs_tags CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari / src

Annotation of OpenXM_contrib/pari/src/make_emacs_tags, Revision 1.1.1.1

1.1       maekawa     1: #!/bin/sh
                      2:
                      3: # Generate a tags file which contains PARI functions, and allows going
                      4: # to help-message for a PARI functions and to a PARI function of C function
                      5: # by repeated C-u M-.
                      6:
                      7: # If you are reading this, you may enjoy imenu-go.el from
                      8: #    ftp://ftp.math.ohio-state.edu/pub/users/ilya/emacs/
                      9:
                     10: # Skip language/init.c, gp/gp_init.c and language/helpmessages.c:
                     11:
                     12: messages='language/helpmsg.c'
                     13: gp_init='gp/gp_init.c'
                     14: init_c='language/init.c'
                     15:
                     16: excluded=`perl -e 'print join "\n",
                     17:                       grep { $_ ne "'$init_c'"
                     18:                             and $_ ne "'$messages'"
                     19:                             and $_ ne "'$gp_init'" }
                     20:                            <*/*.[chs]>, <*/*/*.[chs]>'`
                     21:
                     22: etags $excluded
                     23:
                     24: # Process declarations like
                     25:
                     26: # {"polredord",1,(void*)ordred,6,"Gp"},
                     27:
                     28: # => an entry for polredord, and an entry for ordred as well
                     29: # (so that one may find which PARI function is implemented by the C one)
                     30:
                     31: re='[ \t]*{[ \t]*"\([a-zA-Z_0-9]+\)"[ \t]*,[ \t]*[0-9]+[ \t]*,[ \t]*([ \t]*void[ \t]*\*[ \t]*)[ \t]*\([a-zA-Z0-9+]+\)[ \t]*,'
                     32:
                     33: etags -a -l c -o TAGS.tmp     -r "/$re/\\1/" -r "/$re/\\2/" $init_c
                     34:
                     35: # Process helpmessages too:
                     36: #  "printtex(a): outputs a in TeX format",
                     37:
                     38: helpre='[ \t]*"\([a-zA-Z_0-9]+\)[=(]'
                     39:
                     40: etags -a -l c -o TAGS.tmp     -r "/$re/\\1/" -r "/$re/\\2/" \
                     41:     -r "/$helpre/\\1/"    $gp_init
                     42:
                     43: etags -a -l c -o TAGS.tmp     -r "/$helpre/\\1/"  $messages
                     44:
                     45: # This would produces a wrong entry size - though AFAIK, nobody uses it
                     46: # uniq TAGS.tm >> TAGS
                     47:
                     48: perl -w014pe 'if (s/^(.*\n)\1+/$1/mg) {                # Remove duplicate lines
                     49:                  $chars = chomp;
                     50:                  s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e;
                     51:                  $_ .= ("\f" x $chars);
                     52:              }' TAGS.tmp > TAGS.tm2
                     53:
                     54: # Since we generate *specific* definitions for the functions in the table,
                     55: # they will be prefered by Emacs over non-specific ones for the code, so we
                     56: # convert non-specific definitions into specific ones (with \x1):
                     57:
                     58: perl -w014pe 'if (s/^( [^\n\x7F\x01]*\b        # 1:   TAG group
                     59:                       (\w+)            #   2: word
                     60:                       [^\w\x7F\x01\n]* #      Most anything
                     61:                       \x7F             #      End of description
                     62:                     )
                     63:                     (\d+,\d+\n)        # 3:   TAGS Trail
                     64:                   /$1$2\x01$3/mgx) {   # Add specific marking
                     65:                  $chars = chomp;
                     66:                  s/^((\n.+,)\d+)/ $2 . (length($_) - length($1) - 1) /e;
                     67:                  $_ .= ("\f" x $chars);
                     68:              }' TAGS > TAGS.tm1 && mv TAGS.tm1 TAGS
                     69:
                     70: cat TAGS.tm2 >> TAGS
                     71: rm TAGS.tm*

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>