global.el
Purpose
-
Provide a (unit-) testeable Emacs Lisp API that wraps
global
binary calls (exposed to developer). -
Optional integration to Emacs using aformentioned API with
project.el
andxref.el
(exposed to final user).
Secondary purposes
-
Integrate to main Emacs branch
-
Do not expose
global
to the final user with commands: user should useproject.el
andxref.el
functions -
Improve response times of queries in remote or big codebase by pre-fetching results in the background.
-
Prevent Emacs from freezing when calling global. While
global
is meant to respond real quickly, calling it using Tramp can freeze Emacs for a few seconds.
Features
-
Navigate files using project.el
-
Navigate tags for current files with Imenu
-
Search for tags using xref
-
Do-what-I-mean: search either a symbol under cursor or header file under cursor (inside a
#include
) -
Pre-fetch results (list files, list tags, database location) for a snappier experience.
Usage
You can setup using GNU global as backend with any of the following two lines:
;; to use GNU Global automagically, regardless of Emacs default configuration
(add-hook 'ruby-mode-hook #'global-tags-exclusive-backend-mode)
;; to use GNU Global automagically, respecting other backends
(add-hook 'ruby-mode-hook #'global-tags-shared-backend-mode)
;; configure Imenu
(add-hook 'ruby-mode-hook #'global-tags-imenu-mode)
Alternatively, you can manually configure project.el and xref.el, add their "recognize this global handled project" to the proper places like so:
;; xref (finding definitions, references)
(add-to-list 'xref-backend-functions 'global-tags-xref-backend)
;; project.el (finding files)
(add-to-list 'project-find-functions 'global-tags-try-project-root)
;; to update database after save
(add-hook 'c++-mode-hook (lambda ()
(add-hook 'after-save-hook
#'global-tags-update-database-with-buffer
nil
t)))
Reporting bugs
Submiting patches / pull requests
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Related projects
-
GNU global: source code tag system
-
counsel-gtags: unmaintained and non-re-usable counsel interface. (my maintained fork here)
-
ggtags: interface using
compilation-mode
. Not a re-usable library (see here). Do-what-I-mean feature was based onggtags-find-tag-dwim
. -
gxref: unmaintained
-
https://github.com/alexmurray/ivy-xref: Use Ivy for xref commands.
-
helm-gtags: unmaintained
-
agtags: no testscript up to date, provides custom interface to final user (adds shortcuts to new commands)