索引
您可能需要使用GNU/global代替的ctags:它支持C++,是在我看來,與大型項目更有效(特別是因爲你可以更新,而不是從頭開始重建它的指數)。而且,使用CEDET/Semantic(如果花時間設置它,這也是一個非常棒的工具),它仍然更加簡單。
實施例使用:
$ cd sources
$ gtags -v # create the index
$ cd subdirectory
$ [hack hack hack]
$ global -u # update the index (can be called from anywhere in the project)
在Emacs中,激活源代碼緩衝器gtags-mode
才能到gtags訪問命令:
gtags-find-tag
(M-。):發現的定義(gtags
可讓您在所有可能的定義之間進行選擇,如果只有一種可能性,則可以直接跳轉)
gtags-pop-stack
(M- *):返回到前面的位置
gtags-find-rtag
:找到指定標籤的所有使用源文件
下面是我對gtags
配置,它會自動激活gtags-mode
如果指數發現:
;; gtags-mode
(eval-after-load "gtags"
'(progn
(define-key gtags-mode-map (kbd "M-,") 'gtags-find-rtag)))
(defun ff/turn-on-gtags()
"Turn `gtags-mode' on if a global tags file has been generated.
This function asynchronously runs 'global -u' to update global
tags. When the command successfully returns, `gtags-mode' is
turned on."
(interactive)
(let ((process (start-process "global -u"
"*global output*"
"global" "-u"))
(buffer (current-buffer)))
(set-process-sentinel
process
`(lambda (process event)
(when (and (eq (process-status process) 'exit)
(eq (process-exit-status process) 0))
(with-current-buffer ,buffer
(message "Activating gtags-mode")
(gtags-mode 1)))))))
(add-hook 'c-mode-common-hook 'ff/turn-on-gtags)
自動完成
我不知道任何比auto-complete
更好的工具。即使它不包含在Emacs中,也可以使用包裝系統輕鬆安裝(例如,在marmalade或melpa存儲庫中)。
您可能想查看GNU global plus xgtags.el和clang based auto-complete。語義也可以同時使用。 – Arne 2013-03-07 22:30:25
檢查鏗鏘C++自動完成:http://root42.blogspot.hu/2012/07/nice-c-autocomplete-configuration-for.html – Tom 2013-03-08 07:11:07
我目前正在開發['clang-tags'](https:/ /github.com/ffevotte/clang-tags),這是一個基於clang的索引工具。它仍處於開發的早期階段,但您可能會發現它是可用的。如果你確實嘗試過,我會很高興在github上獲得一些反饋。 – Francesco 2013-03-08 07:29:04