Skip to content
Use GNU Global in Emacs
Emacs Lisp
Find file
Pull request Compare This branch is 178 commits behind leoliu:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Makefile
README.rst
ggtags.el

README.rst

Use GNU Global in Emacs

A package for working with GNU Global source tagging system in Emacs.

This package is part of GNU ELPA (M-x list-packages).

Patches, feature requests and bug reports are welcome. Thanks.

Features

  1. Automatically update Global's tag files when needed with tuning for large source trees.
  2. Build on compile.el for asynchronicity and its large feature-set.
  3. Intuitive navigation among multiple matches with mode-line display of current match, total matches and exit status.
  4. Manage Global's environment variables on a per-project basis.
  5. Support all Global search backends: grep, idutils etc.
  6. Query replace.
  7. Highlight (definition) tag at point.
  8. Abbreviated display of file names.
  9. Support exuberant ctags backend.
  10. Support all Global's output formats: grep, ctags-x, cscope etc.

Why GNU Global

The opengrok project composed a feature comparison table between a few tools.

Screenshot

ggtags.png

Config

Enable ggtags-mode for C/C++/Java modes:

(add-hook 'c-mode-common-hook
          (lambda ()
            (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
              (ggtags-mode 1))))

More languages/modes are supported if GNU Global is compiled with --with-exuberant-ctags to support exuberant ctags. Also set the environment variable GTAGSCONF to the correct location of gtags.conf. For example:

export GTAGSCONF=/usr/local/share/gtags/gtags.conf

See plugin-factory/README in GNU Global source for further information.

Also see https://github.com/leoliu/ggtags/wiki for more examples.

Tutorial

Type M-x ggtags-mode to enable the minor mode, or as usual enable it in your desired major mode hooks. When the mode is on the symbol at point is underlined if it is a valid (definition) tag.

M-. finds definitions or references according to the tag at point, i.e. if point is at a definition tag find references and vice versa. M-] finds references.

If multiple matches are found, navigation mode is entered, the mode-line lighter changed, and a navigation menu-bar entry presented. In this mode, M-n and M-p moves to next and previous match, M-} and M-{ to next and previous file respectively. M-o toggles between full and abbreviated displays of file names in the auxiliary popup window. When you locate the right match, press RET to finish which hides the auxiliary window and exits navigation mode. You can continue the search using M-,. To abort the search press M-*.

Normally after a few searches a dozen buffers are created visiting files tracked by GNU Global. C-c M-k helps clean them up.

Check the menu-bar entry Ggtags for other useful commands.

Development

The goal is to make working with GNU Global in Emacs as effortlessly and intuitively as possible.

Bugs

https://github.com/leoliu/ggtags/issues

known problems

When there is only one match a window is still popped up to be closed immediately due to a bug in compile.el.

Something went wrong with that request. Please try again.