33.2.2 Creating Tags Tables
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 program reads the specified files, and writes a tags
table named TAGS in the current working directory.
If the specified files don't exist,
etags looks for
compressed versions of them and uncompresses them to read them. Under
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. If the tags table fails to record
a tag, or records it for the wrong file, then Emacs cannot possibly
find its definition until you update the tags table. However, if the
position recorded in the tags table becomes a little bit wrong (due to
other editing), the only consequence is a slight delay in finding the
tag. Even if the stored position is very far wrong, Emacs will still
find the tag, after searching most of the file for it. Even that
delay is hardly noticeable with today's computers.
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 virtually 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 covered all the source 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 the tags file is in /dev, however, the file names are
made relative to the current working directory.
If you specify absolute file names as arguments to
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
etags recognizes tags by regexp matching alone
(see Etags Regexps).
The option ‘--parse-stdin=file’ is mostly useful when
etags from programs. It can be used (only once) in
place of a file name on the command line.
Etags will read from
standard input and mark the produced tags as belonging to the file
‘etags --help’ prints the list of the languages
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. If followed by one or more ‘--language=lang’
options, prints detailed information about how tags are generated for