萬盛學電腦網

 萬盛學電腦網 >> Linux教程 >> 實用技巧:使用Emacs+Cscope來閱讀代碼

實用技巧:使用Emacs+Cscope來閱讀代碼

class="21182"> ; 1. 安裝 cscope, http://cscope.sourceforge.net/ 到這裡下載cscope, 最新版本為 15.6。 如果你使用 debian 或者 ubuntu,直接 sudo apt-get install cscope就可以了 2. 安裝 xcscope.el 把 cscope 附帶的 xcscope.el 文件放到你的 emacs的 load-path 下,在 ~/.emacs 中增加: (require 'xcscope) 3. 生成 project 文件列表,可以用如下命令完成。例如kernel代碼,找出所以 .h, .c, .S文件 find -type f | grep -E '.[chS]$' > cscope.files 4. 生成 cscope 索引文件, -k 專門用於生成 linux kernel 源碼的索引 cscope -b -k 5. 運行 emacs,以下是一些常用的按鍵 C-c s C-h 查看所有的 cscope 相關的按鍵 C-c s a 設定索引文件所在目錄 C-c s c 查找調用該函數的地方 C-c s g 查找該符號的全局定義 C-c s f 查找該符號對應的文件 ... 如果習慣了Emacs的這種按鍵,感覺使用起來還是挺方便的,感興趣的可以自己體會。

copyright © 萬盛學電腦網 all rights reserved