[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
33.3.1 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
andenum
.#define
macro definitions,#undef
andenum
constants are also tags, unless you specify ‘--no-defines’ when making the tags table. Similarly, global variables are tags, unless you specify ‘--no-globals’, and so are struct members, unless you specify ‘--no-members’. Use of ‘--no-globals’, ‘--no-defines’ and ‘--no-members’ can make the tags table file much smaller.You can tag function declarations and external variables in addition to function definitions by giving the ‘--declarations’ option to
etags
. -
In C++ code, in addition to all the tag constructs of C code, member
functions are also recognized; member variables are also recognized,
unless you use the ‘--no-members’ option. Tags for variables and
functions in classes are named ‘class::variable’ and
‘class::function’.
operator
definitions have tag names like ‘operator+’. -
In Java code, tags include all the constructs recognized in C++, plus
the
interface
,extends
andimplements
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
,\index
,\def
,\newcommand
,\renewcommand
,\newenvironment
or\renewenvironment
is a tag.Other commands can make tags as well, if you specify them in the environment variable
TEXTAGS
before invokingetags
. The value of this environment variable should be a colon-separated list of command names. For example,TEXTAGS="mycommand:myothercommand" export TEXTAGS
specifies (using Bourne shell syntax) that the commands ‘\mycommand’ and ‘\myothercommand’ also define tags.
-
In Lisp code, any function defined with
defun
, any variable defined withdefvar
ordefconst
, 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 withset!
at top level in the file.
Several other languages are also supported:
-
In Ada code, functions, procedures, packages, tasks and types are
tags. Use the ‘--packages-only’ option to create tags for
packages only.
In Ada, the same name can be used for different kinds of entity (e.g., for a procedure and for a function). Also, for things like packages, procedures and functions, there is the spec (i.e. the interface) and the body (i.e. the implementation). To make it easier to pick the definition you want, Ada tag name have suffixes indicating the type of entity:
- ‘/b’
package body.
- ‘/f’
function.
- ‘/k’
task.
- ‘/p’
procedure.
- ‘/s’
package spec.
- ‘/t’
type.
Thus, M-x find-tag <RET> bidule/b <RET> will go directly to the body of the package
bidule
, while M-x find-tag <RET> bidule <RET> will just search for any tagbidule
. - 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 block data are tags.
-
In HTML input files, the tags are the
title
and theh1
,h2
,h3
headers. Also, tags arename=
in anchors and all occurrences ofid=
. - In Lua input files, all functions are tags.
- In makefiles, targets are tags; additionally, variables are tags unless you specify ‘--no-globals’.
- In Objective C code, tags include Objective C definitions for classes, class categories, methods and protocols. Tags for variables and functions in classes are named ‘class::variable’ and ‘class::function’.
- In Pascal code, the tags are the functions and procedures defined in the file.
-
In Perl code, the tags are the packages, subroutines and variables
defined by the
package
,sub
,my
andlocal
keywords. Use ‘--globals’ if you want to tag global variables. Tags for subroutines are named ‘package::sub’. The name for subroutines defined in the default package is ‘main::sub’. - In PHP code, tags are functions, classes and defines. Vars are tags too, unless you use the ‘--no-members’ option.
- In PostScript code, the tags are the functions.
- In Prolog code, tags are predicates and rules at the beginning of line.
-
In Python code,
def
orclass
at the beginning of a line generate a tag.
You can also generate tags based on regexp matching (see section Etags Regexps) to handle other formats and languages.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |