Mercurial > hg > xemacs-beta
comparison man/xemacs/programs.texi @ 155:43dd3413c7c7 r20-3b4
Import from CVS: tag r20-3b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:39:39 +0200 |
parents | 131b0175ea99 |
children | 972bbb6d6ca2 |
comparison
equal
deleted
inserted
replaced
154:94141801dd7e | 155:43dd3413c7c7 |
---|---|
1007 @section Tags Tables | 1007 @section Tags Tables |
1008 @cindex tags table | 1008 @cindex tags table |
1009 | 1009 |
1010 A @dfn{tags table} is a description of how a multi-file program is | 1010 A @dfn{tags table} is a description of how a multi-file program is |
1011 broken up into files. It lists the names of the component files and the | 1011 broken up into files. It lists the names of the component files and the |
1012 names and positions of the functions in each file. Grouping the related | 1012 names and positions of the functions (or other named subunits) in each |
1013 files makes it possible to search or replace through all the files with | 1013 file. Grouping the related files makes it possible to search or replace |
1014 one command. Recording the function names and positions makes it | 1014 through all the files with one command. Recording the function names |
1015 possible to use the @kbd{Meta-.} command, which finds the definition of a | 1015 and positions makes possible the @kbd{M-.} command which finds the |
1016 function without asking for information on the file it is in. | 1016 definition of a function by looking up which of the files it is in. |
1017 | 1017 |
1018 tags tables are stored in files called @dfn{tags table files}. The | 1018 Tags tables are stored in files called @dfn{tags table files}. The |
1019 conventional name for a tags table file is @file{TAGS}. | 1019 conventional name for a tags table file is @file{TAGS}. |
1020 | 1020 |
1021 Each entry in the tags table records the name of one tag, the name of the | 1021 Each entry in the tags table records the name of one tag, the name of the |
1022 file that the tag is defined in (implicitly), and the position in that file | 1022 file that the tag is defined in (implicitly), and the position in that file |
1023 of the tag's definition. | 1023 of the tag's definition. |
1024 | 1024 |
1025 The programming language of a file determines what names are recorded | 1025 Just what names from the described files are recorded in the tags table |
1026 in the tags table depends on. Normally, Emacs includes all functions and | 1026 depends on the programming language of the described file. They |
1027 subroutines, and may also include global variables, data types, and | 1027 normally include all functions and subroutines, and may also include |
1028 anything else convenient. Each recorded name is called a @dfn{tag}. | 1028 global variables, data types, and anything else convenient. Each name |
1029 recorded is called a @dfn{tag}. | |
1029 | 1030 |
1030 @menu | 1031 @menu |
1031 * Tag Syntax:: Tag syntax for various types of code and text files. | 1032 * Tag Syntax:: Tag syntax for various types of code and text files. |
1032 * Create Tags Table:: Creating a tags table with @code{etags}. | 1033 * Create Tags Table:: Creating a tags table with @code{etags}. |
1033 * Select Tags Table:: How to visit a tags table. | 1034 * Select Tags Table:: How to visit a tags table. |
1034 * Find Tag:: Commands to find the definition of a specific tag. | 1035 * Find Tag:: Commands to find the definition of a specific tag. |
1035 * Tags Search:: Using a tags table for searching and replacing. | 1036 * Tags Search:: Using a tags table for searching and replacing. |
1036 * List Tags:: Listing and finding tags defined in a file. | 1037 * List Tags:: Listing and finding tags defined in a file. |
1037 @end menu | 1038 @end menu |
1038 | 1039 |
1039 @node Tag Syntax, Create Tags Table, Tags, Tags | 1040 @node Tag Syntax |
1040 @subsection Source File Tag Syntax | 1041 @subsection Source File Tag Syntax |
1041 | 1042 |
1043 Here is how tag syntax is defined for the most popular languages: | |
1044 | |
1042 @itemize @bullet | 1045 @itemize @bullet |
1043 @item | |
1044 In Lisp code, any function defined with @code{defun}, any variable | |
1045 defined with @code{defvar} or @code{defconst}, and in general the first | |
1046 argument of any expression that starts with @samp{(def} in column zero, is | |
1047 a tag. | |
1048 | |
1049 @item | |
1050 In Scheme code, tags include anything defined with @code{def} or with a | |
1051 construct whose name starts with @samp{def}. They also include variables | |
1052 set with @code{set!} at top level in the file. | |
1053 | |
1054 @item | 1046 @item |
1055 In C code, any C function or typedef is a tag, and so are definitions of | 1047 In C code, any C function or typedef is a tag, and so are definitions of |
1056 @code{struct}, @code{union} and @code{enum}. @code{#define} macro | 1048 @code{struct}, @code{union} and @code{enum}. @code{#define} macro |
1057 definitions and @code{enum} constant are also tags, unless | 1049 definitions and @code{enum} constants are also tags, unless you specify |
1058 @samp{--no-defines} is specified when the tags table is constructed, | 1050 @samp{--no-defines} when making the tags table. Similarly, global |
1059 which sometimes makes the tags file much smaller. In C++ code, member | 1051 variables are tags, unless you specify @samp{--no-globals}. Use of |
1060 functions are also recognized. | 1052 @samp{--no-globals} and @samp{--no-defines} can make the tags table file |
1061 | 1053 much smaller. |
1062 @item | 1054 |
1063 In Yacc or Bison input files, each rule defines as a tag the | 1055 @item |
1064 nonterminal it constructs. The portions of the file that contain C code | 1056 In C++ code, in addition to all the tag constructs of C code, member |
1065 are parsed as C code. | 1057 functions are also recognized, and optionally member variables if you |
1066 | 1058 use the @samp{--members} option. Tags for variables and functions in |
1067 @item | 1059 classes are named @samp{@var{class}::@var{variable}} and |
1068 In Fortran code, functions and subroutines are tags. | 1060 @samp{@var{class}::@var{function}}. |
1069 | 1061 |
1070 @item | 1062 @item |
1071 In Pascal code, the tags are the functions and procedures defined in | 1063 In Java code, tags include all the constructs recognized in C++, plus |
1072 the file. | 1064 the @code{extends} and @code{implements} constructs. Tags for variables |
1073 | 1065 and functions in classes are named @samp{@var{class}.@var{variable}} and |
1074 @item | 1066 @samp{@var{class}.@var{function}}. |
1075 In Perl code, the tags are the procedures defined by the @code{sub} | |
1076 keyword. | |
1077 | |
1078 @item | |
1079 In Prolog code, a tag name appears at the left margin. | |
1080 | |
1081 @item | |
1082 In Erlang code, the tags are the functions, records, and macros defined | |
1083 in the file. | |
1084 | |
1085 @item | |
1086 In assembler code, labels appearing at the beginning of a line, | |
1087 followed by a colon, are tags. | |
1088 | 1067 |
1089 @item | 1068 @item |
1090 In La@TeX{} text, the argument of any of the commands @code{\chapter}, | 1069 In La@TeX{} text, the argument of any of the commands @code{\chapter}, |
1091 @code{\section}, @code{\subsection}, @code{\subsubsection}, | 1070 @code{\section}, @code{\subsection}, @code{\subsubsection}, |
1092 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem}, | 1071 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem}, |
1106 @noindent | 1085 @noindent |
1107 specifies (using Bourne shell syntax) that the commands @samp{\def}, | 1086 specifies (using Bourne shell syntax) that the commands @samp{\def}, |
1108 @samp{\newcommand} and @samp{\newenvironment} also define tags. | 1087 @samp{\newcommand} and @samp{\newenvironment} also define tags. |
1109 | 1088 |
1110 @item | 1089 @item |
1111 You can also generate tags based on regexp matching | 1090 In Lisp code, any function defined with @code{defun}, any variable |
1112 (@pxref{Create Tags Table}) for any text file. | 1091 defined with @code{defvar} or @code{defconst}, and in general the first |
1092 argument of any expression that starts with @samp{(def} in column zero, is | |
1093 a tag. | |
1094 | |
1095 @item | |
1096 In Scheme code, tags include anything defined with @code{def} or with a | |
1097 construct whose name starts with @samp{def}. They also include variables | |
1098 set with @code{set!} at top level in the file. | |
1113 @end itemize | 1099 @end itemize |
1114 | 1100 |
1115 @node Create Tags Table, Select Tags Table, Tag Syntax, Tags | 1101 Several other languages are also supported: |
1102 | |
1103 @itemize @bullet | |
1104 @item | |
1105 In assembler code, labels appearing at the beginning of a line, | |
1106 followed by a colon, are tags. | |
1107 | |
1108 @item | |
1109 In Bison or Yacc input files, each rule defines as a tag the nonterminal | |
1110 it constructs. The portions of the file that contain C code are parsed | |
1111 as C code. | |
1112 | |
1113 @item | |
1114 In Cobol code, paragraphs names are the tags, i.e. any word starting in | |
1115 column 8 and followed by a full stop. | |
1116 | |
1117 @item | |
1118 In Erlang code, the tags are the functions, records, and macros defined | |
1119 in the file. | |
1120 | |
1121 @item | |
1122 In Fortran code, functions and subroutines are tags. | |
1123 | |
1124 @item | |
1125 In Objective C code, tags include Objective C definitions for classes, | |
1126 class categories, methods and protocols. | |
1127 | |
1128 @item | |
1129 In Pascal code, the tags are the functions and procedures defined in | |
1130 the file. | |
1131 | |
1132 @item | |
1133 In Perl code, the tags are the procedures defined by the @code{sub} | |
1134 keyword. | |
1135 | |
1136 @item | |
1137 In Postscript code, the tags are the functions. | |
1138 | |
1139 @item | |
1140 In Prolog code, a tag name appears at the left margin. | |
1141 @end itemize | |
1142 | |
1143 You can also generate tags based on regexp matching (@pxref{Create | |
1144 Tags Table}) to handle other formats and languages. | |
1145 | |
1146 @node Create Tags Table | |
1116 @subsection Creating Tags Tables | 1147 @subsection Creating Tags Tables |
1117 @cindex etags program | 1148 @cindex @code{etags} program |
1118 | 1149 |
1119 The @code{etags} program is used to create a tags table file. It knows | 1150 The @code{etags} program is used to create a tags table file. It knows |
1120 the syntax of several languages, as described in | 1151 the syntax of several languages, as described in |
1121 @iftex | 1152 @iftex |
1122 the previous section. | 1153 the previous section. |
1206 where @var{tagregexp} is used to match the lines to tag. It is always | 1237 where @var{tagregexp} is used to match the lines to tag. It is always |
1207 anchored, that is, it behaves as if preceded by @samp{^}. If you want | 1238 anchored, that is, it behaves as if preceded by @samp{^}. If you want |
1208 to account for indentation, just match any initial number of blanks by | 1239 to account for indentation, just match any initial number of blanks by |
1209 beginning your regular expression with @samp{[ \t]*}. In the regular | 1240 beginning your regular expression with @samp{[ \t]*}. In the regular |
1210 expressions, @samp{\} quotes the next character, and @samp{\t} stands | 1241 expressions, @samp{\} quotes the next character, and @samp{\t} stands |
1211 for the tab character. Note that @code{etags} does not handle the | 1242 for the tab character. Note that @code{etags} does not handle the other |
1212 other C escape sequences for special characters. | 1243 C escape sequences for special characters. |
1244 | |
1245 @cindex interval operator (in regexps) | |
1246 The syntax of regular expressions in @code{etags} is the same as in | |
1247 Emacs, augmented with the @dfn{interval operator}, which works as in | |
1248 @code{grep} and @code{ed}. The syntax of an interval operator is | |
1249 @samp{\@{@var{m},@var{n}\@}}, and its meaning is to match the preceding | |
1250 expression at least @var{m} times and up to @var{n} times. | |
1213 | 1251 |
1214 You should not match more characters with @var{tagregexp} than that | 1252 You should not match more characters with @var{tagregexp} than that |
1215 needed to recognize what you want to tag. If the match is such that | 1253 needed to recognize what you want to tag. If the match is such that |
1216 more characters than needed are unavoidably matched by @var{tagregexp}, | 1254 more characters than needed are unavoidably matched by @var{tagregexp}, |
1217 you may find useful to add a @var{nameregexp}, in order to narrow the | 1255 you may find useful to add a @var{nameregexp}, in order to narrow the tag |
1218 tag scope. You can find some examples below. | 1256 scope. You can find some examples below. |
1219 | 1257 |
1220 The @samp{-R} option deletes all the regexps defined with | 1258 The @samp{-R} option deletes all the regexps defined with |
1221 @samp{--regex} options. It applies to the file names following it, as | 1259 @samp{--regex} options. It applies to the file names following it, as |
1222 you can see from the following example: | 1260 you can see from the following example: |
1223 | 1261 |
1251 @example | 1289 @example |
1252 --language=none | 1290 --language=none |
1253 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' | 1291 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/' |
1254 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\ | 1292 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\ |
1255 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/' | 1293 \( BODY\)?\|PROCEDURE\|PROCESS\|TYPE\)[ \t]+\([^ \t(]+\)/\3/' |
1256 @end example | |
1257 | |
1258 @noindent | |
1259 Tag Cobol files (every label starting in column seven): | |
1260 | |
1261 @example | |
1262 --language=none --regex='/.......[a-zA-Z0-9-]+\./' | |
1263 @end example | |
1264 | |
1265 @noindent | |
1266 Tag Postscript files (every label starting in column one): | |
1267 | |
1268 @example | |
1269 --language=none --regex='#/[^ \t@{]+#/' | |
1270 @end example | 1294 @end example |
1271 | 1295 |
1272 @noindent | 1296 @noindent |
1273 Tag TCL files (this last example shows the usage of a @var{nameregexp}): | 1297 Tag TCL files (this last example shows the usage of a @var{nameregexp}): |
1274 | 1298 |