Showing posts with label TAGS. Show all posts
Showing posts with label TAGS. Show all posts

"global" just got sexy

Ever since I got used to the OpenGrok based code navigation server at work I was itching to try something similar with gtags. I have been using gtags with emacs for a long time now. Today I found about htags that provides an HTML based front end to global and ain't it sexy!

Just run "htags" on the folder where "gtags" was run earlier. If you are running it for the first time simply run "htags -g". This creates all the G* tag files and also an HTML folder.

To view the tag you can use gozilla. For example,


$ global -x foo
foo 100 src/foo.cpp
foo 200 src/bar.cpp
$ gozilla -b firefox +100 src/foo.cpp

This will open firefox and from there on you can navigate the code as each and every tag is clickable. Otherwise you can open the HTML/mains.html file in the browser of your choice.

To update the tags run "global -uv" followed by "htags" again. As simple as that.

Using gtags (global)

As a follow up to the last post, I tried emacs+gtags and it is really powerful when compared to emacs+etags.

Important things to get started.

First run gtags on the code.
$ gtags

This would create four files GPATH, GRTAGS, GSYMS, GTAGS

Open emacs and enable gtags
M-x gtags-mode RET

To enable auto completion of function names\symbols etc use,
M-x gtags-make-complete-list
NOTE: This is deprecated and not required now.

To locate a function use,
M-x gtags-find-tag function_name.
You can also use M-.

If more than one is found a stack is returned. Select one and hit RET. In order to get the stack use,
M-x gtags-pop-stack.
You can also use M-*

To find a symbol use,
M-x gtags-find-symbol m_myVar

To find anything use,
M-x gtags-find-with-grep "gtags rules"

Once you modify the code, just update the code
global -u -v

To visit the tags folder use,
M-x gtags-visit-rootdir and point it to the folder that has the TAGS!

global and gtags

I have heard a lot about GNU GLOBAL source code tag system, need to try it out.

GNU global