Install "global" to read the source code.
Install
Refer this install page in Japanese, to install global on Mac.
http://qiita.com/5t111111/items/c14ac68f762ce71a7760
$ brew install global --with-exuberant-ctags --with-pygments ==> Downloading http://ftpmirror.gnu.org/global/global-6.5.tar.gz ==> Downloading from http://gd.tuwien.ac.at/gnu/gnusrc/global/global-6.5.tar.gz ######################################################################## 100.0% ==> Downloading https://pypi.python.org/packages/source/P/Pygments/Pygments-1.6.tar.gz ######################################################################## 100.0% ==> python setup.py build install --prefix=/usr/local/Cellar/global/6.5/libexec ==> ./configure --prefix=/usr/local/Cellar/global/6.5 --sysconfdir=/usr/local/etc --with-exu ==> make install
$ which global
/usr/local/bin/global
How to use
Create tag files.
Check config file.
You can see available file types for pygments parser too in this file.
$ view /usr/local/etc/gtags.conf ... default:\ :tc=native: native:\ :tc=gtags:tc=htags: user:\ :tc=user-custom:tc=htags: ctags:\ :tc=exuberant-ctags:tc=htags: pygments:\ :tc=pygments-parser:tc=htags: ... # # Plug-in parser to use Pygments. # pygments-parser|Pygments plug-in parser:\ ...
Create tag files.
Create tags for C, C++, Ruby, and JavaScript, and etc files in Ruby source.
I took 5 minutes to finish this process.
$ cd $GIT_DIR/ruby $ gtags --gtagslabel=pygments --debug
Tag files are created.
$ ls -rlt ... -rw-r--r-- 1 jun.aruga staff 10289152 Dec 10 14:09 GTAGS -rw-r--r-- 1 jun.aruga staff 21258240 Dec 10 14:09 GRTAGS -rw-r--r-- 1 jun.aruga staff 1998848 Dec 10 14:09 GPATH
Search files with function in the directory.
Simply display files with main function, and .c file.
$ global main | grep '\.c$' enc/mktable.c ext/digest/md5/md5.c ext/nkf/nkf-utf8/nkf.c ext/openssl/ossl.c main.c missing/langinfo.c strftime.c
With ctags format.
$ global -t main ... main main.c 23 ...
With ctags cxref format.
$ global -x main ... main 23 main.c main(int argc, char **argv) ...
$ global -x parser_yylex parser_yylex 13628 ext/ripper/ripper.c parser_yylex(struct parser_params *parser) parser_yylex 13560 parse.c parser_yylex(struct parser_params *parser)
Search files referring the function
Use -r option.
$ global -x -r parser_yylex parser_yylex 14297 ext/ripper/ripper.c t = parser_yylex(parser); parser_yylex 14229 parse.c t = parser_yylex(parser);
Funtastic!!