]> code.delx.au - gnu-emacs-elpa/blob - README.rst
Merge pull request #69 from jfeltz/patch-1
[gnu-emacs-elpa] / 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/LX7PVc3.png
44 :width: 500px
45 :target: http://i.imgur.com/LX7PVc3.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
72 pip install pygments
73 git clone https://github.com/yoshizow/global-pygments-plugin.git
74 cd global-pygments-plugin/
75 sh reconf.sh
76 ./configure --prefix=<PREFIX> --with-exuberant-ctags=/usr/local/bin/ctags
77 make && make install
78 cp sample.globalrc $HOME/.globalrc
79
80 Make sure the value of ``<PREFIX>`` agree with step 1.
81
82 Config
83 ~~~~~~
84
85 Global with ``exuberant-ctags`` and ``pygments`` plugins can support
86 dozens of programming languages. For example, to enable
87 ``ggtags-mode`` for C/C++/Java modes::
88
89 (add-hook 'c-mode-common-hook
90 (lambda ()
91 (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
92 (ggtags-mode 1))))
93
94 Also see https://github.com/leoliu/ggtags/wiki for more examples.
95
96 Usage
97 ~~~~~
98
99 Open any file in a project and type ``M-x ggtags-mode``. Use ``M-.``
100 (``ggtags-find-tag-dwim``) to find the tag at point. If the project
101 has not been indexed (i.e. no ``GTAGS`` file exists), ``ggtags`` will
102 ask for the project root directory and index it recursively.
103 Alternatively one can invoke ``ggtags-create-tags`` to index a
104 directory. The mode line will display the directory name next to the
105 buffer name. If point is at a valid definition tag, it is underlined.
106
107 ``ggtags`` is similar to the standard ``etags`` package. For example
108 these keys ``M-.``, ``M-,``, ``M-*`` and ``C-M-.`` should work as
109 expected in ``ggtags-mode``.
110
111 The following search commands are available:
112
113 ggtags-find-tag-dwim
114
115 Find a tag by context.
116
117 If point is at a definition tag, find references, and vice versa.
118 If point is at a line that matches ``ggtags-include-pattern``, find
119 the include file instead.
120
121 To force finding a definition tag, call it with a prefix (``C-u``).
122
123 ggtags-find-tag-mouse
124
125 Like ``ggtags-find-tag-dwim`` but suitable for binding to mouse
126 events.
127
128 ggtags-find-definition
129
130 Find definition tags. With ``C-u`` ask for the tag name with
131 completion.
132
133 ggtags-find-reference
134
135 Find reference tags. With ``C-u`` ask for the tag name with completion.
136
137 ggtags-find-other-symbol
138
139 Find tags that have no definitions. With ``C-u`` ask for the tag
140 name with completion.
141
142 ggtags-find-tag-regexp
143
144 Find definition tags matching a regexp. By default it lists all
145 matching tags in the project. With ``C-u`` restrict the lists to a
146 directory of choice.
147
148 ggtags-idutils-query
149
150 Use idutils to find matches.
151
152 ggtags-grep
153
154 Grep for lines matching a regexp. This is usually the slowest.
155
156 ggtags-find-file
157
158 Find a file from all the files indexed by ``gtags``.
159
160 ggtags-query-replace
161
162 Do a query replace in all files found in a search.
163
164 Handling multiple matches
165 +++++++++++++++++++++++++
166
167 When a search finds multiple matches, a buffer named
168 ``*ggtags-global*`` is popped up and ``ggtags-navigation-mode`` is
169 turned on to facilitate locating the right match.
170 ``ggtags-navigation-mode`` makes a few commands in the
171 ``*ggtags-global*`` buffer globally accessible:
172
173 ``M-n``
174
175 Move to the next match.
176
177 ``M-p``
178
179 Move to the previous match.
180
181 ``M-}``
182
183 Move to next file.
184
185 ``M-{``
186
187 Move to previous file.
188
189 ``M-<``
190
191 Move to the first match.
192
193 ``M->``
194
195 Move to the last match.
196
197 ``C-M-s`` or ``M-s s``
198
199 Use ``isearch`` to find the match.
200
201 ``RET``
202
203 Found the right match so exit navigation mode. Resumable by ``M-,``
204 (``tags-loop-continue``).
205
206 ``M-*``
207
208 Abort and go back to the location where the search was started.
209
210 Miscellaneous commands
211 ++++++++++++++++++++++
212
213 Commands are avaiable from the ``Ggtags`` menu in ``ggtags-mode``.
214
215 ggtags-prev-mark
216
217 Move to the previously (older) visited location. Unlike ``M-*``
218 this doesn't delete the location from the tag ring.
219
220 ggtags-next-mark
221
222 Move to the next (newer) visited location.
223
224 ggtags-view-tag-history
225
226 Pop to a buffer listing all visited locations from newest to
227 oldest. The buffer is a next error buffer and works with standard
228 commands ``next-error`` and ``previous-error``. In addition ``TAB``
229 and ``S-TAB`` move to next/prev entry, and ``RET`` visits the
230 location. ``M-n`` and ``M-p`` move to and display the next/previous
231 entry.
232
233 ggtags-view-search-history
234
235 View or re-run past searches as kept in
236 ``ggtags-global-search-history``.
237
238 ggtags-kill-file-buffers
239
240 Kill all file-visiting buffers of current project.
241
242 ggtags-toggle-project-read-only
243
244 Toggle opening files in ``read-only`` mode. Handy if the main
245 purpose of source navigation is to read code.
246
247 ggtags-visit-project-root
248
249 Open the project root directory in ``dired``.
250
251 ggtags-delete-tags
252
253 Delete the GTAGS, GRTAGS, GPATH and ID files of current project.
254
255 ggtags-browse-file-as-hypertext
256
257 Use ``htags`` to generate HTML of the source tree. This allows
258 browsing the porject in a browser with cross-references.
259
260 Integration with other packages
261 +++++++++++++++++++++++++++++++
262
263 * eldoc
264
265 ``Eldoc`` support can be enabled by, for example, setting this in
266 the desired major mode with:
267
268 ::
269
270 (setq-local eldoc-documentation-function #'ggtags-eldoc-function)
271
272 * imenu
273
274 Emacs major modes usually have excellent support for ``imenu`` so
275 this is not enabled by default. To use:
276 ::
277
278 (setq-local imenu-create-index-function #'ggtags-build-imenu-index)
279
280 * hippie-exp
281 ::
282
283 (setq-local hippie-expand-try-functions-list
284 (cons 'ggtags-try-complete-tag hippie-expand-try-functions-list))
285
286 * company
287
288 ``company`` can use ``ggtags`` as completion source via
289 ``company-capf`` which is enabled by default.
290
291 * helm
292
293 If ``helm-mode`` is enabled ``ggtags`` will use it for completion if
294 ``ggtags-completing-read-function`` is nil.
295
296 NEWS
297 ~~~~
298
299 [devel]
300 ~~~~~~~
301
302 #. ``ggtags-show-definition`` shows definition with font locking.
303
304
305 [2014-06-22 Sun] 0.8.5
306 ++++++++++++++++++++++
307
308 #. New command ``ggtags-find-tag-mouse`` for mouse support.
309 #. New command ``ggtags-find-definition``.
310 #. Variable ``ggtags-completing-read-function`` restored.
311 #. ``ggtags-navigation-isearch-forward`` can also be invoked using
312 ``M-s s``.
313 #. Command ``ggtags-global-rerun-search`` renamed to
314 ``ggtags-view-search-history``.
315 #. The output buffer from ``ggtags-view-search-history`` looks
316 cleaner.
317 #. Search history items can be re-arranged with ``C-k`` and ``C-y``.
318
319 [2014-05-06 Tue] 0.8.4
320 ++++++++++++++++++++++
321
322 #. ``M-.`` (``ggtags-find-tag-dwim``) is smarter on new files.
323 #. Always update tags for current file on save.
324 #. Can continue search ``GTAGSLIBPATH`` if search turns up 0 matches.
325 Customisable via ``ggtags-global-search-libpath-for-reference``.
326
327 [2014-04-12 Sat] 0.8.3
328 ++++++++++++++++++++++
329
330 #. Tweak mode-line ligter in ``ggtags-navigation-mode``.
331
332 [2014-04-05 Sat] 0.8.2
333 ++++++++++++++++++++++
334
335 #. Default ``ggtags-auto-jump-to-match`` to ``history``.
336 #. Add eldoc support; see ``ggtags-eldoc-function``.
337 #. Improved support for tramp.
338
339 [2014-03-30 Sun] 0.8.1
340 ++++++++++++++++++++++
341
342 #. Improve ``ggtags-view-tag-history`` and tag history navigation.
343 #. New customsable variable ``ggtags-global-use-color``.
344 #. Automatically jump to match from location stored in search history.
345 See ``ggtags-auto-jump-to-match``.
346 #. Rename ``ggtags-supress-navigation-keys`` to
347 ``ggtags-enable-navigation-keys`` with a better way to suppress
348 navigation key bindings in some buffers including
349 ``*ggtags-global*`` buffer.
350
351 [2014-03-24 Mon] 0.8.0
352 ++++++++++++++++++++++
353
354 #. Record search history and re-run past searches.
355 #. Bookmark or save search to register.
356 #. New command ``ggtags-show-definition``.
357 #. Project name on mode line.
358 #. Automatically use ``.globalrc`` or ``gtags.conf`` file at project
359 root.
360 #. Better completion based on tag types.
361 #. Use colored output to get column number for jumping to tag.
362 #. Improve detection of stale GTAGS file based on file modification
363 time.
364 #. New customisable variables ``ggtags-executable-directory``,
365 ``ggtags-global-always-update``, ``ggtags-mode-sticky`` and
366 ``ggtags-supress-navigation-keys``.
367 #. Other bug fixes.
368
369 Bugs
370 ~~~~
371
372 https://github.com/leoliu/ggtags/issues