gtags emmacs

看看Tutorial(指导)中的Overview就知道,通过gtags能够建立软件工程项目。
这就说明,Emacs+gtags的组合,就可以是能够创建工程项目的编辑软件了。
(基本等于sourceinsight,如果在加上cedet和ecb就更完美了)

GNU GLOBAL is a source code tagging system that works the same way across diverse environments (emacs, vi, less, bash, web browser, etc). You can locate objects in source files and move there easily. It is useful for hacking a large project containing many subdirectories, many  #ifdef  and many  main()  functions. It is similar to ctags or etags but is different from them at the point of independence of any editor. It runs on a UNIX(POSIX) compatible operating system like GNU and BSD.
GNU GLOBAL is part of the  GNU project , and is  free software . You can freely copy, modify and redistribute this program under  GNU GPL
support C, C++, Yacc, Java and PHP4. 
下载地址:
http://www.gnu.org/software/global/

How to install.

    $ ./configure     $ make

$ sudo make install (此处可能没有权限,所以使用sudo切换到root权限)


与gtags相似的组件:cscope;

支持的基本环境:
    * Shell command line
    * Bash shell
    * Vi editor (Nvi, Elvis, vim)
    * Less viewer
    * Emacs editor (Emacs, Mule, Xemacs)
    * Web browser
    * Doxygen documentation system 

基本用法:
①下载安装gtags后,在源文件的目录中,键入"gtags -v"命令,就会生成相应文件。

[xx@localhost sys]$ gtags -v

例:source code(/usr/src/sys)       123MB

    GPATH                             1MB `GPATH'  path name database     GTAGS                            26MB `GTAGS'  definition database     GRTAGS                           22MB `GRTAGS' reference database     GSYMS                            23MB `GSYMS'  symbol database     -------------------------------------     total of tag files               72MB


gtags的其他options的含义,请参考man手册。
(辅助: http://blog.chinaunix.net/u3/98822/showart_2129660.html

②下载安装gtags后,会有名为gtags.el的文件,注意看安装时make install的list,即可找到gtags.el的安装位置(默认目录是:/usr/local/share/gtags/)。
将gtags.el的路径设置为Emacs的<load-path>。
例:在`$HOME/.emacs'文件中加入下记代码例。

(setq load-path (cons "/home/owner/global" load-path));gtags.el load-path (autoload 'gtags-mode "gtags" "" t);gtags-mode is true

从此启动Emacs后,及在<load-path>中load了gtags.el文件,并将gtags-mode设置为真(等同于每次启动后,都在Emacs中的M-x,手动键入gtags-mode)。

个人.emacs文件中的内容:

;##global(GNU GLOBAL source code tag system);;;;;;;;;;;;;;;;;;;;; ;to use global from Emacs, you need to load the `gtags.el' and execute gtags-mode function in it. ;you need to add it to load-path. for `gtags.el'file. ;(add-to-list 'load-path "<path to gtags.el>");已经在之前的代码中load完了 (autoload 'gtags-mode "gtags" "" t);;start Emacs and execute gtags-mode function.  (setq c-mode-hook       '(lambda ()      (gtags-mode 1)));get into gtags-mode whenever you get into c-mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


③当源程序的源文件的内容变化了(导致行号变化),或追加删除了源文件等等。只要有改变,就要更新gtags生成的那4个文件。
例:source code(/usr/src/sys)

[xx@localhost sys]$ gtags -vi or [xx@localhost sys]$ global -u (推荐)


详细用法:
直接参考gtags的英文的Tutorial(指导)。
有很多章节可以跳过,因为那是global在别的编辑软件中的应用方法的说明。(例如shell,vi等)
 章节还是要必看的。

看了gtags的英文的Tutorial(指导)后,发现htags也蛮有用的。

$ htags -Ff -sanohIvt 'Welcome to XXX source tour!' --table-flist=1 $

gtags完成的基本动作(具备键盘的快捷键):
    * 鼠标滚轮键(下按):根据上下文,找到"函数或常量或变量"的"定义或调用"的位置。
      或,按【enter】。
    * 鼠标右键:返回。(就是按完滚轮键后,想返回到原来刚才的位置的话,就按右键)
      鼠标右键(返回),我想应该是emacs的功能,而不是Global的功能。
      如果键盘操作的话,应该是:
      ①调用处搜索关键字→ 结果列表→ [Enter]键选择→ 被选部分的代码表示
      ②被选部分处,再次搜索相同关键字→ 结果列表→ [Enter]键选择→ 原调用处的代码再表示
    * 光标+Enter:当按滚轮键后,出现的调用位置的结果为多个时,将光标调整到相应行,按下回车即可跳转到对应位置。
      (如图,名为_exit_ts的函数在整个项目中,有多个位置调用他)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值