Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctags

前端 未结 5 1409
清酒与你
清酒与你 2020-12-22 16:16

I work on C++ projects, and I went through Alex Ott\'s guide to CEDET and other threads about tags in StackOverflow, but I am still confused about how Emacs interfaces with

5条回答
  •  猫巷女王i
    2020-12-22 17:08

    I'll try to add some explanations to 1.

    What is it?

    • Etags is a command to generate 'TAGS' file which is the tag file for Emacs. You can use the file with etags.el which is part of emacs package.
    • Ctags is a command to generate 'tags' file which is the tag file for vi. Universal Ctags, the successor of Exuberant Ctags, can generate 'TAGS' file by the -e option, supporting more than 41 programming languages.
    • Cscope is an all-in-one source code browsing tool for C language. It has own fine CUI (character user interface) and tag databases (cscope.in.out, cscope.out, cscope.po.out). You can use cscope from Emacs using xcscope.el which is part of cscope package.
    • GNU GLOBAL is a source code tagging system. Though it is similar to above tools, it differs from them at the point of that it is dependent from any editor, and it has no user interface except for command line. Gtags is a command to generate tag files for GLOBAL (GTAGS, GRTAGS, GPATH). You can use GLOBAL from emacs using gtags.el which is part of GLOBAL package. In addition to this, there are many elisp libraries for it (xgtags.el, ggtags.el, anything-gtags.el, helm-gtags.el, etc).

    Comparison

    • Ctags and etags treat only definitions. Cscope and GNU GLOBAL treat not only definitions but also references.
    • Ctags and etags use a flat text tag file. Cscope and GNU GLOBAL use key-value tag databases.
    • Cscope and GNU GLOBAL have a grep like search engine and incremental updating facility of tag files.

    Combination

    You can combine Universal Ctags's rich language support and GNU GLOBAL's database facility by using ctags as a plug-in parser of GLOBAL.

    Try the following: (requires GLOBAL-6.5.3+ and Universal Ctags respectively)

    Building GNU GLOBAL:

    $ ./configure --with-universal-ctags=/usr/local/bin/ctags
    $ sudo make install
    

    Usage:

    $ export GTAGSCONF=/usr/local/share/gtags/gtags.conf
    $ export GTAGSLABEL=new-ctags
    $ gtags                     # invokes Universal Ctags internally
    $ emacs -f gtags-mode       # load gtags.el
    

    (However, you cannot treat references by this method, because ctags don't treat references.)

    You can also use cscope as a client of GNU GLOBAL. GLOBAL package includes a command named 'gtags-cscope' which is a port of cscope, that is, it is cscope itself except that it use GLOBAL as a search engine instead of cscope's one.

    $ gtags-cscope          # this is GLOBAL version of cscope
    

    With the combinations, you can use cscope for 41 languages.

    Good luck!

提交回复
热议问题