4

为 Emacs cscope 加入 Java 支持

 2 years ago
source link: https://blog.yxwang.me/2013/01/java-and-aidl-support-in-emacs-cscope/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

为 Emacs cscope 加入 Java 支持

Wed, Jan 9, 2013 • Tooling

Emacs 的 xcscope 插件默认不会扫描 Java 文件,另外 Android 源码里有不少 .aidl 的文件,默认也不包含在 xcscope 的扫描范围里。解决这个问题的一个方法是在项目根目录下手动创建 cscope 索引:

$ find . -name "*.java" -or -name "*.aidl" -or -name "*.cpp" > cscope.files

$ cscope -b

这样做的缺点很明显,索引功能没有做到 Emacs 里,需要单独起一个 shell,比较麻烦。我发现这个问题的本质在于 xcscope 创建索引用的是 cscope-indexer 这个脚本,而 cscope-indexer 默认只会扫描 C/C++ 的源码文件。所以其实只要修改 cscope-indexer,把第 140 行从原来的

    egrep -i '\.([chly](xx|pp)*|cc|hh)$' | \
    egrep -i '\.([chly](xx|pp)*|cc|hh|java|aidl)$' | \

之后就能用 C-c s I 在 Emacs 中创建 Android 项目的索引了。

本作品采用知识共享署名-非商业性使用 3.0 版本许可协议进行许可,欢迎转载,演绎,但是必须保留本文的署名 zellux(包含链接),且不得用于商业目的。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK