aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2016-01-09 21:12:46 +0200
committerEli Zaretskii2016-01-09 21:12:46 +0200
commitf8208b69192359a97735d461f05060f6579df0f2 (patch)
tree6bc8a541209f3b4734c920b68565c90991e88102
parentb131fb85580f3379d028bbb60dddd138dcbe3c98 (diff)
downloademacs-f8208b69192359a97735d461f05060f6579df0f2.tar.gz
emacs-f8208b69192359a97735d461f05060f6579df0f2.zip
Document the user-level features of the Xref package
* doc/emacs/maintaining.texi (Maintaining): Add a list of described features. (Xref): New section, made out of thoroughly rewritten "Tags" section. (Find Identifiers, Looking Up Identifiers, Xref Commands) (Identifier Search, List Identifiers): New subsections, incorporating the old tags commands and the new xref commands. (Tags Tables, Tag Syntax, Create Tags Table, Etags Regexps): Section and subsections demoted to a lower level. * doc/emacs/search.texi (Search): * doc/emacs/windows.texi (Pop Up Window): * doc/emacs/frames.texi (Creating Frames): * doc/emacs/programs.texi (Imenu, Symbol Completion): * doc/emacs/building.texi (Grep Searching): * doc/emacs/dired.texi (Operating on Files): * doc/emacs/glossary.texi (Glossary): All references to tags changed.
-rw-r--r--doc/emacs/building.texi4
-rw-r--r--doc/emacs/dired.texi8
-rw-r--r--doc/emacs/emacs.texi22
-rw-r--r--doc/emacs/frames.texi6
-rw-r--r--doc/emacs/glossary.texi2
-rw-r--r--doc/emacs/maintaining.texi647
-rw-r--r--doc/emacs/programs.texi6
-rw-r--r--doc/emacs/search.texi8
-rw-r--r--doc/emacs/windows.texi5
-rw-r--r--etc/NEWS3
10 files changed, 449 insertions, 262 deletions
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 3a12795d2b0..3fa89d9062d 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -360,8 +360,8 @@ that specifies how to run @command{grep}. Use the same arguments you
360would give @command{grep} when running it normally: a @command{grep}-style 360would give @command{grep} when running it normally: a @command{grep}-style
361regexp (usually in single-quotes to quote the shell's special 361regexp (usually in single-quotes to quote the shell's special
362characters) followed by file names, which may use wildcards. If you 362characters) followed by file names, which may use wildcards. If you
363specify a prefix argument for @kbd{M-x grep}, it finds the tag 363specify a prefix argument for @kbd{M-x grep}, it finds the identifier
364(@pxref{Tags}) in the buffer around point, and puts that into the 364(@pxref{Xref}) in the buffer around point, and puts that into the
365default @command{grep} command. 365default @command{grep} command.
366 366
367 Your command need not simply run @command{grep}; you can use any shell 367 Your command need not simply run @command{grep}; you can use any shell
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index f3211b5fecf..855e6531a66 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -785,8 +785,8 @@ Search all the specified files for the regular expression @var{regexp}
785(@code{dired-do-search}). 785(@code{dired-do-search}).
786 786
787This command is a variant of @code{tags-search}. The search stops at 787This command is a variant of @code{tags-search}. The search stops at
788the first match it finds; use @kbd{M-,} to resume the search and find 788the first match it finds; use @kbd{M-x tags-loop-continue} to resume
789the next match. @xref{Tags Search}. 789the search and find the next match. @xref{Identifier Search}.
790 790
791@kindex Q @r{(Dired)} 791@kindex Q @r{(Dired)}
792@findex dired-do-query-replace-regexp 792@findex dired-do-query-replace-regexp
@@ -797,8 +797,8 @@ replacing matches for @var{regexp} with the string
797@var{to} (@code{dired-do-query-replace-regexp}). 797@var{to} (@code{dired-do-query-replace-regexp}).
798 798
799This command is a variant of @code{tags-query-replace}. If you exit the 799This command is a variant of @code{tags-query-replace}. If you exit the
800query replace loop, you can use @kbd{M-,} to resume the scan and replace 800query replace loop, you can use @kbd{M-x tags-loop-continue} to resume
801more matches. @xref{Tags Search}. 801the scan and replace more matches. @xref{Identifier Search}.
802@end table 802@end table
803 803
804@node Shell Commands in Dired 804@node Shell Commands in Dired
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 53b689fbfbe..5ef938566de 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -788,8 +788,8 @@ Maintaining Large Programs
788 788
789* Version Control:: Using version control systems. 789* Version Control:: Using version control systems.
790* Change Log:: Maintaining a change history for your program. 790* Change Log:: Maintaining a change history for your program.
791* Tags:: Go directly to any function in your program in one 791* Xref:: Find definitions and references of any function,
792 command. Tags remembers which file it is in. 792 method, struct, macro, @dots{} in your program.
793* EDE:: An integrated development environment for Emacs. 793* EDE:: An integrated development environment for Emacs.
794@ifnottex 794@ifnottex
795* Emerge:: A convenient way of merging two versions of a program. 795* Emerge:: A convenient way of merging two versions of a program.
@@ -861,15 +861,25 @@ Change Logs
861* Change Log Commands:: Commands for editing change log files. 861* Change Log Commands:: Commands for editing change log files.
862* Format of ChangeLog:: What the change log file looks like. 862* Format of ChangeLog:: What the change log file looks like.
863 863
864Xref
865
866* Find Identifiers:: Commands to find where an identifier is defined
867 or referenced, to list identifiers, etc.
868* Tags Tables:: Tags table records which file defines a symbol.
869* Select Tags Table:: How to visit a specific tags table.
870
871Find Identifiers
872
873* Looking Up Identifiers:: Commands to find the definition of a specific tag.
874* Xref Commands:: Commands in the @file{*xref*} buffer.
875* Identifier Search:: Searching and replacing identifiers.
876* List Identifiers:: Listing identifiers and completing on them.
877
864Tags Tables 878Tags Tables
865 879
866* Tag Syntax:: Tag syntax for various types of code and text files. 880* Tag Syntax:: Tag syntax for various types of code and text files.
867* Create Tags Table:: Creating a tags table with @command{etags}. 881* Create Tags Table:: Creating a tags table with @command{etags}.
868* Etags Regexps:: Create arbitrary tags using regular expressions. 882* Etags Regexps:: Create arbitrary tags using regular expressions.
869* Select Tags Table:: How to visit a tags table.
870* Find Tag:: Commands to find the definition of a specific tag.
871* Tags Search:: Using a tags table for searching and replacing.
872* List Tags:: Using tags for completion, and listing them.
873 883
874@ifnottex 884@ifnottex
875Merging Files with Emerge 885Merging Files with Emerge
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index a0489975c7d..5fbe0fc5774 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -416,9 +416,9 @@ Start composing a mail message in another frame. This runs
416@code{compose-mail-other-frame}. It is the other-frame variant of 416@code{compose-mail-other-frame}. It is the other-frame variant of
417@kbd{C-x m}. @xref{Sending Mail}. 417@kbd{C-x m}. @xref{Sending Mail}.
418@item C-x 5 . 418@item C-x 5 .
419Find a tag in the current tag table in another frame. This runs 419Find the definition of an identifier in another frame. This runs
420@code{find-tag-other-frame}, the multiple-frame variant of @kbd{M-.}. 420@code{xref-find-definitions-other-frame}, the multiple-frame variant
421@xref{Tags}. 421of @kbd{M-.}. @xref{Xref}.
422@item C-x 5 r @var{filename} @key{RET} 422@item C-x 5 r @var{filename} @key{RET}
423@kindex C-x 5 r 423@kindex C-x 5 r
424@findex find-file-read-only-other-frame 424@findex find-file-read-only-other-frame
diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi
index 4b9832f904b..bce97dacee2 100644
--- a/doc/emacs/glossary.texi
+++ b/doc/emacs/glossary.texi
@@ -1329,7 +1329,7 @@ indentation or completion.
1329@anchor{Glossary---Tags Table} 1329@anchor{Glossary---Tags Table}
1330@item Tags Table 1330@item Tags Table
1331A tags table is a file that serves as an index to the function 1331A tags table is a file that serves as an index to the function
1332definitions in one or more other files. @xref{Tags}. 1332definitions in one or more other files. @xref{Tags Tables}.
1333 1333
1334@item Termscript File 1334@item Termscript File
1335A termscript file contains a record of all characters sent by Emacs to 1335A termscript file contains a record of all characters sent by Emacs to
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 7b72e6650c8..8842b8ea2f5 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -5,17 +5,42 @@
5@node Maintaining 5@node Maintaining
6@chapter Maintaining Large Programs 6@chapter Maintaining Large Programs
7 7
8 This chapter describes Emacs features for maintaining large 8 This chapter describes Emacs features for maintaining medium- to
9programs. If you are maintaining a large Lisp program, then in 9large-size programs and packages. These features include:
10addition to the features described here, you may find 10
11the Emacs Lisp Regression Testing (ERT) library useful 11@itemize @minus
12(@pxref{Top,,ERT,ert, Emacs Lisp Regression Testing}). 12@item
13Unified interface to Support for Version Control Systems
14(@acronym{VCS}) that record the history of changes to source files.
15
16@item
17A specialized mode for maintaining @file{ChangeLog} files that provide
18a chronological log of program changes.
19
20@item
21@acronym{Xref}, a set of commands for displaying definitions of
22symbols (a.k.a.@: ``identifiers'') and their references.
23
24@item
25@acronym{EDE}, the Emacs's own IDE.
26
27@ifnottex
28@item
29A mode for merging changes to program sources made on separate
30branches of development.
31@end ifnottex
32@end itemize
33
34If you are maintaining a large Lisp program, then in addition to the
35features described here, you may find the Emacs Lisp Regression
36Testing (@acronym{ERT}) library useful (@pxref{Top,,ERT,ert, Emacs
37Lisp Regression Testing}).
13 38
14@menu 39@menu
15* Version Control:: Using version control systems. 40* Version Control:: Using version control systems.
16* Change Log:: Maintaining a change history for your program. 41* Change Log:: Maintaining a change history for your program.
17* Tags:: Go directly to any function in your program in one 42* Xref:: Find definitions and references of any function,
18 command. Tags remembers which file it is in. 43 method, struct, macro, @dots{} in your program.
19* EDE:: An integrated development environment for Emacs. 44* EDE:: An integrated development environment for Emacs.
20@ifnottex 45@ifnottex
21* Emerge:: A convenient way of merging two versions of a program. 46* Emerge:: A convenient way of merging two versions of a program.
@@ -1660,16 +1685,370 @@ permitted provided the copyright notice and this notice are preserved.
1660@noindent 1685@noindent
1661Of course, you should substitute the proper years and copyright holder. 1686Of course, you should substitute the proper years and copyright holder.
1662 1687
1663@node Tags 1688@node Xref
1664@section Tags Tables 1689@section Find Identifier Definitions and References
1665@cindex tags and tag tables 1690@cindex xref
1691
1692 An @dfn{identifier} is a syntactic elements of the program: a
1693function, a subroutine, a method, a class, a data type, a macro, etc.
1694In a programming language, each identifier is a symbol in the
1695language's syntax. Many program development tools provide
1696capabilities to extract references to identifiers from source files,
1697record them on specialized data bases, and then use those data bases
1698to quickly find where each identifier was defined and referenced.
1699
1700Emacs provides a unified user interface to these tools, called
1701@samp{xref}. The tools supported by @samp{xref} include:
1702
1703@enumerate a
1704@item
1705Some major modes provide built-in means for looking up the language
1706symbols. For example, Emacs Lisp symbols can be identified by
1707searching the package load history, maintained by the Emacs Lisp
1708interpreter, and by consulting the built-in documentation strings; the
1709Emacs Lisp mode uses these facilities to find definitions of symbols.
1710
1711@item
1712Etags, the command for tagging identifier definitions which is part of
1713the Emacs distribution. @xref{Create Tags Table}.
1714
1715@item
1716@acronym{GNU} GLOBAL, the source code tagging system, which provides
1717the @command{gtags} command and associated utilities. @xref{Command
1718Line, gtags, , global, GNU GLOBAL source code tag system}.
1719
1720@item
1721Cscope (@uref{http://cscope.sourceforge.net/}, a tool for browsing
1722source code.
1723
1724@item
1725@acronym{GNU} IDUtils, a package for generating databases of
1726identifier references and querying those databases. @xref{Top,,,
1727idutils, ID database utilities}.
1728
1729@item
1730Grep, the venerable program that searches files for lines matching
1731patterns. @xref{Invoking,,, grep, GNU Grep Manual}.
1732@end enumerate
1733
1734@noindent
1735Additional tools could be supported as they become available, or as
1736user extensions. Each such tool is used as a @dfn{backend} by
1737commands described in this section. Each command detects which
1738backends are available for the current major mode, and uses the most
1739capable of the available backends, with Grep generally serving as the
1740fall-back backend.
1741
1742@cindex tag
1743The commands described here are useful for finding references in major
1744modes other than those defined to support programming languages. For
1745example, chapters, sections, appendices, etc. of a text or a @TeX{}
1746document can be treated as identifiers as well. In this chapter, we
1747collectively refer to a reference that specifies the name of the file
1748where the corresponding subunit is defined, and the position of the
1749subunit's definition in that file, as a @dfn{tag}. We refer to the
1750backends used by @code{xref} as @dfn{tagging backends}.
1751
1752@menu
1753* Find Identifiers:: Commands to find where an identifier is defined
1754 or referenced, to list identifiers, etc.
1755* Tags Tables:: Tags table records which file defines a symbol.
1756* Select Tags Table:: How to visit a specific tags table.
1757@end menu
1758
1759@node Find Identifiers
1760@subsection Find Identifiers
1761
1762 This subsection describes the commands that use the tagging backends
1763in order to find definitions of identifiers, references to
1764identifiers, and perform various queries about identifiers. With most
1765backends, these definitions and references were recorded as tags in
1766the database created and maintained by the backend.
1767
1768@menu
1769* Looking Up Identifiers:: Commands to find the definition of a specific tag.
1770* Xref Commands:: Commands in the @file{*xref*} buffer.
1771* Identifier Search:: Searching and replacing identifiers.
1772* List Identifiers:: Listing identifiers and completing on them.
1773@end menu
1774
1775@node Looking Up Identifiers
1776@subsubsection Looking Up Identifiers
1777@cindex find definition of symbols
1778@cindex identifier, finding definition of
1779@cindex find references to symbols
1780
1781 The most important thing that @code{xref} enables you to do is to find
1782the definition of a specific identifier.
1783
1784@table @kbd
1785@item M-.@:
1786Find definitions of an identifier (@code{xref-find-definitions}).
1787@item C-M-. @var{pattern} @key{RET}
1788Find all identifiers whose name matches @var{pattern}
1789(@code{xref-find-apropos}).
1790@item C-x 4 .@: @key{RET}
1791Find definitions of identifier, but display it in another window
1792(@code{xref-find-definitions-other-window}).
1793@item C-x 5 .@: @key{RET}
1794Find definition of identifier, and display it in a new frame
1795(@code{xref-find-definitions-other-frame}).
1796@item M-,
1797Pop back to where you previously invoked @kbd{M-.} and friends
1798(@code{xref-pop-marker-stack}).
1799@end table
1800
1801@kindex M-.
1802@findex xref-find-definitions
1803 @kbd{M-.}@: (@code{xref-find-definitions}) shows the definitions of
1804the identifier at point. With a prefix argument, or if there's no
1805valid identifier at point, it prompts for the identifier. If the
1806identifier has only one definition, the command jumps to it. If the
1807identifier has more than one possible definition (e.g., in an
1808object-oriented language, or if there's a function and a variable by
1809the same name), the command shows the candidate definitions in a
1810@file{*xref*} buffer, together with the files in which these
1811definitions are found. Selecting one of these candidates by typing
1812@kbd{@key{RET}} or clicking @kbd{Mouse-2} will pop a buffer showing
1813the corresponding definition.
1814
1815 When entering the identifier argument to @kbd{M-.}, the usual
1816minibuffer completion commands can be used (@pxref{Completion}), with
1817the known identifier names as completion candidates.
1666 1818
1667 A @dfn{tag} is a reference to a subunit in a program or in a 1819@kindex C-x 4 .
1668document. In source code, tags reference syntactic elements of the 1820@findex xref-find-definitions-other-window
1669program: functions, subroutines, data types, macros, etc. In a 1821@kindex C-x 5 .
1670document, tags reference chapters, sections, appendices, etc. Each 1822@findex xref-find-definitions-other-frame
1671tag specifies the name of the file where the corresponding subunit is 1823 Like most commands that can switch buffers,
1672defined, and the position of the subunit's definition in that file. 1824@code{xref-find-definitions} has a variant that displays the new
1825buffer in another window, and one that makes a new frame for it. The
1826former is @w{@kbd{C-x 4 .}}
1827(@code{xref-find-definitions-other-window}), and the latter is
1828@w{@kbd{C-x 5 .}} (@code{xref-find-definitions-other-frame}).
1829
1830@findex xref-find-apropos
1831@kindex C-M-.
1832 The command @kbd{C-M-.} (@code{xref-find-apropos}) finds the
1833definitions of one or more identifiers that match a specified regular
1834expression. It is just like @kbd{M-.} except that it does regexp
1835matching of identifiers instead of symbol name matching.
1836
1837 When any of the above commands finds more than one definition, it
1838presents the @file{*xref*} buffer showing the definition candidates.
1839In that buffer, you have several specialized commands, described in
1840@ref{Xref Commands}.
1841
1842@kindex M-,
1843@findex xref-pop-marker-stack
1844@vindex xref-marker-ring-length
1845 To go back to places @emph{from where} you found the definition,
1846use @kbd{M-,} (@code{xref-pop-marker-stack}). It jumps back to the
1847point of the last invocation of @kbd{M-.}. Thus you can find and
1848examine the definition of something with @kbd{M-.} and then return to
1849where you were with @kbd{M-,}. @kbd{M-,} allows you to retrace your
1850steps to a depth determined by the variable
1851@code{xref-marker-ring-length}, which defaults to 16.
1852
1853@node Xref Commands
1854@subsubsection Commands Available in the @file{*xref*} Buffer
1855@cindex commands in @file{*xref*} buffers
1856@cindex XREF mode
1857
1858 The following commands are provided in the @file{*xref*} buffer by
1859the special XREF mode:
1860
1861@table @kbd
1862@item @key{RET}
1863@itemx Mouse-2
1864Display the reference on the current line and bury the @file{*xref*}
1865buffer.
1866@item n
1867@itemx .
1868@findex xref-next-line
1869Move to the next reference and display it in the other window
1870(@code{xref-next-line}).
1871@item p
1872@itemx ,
1873@findex xref-prev-line
1874Move to the previous reference and display it in the other window
1875(@code{xref-prev-line}).
1876@item C-o
1877@findex xref-show-location-at-point
1878Display the reference on the current line in the other window
1879(@code{xref-show-location-at-point}).
1880@findex xref-query-replace
1881@item r @var{pattern} @key{RET} @var{replacement} @key{RET}
1882Perform interactive query-replace on references that match
1883@var{pattern} (@code{xref-query-replace}), replacing the match with
1884@var{replacement}. @xref{Identifier Search}.
1885@findex xref-quit
1886@item q
1887Quit the window showing the @file{*xref*} buffer (@code{xref-quit}).
1888@end table
1889
1890In addition, the usual navigation commands, such as the arrow keys,
1891@kbd{C-n}, and @kbd{C-p} are available for moving around the buffer
1892without displaying the references.
1893
1894@node Identifier Search
1895@subsubsection Searching and Replacing with Identifiers
1896@cindex search and replace in multiple files
1897@cindex multiple-file search and replace
1898
1899 The commands in this section visit and search all the files listed
1900in the @code{xref} backend's database, one by one. For these
1901commands, the database serves only to specify a sequence of files to
1902search. These commands scan all the databases starting with the first
1903one (if any) that describes the current file, proceed from there to
1904the end of the list, and then scan from the beginning of the list
1905until they have covered all the databases in the list.
1906
1907@table @kbd
1908@item M-?
1909Find all the references for the identifier at point.
1910@item M-x xref-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
1911Interactively replace @var{regexp} with @var{replacement} in the names
1912of all the identifiers shown in the @file{*xref*} buffer.
1913@item M-x tags-search @key{RET} @var{regexp} @key{RET}
1914Search for @var{regexp} through the files in the selected tags
1915table.
1916@item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
1917Perform a @code{query-replace-regexp} on each file in the selected tags table.
1918@item M-x tags-loop-continue
1919Restart one of the last 2 commands above, from the current location of point.
1920@end table
1921
1922@kindex M-?
1923@findex xref-find-references
1924 @kbd{M-?} finds all the references for the identifier at point. If
1925there's no valid identifier at point, or when invoked with a prefix
1926argument, the command prompts for the identifier, with completion. It
1927then presents a @file{*xref*} buffer with all the references to the
1928identifier, showing the file name and the line where the identifier is
1929referenced. The XREF mode commands are available in this buffer, see
1930@ref{Xref Commands}.
1931
1932@findex xref-query-replace
1933 @kbd{M-x xref-query-replace} reads a regexp to match identifier
1934names and a string to replace with, just like ordinary @kbd{M-x
1935query-replace-regexp}. It then performs the specified replacement in
1936the names of the matching identifiers in all the places in all the
1937files where these identifiers are referenced. This is useful when you
1938rename your identifiers as part of refactoring. This command should
1939be invoked in the @file{*xref*} buffer generated by @code{M-?}.
1940
1941@findex tags-search
1942 @kbd{M-x tags-search} reads a regexp using the minibuffer, then
1943searches for matches in all the files in the selected tags table, one
1944file at a time. It displays the name of the file being searched so
1945you can follow its progress. As soon as it finds an occurrence,
1946@code{tags-search} returns. This command works only with the etags
1947backend, and requires tags tables to be available (@pxref{Tags
1948Tables}).
1949
1950@findex tags-loop-continue
1951 Having found one match, you probably want to find all the rest.
1952Type @kbd{M-x tags-loop-continue}) to resume the @code{tags-search},
1953finding one more match. This searches the rest of the current buffer,
1954followed by the remaining files of the tags table.
1955
1956@findex tags-query-replace
1957 @kbd{M-x tags-query-replace} performs a single
1958@code{query-replace-regexp} through all the files in the tags table. It
1959reads a regexp to search for and a string to replace with, just like
1960ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x
1961tags-search}, but repeatedly, processing matches according to your
1962input. @xref{Query Replace}, for more information on query replace.
1963This command works only with the etags backend.
1964
1965@vindex tags-case-fold-search
1966@cindex case-sensitivity and tags search
1967 You can control the case-sensitivity of tags search commands by
1968customizing the value of the variable @code{tags-case-fold-search}. The
1969default is to use the same setting as the value of
1970@code{case-fold-search} (@pxref{Lax Search}).
1971
1972 It is possible to get through all the files in the tags table with a
1973single invocation of @kbd{M-x tags-query-replace}. But often it is
1974useful to exit temporarily, which you can do with any input event that
1975has no special query replace meaning. You can resume the query
1976replace subsequently by typing @kbd{M-x tags-loop-continue}; this
1977command resumes the last tags search or replace command that you did.
1978For instance, to skip the rest of the current file, you can type
1979@kbd{M-> M-x tags-loop-continue}.
1980
1981 The commands in this section carry out much broader searches than
1982the @code{xref-find-definitions} family. The
1983@code{xref-find-definitions} commands search only for definitions of
1984identifiers that match your string or regexp. The commands
1985@code{tags-search} and @code{tags-query-replace} find every occurrence
1986of the regexp, as ordinary search commands and replace commands do in
1987the current buffer.
1988
1989 As an alternative to @code{tags-search}, you can run @command{grep}
1990as a subprocess and have Emacs show you the matching lines one by one.
1991@xref{Grep Searching}.
1992
1993@node List Identifiers
1994@subsubsection Identifier Inquiries
1995
1996@table @kbd
1997@item C-M-i
1998@itemx M-@key{TAB}
1999Perform completion on the text around point, using the @code{xref}
2000backend if one is available (@code{completion-at-point}).
2001@item M-x list-tags @key{RET} @var{file} @key{RET}
2002Display a list of the tags defined in the program file @var{file}.
2003@item M-x xref-find-apropos @key{RET} @var{regexp} @key{RET}
2004Display a list of all known identifiers matching @var{regexp}.
2005@end table
2006
2007@cindex completion (symbol names)
2008 In most programming language modes, you can type @kbd{C-M-i} or
2009@kbd{M-@key{TAB}} (@code{completion-at-point}) to complete the symbol
2010at point. If there is an @code{xref} backend available, this command
2011can use it to generate completion candidates more intelligently.
2012@xref{Symbol Completion}.
2013
2014@findex list-tags
2015 @kbd{M-x list-tags} reads the name of one of the files covered by
2016the selected tags table, and displays a list of tags defined in that
2017file. Do not include a directory as part of the file name unless the
2018file name recorded in the tags table includes a directory. This
2019command works only with the etags backend, and requires a tags table
2020for the project to be available. @xref{Tags Tables}.
2021
2022@c Sadly, the new-and-improved Xref feature doesn't provide anything
2023@c close to the described below features of the now-obsoleted
2024@c tags-apropos. I'm leaving this here to encourage enhancements to
2025@c xref.el.
2026@ignore
2027@findex tags-apropos
2028@vindex tags-apropos-verbose
2029@vindex tags-tag-face
2030@vindex tags-apropos-additional-actions
2031 @kbd{M-x tags-apropos} is like @code{apropos} for tags
2032(@pxref{Apropos}). It displays a list of tags in the selected tags
2033table whose entries match @var{regexp}. If the variable
2034@code{tags-apropos-verbose} is non-@code{nil}, it displays the names
2035of the tags files together with the tag names. You can customize the
2036appearance of the output by setting the variable @code{tags-tag-face}
2037to a face. You can display additional output by customizing the
2038variable @code{tags-apropos-additional-actions}; see its documentation
2039for details.
2040@end ignore
2041
2042@findex next-file
2043 @kbd{M-x next-file} visits files covered by the selected tags table.
2044The first time it is called, it visits the first file covered by the
2045table. Each subsequent call visits the next covered file, unless a
2046prefix argument is supplied, in which case it returns to the first
2047file. This command works only with the etags backend.
2048
2049@node Tags Tables
2050@subsection Tags Tables
2051@cindex tags and tag tables
1673 2052
1674 A @dfn{tags table} records the tags extracted by scanning the source 2053 A @dfn{tags table} records the tags extracted by scanning the source
1675code of a certain program or a certain document. Tags extracted from 2054code of a certain program or a certain document. Tags extracted from
@@ -1685,12 +2064,14 @@ source files.
1685on a document or the source code file. The @samp{etags} program 2064on a document or the source code file. The @samp{etags} program
1686writes the tags to a @dfn{tags table file}, or @dfn{tags file} in 2065writes the tags to a @dfn{tags table file}, or @dfn{tags file} in
1687short. The conventional name for a tags file is @file{TAGS}@. 2066short. The conventional name for a tags file is @file{TAGS}@.
1688@xref{Create Tags Table}. 2067@xref{Create Tags Table}. (It is also possible to create a tags table
2068by using one of the commands from other packages that can produce such
2069tables in the same format.)
1689 2070
1690 Emacs provides many commands for searching and replacing using the 2071 Emacs uses the tags tables via the @code{etags} package as one of
1691information recorded in tags tables. For instance, the @kbd{M-.} 2072the supported backends for @code{xref}. Because tags tables are
1692(@code{find-tag}) jumps to the location of a specified function 2073produced by the @command{etags} command that is part of an Emacs
1693definition in its source file. @xref{Find Tag}. 2074distribution, we describe tags tables in more detail here.
1694 2075
1695@cindex C++ class browser, tags 2076@cindex C++ class browser, tags
1696@cindex tags, C++ 2077@cindex tags, C++
@@ -1706,14 +2087,10 @@ use tags, separate from the @command{etags} facility.
1706* Tag Syntax:: Tag syntax for various types of code and text files. 2087* Tag Syntax:: Tag syntax for various types of code and text files.
1707* Create Tags Table:: Creating a tags table with @command{etags}. 2088* Create Tags Table:: Creating a tags table with @command{etags}.
1708* Etags Regexps:: Create arbitrary tags using regular expressions. 2089* Etags Regexps:: Create arbitrary tags using regular expressions.
1709* Select Tags Table:: How to visit a tags table.
1710* Find Tag:: Commands to find the definition of a specific tag.
1711* Tags Search:: Using a tags table for searching and replacing.
1712* List Tags:: Using tags for completion, and listing them.
1713@end menu 2090@end menu
1714 2091
1715@node Tag Syntax 2092@node Tag Syntax
1716@subsection Source File Tag Syntax 2093@subsubsection Source File Tag Syntax
1717 2094
1718 Here is how tag syntax is defined for the most popular languages: 2095 Here is how tag syntax is defined for the most popular languages:
1719 2096
@@ -1883,13 +2260,17 @@ line.
1883@item 2260@item
1884In Python code, @code{def} or @code{class} at the beginning of a line 2261In Python code, @code{def} or @code{class} at the beginning of a line
1885generate a tag. 2262generate a tag.
2263
2264@item
2265In Ruby code, @code{def} or @code{class} or @code{module} at the
2266beginning of a line generate a tag.
1886@end itemize 2267@end itemize
1887 2268
1888 You can also generate tags based on regexp matching (@pxref{Etags 2269 You can also generate tags based on regexp matching (@pxref{Etags
1889Regexps}) to handle other formats and languages. 2270Regexps}) to handle other formats and languages.
1890 2271
1891@node Create Tags Table 2272@node Create Tags Table
1892@subsection Creating Tags Tables 2273@subsubsection Creating Tags Tables
1893@cindex @command{etags} program 2274@cindex @command{etags} program
1894 2275
1895 The @command{etags} program is used to create a tags table file. It knows 2276 The @command{etags} program is used to create a tags table file. It knows
@@ -1946,7 +2327,7 @@ source files, and the tags file will still refer correctly to the source
1946files. If the tags file is @file{-} or is in the @file{/dev} directory, 2327files. If the tags file is @file{-} or is in the @file{/dev} directory,
1947however, the file names are 2328however, the file names are
1948made relative to the current working directory. This is useful, for 2329made relative to the current working directory. This is useful, for
1949example, when writing the tags to @file{/dev/stdout}. 2330example, when writing the tags to the standard output.
1950 2331
1951 When using a relative file name, it should not be a symbolic link 2332 When using a relative file name, it should not be a symbolic link
1952pointing to a tags file in a different directory, because this would 2333pointing to a tags file in a different directory, because this would
@@ -1992,7 +2373,7 @@ options, it outputs detailed information about how tags are generated for
1992@var{lang}. 2373@var{lang}.
1993 2374
1994@node Etags Regexps 2375@node Etags Regexps
1995@subsection Etags Regexps 2376@subsubsection Etags Regexps
1996 2377
1997 The @samp{--regex} option to @command{etags} allows tags to be 2378 The @samp{--regex} option to @command{etags} allows tags to be
1998recognized by regular expression matching. You can intermix this 2379recognized by regular expression matching. You can intermix this
@@ -2151,7 +2532,7 @@ etags --language=none \
2151@subsection Selecting a Tags Table 2532@subsection Selecting a Tags Table
2152 2533
2153@findex visit-tags-table 2534@findex visit-tags-table
2154 Emacs has at any time one @dfn{selected} tags table. All the 2535 Emacs has at any time at most one @dfn{selected} tags table. All the
2155commands for working with tags tables use the selected one. To select 2536commands for working with tags tables use the selected one. To select
2156a tags table, type @kbd{M-x visit-tags-table}, which reads the tags 2537a tags table, type @kbd{M-x visit-tags-table}, which reads the tags
2157table file name as an argument, with @file{TAGS} in the default 2538table file name as an argument, with @file{TAGS} in the default
@@ -2192,212 +2573,6 @@ table mentions that file, as explained above.
2192 2573
2193 Do not set both @code{tags-file-name} and @code{tags-table-list}. 2574 Do not set both @code{tags-file-name} and @code{tags-table-list}.
2194 2575
2195@node Find Tag
2196@subsection Finding a Tag
2197
2198 The most important thing that a tags table enables you to do is to find
2199the definition of a specific tag.
2200
2201@table @kbd
2202@item M-.@: @var{tag} @key{RET}
2203Find first definition of @var{tag} (@code{find-tag}).
2204@item C-u M-.
2205Find next alternate definition of last tag specified.
2206@item C-u - M-.
2207Go back to previous tag found.
2208@item C-M-. @var{pattern} @key{RET}
2209Find a tag whose name matches @var{pattern} (@code{find-tag-regexp}).
2210@item C-u C-M-.
2211Find the next tag whose name matches the last pattern used.
2212@item C-x 4 .@: @var{tag} @key{RET}
2213Find first definition of @var{tag}, but display it in another window
2214(@code{find-tag-other-window}).
2215@item C-x 5 .@: @var{tag} @key{RET}
2216Find first definition of @var{tag}, and create a new frame to select the
2217buffer (@code{find-tag-other-frame}).
2218@item M-*
2219Pop back to where you previously invoked @kbd{M-.} and friends.
2220@end table
2221
2222@kindex M-.
2223@findex find-tag
2224 @kbd{M-.}@: (@code{find-tag}) prompts for a tag name and jumps to
2225its source definition. It works by searching through the tags table
2226for that tag's file and approximate character position, visiting that
2227file, and searching for the tag definition at ever-increasing
2228distances away from the recorded approximate position.
2229
2230 When entering the tag argument to @kbd{M-.}, the usual minibuffer
2231completion commands can be used (@pxref{Completion}), with the tag
2232names in the selected tags table as completion candidates. If you
2233specify an empty argument, the balanced expression in the buffer
2234before or around point is the default argument. @xref{Expressions}.
2235
2236 You don't need to give @kbd{M-.} the full name of the tag; a part
2237will do. @kbd{M-.} finds tags which contain that argument as a
2238substring. However, it prefers an exact match to a substring match.
2239To find other tags that match the same substring, give @code{find-tag}
2240a numeric argument, as in @kbd{C-u M-.} or @kbd{M-0 M-.}; this does
2241not read a tag name, but continues searching the tags table's text for
2242another tag containing the same substring last used.
2243
2244@kindex C-x 4 .
2245@findex find-tag-other-window
2246@kindex C-x 5 .
2247@findex find-tag-other-frame
2248 Like most commands that can switch buffers, @code{find-tag} has a
2249variant that displays the new buffer in another window, and one that
2250makes a new frame for it. The former is @w{@kbd{C-x 4 .}}
2251(@code{find-tag-other-window}), and the latter is @w{@kbd{C-x 5 .}}
2252(@code{find-tag-other-frame}).
2253
2254 To move back to previous tag definitions, use @kbd{C-u - M-.}; more
2255generally, @kbd{M-.} with a negative numeric argument. Similarly,
2256@w{@kbd{C-x 4 .}} with a negative argument finds the previous tag
2257location in another window.
2258
2259@kindex M-*
2260@findex pop-tag-mark
2261@vindex find-tag-marker-ring-length
2262 As well as going back to places you've found tags recently, you can
2263go back to places @emph{from where} you found them, using @kbd{M-*}
2264(@code{pop-tag-mark}). Thus you can find and examine the definition
2265of something with @kbd{M-.} and then return to where you were with
2266@kbd{M-*}.
2267
2268 Both @kbd{C-u - M-.} and @kbd{M-*} allow you to retrace your steps to
2269a depth determined by the variable @code{find-tag-marker-ring-length}.
2270
2271@findex find-tag-regexp
2272@kindex C-M-.
2273 The command @kbd{C-M-.} (@code{find-tag-regexp}) visits the tags that
2274match a specified regular expression. It is just like @kbd{M-.} except
2275that it does regexp matching instead of substring matching.
2276
2277@node Tags Search
2278@subsection Searching and Replacing with Tags Tables
2279@cindex search and replace in multiple files
2280@cindex multiple-file search and replace
2281
2282 The commands in this section visit and search all the files listed
2283in the selected tags table, one by one. For these commands, the tags
2284table serves only to specify a sequence of files to search. These
2285commands scan the list of tags tables starting with the first tags
2286table (if any) that describes the current file, proceed from there to
2287the end of the list, and then scan from the beginning of the list
2288until they have covered all the tables in the list.
2289
2290@table @kbd
2291@item M-x tags-search @key{RET} @var{regexp} @key{RET}
2292Search for @var{regexp} through the files in the selected tags
2293table.
2294@item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} @var{replacement} @key{RET}
2295Perform a @code{query-replace-regexp} on each file in the selected tags table.
2296@item M-,
2297Restart one of the commands above, from the current location of point
2298(@code{tags-loop-continue}).
2299@end table
2300
2301@findex tags-search
2302 @kbd{M-x tags-search} reads a regexp using the minibuffer, then
2303searches for matches in all the files in the selected tags table, one
2304file at a time. It displays the name of the file being searched so you
2305can follow its progress. As soon as it finds an occurrence,
2306@code{tags-search} returns.
2307
2308@kindex M-,
2309@findex tags-loop-continue
2310 Having found one match, you probably want to find all the rest.
2311Type @kbd{M-,} (@code{tags-loop-continue}) to resume the
2312@code{tags-search}, finding one more match. This searches the rest of
2313the current buffer, followed by the remaining files of the tags table.
2314
2315@findex tags-query-replace
2316 @kbd{M-x tags-query-replace} performs a single
2317@code{query-replace-regexp} through all the files in the tags table. It
2318reads a regexp to search for and a string to replace with, just like
2319ordinary @kbd{M-x query-replace-regexp}. It searches much like @kbd{M-x
2320tags-search}, but repeatedly, processing matches according to your
2321input. @xref{Query Replace}, for more information on query replace.
2322
2323@vindex tags-case-fold-search
2324@cindex case-sensitivity and tags search
2325 You can control the case-sensitivity of tags search commands by
2326customizing the value of the variable @code{tags-case-fold-search}. The
2327default is to use the same setting as the value of
2328@code{case-fold-search} (@pxref{Lax Search}).
2329
2330 It is possible to get through all the files in the tags table with a
2331single invocation of @kbd{M-x tags-query-replace}. But often it is
2332useful to exit temporarily, which you can do with any input event that
2333has no special query replace meaning. You can resume the query
2334replace subsequently by typing @kbd{M-,}; this command resumes the
2335last tags search or replace command that you did. For instance, to
2336skip the rest of the current file, you can type @kbd{M-> M-,}.
2337
2338 The commands in this section carry out much broader searches than the
2339@code{find-tag} family. The @code{find-tag} commands search only for
2340definitions of tags that match your substring or regexp. The commands
2341@code{tags-search} and @code{tags-query-replace} find every occurrence
2342of the regexp, as ordinary search commands and replace commands do in
2343the current buffer.
2344
2345 These commands create buffers only temporarily for the files that they
2346have to search (those which are not already visited in Emacs buffers).
2347Buffers in which no match is found are quickly killed; the others
2348continue to exist.
2349
2350 As an alternative to @code{tags-search}, you can run @command{grep}
2351as a subprocess and have Emacs show you the matching lines one by one.
2352@xref{Grep Searching}.
2353
2354@node List Tags
2355@subsection Tags Table Inquiries
2356
2357@table @kbd
2358@item C-M-i
2359@itemx M-@key{TAB}
2360Perform completion on the text around point, using the selected tags
2361table if one is loaded (@code{completion-at-point}).
2362@item M-x list-tags @key{RET} @var{file} @key{RET}
2363Display a list of the tags defined in the program file @var{file}.
2364@item M-x tags-apropos @key{RET} @var{regexp} @key{RET}
2365Display a list of all tags matching @var{regexp}.
2366@end table
2367
2368@cindex completion (symbol names)
2369 In most programming language modes, you can type @kbd{C-M-i} or
2370@kbd{M-@key{TAB}} (@code{completion-at-point}) to complete the symbol
2371at point. If there is a selected tags table, this command can use it
2372to generate completion candidates. @xref{Symbol Completion}.
2373
2374@findex list-tags
2375 @kbd{M-x list-tags} reads the name of one of the files covered by
2376the selected tags table, and displays a list of tags defined in that
2377file. Do not include a directory as part of the file name unless the
2378file name recorded in the tags table includes a directory.
2379
2380@findex tags-apropos
2381@vindex tags-apropos-verbose
2382@vindex tags-tag-face
2383@vindex tags-apropos-additional-actions
2384 @kbd{M-x tags-apropos} is like @code{apropos} for tags
2385(@pxref{Apropos}). It displays a list of tags in the selected tags
2386table whose entries match @var{regexp}. If the variable
2387@code{tags-apropos-verbose} is non-@code{nil}, it displays the names
2388of the tags files together with the tag names. You can customize the
2389appearance of the output by setting the variable @code{tags-tag-face}
2390to a face. You can display additional output by customizing the
2391variable @code{tags-apropos-additional-actions}; see its documentation
2392for details.
2393
2394@findex next-file
2395 @kbd{M-x next-file} visits files covered by the selected tags table.
2396The first time it is called, it visits the first file covered by the
2397table. Each subsequent call visits the next covered file, unless a
2398prefix argument is supplied, in which case it returns to the first
2399file.
2400
2401@node EDE 2576@node EDE
2402@section Emacs Development Environment 2577@section Emacs Development Environment
2403@cindex EDE (Emacs Development Environment) 2578@cindex EDE (Emacs Development Environment)
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi
index 97c74a9ce81..e4bd85c0ddd 100644
--- a/doc/emacs/programs.texi
+++ b/doc/emacs/programs.texi
@@ -271,7 +271,7 @@ bindings for that purpose.
271 The Imenu facility offers a way to find the major definitions in 271 The Imenu facility offers a way to find the major definitions in
272a file by name. It is also useful in text formatter major modes, 272a file by name. It is also useful in text formatter major modes,
273where it treats each chapter, section, etc., as a definition. 273where it treats each chapter, section, etc., as a definition.
274(@xref{Tags}, for a more powerful feature that handles multiple files 274(@xref{Xref}, for a more powerful feature that handles multiple files
275together.) 275together.)
276 276
277@findex imenu 277@findex imenu
@@ -1358,7 +1358,7 @@ the @kbd{M-@key{TAB}} key is usually reserved by the window manager
1358for switching graphical windows, so you should type @kbd{C-M-i} or 1358for switching graphical windows, so you should type @kbd{C-M-i} or
1359@kbd{@key{ESC} @key{TAB}} instead. 1359@kbd{@key{ESC} @key{TAB}} instead.
1360 1360
1361@cindex tags-based completion 1361@cindex xref-based completion
1362@findex completion-at-point 1362@findex completion-at-point
1363@cindex Lisp symbol completion 1363@cindex Lisp symbol completion
1364@cindex completion (Lisp symbols) 1364@cindex completion (Lisp symbols)
@@ -1368,7 +1368,7 @@ which generates its completion list in a flexible way. If Semantic
1368mode is enabled, it tries to use the Semantic parser data for 1368mode is enabled, it tries to use the Semantic parser data for
1369completion (@pxref{Semantic}). If Semantic mode is not enabled or 1369completion (@pxref{Semantic}). If Semantic mode is not enabled or
1370fails at performing completion, it tries to complete using the 1370fails at performing completion, it tries to complete using the
1371selected tags table (@pxref{Tags}). If in Emacs Lisp mode, it 1371available @code{xref} backend (@pxref{Xref}). If in Emacs Lisp mode, it
1372performs completion using the function, variable, or property names 1372performs completion using the function, variable, or property names
1373defined in the current Emacs session. 1373defined in the current Emacs session.
1374 1374
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index cc516ec2d45..bef74e3b2c5 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -12,10 +12,10 @@ a string. Emacs also has commands to replace occurrences of a string
12with a different string. There are also commands that do the same 12with a different string. There are also commands that do the same
13thing, but search for patterns instead of fixed strings. 13thing, but search for patterns instead of fixed strings.
14 14
15 You can also search multiple files under the control of a tags table 15 You can also search multiple files under the control of an
16(@pxref{Tags Search}) or through the Dired @kbd{A} command 16@code{xref} backend (@pxref{Identifier Search}) or through the Dired
17(@pxref{Operating on Files}), or ask the @code{grep} program to do it 17@kbd{A} command (@pxref{Operating on Files}), or ask the @code{grep}
18(@pxref{Grep Searching}). 18program to do it (@pxref{Grep Searching}).
19 19
20@menu 20@menu
21* Incremental Search:: Search happens as you type the string. 21* Incremental Search:: Search happens as you type the string.
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index cd7d08dede6..f99234b5c1b 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -231,8 +231,9 @@ Mail}), but in another window (@code{compose-mail-other-window}).
231 231
232@findex find-tag-other-window 232@findex find-tag-other-window
233@item C-x 4 . 233@item C-x 4 .
234Find a tag in the current tags table, similar to @kbd{M-.} 234Find the definition of an identifier, similar to @kbd{M-.}
235(@pxref{Tags}), but in another window (@code{find-tag-other-window}). 235(@pxref{Xref}), but in another window
236(@code{xref-find-definitions-other-window}).
236@item C-x 4 r @var{filename} @key{RET} 237@item C-x 4 r @var{filename} @key{RET}
237Visit file @var{filename} read-only, and select its buffer in another 238Visit file @var{filename} read-only, and select its buffer in another
238window (@code{find-file-read-only-other-window}). @xref{Visiting}. 239window (@code{find-file-read-only-other-window}). @xref{Visiting}.
diff --git a/etc/NEWS b/etc/NEWS
index 0b450874124..407d13b31b3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -938,6 +938,7 @@ New options `tildify-space-string', `tildify-pattern', and
938`tildify-ignored-environments-alist' variables (as well as a few 938`tildify-ignored-environments-alist' variables (as well as a few
939helper functions) obsolete. 939helper functions) obsolete.
940 940
941+++
941** New package Xref replaces Etags's front-end and UI 942** New package Xref replaces Etags's front-end and UI
942 943
943The new package Xref provides a generic framework and new commands to 944The new package Xref provides a generic framework and new commands to
@@ -960,7 +961,7 @@ As a result of this, the following commands are now obsolete:
960`find-tag-other-window', `find-tag-other-frame', `find-tag-regexp', 961`find-tag-other-window', `find-tag-other-frame', `find-tag-regexp',
961`tags-apropos', and `tags-loop-continue'. 962`tags-apropos', and `tags-loop-continue'.
962 963
963The framework's API is still experimental and can change in major, 964The framework's Lisp API is still experimental and can change in major,
964backward-incompatible ways. 965backward-incompatible ways.
965 966
966** New package Project 967** New package Project