我最想在emacs和vim中拥有的IDE功能是代码导航和查找用法。这两个编辑器都有以下类似的功能:
- 标签 - 特定文件中的标识符被索引,当你按下快捷键时,会导航到该位置
- CScope - 它允许您导航到标识符的“用法”
我在Emacs中使用cscope和semantic。对我来说已经足够了。
在cscope中,我经常使用的两个函数是cscope-find-global-definition和cscope-find-this-symbol。前一个函数非常精确。
C-c s s Find symbol.
C-c s d Find global definition.
(global-set-key [f8] 'semantic-ia-fast-jump) ;; jump to definition.
(global-set-key [S-f8] ;; jump back
(lambda ()
(interactive)
(if (ring-empty-p (oref semantic-mru-bookmark-ring ring))
(error "Semantic Bookmark ring is currently empty"))
(let* ((ring (oref semantic-mru-bookmark-ring ring))
(alist (semantic-mrub-ring-to-assoc-list ring))
(first (cdr (car alist))))
(if (semantic-equivalent-tag-p (oref first tag)
(semantic-current-tag))
(setq first (cdr (car (cdr alist)))))
(semantic-mrub-switch-tags first))))