Using Gnu Global to navigating source code
Using GNU Global to navigating source code
I use etags as the default tagging system to navigating the C-like source code before. It works good, but sometimes it didn't perform as good as ctags which were used by vimer.Table of Contents
- 1 why not etags?
- 2 gtags's advantage
- 3 gtags's disadvantage
- 4 Install gtags
- 5 tagging source code systems of emacs
1 why not etags?
Etags has a flaw compared with ctags, which is it didn't pop up the mini-buffer when searching a symbol. Which means I can not get options then decide where to jump when multi locations match the symbol. I have to jump one by one to find the right location in emacs with etags,which push me over the edge sometimes.
2 gtags's advantage
Today I tried the gtags source tagging system which provided by Gnu Global project.
It can pop up the minibuffer when multiple targets match the symbol, which functions let me felt much more comfortable.
It can pop up the minibuffer when multiple targets match the symbol, which functions let me felt much more comfortable.
3 gtags's disadvantage
It doesn't support tags table, compared with etags tagging system. So I choice to combine the two tagging systems to work together.
When I need to jump to source code which located in different source trees, I use etags. While when I want to jump to the place where is hard to target, I use gtags.
When I need to jump to source code which located in different source trees, I use etags. While when I want to jump to the place where is hard to target, I use gtags.
4 Install gtags
First, I install the Gnu Global into my system. Then I install gtags-mode into emacs. gtags-mode is not the default available package in emacs, so I need to install it by myself, thanks to emacs's excellent package management system, I can install it easily.
Now configure the gtags-mode.
Variable gtags-suggested-key-mapping provide the default key-bindings which are exactly alike with etags. It is a really convenient setting.
Above configuration enabled gtags by default. So, When I need to refer to etags, I need to disable gtags by the following command.
M-x gtags-mode
And when I try to enable gtags again, just repeat above command again.
Now configure the gtags-mode.
(autoload 'gtags-mode "gtags" "" t) ;; provide the default key binding (setq gtags-suggested-key-mapping t) (add-hook 'c-mode-common-hook '(lambda () (gtags-mode 1)))
Variable gtags-suggested-key-mapping provide the default key-bindings which are exactly alike with etags. It is a really convenient setting.
Above configuration enabled gtags by default. So, When I need to refer to etags, I need to disable gtags by the following command.
M-x gtags-mode
And when I try to enable gtags again, just repeat above command again.
5 tagging source code systems of emacs
There are three Emacs's tagging source code systems which I had used.
- gtags
- etags
- cscope
Comments
Post a Comment