Next: , Previous: , Up: Tags   [Contents][Index]


21.11.2 Creating Tags Tables

The etags program is used to create a tags table file. It knows the syntax of several languages, as described in Here is how to run etags:

etags inputfiles

The etags program reads the specified files, and writes a tags table named TAGS in the current working directory. You can intermix compressed and plain text source file names. etags knows about the most common compression formats, and does the right thing. So you can compress all your source files and have etags look for compressed versions of its file name arguments, if it does not find uncompressed versions. Under MS-DOS, etags also looks for file names like ‘mycode.cgz’ if it is given ‘mycode.c’ on the command line and ‘mycode.c’ does not exist.

etags recognizes the language used in an input file based on its file name and contents. You can specify the language with the ‘--language=name’ option, described below.

If the tags table data become outdated due to changes in the files described in the table, the way to update the tags table is the same way it was made in the first place. It is not necessary to do this often.

If the tags table fails to record a tag, or records it for the wrong file, then Emacs cannot possibly find its definition. However, if the position recorded in the tags table becomes a little bit wrong (due to some editing in the file that the tag definition is in), the only consequence is a slight delay in finding the tag. Even if the stored position is very wrong, Emacs will still find the tag, but it must search the entire file for it.

So you should update a tags table when you define new tags that you want to have listed, or when you move tag definitions from one file to another, or when changes become substantial. Normally there is no need to update the tags table after each edit, or even every day.

One tags table can effectively include another. Specify the included tags file name with the ‘--include=file’ option when creating the file that is to include it. The latter file then acts as if it contained all the files specified in the included file, as well as the files it directly contains.

If you specify the source files with relative file names when you run etags, the tags file will contain file names relative to the directory where the tags file was initially written. This way, you can move an entire directory tree containing both the tags file and the source files, and the tags file will still refer correctly to the source files.

If you specify absolute file names as arguments to etags, then the tags file will contain absolute file names. This way, the tags file will still refer to the same files even if you move it, as long as the source files remain in the same place. Absolute file names start with ‘/’, or with ‘device:/’ on MS-DOS and MS-Windows.

When you want to make a tags table from a great number of files, you may have problems listing them on the command line, because some systems have a limit on its length. The simplest way to circumvent this limit is to tell etags to read the file names from its standard input, by typing a dash in place of the file names, like this:

find . -name "*.[chCH]" -print | etags -

Use the option ‘--language=name’ to specify the language explicitly. You can intermix these options with file names; each one applies to the file names that follow it. Specify ‘--language=auto’ to tell etags to resume guessing the language from the file names and file contents. Specify ‘--language=none’ to turn off language-specific processing entirely; then etags recognizes tags by regexp matching alone (see Etags Regexps).

etags --help’ prints the list of the languages etags knows, and the file name rules for guessing the language. It also prints a list of all the available etags options, together with a short explanation.


Next: , Previous: , Up: Tags   [Contents][Index]