A tag is a reference to a subunit in a program or in a document. In program source code, tags reference syntactic elements of the program: functions, subroutines, data types, macros, etc. In a document, tags reference chapters, sections, appendices, etc. Each tag specifies the name of the file where the corresponding subunit is defined, and the position of the subunit's definition in that file.
A tags table records the tags extracted by scanning the source code of a certain program or a certain document. Tags extracted from generated files reference the original files, rather than the generated files that were scanned during tag extraction. Examples of generated files include C files generated from Cweb source files, from a Yacc parser, or from Lex scanner definitions; .i preprocessed C files; and Fortran files produced by preprocessing .fpp source files.
To produce a tags table, you use the ‘etags’ command, submitting it a document or the source code of a program. ‘etags’ writes the tags to a tags table file, or tags file in short. The conventional name for a tags file is TAGS.
Emacs uses the information recorded in tags tables in commands that search or replace through multiple source files: these commands use the names of the source files recorded in the tags table to know which files to search. Other commands, such as M-., which finds the definition of a function, use the recorded information about the function names and positions to find the source file and the position within that file where the function is defined.
See also the Ebrowse facility, which is tailored for C++. Seeblog comments powered by . Disqus