comparison man/xemacs/programs.texi @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 376386a54a3c
children 43dd3413c7c7
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
1002 (case where line is killed, point is at eob and that line is 1002 (case where line is killed, point is at eob and that line is
1003 not displayed), set it again in final compute_motion. 1003 not displayed), set it again in final compute_motion.
1004 @end smallexample 1004 @end smallexample
1005 1005
1006 @node Tags, Fortran, Change Log, Programs 1006 @node Tags, Fortran, Change Log, Programs
1007 @section Tag Tables 1007 @section Tags Tables
1008 @cindex tag table 1008 @cindex tags table
1009 1009
1010 A @dfn{tag 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 in each file. Grouping the related
1013 files makes it possible to search or replace through all the files with 1013 files makes it possible to search or replace through all the files with
1014 one command. Recording the function names and positions makes it 1014 one command. Recording the function names and positions makes it
1015 possible to use the @kbd{Meta-.} command, which finds the definition of a 1015 possible to use the @kbd{Meta-.} command, which finds the definition of a
1016 function without asking for information on the file it is in. 1016 function without asking for information on the file it is in.
1017 1017
1018 Tag tables are stored in files called @dfn{tag table files}. The 1018 tags tables are stored in files called @dfn{tags table files}. The
1019 conventional name for a tag table file is @file{TAGS}. 1019 conventional name for a tags table file is @file{TAGS}.
1020 1020
1021 Each entry in the tag 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 The programming language of a file determines what names are recorded
1026 in the tag table depends on. Normally, Emacs includes all functions and 1026 in the tags table depends on. Normally, Emacs includes all functions and
1027 subroutines, and may also include global variables, data types, and 1027 subroutines, and may also include global variables, data types, and
1028 anything else convenient. Each recorded name is called a @dfn{tag}. 1028 anything else convenient. Each recorded name is called a @dfn{tag}.
1029 1029
1030 @menu 1030 @menu
1031 * Tag Syntax:: 1031 * Tag Syntax:: Tag syntax for various types of code and text files.
1032 * Create Tag Table:: 1032 * Create Tags Table:: Creating a tags table with @code{etags}.
1033 * Select Tag Table:: 1033 * Select Tags Table:: How to visit a tags table.
1034 * Find Tag:: 1034 * Find Tag:: Commands to find the definition of a specific tag.
1035 * Tags Search:: 1035 * Tags Search:: Using a tags table for searching and replacing.
1036 * Tags Stepping:: 1036 * List Tags:: Listing and finding tags defined in a file.
1037 * List Tags::
1038 @end menu 1037 @end menu
1039 1038
1040 @node Tag Syntax, Create Tag Table, Tags, Tags 1039 @node Tag Syntax, Create Tags Table, Tags, Tags
1041 @subsection Source File Tag Syntax 1040 @subsection Source File Tag Syntax
1042 1041
1043 In Lisp code, any function defined with @code{defun}, any variable 1042 @itemize @bullet
1044 defined with @code{defvar} or @code{defconst}, and the first argument of 1043 @item
1045 any expression that starts with @samp{(def} in column zero, is a tag. 1044 In Lisp code, any function defined with @code{defun}, any variable
1046 1045 defined with @code{defvar} or @code{defconst}, and in general the first
1047 In C code, any C function is a tag, and so is any typedef if @code{-t} is 1046 argument of any expression that starts with @samp{(def} in column zero, is
1048 specified when the tag table is constructed. 1047 a tag.
1049 1048
1050 In Fortran code, functions and subroutines are tags. 1049 @item
1051 1050 In Scheme code, tags include anything defined with @code{def} or with a
1052 In La@TeX{} text, the argument of any of the commands @code{\chapter}, 1051 construct whose name starts with @samp{def}. They also include variables
1053 @code{\section}, @code{\subsection}, @code{\subsubsection}, @code{\eqno}, 1052 set with @code{set!} at top level in the file.
1054 @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem}, and 1053
1055 @*@code{\typeout} is a tag.@refill 1054 @item
1056 1055 In C code, any C function or typedef is a tag, and so are definitions of
1057 @node Create Tag Table, Select Tag Table, Tag Syntax, Tags 1056 @code{struct}, @code{union} and @code{enum}. @code{#define} macro
1058 @subsection Creating Tag Tables 1057 definitions and @code{enum} constant are also tags, unless
1058 @samp{--no-defines} is specified when the tags table is constructed,
1059 which sometimes makes the tags file much smaller. In C++ code, member
1060 functions are also recognized.
1061
1062 @item
1063 In Yacc or Bison input files, each rule defines as a tag the
1064 nonterminal it constructs. The portions of the file that contain C code
1065 are parsed as C code.
1066
1067 @item
1068 In Fortran code, functions and subroutines are tags.
1069
1070 @item
1071 In Pascal code, the tags are the functions and procedures defined in
1072 the file.
1073
1074 @item
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
1089 @item
1090 In La@TeX{} text, the argument of any of the commands @code{\chapter},
1091 @code{\section}, @code{\subsection}, @code{\subsubsection},
1092 @code{\eqno}, @code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem},
1093 @code{\part}, @code{\appendix}, @code{\entry}, or @code{\index}, is a
1094 tag.@refill
1095
1096 Other commands can make tags as well, if you specify them in the
1097 environment variable @code{TEXTAGS} before invoking @code{etags}. The
1098 value of this environment variable should be a colon-separated list of
1099 commands names. For example,
1100
1101 @example
1102 TEXTAGS="def:newcommand:newenvironment"
1103 export TEXTAGS
1104 @end example
1105
1106 @noindent
1107 specifies (using Bourne shell syntax) that the commands @samp{\def},
1108 @samp{\newcommand} and @samp{\newenvironment} also define tags.
1109
1110 @item
1111 You can also generate tags based on regexp matching
1112 (@pxref{Create Tags Table}) for any text file.
1113 @end itemize
1114
1115 @node Create Tags Table, Select Tags Table, Tag Syntax, Tags
1116 @subsection Creating Tags Tables
1059 @cindex etags program 1117 @cindex etags program
1060 1118
1061 The @code{etags} program is used to create a tag table file. It knows 1119 The @code{etags} program is used to create a tags table file. It knows
1062 the syntax of C, Fortran, La@TeX{}, Scheme, and Emacs Lisp/Common Lisp. To 1120 the syntax of several languages, as described in
1063 use @code{etags}, use it as a shell command: 1121 @iftex
1122 the previous section.
1123 @end iftex
1124 @ifinfo
1125 @ref{Tag Syntax}.
1126 @end ifinfo
1127 Here is how to run @code{etags}:
1064 1128
1065 @example 1129 @example
1066 etags @var{inputfiles}@dots{} 1130 etags @var{inputfiles}@dots{}
1067 @end example 1131 @end example
1132
1068 @noindent 1133 @noindent
1069 1134 The @code{etags} program reads the specified files, and writes a tags table
1070 The program reads the specified files and writes a tag table
1071 named @file{TAGS} in the current working directory. @code{etags} 1135 named @file{TAGS} in the current working directory. @code{etags}
1072 recognizes the language used in an input file based on the name and 1136 recognizes the language used in an input file based on its file name and
1073 contents of the file; there are no switches for specifying the language. 1137 contents. You can specify the language with the
1074 The @code{-t} switch tells @code{etags} to record typedefs in C code as 1138 @samp{--language=@var{name}} option, described below.
1075 tags. 1139
1076 1140 If the tags table data become outdated due to changes in the files
1077 If the tag table data become outdated due to changes in the files 1141 described in the table, the way to update the tags table is the same way it
1078 described in the table, you can update the tag table by running the 1142 was made in the first place. It is not necessary to do this often.
1079 program from the shell again. It is not necessary to do this often. 1143
1080 1144 If the tags table fails to record a tag, or records it for the wrong
1081 If the tag table fails to record a tag, or records it for the wrong file, 1145 file, then Emacs cannot possibly find its definition. However, if the
1082 Emacs cannot find its definition. However, if the position 1146 position recorded in the tags table becomes a little bit wrong (due to
1083 recorded in the tag table becomes a little bit wrong (due to some editing 1147 some editing in the file that the tag definition is in), the only
1084 in the file that the tag definition is in), the only consequence is to slow 1148 consequence is a slight delay in finding the tag. Even if the stored
1085 down finding the tag slightly. Even if the stored position is very wrong, 1149 position is very wrong, Emacs will still find the tag, but it must
1086 Emacs will still find the tag, but it must search the entire file for it. 1150 search the entire file for it.
1087 1151
1088 You should update a tag table when you define new tags you want 1152 So you should update a tags table when you define new tags that you want
1089 to have listed, when you move tag definitions from one file to another, 1153 to have listed, or when you move tag definitions from one file to another,
1090 or when changes become substantial. You don't have to update 1154 or when changes become substantial. Normally there is no need to update
1091 the tag table after each edit, or even every day. 1155 the tags table after each edit, or even every day.
1092 1156
1093 @node Select Tag Table, Find Tag, Create Tag Table, Tags 1157 One tags table can effectively include another. Specify the included
1094 @subsection Selecting a Tag Table 1158 tags file name with the @samp{--include=@var{file}} option when creating
1159 the file that is to include it. The latter file then acts as if it
1160 contained all the files specified in the included file, as well as the
1161 files it directly contains.
1162
1163 If you specify the source files with relative file names when you run
1164 @code{etags}, the tags file will contain file names relative to the
1165 directory where the tags file was initially written. This way, you can
1166 move an entire directory tree containing both the tags file and the
1167 source files, and the tags file will still refer correctly to the source
1168 files.
1169
1170 If you specify absolute file names as arguments to @code{etags}, then
1171 the tags file will contain absolute file names. This way, the tags file
1172 will still refer to the same files even if you move it, as long as the
1173 source files remain in the same place. Absolute file names start with
1174 @samp{/}, or with @samp{@var{device}:/} on MS-DOS and Windows.
1175
1176 When you want to make a tags table from a great number of files, you
1177 may have problems listing them on the command line, because some systems
1178 have a limit on its length. The simplest way to circumvent this limit
1179 is to tell @code{etags} to read the file names from its standard input,
1180 by typing a dash in place of the file names, like this:
1181
1182 @example
1183 find . -name "*.[chCH]" -print | etags -
1184 @end example
1185
1186 Use the option @samp{--language=@var{name}} to specify the language
1187 explicitly. You can intermix these options with file names; each one
1188 applies to the file names that follow it. Specify
1189 @samp{--language=auto} to tell @code{etags} to resume guessing the
1190 language from the file names and file contents. Specify
1191 @samp{--language=none} to turn off language-specific processing
1192 entirely; then @code{etags} recognizes tags by regexp matching alone.
1193 @samp{etags --help} prints the list of the languages @code{etags} knows,
1194 and the file name rules for guessing the language.
1195
1196 The @samp{--regex} option provides a general way of recognizing tags
1197 based on regexp matching. You can freely intermix it with file names.
1198 Each @samp{--regex} option adds to the preceding ones, and applies only
1199 to the following files. The syntax is:
1200
1201 @example
1202 --regex=/@var{tagregexp}[/@var{nameregexp}]/
1203 @end example
1204
1205 @noindent
1206 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
1208 to account for indentation, just match any initial number of blanks by
1209 beginning your regular expression with @samp{[ \t]*}. In the regular
1210 expressions, @samp{\} quotes the next character, and @samp{\t} stands
1211 for the tab character. Note that @code{etags} does not handle the
1212 other C escape sequences for special characters.
1213
1214 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
1216 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
1218 tag scope. You can find some examples below.
1219
1220 The @samp{-R} option deletes all the regexps defined with
1221 @samp{--regex} options. It applies to the file names following it, as
1222 you can see from the following example:
1223
1224 @example
1225 etags --regex=/@var{reg1}/ voo.doo --regex=/@var{reg2}/ \
1226 bar.ber -R --lang=lisp los.er
1227 @end example
1228
1229 @noindent
1230 Here @code{etags} chooses the parsing language for @file{voo.doo} and
1231 @file{bar.ber} according to their contents. @code{etags} also uses
1232 @var{reg1} to recognize additional tags in @file{voo.doo}, and both
1233 @var{reg1} and @var{reg2} to recognize additional tags in
1234 @file{bar.ber}. @code{etags} uses the Lisp tags rules, and no regexp
1235 matching, to recognize tags in @file{los.er}.
1236
1237 Here are some more examples. The regexps are quoted to protect them
1238 from shell interpretation.
1239
1240 @noindent
1241 Tag the @code{DEFVAR} macros in the emacs source files:
1242
1243 @example
1244 --regex='/[ \t]*DEFVAR_[A-Z_ \t(]+"\([^"]+\)"/'
1245 @end example
1246
1247 @noindent
1248 Tag VHDL files (this example is a single long line, broken here for
1249 formatting reasons):
1250
1251 @example
1252 --language=none
1253 --regex='/[ \t]*\(ARCHITECTURE\|CONFIGURATION\) +[^ ]* +OF/'
1254 --regex='/[ \t]*\(ATTRIBUTE\|ENTITY\|FUNCTION\|PACKAGE\
1255 \( 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
1271
1272 @noindent
1273 Tag TCL files (this last example shows the usage of a @var{nameregexp}):
1274
1275 @example
1276 --lang=none --regex='/proc[ \t]+\([^ \t]+\)/\1/'
1277 @end example
1278
1279 For a list of the other available @code{etags} options, execute
1280 @code{etags --help}.
1281
1282 @node Select Tags Table, Find Tag, Create Tags Table, Tags
1283 @subsection Selecting a Tags Table
1095 1284
1096 @vindex tag-table-alist 1285 @vindex tag-table-alist
1097 At any time Emacs has one @dfn{selected} tag table, and all the commands 1286 At any time Emacs has one @dfn{selected} tags table, and all the commands
1098 for working with tag tables use the selected one. To select a tag table, 1287 for working with tags tables use the selected one. To select a tags table,
1099 use the variable @code{tag-table-alist}. 1288 use the variable @code{tag-table-alist}.
1100 1289
1101 The value of @code{tag-table-alist} is a list that determines which 1290 The value of @code{tag-table-alist} is a list that determines which
1102 @code{TAGS} files should be active for a given buffer. This is not 1291 @code{TAGS} files should be active for a given buffer. This is not
1103 really an association list, in that all elements are checked. The car 1292 really an association list, in that all elements are checked. The car
1127 ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/") 1316 ("/jbw/gnu/" . "/usr15/degree/stud/jbw/gnu/")
1128 ("" . "/usr/local/emacs/src/") 1317 ("" . "/usr/local/emacs/src/")
1129 )) 1318 ))
1130 @end example 1319 @end example
1131 1320
1132 The example defines the tag table alist in the following way: 1321 The example defines the tags table alist in the following way:
1133 1322
1134 @itemize @bullet 1323 @itemize @bullet
1135 @item 1324 @item
1136 Anything in the directory @file{/usr/src/public/perl/} 1325 Anything in the directory @file{/usr/src/public/perl/}
1137 should use the @file{TAGS} file @file{/usr/src/public/perl/perl-3.0/TAGS}. 1326 should use the @file{TAGS} file @file{/usr/src/public/perl/perl-3.0/TAGS}.
1171 the variable @code{tag-table-alist}, tells tags commands to use the tags 1360 the variable @code{tag-table-alist}, tells tags commands to use the tags
1172 table file @var{file} first. The @var{file} should be the name of a 1361 table file @var{file} first. The @var{file} should be the name of a
1173 file created with the @code{etags} program. A directory name is also 1362 file created with the @code{etags} program. A directory name is also
1174 acceptable; it means the file @file{TAGS} in that directory. The 1363 acceptable; it means the file @file{TAGS} in that directory. The
1175 function only stores the file name you provide in the variable 1364 function only stores the file name you provide in the variable
1176 @code{tags-file-name}. Emacs does not actually read in the tag table 1365 @code{tags-file-name}. Emacs does not actually read in the tags table
1177 contents until you try to use them. You can set the variable explicitly 1366 contents until you try to use them. You can set the variable explicitly
1178 instead of using @code{visit-tags-table}. The value of the variable 1367 instead of using @code{visit-tags-table}. The value of the variable
1179 @code{tags-file-name} is the name of the tags table used by all buffers. 1368 @code{tags-file-name} is the name of the tags table used by all buffers.
1180 This is for backward compatibility, and is largely supplanted by the 1369 This is for backward compatibility, and is largely supplanted by the
1181 variable @code{tag-table-alist}. 1370 variable @code{tag-table-alist}.
1182 1371
1183 @node Find Tag, Tags Search, Select Tag Table, Tags 1372 @node Find Tag, Tags Search, Select Tags Table, Tags
1184 @subsection Finding a Tag 1373 @subsection Finding a Tag
1185 1374
1186 The most important thing that a tag table enables you to do is to find 1375 The most important thing that a tags table enables you to do is to find
1187 the definition of a specific tag. 1376 the definition of a specific tag.
1188 1377
1189 @table @kbd 1378 @table @kbd
1190 @item M-.@: @var{tag &optional other-window} 1379 @item M-.@: @var{tag &optional other-window}
1191 Find first definition of @var{tag} (@code{find-tag}). 1380 Find first definition of @var{tag} (@code{find-tag}).
1197 @end table 1386 @end table
1198 1387
1199 @kindex M-. 1388 @kindex M-.
1200 @findex find-tag 1389 @findex find-tag
1201 @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of 1390 @kbd{M-.}@: (@code{find-tag}) is the command to find the definition of
1202 a specified tag. It searches through the tag table for that tag, as a 1391 a specified tag. It searches through the tags table for that tag, as a
1203 string, then uses the tag table information to determine the file in 1392 string, then uses the tags table information to determine the file in
1204 which the definition is used and the approximate character position of 1393 which the definition is used and the approximate character position of
1205 the definition in the file. Then @code{find-tag} visits the file, 1394 the definition in the file. Then @code{find-tag} visits the file,
1206 moves point to the approximate character position, and starts searching 1395 moves point to the approximate character position, and starts searching
1207 ever-increasing distances away for the text that should appear at 1396 ever-increasing distances away for the text that should appear at
1208 the beginning of the definition. 1397 the beginning of the definition.
1212 @xref{Lists}, for information on sexps. 1401 @xref{Lists}, for information on sexps.
1213 1402
1214 The argument to @code{find-tag} need not be the whole tag name; it can 1403 The argument to @code{find-tag} need not be the whole tag name; it can
1215 be a substring of a tag name. However, there can be many tag names 1404 be a substring of a tag name. However, there can be many tag names
1216 containing the substring you specify. Since @code{find-tag} works by 1405 containing the substring you specify. Since @code{find-tag} works by
1217 searching the text of the tag table, it finds the first tag in the table 1406 searching the text of the tags table, it finds the first tag in the table
1218 that the specified substring appears in. To find other tags that match 1407 that the specified substring appears in. To find other tags that match
1219 the substring, give @code{find-tag} a numeric argument, as in @kbd{C-u 1408 the substring, give @code{find-tag} a numeric argument, as in @kbd{C-u
1220 M-.}. This does not read a tag name, but continues searching the tag 1409 M-.}. This does not read a tag name, but continues searching the tag
1221 table's text for another tag containing the same substring last used. 1410 table's text for another tag containing the same substring last used.
1222 If your keyboard has a real @key{META} key, @kbd{M-0 M-.}@: is an easier 1411 If your keyboard has a real @key{META} key, @kbd{M-0 M-.}@: is an easier
1255 Like most commands that can switch buffers, @code{find-tag} has another 1444 Like most commands that can switch buffers, @code{find-tag} has another
1256 similar command that displays the new buffer in another window. @kbd{C-x 4 1445 similar command that displays the new buffer in another window. @kbd{C-x 4
1257 .}@: invokes the function @code{find-tag-other-window}. (This key sequence 1446 .}@: invokes the function @code{find-tag-other-window}. (This key sequence
1258 ends with a period.) 1447 ends with a period.)
1259 1448
1260 Emacs comes with a tag table file @file{TAGS} (in the directory 1449 Emacs comes with a tags table file @file{TAGS} (in the directory
1261 containing Lisp libraries) that includes all the Lisp libraries and all 1450 containing Lisp libraries) that includes all the Lisp libraries and all
1262 the C sources of Emacs. By specifying this file with @code{visit-tags-table} 1451 the C sources of Emacs. By specifying this file with @code{visit-tags-table}
1263 and then using @kbd{M-.}@: you can quickly look at the source of any Emacs 1452 and then using @kbd{M-.}@: you can quickly look at the source of any Emacs
1264 function. 1453 function.
1265 1454
1266 @node Tags Search, Tags Stepping, Find Tag, Tags 1455 @node Tags Search, List Tags, Find Tag, Tags
1267 @subsection Searching and Replacing with Tag Tables 1456 @subsection Searching and Replacing with Tags Tables
1268 1457
1269 The commands in this section visit and search all the files listed in the 1458 The commands in this section visit and search all the files listed in the
1270 selected tag table, one by one. For these commands, the tag table serves 1459 selected tags table, one by one. For these commands, the tags table serves
1271 only to specify a sequence of files to search. A related command is 1460 only to specify a sequence of files to search. A related command is
1272 @kbd{M-x grep} (@pxref{Compilation}). 1461 @kbd{M-x grep} (@pxref{Compilation}).
1273 1462
1274 @table @kbd 1463 @table @kbd
1275 @item M-x tags-search 1464 @item M-x tags-search @key{RET} @var{regexp} @key{RET}
1276 Search for the specified regexp through the files in the selected tag 1465 Search for @var{regexp} through the files in the selected tags
1277 table. 1466 table.
1278 @item M-x tags-query-replace 1467 @item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
1279 Perform a @code{query-replace} on each file in the selected tag table. 1468 Perform a @code{query-replace-regexp} on each file in the selected tags table.
1280 @item M-, 1469 @item M-,
1281 Restart one of the commands above, from the current location of point 1470 Restart one of the commands above, from the current location of point
1282 (@code{tags-loop-continue}). 1471 (@code{tags-loop-continue}).
1283 @end table 1472 @end table
1284 1473
1285 @findex tags-search 1474 @findex tags-search
1286 @kbd{M-x tags-search} reads a regexp using the minibuffer, then visits 1475 @kbd{M-x tags-search} reads a regexp using the minibuffer, then
1287 the files of the selected tag table one by one, and searches through each 1476 searches for matches in all the files in the selected tags table, one
1288 file for that regexp. It displays the name of the file being searched so 1477 file at a time. It displays the name of the file being searched so you
1289 you can follow its progress. As soon as an occurrence is found, 1478 can follow its progress. As soon as it finds an occurrence,
1290 @code{tags-search} returns. 1479 @code{tags-search} returns.
1291 1480
1292 @kindex M-, 1481 @kindex M-,
1293 @findex tags-loop-continue 1482 @findex tags-loop-continue
1294 After you have found one match, you probably want to find all the rest. 1483 Having found one match, you probably want to find all the rest. To find
1295 To find one more match, type @kbd{M-,} (@code{tags-loop-continue}) to 1484 one more match, type @kbd{M-,} (@code{tags-loop-continue}) to resume the
1296 resume the @code{tags-search}. This searches the rest of the current 1485 @code{tags-search}. This searches the rest of the current buffer, followed
1297 buffer, followed by the remaining files of the tag table. 1486 by the remaining files of the tags table.@refill
1298 1487
1299 @findex tags-query-replace 1488 @findex tags-query-replace
1300 @kbd{M-x tags-query-replace} performs a single @code{query-replace} 1489 @kbd{M-x tags-query-replace} performs a single
1301 through all the files in the tag table. It reads a string to search for 1490 @code{query-replace-regexp} through all the files in the tags table. It
1302 and a string to replace with, just like ordinary @kbd{M-x query-replace}. 1491 reads a regexp to search for and a string to replace with, just like
1303 It searches much like @kbd{M-x tags-search} but repeatedly, processing 1492 ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x
1304 matches according to your input. @xref{Replace}, for more information on 1493 tags-search}, but repeatedly, processing matches according to your
1305 @code{query-replace}.@refill 1494 input. @xref{Replace}, for more information on query replace.
1306 1495
1307 It is possible to get through all the files in the tag table with a 1496 It is possible to get through all the files in the tags table with a
1308 single invocation of @kbd{M-x tags-query-replace}. But since any 1497 single invocation of @kbd{M-x tags-query-replace}. But often it is
1309 unrecognized character causes the command to exit, you may need to continue 1498 useful to exit temporarily, which you can do with any input event that
1310 from where you left off. You can use @kbd{M-,} to do this. It resumes 1499 has no special query replace meaning. You can resume the query replace
1311 the last tags search or replace command that you did. 1500 subsequently by typing @kbd{M-,}; this command resumes the last tags
1312 1501 search or replace command that you did.
1313 It may have struck you that @code{tags-search} is a lot like @code{grep}. 1502
1314 You can also run @code{grep} itself as an inferior of Emacs and have Emacs 1503 The commands in this section carry out much broader searches than the
1315 show you the matching lines one by one. This works mostly the same as 1504 @code{find-tag} family. The @code{find-tag} commands search only for
1316 running a compilation and having Emacs show you where the errors were. 1505 definitions of tags that match your substring or regexp. The commands
1506 @code{tags-search} and @code{tags-query-replace} find every occurrence
1507 of the regexp, as ordinary search commands and replace commands do in
1508 the current buffer.
1509
1510 These commands create buffers only temporarily for the files that they
1511 have to search (those which are not already visited in Emacs buffers).
1512 Buffers in which no match is found are quickly killed; the others
1513 continue to exist.
1514
1515 It may have struck you that @code{tags-search} is a lot like
1516 @code{grep}. You can also run @code{grep} itself as an inferior of
1517 Emacs and have Emacs show you the matching lines one by one. This works
1518 much like running a compilation; finding the source locations of the
1519 @code{grep} matches works like finding the compilation errors.
1317 @xref{Compilation}. 1520 @xref{Compilation}.
1318 1521
1319 @node Tags Stepping, List Tags, Tags Search, Tags 1522 If you wish to process all the files in a selected tags table, but
1320 @subsection Stepping Through a Tag Table
1321 @findex next-file
1322
1323 If you wish to process all the files in a selected tag table, but
1324 @kbd{M-x tags-search} and @kbd{M-x tags-query-replace} are not giving 1523 @kbd{M-x tags-search} and @kbd{M-x tags-query-replace} are not giving
1325 you the desired result, you can use @kbd{M-x next-file}. 1524 you the desired result, you can use @kbd{M-x next-file}.
1326 1525
1327 @table @kbd 1526 @table @kbd
1328 @item C-u M-x next-file 1527 @item C-u M-x next-file
1329 With a numeric argument, regardless of its value, visit the first 1528 With a numeric argument, regardless of its value, visit the first
1330 file in the tag table and prepare to advance sequentially by files. 1529 file in the tags table and prepare to advance sequentially by files.
1331 @item M-x next-file 1530 @item M-x next-file
1332 Visit the next file in the selected tag table. 1531 Visit the next file in the selected tags table.
1333 @end table 1532 @end table
1334 1533
1335 @node List Tags,, Tags Stepping, Tags 1534 @node List Tags,, Tags Search, Tags
1336 @subsection Tag Table Inquiries 1535 @subsection Tags Table Inquiries
1337 1536
1338 @table @kbd 1537 @table @kbd
1339 @item M-x list-tags 1538 @item M-x list-tags
1340 Display a list of the tags defined in a specific program file. 1539 Display a list of the tags defined in a specific program file.
1341 @item M-x tags-apropos 1540 @item M-x tags-apropos
1342 Display a list of all tags matching a specified regexp. 1541 Display a list of all tags matching a specified regexp.
1343 @end table 1542 @end table
1344 1543
1345 @findex list-tags 1544 @findex list-tags
1346 @kbd{M-x list-tags} reads the name of one of the files described by the 1545 @kbd{M-x list-tags} reads the name of one of the files described by the
1347 selected tag table, and displays a list of all the tags defined in that 1546 selected tags table, and displays a list of all the tags defined in that
1348 file. The ``file name'' argument is really just a string to compare 1547 file. The ``file name'' argument is really just a string to compare
1349 against the names recorded in the tag table; it is read as a string rather 1548 against the names recorded in the tags table; it is read as a string rather
1350 than a file name. Therefore, completion and defaulting are not 1549 than a file name. Therefore, completion and defaulting are not
1351 available, and you must enter the string the same way it appears in the tag 1550 available, and you must enter the string the same way it appears in the tag
1352 table. Do not include a directory as part of the file name unless the file 1551 table. Do not include a directory as part of the file name unless the file
1353 name recorded in the tag table contains that directory. 1552 name recorded in the tags table contains that directory.
1354 1553
1355 @findex tags-apropos 1554 @findex tags-apropos
1356 @kbd{M-x tags-apropos} is like @code{apropos} for tags. It reads a regexp, 1555 @kbd{M-x tags-apropos} is like @code{apropos} for tags. It reads a regexp,
1357 then finds all the tags in the selected tag table whose entries match that 1556 then finds all the tags in the selected tags table whose entries match that
1358 regexp, and displays the tag names found. 1557 regexp, and displays the tag names found.
1359 1558
1360 @node Fortran, Asm Mode, Tags, Programs 1559 @node Fortran, Asm Mode, Tags, Programs
1361 @section Fortran Mode 1560 @section Fortran Mode
1362 @cindex Fortran mode 1561 @cindex Fortran mode