Created
June 30, 2018 13:21
-
-
Save c02y/3f083ff874d412f66660f13f33fd2c9e to your computer and use it in GitHub Desktop.
emacs+cscope/gtags/etags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find the files containing the obsolete: | |
such as assoc: | |
find ~/.emacs.d/ -name "*.el" -exec grep -H "(require 'assoc)" {} \; | |
# for the differences of cscope ctags, etags, global(gtags, ggtags..)...: | |
# https://github.com/OpenGrok/OpenGrok/wiki/Comparison-with-Similar-Tools | |
# etags for small c;cscope for big project | |
etags: | |
find /usr/include/XXX | egrep '.h$|.hpp$|.c$|.cpp$' | etags - | |
or | |
find /usr/include/ -name "*.[cChHsS]" | etags - (using this) | |
or | |
etags -a -i /usr/include/XXX/TAGS | |
.emacs: | |
(setq tags-file-name "/usr/src/linux/TAGS") | |
(setq tags-table-list '("path1/TAGS" "path2/TAGS")) /* multi-TAGSs | |
M-. :跳至相应的函数定义处; | |
M-* :返回刚才的函数名处; | |
C-u M-. :如果emacs找错了,找下一个; | |
M-Tab :自动补齐函数名; | |
cscope: install cscope cscope-el | |
1: | |
under project path: /* it seems the files output by `make cscope` is working faster than 2 & 3 | |
make cscope # size cscope* #2 | |
make cscope ARCH=arm # specific platform, size cscope* #1 | |
---using this *******************************use1************************ | |
2: cscope-indexer用于处理源代码并不是在一个文件夹下面的情况 | |
under project path: /* to produce cscope.files & cscope.out */ | |
cscope-indexer -v -r #cannot be -vr, if no Makefile, you can use this, size cscope* #3 | |
or | |
find . -name "*.[ch]" -print > cscope.files | |
find /usr/include -type f >> cscope.files | |
cscope -b -q -R # this file will call cscope.files , not -k for kernel mode, man cscope | |
3:http://cscope.sourceforge.net/large_projects.html | |
默认是的快捷键都是绑定到 C-c s 的前缀上面,如果嫌麻烦的话可以自己更改 快捷键绑定。这是默认的用于查找的键绑定: | |
C-c s s Find symbol. | |
C-c s d Find global definition. | |
C-c s g Find global definition (alternate binding). | |
C-c s G Find global definition without prompting. | |
C-c s c Find functions calling a function. | |
C-c s C Find called functions (list functions called from a function). | |
C-c s t Find text string. | |
C-c s e Find egrep pattern. | |
C-c s f Find a file. | |
C-c s i Find files #including a file. | |
下面是在搜索到的结果之间切换用的快捷键: | |
C-c s b Display *cscope* buffer. | |
C-c s B Auto display *cscope* buffer toggle. | |
C-c s n Next symbol. | |
C-c s N Next file. | |
C-c s p Previous symbol. | |
C-c s P Previous file. | |
C-c s u Pop mark. | |
更详细的使用说明请参见 xcscope.el 文件头部的注释 | |
global: install global gtags | |
# http://www.gnu.org/software/global/manual/global.html | |
# gtags can browser assembly file, should use global(gtags) and etags together, gtags are much faster than etags and generally more accurate. I did find a few issues where it was incorrectly parsing code. | |
# 安装好以后,有global、gtags、gtags-cscope三个命令。global是查询,gtags是生成索引文件,gtags-cscope是与cscope一样的界面。而gtags相对于cscope的优势就在这里:增量更新单个文件的速度极快,几乎是瞬间完成。可以在终端下面使用global命令行查询,详见上链接 | |
1: | |
under project dir: if no Makefile, you can only use gtags of the two | |
gtags -v # ouput GTAGS, GRTAGS, GPATH, GSYMS size G* #1 | |
make gtags # size G* #3 | |
make gtags ARCH=arm # specific platform, size G* #2 | |
# if you have a project which is not a kernel big, and you want to include both the system include and the projects files into your G* files, then: (in the project dir) | |
ln -s /usr/include include_sys | |
gtags | |
*********************use2*********************** | |
2: | |
read gtags.el | |
## | |
ggtags: https://github.com/leoliu/ggtags | |
if gtags isn't working, use ggtags, it will use the G* files above: | |
############### for kernel project #################### | |
##use1 and use2 size comparision, linux-3.14.1 for example | |
make cscope # 570M = cscope.files + cscope.out + cscope.out.in + cscope.out.po | |
make ARCH=arm cscope # 583M = .. | |
make gtags # 390M = GPATH + GTAGS + GSYMS + GRTAGS | |
make ARCH=arm gtags # 402M = .. | |
# sometimes, the above(no ARCH or not) will be the same, if ARCH is specific in Makefile | |
############### for program project ################### | |
check .local/bin/tag | |
gtags # 473M = G.. | |
cscope-indexer -r # 358M = cscope.out + cscope.files | |
# after installing all the .el, do the following | |
1. replace the old expressions | |
M-x find-name-dired --> .emacs.d --> *.el* --> interactive-p --> \ | |
called-interactively-p --> ! many times | |
2. recompile all the .el | |
C-x 0 M-x byte-recompile-directory --> .emacs.d | |
3. right the wrongs, then delete all the .elc | |
M-x find-name-dired --> .emacs.d --> *.elc --> t to mark all --> D to \ | |
delete all | |
4. repeat step 2 once again | |
# if Message shows that "Warning: called-interactively-p called with 0 arguments, but requires 1" | |
1. | |
M-x igrep (called-interactively-p) | |
replace all (called-interactively-p) by (called-interactively-p 'any) | |
2. | |
do step 3 and 4 | |
(iyou can also put (setq byte-compile-warnings nil) to .emacs to avoid it) | |
# view code in read-only mode | |
# create a file called `.dir-locals.el` in the root directory you want to protect with the content: | |
((nil . ((eval . (view-mode 1))))) | |
# or just use C-x C-q in that buffer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment