Sync to HEAD
[bpt/emacs.git] / etc / etags.1
CommitLineData
f9f999d9 1.\" Copyright (c) 1992, 2001 Free Software Foundation
a933dad1 2.\" See section COPYING for conditions for redistribution
544b00c1 3.TH etags 1 "23nov2001" "GNU Tools" "GNU Tools"
a933dad1
DL
4.de BP
5.sp
6.ti -.2i
7\(**
8..
9
10.SH NAME
11etags, ctags \- generate tag file for Emacs, vi
12.SH SYNOPSIS
13.hy 0
14.na
e6dd1a49 15\fBetags\fP [\|\-aCDGImRVh\|] [\|\-i \fIfile\fP\|] [\|\-l \fIlanguage\fP\|]
8dc78b52 16.if n .br
e6dd1a49 17[\|\-o \fItagfile\fP\|] [\|\-r \fIregexp\fP\|]
0f374b8b 18[\|\-\-parse\-stdin=\fIfile\fP\|]
8dc78b52 19.br
e6dd1a49 20[\|\-\-append\|] [\|\-\-no\-defines\|]
8dc78b52
FP
21[\|\-\-no\-globals\|] [\|\-\-include=\fIfile\fP\|]
22[\|\-\-ignore\-indentation\|] [\|\-\-language=\fIlanguage\fP\|]
23[\|\-\-members\|] [\|\-\-output=\fItagfile\fP\|]
24[\|\-\-regex=\fIregexp\fP\|] [\|\-\-no\-regex\|]
25[\|\-\-help\|] [\|\-\-version\|]
26\fIfile\fP .\|.\|.
a933dad1 27
e6dd1a49 28\fBctags\fP [\|\-aCdgImRVh\|] [\|\-BtTuvwx\|] [\|\-l \fIlanguage\fP\|]
8dc78b52 29.if n .br
e6dd1a49 30[\|\-o \fItagfile\fP\|] [\|\-r \fIregexp\fP\|]
0f374b8b 31[\|\-\-parse\-stdin=\fIfile\fP\|]
8dc78b52 32.br
e6dd1a49 33[\|\-\-append\|] [\|\-\-backward\-search\|]
8dc78b52
FP
34[\|\-\-cxref\|] [\|\-\-defines\|] [\|\-\-forward\-search\|]
35[\|\-\-globals\|] [\|\-\-ignore\-indentation\|]
36[\|\-\-language=\fIlanguage\fP\|] [\|\-\-members\|]
37[\|\-\-output=\fItagfile\fP\|] [\|\-\-regex=\fIregexp\fP\|]
38[\|\-\-typedefs\|] [\|\-\-typedefs\-and\-c++\|]
39[\|\-\-update\|] [\|\-\-no\-warn\|]
a933dad1 40[\|\-\-help\|] [\|\-\-version\|]
8dc78b52 41\fIfile\fP .\|.\|.
a933dad1
DL
42.ad b
43.hy 1
44.SH DESCRIPTION
f9f999d9 45The \|\fBetags\fP\| program is used to create a tag table file, in a format
a933dad1
DL
46understood by
47.BR emacs ( 1 )\c
f9f999d9 48\&; the \|\fBctags\fP\| program is used to create a similar table in a
a933dad1
DL
49format understood by
50.BR vi ( 1 )\c
51\&. Both forms of the program understand
2c37653c 52the syntax of C, Objective C, C++, Java, Fortran, Ada, Cobol, Erlang, HTML,
e94a3679 53LaTeX, Emacs Lisp/Common Lisp, makefiles, Pascal, Perl, PHP, Postscript,
e6dd1a49 54Python, Prolog, Scheme and
8dc78b52 55most assembler\-like syntaxes.
a933dad1 56Both forms read the files specified on the command line, and write a tag
f9f999d9 57table (defaults: \fBTAGS\fP for \fBetags\fP, \fBtags\fP for
a933dad1
DL
58\fBctags\fP) in the current working directory.
59Files specified with relative file names will be recorded in the tag
60table with file names relative to the directory where the tag table
61resides. Files specified with absolute file names will be recorded
0eaa5fcc
FP
62with absolute file names. Files generated from a source file\-\-like
63a C file generated from a source Cweb file\-\-will be recorded with
64the name of the source file.
a933dad1 65The programs recognize the language used in an input file based on its
f9f999d9 66file name and contents. The \fB\-\-language\fP switch can be used to force
a933dad1
DL
67parsing of the file names following the switch according to the given
68language, overriding guesses based on filename extensions.
69.SH OPTIONS
70Some options make sense only for the \fBvi\fP style tag files produced
71by ctags;
72\fBetags\fP does not recognize them.
73The programs accept unambiguous abbreviations for long option names.
74.TP
75.B \-a, \-\-append
f9f999d9 76Append to existing tag file. (For \fBvi\fP-format tag files, see also
a933dad1
DL
77\fB\-\-update\fP.)
78.TP
79.B \-B, \-\-backward\-search
80Tag files written in the format expected by \fBvi\fP contain regular
81expression search instructions; the \fB\-B\fP option writes them using
82the delimiter `\|\fB?\fP\|', to search \fIbackwards\fP through files.
83The default is to use the delimiter `\|\fB/\fP\|', to search \fIforwards\fP
84through files.
85Only \fBctags\fP accepts this option.
86.TP
8dc78b52
FP
87.B \-\-declarations
88In C and derived languages, create tags for function declarations,
89and create tags for extern variables unless \-\-no\-globals is used.
90.TP
a933dad1 91.B \-d, \-\-defines
8dc78b52
FP
92Create tag entries for C preprocessor constant definitions
93and enum constants, too. This is the
94default behavior for \fBetags\fP.
a933dad1
DL
95.TP
96.B \-D, \-\-no\-defines
8dc78b52
FP
97Do not create tag entries for C preprocessor constant definitions
98and enum constants.
a933dad1 99This may make the tags file much smaller if many header files are tagged.
8dc78b52
FP
100This is the default behavior for \fBctags\fP.
101.TP
102.B \-g, \-\-globals
103Create tag entries for global variables in C, C++, Objective C, Java,
104and Perl.
105This is the default behavior for \fBetags\fP.
106.TP
107.B \-G, \-\-no\-globals
108Do not tag global variables. Typically this reduces the file size by
109one fourth. This is the default behavior for \fBctags\fP.
110.TP
111\fB\-i\fP \fIfile\fP, \fB\-\-include=\fIfile\fP
112Include a note in the tag file indicating that, when searching for a
113tag, one should also consult the tags file \fIfile\fP after checking the
114current file. This options is only accepted by \fBetags\fP.
115.TP
116.B \-I, \-\-ignore\-indentation
117Don't rely on indentation as much as we normally do. Currently, this
118means not to assume that a closing brace in the first column is the
119final brace of a function or structure definition in C and C++.
a933dad1
DL
120.TP
121\fB\-l\fP \fIlanguage\fP, \fB\-\-language=\fIlanguage\fP
122Parse the following files according to the given language. More than
123one such options may be intermixed with filenames. Use \fB\-\-help\fP
124to get a list of the available languages and their default filename
125extensions. The `auto' language can be used to restore automatic
e6dd1a49 126detection of language based on the file name. The `none'
a933dad1
DL
127language may be used to disable language parsing altogether; only
128regexp matching is done in this case (see the \fB\-\-regex\fP option).
129.TP
8dc78b52
FP
130.B \-m, \-\-members
131Create tag entries for variables that are members of structure-like
132constructs in C++, Objective C, Java.
133.TP
134.B \-M, \-\-no\-members
135Do not tag member variables. This is the default behavior.
136.TP
137.B \-\-packages\-only
138Only tag packages in Ada files.
139.TP
0f374b8b
FP
140\fB\-\-parse\-stdin=\fIfile\fP
141May be used (only once) in place of a file name on the command line.
5cc4f104 142\fBetags\fP will read from standard input and mark the produced tags
0f374b8b
FP
143as belonging to the file \fBFILE\fP.
144.TP
a933dad1 145\fB\-o\fP \fItagfile\fP, \fB\-\-output=\fItagfile\fP
f9f999d9
EZ
146Explicit name of file for tag table; overrides default \fBTAGS\fP or
147\fBtags\fP. (But ignored with \fB\-v\fP or \fB\-x\fP.)
a933dad1
DL
148.TP
149\fB\-r\fP \fIregexp\fP, \fB\-\-regex=\fIregexp\fP
6861f0e3
FP
150
151Make tags based on regexp matching for the files following this option,
152in addition to the tags made with the standard parsing based on
153language. May be freely intermixed with filenames and the \fB\-R\fP
154option. The regexps are cumulative, i.e. each such option will add to
df3eebcb 155the previous ones. The regexps are of one of the forms:
a933dad1 156.br
df3eebcb
FP
157 [\fB{\fP\fIlanguage\fP\fB}\fP]\fB/\fP\fItagregexp/\fP[\fInameregexp\fP\fB/\fP]\fImodifiers\fP
158.br
159 \fB@\fP\fIregexfile\fP
a933dad1
DL
160.br
161
6861f0e3
FP
162where \fItagregexp\fP is used to match the tag. It should not match
163useless characters. If the match is such that more characters than
164needed are unavoidably matched by \fItagregexp\fP, it may be useful to
165add a \fInameregexp\fP, to narrow down the tag scope. \fBctags\fP
166ignores regexps without a \fInameregexp\fP. The syntax of regexps is
167the same as in emacs. The following character escape sequences are
168supported: \\a, \\b, \\d, \\e, \\f, \\n, \\r, \\t, \\v, which
169respectively stand for the ASCII characters BEL, BS, DEL, ESC, FF, NL,
170CR, TAB, VT.
171.br
172The \fImodifiers\fP are a sequence of 0 or more characters among
173\fIi\fP, which means to ignore case when matching; \fIm\fP, which means
174that the \fItagregexp\fP will be matched against the whole file contents
175at once, rather than line by line, and the matching sequence can match
176multiple lines; and \fIs\fP, which implies \fIm\fP and means that the
177dot character in \fItagregexp\fP matches the newline char as well.
df3eebcb 178.br
3bc04ecc
FP
179The separator, which is \fB/\fP in the examples, can be any character
180different from space, tab, braces and \fB@\fP. If the separator
181character is needed inside the regular expression, it must be quoted
182by preceding it with \fB\\\fP.
183.br
184The optional \fB{\fP\fIlanguage\fP\fB}\fP prefix means that the tag
185should be
df3eebcb
FP
186created only for files of language \fIlanguage\fP, and ignored
187otherwise. This is particularly useful when storing many predefined
188regexps in a file.
189.br
3bc04ecc
FP
190In its second form, \fIregexfile\fP is the name of a file that contains
191a number of arguments to the \fI\-\-regex\=\fP option,
192one per line. Lines beginning with a space or tab are assumed
df3eebcb 193to be comments, and ignored.
b4b39c67 194
a933dad1
DL
195.br
196Here are some examples. All the regexps are quoted to protect them
197from shell interpretation.
198.br
199
200Tag the DEFVAR macros in the emacs source files:
201.br
202\fI\-\-regex\='/[ \\t]*DEFVAR_[A-Z_ \\t(]+"\\([^"]+\\)"\/'\fP
e94a3679 203.\"" This comment is to avoid confusion to Emacs syntax highlighting
a933dad1
DL
204.br
205
206Tag VHDL files (this example is a single long line, broken here for
207formatting reasons):
208.br
209\fI\-\-language\=none\ \-\-regex='/[\ \\t]*\\(ARCHITECTURE\\|\\
210CONFIGURATION\\)\ +[^\ ]*\ +OF/'\ \-\-regex\='/[\ \\t]*\\
211\\(ATTRIBUTE\\|ENTITY\\|FUNCTION\\|PACKAGE\\(\ BODY\\)?\\
212\\|PROCEDURE\\|PROCESS\\|TYPE\\)[\ \\t]+\\([^\ \\t(]+\\)/\\3/'\fP
213.br
214
a933dad1
DL
215Tag TCL files (this last example shows the usage of a \fItagregexp\fP):
216.br
217\fI\-\-lang\=none \-\-regex\='/proc[\ \\t]+\\([^\ \\t]+\\)/\\1/'\fP
218
caac7f2c 219.br
e6dd1a49 220A regexp can be preceded by {\fIlang\fP}, thus restricting it to match
f9f999d9
EZ
221lines of files of the specified language. Use \fBetags --help\fP to obtain
222a list of the recognised languages. This feature is particularly useful inside
223\fBregex files\fP. A regex file contains one regex per line. Empty lines,
caac7f2c
FP
224and those lines beginning with space or tab are ignored. Lines beginning
225with @ are references to regex files whose name follows the @ sign. Other
f9f999d9 226lines are considered regular expressions like those following \fB\-\-regex\fP.
caac7f2c
FP
227.br
228For example, the command
229.br
f9f999d9 230\fIetags \-\-regex=@regex.file *.c\fP
caac7f2c
FP
231.br
232reads the regexes contained in the file regex.file.
a933dad1
DL
233.TP
234.B \-R, \-\-no\-regex
235Don't do any more regexp matching on the following files. May be
236freely intermixed with filenames and the \fB\-\-regex\fP option.
237.TP
a933dad1 238.B \-t, \-\-typedefs
f76041d5 239Record typedefs in C code as tags. Since this is the default behavior
a933dad1
DL
240of \fBetags\fP, only \fBctags\fP accepts this option.
241.TP
242.B \-T, \-\-typedefs\-and\-c++
243Generate tag entries for typedefs, struct, enum, and union tags, and
f76041d5 244C++ member functions. Since this is the default behavior
a933dad1
DL
245of \fBetags\fP, only \fBctags\fP accepts this option.
246.TP
247.B \-u, \-\-update
248Update tag entries for \fIfiles\fP specified on command line, leaving
249tag entries for other files in place. Currently, this is implemented
250by deleting the existing entries for the given files and then
251rewriting the new entries at the end of the tags file. It is often
252faster to simply rebuild the entire tag file than to use this.
253Only \fBctags\fP accepts this option.
254.TP
255.B \-v, \-\-vgrind
256Instead of generating a tag file, write index (in \fBvgrind\fP format)
257to standard output. Only \fBctags\fP accepts this option.
258.TP
259.B \-w, \-\-no\-warn
260Suppress warning messages about duplicate entries. The \fBetags\fP
261program does not check for duplicate entries, so this option is not
262allowed with it.
263.TP
264.B \-x, \-\-cxref
265Instead of generating a tag file, write a cross reference (in
266\fBcxref\fP format) to standard output. Only \fBctags\fP accepts this option.
267.TP
8dc78b52 268.B \-h, \-H, \-\-help
a933dad1
DL
269Print usage information.
270.TP
271.B \-V, \-\-version
272Print the current version of the program (same as the version of the
273emacs \fBetags\fP is shipped with).
274
275.SH "SEE ALSO"
276`\|\fBemacs\fP\|' entry in \fBinfo\fP; \fIGNU Emacs Manual\fP, Richard
277Stallman.
278.br
279.BR cxref ( 1 ),
280.BR emacs ( 1 ),
281.BR vgrind ( 1 ),
282.BR vi ( 1 ).
283
284.SH COPYING
e6dd1a49 285Copyright
8cd13fd1
EZ
286.if t \(co
287.if n (c)
2881999, 2001 Free Software Foundation, Inc.
a933dad1 289.PP
544b00c1
EZ
290Permission is granted to make and distribute verbatim copies of this
291document provided the copyright notice and this permission notice are
292preserved on all copies.
a933dad1 293.PP
544b00c1
EZ
294Permission is granted to copy and distribute modified versions of
295this document under the conditions for verbatim copying, provided that
296the entire resulting derived work is distributed under the terms of
297a permission notice identical to this one.
298.PP
299Permission is granted to copy and distribute translations of this
300document into another language, under the above conditions for
301modified versions, except that this permission notice may be stated
302in a translation approved by the Free Software Foundation.
6b61353c
KH
303
304.\" arch-tag: 9534977f-af78-42f0-991d-1df6b6c05573