]> code.delx.au - gnu-emacs-elpa/blob - packages/ggtags/README.rst
Merge commit 'b56ef781d5a712fd06378f78eb9551ab9269bb2e'
[gnu-emacs-elpa] / packages / ggtags / README.rst
1 =========================================================
2 Emacs frontend to GNU Global source code tagging system
3 =========================================================
4
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>`_.
8
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,
12 24.4 and trunk. Patches, feature requests and bug reports are welcome.
13 Thanks.
14
15 Features
16 ~~~~~~~~
17
18 #. Build on ``compile.el`` for asynchronicity and its large
19 feature-set.
20 #. Automatically update Global's tag files when needed with tuning for
21 large source trees.
22 #. Intuitive navigation among multiple matches with mode-line display
23 of current match, total matches and exit status.
24 #. Read tag with completion.
25 #. Show definition at point.
26 #. Jump to #include files.
27 #. Support search history and saving a search to register/bookmark.
28 #. Query replace.
29 #. Manage Global's environment variables on a per-project basis.
30 #. Highlight (definition) tag at point.
31 #. Abbreviated display of file names.
32 #. Support all Global search backends: ``grep``, ``idutils`` etc.
33 #. Support `exuberant ctags <http://ctags.sourceforge.net/>`_ backend.
34 #. Support all Global's output formats: ``grep``, ``ctags-x``,
35 ``cscope`` etc.
36 #. Support projects on remote hosts (e.g. via ``tramp``).
37 #. Support eldoc.
38 #. Search ``GTAGSLIBPATH`` for references and symbols.
39
40 Screenshot
41 ~~~~~~~~~~
42
43 .. figure:: http://i.imgur.com/wx8ZPGe.png
44 :width: 500px
45 :target: http://i.imgur.com/wx8ZPGe.png
46 :alt: ggtags.png
47
48 Why GNU Global
49 ~~~~~~~~~~~~~~
50
51 The opengrok project composed a feature comparison `table
52 <https://github.com/OpenGrok/OpenGrok/wiki/Comparison-with-Similar-Tools>`_
53 between a few tools.
54
55 Install Global and plugins
56 ~~~~~~~~~~~~~~~~~~~~~~~~~~
57
58 1. Compile and install Global with ``exuberant-ctags``
59 ::
60
61 ./configure --prefix=<PREFIX> --with-exuberant-ctags=/usr/local/bin/ctags
62 make && make install
63
64 The executable ``ctags`` is unfortunately named because ``emacs`` also
65 includes a command of the same name. So make sure it is from
66 http://ctags.sourceforge.net. See ``plugin-factory/README`` in GNU
67 Global source for further information.
68
69 2. Install ``pygments`` plugin
70
71 The ``pygments`` plugin has been included in ``global`` since
72 version ``6.3.2``. ``pip install pygments`` is the only step
73 required. Note the plugin is not activated by the default
74 ``gtags.conf`` or ``.globalrc``. See
75 ``global/plugin-factory/PLUGIN_HOWTO.pygments`` for details.
76
77 The following instructions are for older ``global``.
78 ::
79
80 pip install pygments
81 git clone https://github.com/yoshizow/global-pygments-plugin.git
82 cd global-pygments-plugin/
83 sh reconf.sh
84 ./configure --prefix=<PREFIX> --with-exuberant-ctags=/usr/local/bin/ctags
85 make && make install
86 cp sample.globalrc $HOME/.globalrc
87
88 Make sure the value of ``<PREFIX>`` agree with step 1.
89
90 Config
91 ~~~~~~
92
93 Global with ``exuberant-ctags`` and ``pygments`` plugins can support
94 dozens of programming languages. For example, to enable
95 ``ggtags-mode`` for C/C++/Java modes::
96
97 (add-hook 'c-mode-common-hook
98 (lambda ()
99 (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
100 (ggtags-mode 1))))
101
102 Also see https://github.com/leoliu/ggtags/wiki for more examples.
103
104 Usage
105 ~~~~~
106
107 Open any file in a project and type ``M-x ggtags-mode``. Use ``M-.``
108 (``ggtags-find-tag-dwim``) to find the tag at point. If the project
109 has not been indexed (i.e. no ``GTAGS`` file exists), ``ggtags`` will
110 ask for the project root directory and index it recursively.
111 Alternatively one can invoke ``ggtags-create-tags`` to index a
112 directory. The mode line will display the directory name next to the
113 buffer name. If point is at a valid definition tag, it is underlined.
114
115 ``ggtags`` is similar to the standard ``etags`` package. For example
116 these keys ``M-.``, ``M-,``, ``M-*`` and ``C-M-.`` should work as
117 expected in ``ggtags-mode``.
118
119 The following search commands are available:
120
121 ggtags-find-tag-dwim
122
123 Find a tag by context.
124
125 If point is at a definition tag, find references, and vice versa.
126 If point is at a line that matches ``ggtags-include-pattern``, find
127 the include file instead.
128
129 To force finding a definition tag, call it with a prefix (``C-u``).
130
131 ggtags-find-tag-mouse
132
133 Like ``ggtags-find-tag-dwim`` but suitable for binding to mouse
134 events.
135
136 ggtags-find-definition
137
138 Find definition tags. With ``C-u`` ask for the tag name with
139 completion.
140
141 ggtags-find-reference
142
143 Find reference tags. With ``C-u`` ask for the tag name with completion.
144
145 ggtags-find-other-symbol
146
147 Find tags that have no definitions. With ``C-u`` ask for the tag
148 name with completion.
149
150 ggtags-find-tag-regexp
151
152 Find definition tags matching a regexp. By default it lists all
153 matching tags in the project. With ``C-u`` restrict the lists to a
154 directory of choice.
155
156 ggtags-idutils-query
157
158 Use idutils to find matches.
159
160 ggtags-grep
161
162 Grep for lines matching a regexp. This is usually the slowest.
163
164 ggtags-find-file
165
166 Find a file from all the files indexed by ``gtags``.
167
168 ggtags-query-replace
169
170 Do a query replace in all files found in a search.
171
172 Handling multiple matches
173 +++++++++++++++++++++++++
174
175 When a search finds multiple matches, a buffer named
176 ``*ggtags-global*`` is popped up and ``ggtags-navigation-mode`` is
177 turned on to facilitate locating the right match.
178 ``ggtags-navigation-mode`` makes a few commands in the
179 ``*ggtags-global*`` buffer globally accessible:
180
181 ``M-n``
182
183 Move to the next match.
184
185 ``M-p``
186
187 Move to the previous match.
188
189 ``M-}``
190
191 Move to next file.
192
193 ``M-{``
194
195 Move to previous file.
196
197 ``M-=``
198
199 Move to the file where navigation session starts.
200
201 ``M-<``
202
203 Move to the first match.
204
205 ``M->``
206
207 Move to the last match.
208
209 ``C-M-s`` or ``M-s s``
210
211 Use ``isearch`` to find the match.
212
213 ``RET``
214
215 Found the right match so exit navigation mode. Resumable by ``M-,``
216 (``tags-loop-continue``).
217
218 ``M-*``
219
220 Abort and go back to the location where the search was started.
221
222 Miscellaneous commands
223 ++++++++++++++++++++++
224
225 Commands are avaiable from the ``Ggtags`` menu in ``ggtags-mode``.
226
227 ggtags-prev-mark
228
229 Move to the previously (older) visited location. Unlike ``M-*``
230 this doesn't delete the location from the tag ring.
231
232 ggtags-next-mark
233
234 Move to the next (newer) visited location.
235
236 ggtags-view-tag-history
237
238 Pop to a buffer listing all visited locations from newest to
239 oldest. The buffer is a next error buffer and works with standard
240 commands ``next-error`` and ``previous-error``. In addition ``TAB``
241 and ``S-TAB`` move to next/prev entry, and ``RET`` visits the
242 location. ``M-n`` and ``M-p`` move to and display the next/previous
243 entry.
244
245 ggtags-view-search-history
246
247 View or re-run past searches as kept in
248 ``ggtags-global-search-history``.
249
250 ggtags-kill-file-buffers
251
252 Kill all file-visiting buffers of current project.
253
254 ggtags-toggle-project-read-only
255
256 Toggle opening files in ``read-only`` mode. Handy if the main
257 purpose of source navigation is to read code.
258
259 ggtags-visit-project-root
260
261 Open the project root directory in ``dired``.
262
263 ggtags-delete-tags
264
265 Delete the GTAGS, GRTAGS, GPATH and ID files of current project.
266
267 ggtags-explain-tags
268
269 Explain how each file is indexed in current project.
270
271 ggtags-browse-file-as-hypertext
272
273 Use ``htags`` to generate HTML of the source tree. This allows
274 browsing the porject in a browser with cross-references.
275
276 Integration with other packages
277 +++++++++++++++++++++++++++++++
278
279 * eldoc
280
281 ``Eldoc`` support is set up by default on emacs 24.4+. For older
282 versions set, for example, in the desired major mode:
283
284 ::
285
286 (setq-local eldoc-documentation-function #'ggtags-eldoc-function)
287
288 * imenu
289
290 Emacs major modes usually have excellent support for ``imenu`` so
291 this is not enabled by default. To use:
292 ::
293
294 (setq-local imenu-create-index-function #'ggtags-build-imenu-index)
295
296 * hippie-exp
297 ::
298
299 (setq-local hippie-expand-try-functions-list
300 (cons 'ggtags-try-complete-tag hippie-expand-try-functions-list))
301
302 * company
303
304 ``company`` can use ``ggtags`` as completion source via
305 ``company-capf`` which is enabled by default.
306
307 * helm
308
309 If ``helm-mode`` is enabled ``ggtags`` will use it for completion if
310 ``ggtags-completing-read-function`` is nil.
311
312 NEWS
313 ~~~~
314
315 [2015-06-12 Fri] 0.8.10
316 +++++++++++++++++++++++
317
318 #. Tags update on save is configurable by ``ggtags-update-on-save``.
319 #. New command ``ggtags-explain-tags`` to explain how each file is
320 indexed in current project. Global 6.4+ required.
321 #. New user option ``ggtags-sort-by-nearness`` that sorts matched tags
322 by nearness to current directory.
323
324 [2015-01-16 Fri] 0.8.9
325 ++++++++++++++++++++++
326
327 #. ``ggtags-visit-project-root`` can visit past projects.
328 #. ``eldoc`` support enabled for emacs 24.4+.
329
330 [2014-12-03 Wed] 0.8.8
331 ++++++++++++++++++++++
332
333 #. Command ``ggtags-update-tags`` now runs in the background for large
334 projects (per ``ggtags-oversize-limit``) without blocking emacs.
335
336 [2014-11-10 Mon] 0.8.7
337 ++++++++++++++++++++++
338
339 #. New navigation command ``ggtags-navigation-start-file``.
340 #. New variable ``ggtags-use-sqlite3`` to enable sqlite3 storage.
341
342 [2014-09-12 Fri] 0.8.6
343 ++++++++++++++++++++++
344
345 #. ``ggtags-show-definition`` shows definition with font locking.
346
347 [2014-06-22 Sun] 0.8.5
348 ++++++++++++++++++++++
349
350 #. New command ``ggtags-find-tag-mouse`` for mouse support.
351 #. New command ``ggtags-find-definition``.
352 #. Variable ``ggtags-completing-read-function`` restored.
353 #. ``ggtags-navigation-isearch-forward`` can also be invoked using
354 ``M-s s``.
355 #. Command ``ggtags-global-rerun-search`` renamed to
356 ``ggtags-view-search-history``.
357 #. The output buffer from ``ggtags-view-search-history`` looks
358 cleaner.
359 #. Search history items can be re-arranged with ``C-k`` and ``C-y``.
360
361 [2014-05-06 Tue] 0.8.4
362 ++++++++++++++++++++++
363
364 #. ``M-.`` (``ggtags-find-tag-dwim``) is smarter on new files.
365 #. Always update tags for current file on save.
366 #. Can continue search ``GTAGSLIBPATH`` if search turns up 0 matches.
367 Customisable via ``ggtags-global-search-libpath-for-reference``.
368
369 [2014-04-12 Sat] 0.8.3
370 ++++++++++++++++++++++
371
372 #. Tweak mode-line ligter in ``ggtags-navigation-mode``.
373
374 [2014-04-05 Sat] 0.8.2
375 ++++++++++++++++++++++
376
377 #. Default ``ggtags-auto-jump-to-match`` to ``history``.
378 #. Add eldoc support; see ``ggtags-eldoc-function``.
379 #. Improved support for tramp.
380
381 [2014-03-30 Sun] 0.8.1
382 ++++++++++++++++++++++
383
384 #. Improve ``ggtags-view-tag-history`` and tag history navigation.
385 #. New customsable variable ``ggtags-global-use-color``.
386 #. Automatically jump to match from location stored in search history.
387 See ``ggtags-auto-jump-to-match``.
388 #. Rename ``ggtags-supress-navigation-keys`` to
389 ``ggtags-enable-navigation-keys`` with a better way to suppress
390 navigation key bindings in some buffers including
391 ``*ggtags-global*`` buffer.
392
393 [2014-03-24 Mon] 0.8.0
394 ++++++++++++++++++++++
395
396 #. Record search history and re-run past searches.
397 #. Bookmark or save search to register.
398 #. New command ``ggtags-show-definition``.
399 #. Project name on mode line.
400 #. Automatically use ``.globalrc`` or ``gtags.conf`` file at project
401 root.
402 #. Better completion based on tag types.
403 #. Use colored output to get column number for jumping to tag.
404 #. Improve detection of stale GTAGS file based on file modification
405 time.
406 #. New customisable variables ``ggtags-executable-directory``,
407 ``ggtags-global-always-update``, ``ggtags-mode-sticky`` and
408 ``ggtags-supress-navigation-keys``.
409 #. Other bug fixes.
410
411 Bugs
412 ~~~~
413
414 https://github.com/leoliu/ggtags/issues