Here's how to use
global installed from a Ubuntu repository. The version I've had in 6.6.3-2.
First, copy the example config to your home directory. A commentary at its top makes it seem like this is unnecessary, but that's not true. The default config it has is much different, and doesn't recognize
.rb files at all, AFAICT.
cat /usr/share/doc/global/examples/gtags.conf.gz | gzip -d >~/.globalrc
Second, you need to choose the underlying mechanism. Pygments sounds great, but it generates "other symbol" entries, not definitions, which is what we normally need.
universal-ctags might be the best choice, but the version of Global seems to need recompiling to use it (either the apt or the snap version).
exuberant-ctags works out of the box, though. The ancient version
Now, as explained in the documentation and in this issue, you would normally need to run
gtags --gtagslabel= in every gem directory:
for d in $(bundle list --paths); do
if [ -d $d ]; then
(cd $d && find . -type f -name "*.rb" | gtags --gtagslabel=ctags -f -)
The use of
find here is to avoid including JS files, etc, mostly because of the minified assets. But you can create a smarter enumeration.
To use the indexes from all these directories you need to set the env var
GTAGSLIBPATH to the appropriate value during an Emacs session. Given that it's different for every project, and even changes over time, maybe the best approach is to manually call a command in the project directory that will do that for you. Here's one you can use:
(defun set-gtagslibpath-to-bundle-paths ()
(process-file-shell-command "bundle list --paths" nil
(while (and paths
(string-match-p "\\`The dependency'" (car paths)))
(setq paths (cdr paths)))
(mapconcat #'identity paths ":"))))