GNU Emacs Manual - Tag Syntax

Go to the first, previous, next, last section, table of contents.

### Source File Tag Syntax

Here is how tag syntax is defined for the most popular languages:

- In C code, any C function or typedef is a tag, and so are definitions of `struct`, `union` and `enum`. `#define` macro definitions and `enum` constants are also tags, unless you specify ``--no-defines'` when making the tags table. Similarly, global variables are tags, unless you specify ``--no-globals'`. Use of ``--no-globals'` and ``--no-defines'` can make the tags table file much smaller.
- In C++ code, in addition to all the tag constructs of C code, member functions are also recognized, and optionally member variables if you use the ``--members'` option. Tags for variables and functions in classes are named ``class::variable'` and ``class::function'`.
- In Java code, tags include all the constructs recognized in C++, plus the `extends` and `implements` constructs. Tags for variables and functions in classes are named ``class.variable'` and ``class.function'`.
- In LaTeX text, the argument of any of the commands `\chapter`, `\section`, `\subsection`, `\subsubsection`, `\eqno`, `\label`, `\ref`, `\cite`, `\bibitem`, `\part`, `\appendix`, `\entry`, or `\index`, is a tag. Other commands can make tags as well, if you specify them in the environment variable `TEXTAGS` before invoking `etags`. The value of this environment variable should be a colon-separated list of command names. For example,

      TEXTAGS="def:newcommand:newenvironment"
      export TEXTAGS

  specifies (using Bourne shell syntax) that the commands ``\def'`, ``\newcommand'` and ``\newenvironment'` also define tags.
- In Lisp code, any function defined with `defun`, any variable defined with `defvar` or `defconst`, and in general the first argument of any expression that starts with ``(def'` in column zero, is a tag.
- In Scheme code, tags include anything defined with `def` or with a construct whose name starts with ``def'`. They also include variables set with `set!` at top level in the file.

Several other languages are also supported:

- In assembler code, labels appearing at the beginning of a line, followed by a colon, are tags.
- In Bison or Yacc input files, each rule defines as a tag the nonterminal it constructs. The portions of the file that contain C code are parsed as C code.
- In Cobol code, tags are paragraph names; that is, any word starting in column 8 and followed by a period.
- In Erlang code, the tags are the functions, records, and macros defined in the file.
- In Fortran code, functions, subroutines and blockdata are tags.
- In Objective C code, tags include Objective C definitions for classes, class categories, methods, and protocols.
- In Pascal code, the tags are the functions and procedures defined in the file.
- In Perl code, the tags are the procedures defined by the `sub` keyword.
- In Postscript code, the tags are the functions.
- In Prolog code, a tag name appears at the left margin.

You can also generate tags based on regexp matching (see section Creating Tags Tables) to handle other formats and languages.

Go to the first, previous, next, last section, table of contents.