1 =========================================================
2 Emacs frontend to GNU Global source code tagging system
3 =========================================================
5 This package is part of `GNU ELPA <http://elpa.gnu.org>`_ (``M-x
6 list-packages``) and is also available on `MELPA
7 <http://melpa.milkbox.net/#/ggtags>`_.
9 The goal is to make working with GNU Global in Emacs as effortlessly
10 and intuitively as possible and to integrate tightly with standard
11 emacs packages. ``ggtags.el`` is tested in emacs 24.1, 24.2, 24.3 and
12 trunk. Patches, feature requests and bug reports are welcome. Thanks.
17 #. Build on ``compile.el`` for asynchronicity and its large
19 #. Automatically update Global's tag files when needed with tuning for
21 #. Intuitive navigation among multiple matches with mode-line display
22 of current match, total matches and exit status.
23 #. Read tag with completion.
24 #. Show definition at point.
25 #. Jump to #include files.
26 #. Support search history and saving a search to register/bookmark.
28 #. Manage Global's environment variables on a per-project basis.
29 #. Highlight (definition) tag at point.
30 #. Abbreviated display of file names.
31 #. Support all Global search backends: ``grep``, ``idutils`` etc.
32 #. Support `exuberant ctags <http://ctags.sourceforge.net/>`_ backend.
33 #. Support all Global's output formats: ``grep``, ``ctags-x``,
35 #. Support projects on remote hosts (e.g. via ``tramp``)
40 .. figure:: http://i.imgur.com/LX7PVc3.png
42 :target: http://i.imgur.com/LX7PVc3.png
48 The opengrok project composed a feature comparison `table
49 <https://github.com/OpenGrok/OpenGrok/wiki/Comparison-with-Similar-Tools>`_
52 Install Global and plugins
53 ~~~~~~~~~~~~~~~~~~~~~~~~~~
55 1. Compile and install Global with ``exuberant-ctags``
58 ./configure --prefix=<PREFIX> --with-exuberant-ctags=/usr/local/bin/ctags
61 The executable ``ctags`` is unfortunately named because ``emacs`` also
62 includes a command of the same name. So make sure it is from
63 http://ctags.sourceforge.net. See ``plugin-factory/README`` in GNU
64 Global source for further information.
66 2. Install ``pygments`` plugin
70 git clone https://github.com/yoshizow/global-pygments-plugin.git
72 ./configure --prefix=<PREFIX> --with-exuberant-ctags=/usr/local/bin/ctags
74 cp sample.globalrc $HOME/.globalrc
76 Make sure the value of ``<PREFIX>`` agree with step 1.
81 Global with ``exuberant-ctags`` and ``pygments`` plugins can support
82 dozens of programming languages. For example, to enable
83 ``ggtags-mode`` for C/C++/Java modes::
85 (add-hook 'c-mode-common-hook
87 (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
90 Also see https://github.com/leoliu/ggtags/wiki for more examples.
95 Open any file in a project and type ``M-x ggtags-mode``. Use ``M-.``
96 (``ggtags-find-tag-dwim``) to find the tag at point. If the project
97 has not been indexed (i.e. no ``GTAGS`` file exists), ``ggtags`` will
98 ask for the project root directory and index it recursively.
99 Alternatively one can invoke ``ggtags-create-tags`` to index a
100 directory. The mode line will display the directory name next to the
101 buffer name. If point is at a valid definition tag, it is underlined.
103 ``ggtags`` is similar to the standard ``etags`` package. For example
104 these keys ``M-.``, ``M-,``, ``M-*`` and ``C-M-.`` should work as
105 expected in ``ggtags-mode``.
107 The following search commands are available:
111 Find a tag by context.
113 If point is at a definition tag, find references, and vice versa.
114 If point is at a line that matches ``ggtags-include-pattern``, find
115 the include file instead.
117 To force finding a definition tag, call it with a prefix (``C-u``).
119 ggtags-find-reference
121 Find references to a tag. With ``C-u`` ask for the tag name with
124 ggtags-find-other-symbol
126 Find a tag that has no definition. With ``C-u`` ask for the tag
127 name with completion.
129 ggtags-find-tag-regexp
131 Find definition tags matching a regexp. By default it lists all
132 matching tags in the project. With ``C-u`` restrict the lists to a
137 Use idutils to find matches.
141 Grep for lines matching a regexp. This is usually the slowest.
145 Find a file from all the files indexed by ``gtags``.
149 Do a query replace in all files found in a search.
151 Handling multiple matches
152 +++++++++++++++++++++++++
154 When a search finds multiple matches, a buffer named
155 ``*ggtags-global*`` is popped up and ``ggtags-navigation-mode`` is
156 turned on to facilitate locating the right match.
157 ``ggtags-navigation-mode`` makes a few commands in the
158 ``*ggtags-global*`` buffer globally accessible:
162 Move to the next match.
166 Move to the previous match.
174 Move to previous file.
178 Move to the first match.
182 Move to the last match.
186 Use ``isearch`` to find the match.
190 Found the right match so exit the navigation mode. Resumable by
191 ``M-,`` (``tags-loop-continue``).
195 Abort and go back to the location where the search was started.
197 Miscellaneous commands
198 ++++++++++++++++++++++
200 Commands are made avaiable via the ``Ggtags`` menu in ``ggtags-mode``.
204 Move to the previously (older) visited location. Unlike ``M-*``
205 this doesn't delete the location from the tag ring.
209 Move to the next (newer) visited location.
211 ggtags-view-tag-history
213 Pop to a buffer listing all visited locations from newest to
214 oldest. Use ``TAB`` and ``S-TAB`` to move to next/prev entry and
217 ggtags-global-rerun-search
219 Re-run a search from search history as kept in
220 ``ggtags-global-search-history``.
222 ggtags-kill-file-buffers
224 Kill all file-visiting buffers of current project.
226 ggtags-toggle-project-read-only
228 Toggle opening files in ``read-only`` mode. Handy if the main
229 purpose of source navigation is to read code.
231 ggtags-visit-project-root
233 Open the project root directory in ``dired``.
235 ggtags-delete-tag-files
237 Delete the GTAGS, GRTAGS, GPATH and ID files of current project.
239 ggtags-browse-file-as-hypertext
241 Use ``htags`` to generate HTML of the source tree. This allows
242 browsing the porject in a browser with cross-references.
247 https://github.com/leoliu/ggtags/issues