Trying to create and use a TAGS file with emacs

1 reply [Last post]
Avron

I am a translator!

Offline
Joined: 08/18/2020

I am trying to use emacs TAGS for ASN.1 files. I ran the following command:

etags etags --regex='/^[[:space:]]*([A-Z][A-Za-z0-9-]*)[[:space:]]*::=/\1/' myfile.asn

It has generated a TAGS file. If I try the less command on this TAGS file (even though it is a binary file), I see things like:

P0-PUSCH-AlphaSet AlphaSet25909,1998957
P0-PUSCH-AlphaSetId AlphaSetId25915,1999332

The definition of P0-PUSCH-AlphaSet starts at line 25909 in the file, I don't know what the second number stands for. However, I wonder why AlphaSet is repeated. For each name with one or several dashes (minus sign), the alphanumerical string after the last dash is repeated, while there is no repetition for names without any dash. I suspect the TAGS may be wrong?

Besides:
- the TAGS file has lines starting with -- which seems to totally contradict with the regexp I used.
- many names are missing

So the regexp might be incorrect? I tried replacing [[:space:]] with [ \t], it makes not difference. At least, used with awk with the exact regexp between the first two /, what I get is exactly what I want to catch here.

Then, even for the names in the TAGS file, when I use M-x visit-tag-file, select the TAGS file, emacs says there is no definition for what I am search for. So maybe the TAGS file is anyway wrong?

Any advice is appreciated.

Avron

I am a translator!

Offline
Joined: 08/18/2020

My current findings:

  • --language=none must be used to only use your own regexps
  • to use a back reference, like \1, the opening and closing parenthesis need to be preceeded by a backslash
  • even though the elisp manual says character classes are supported, they don't work with etags

For what I need, the following seems to work:

etags --language=none --regex='/\([A-Z][A-Za-z0-9-]*\)[ \t]*::=/\1/' *.asn