Linux上的emacs 22.2.1
我正在使用emacs进行C/C++编程。我想知道emacs是否支持自动完成(类似于Visual Studio中的IntelliSense)。
例如,在填写结构时,我希望在输入句点或箭头操作符时看到成员列表。
同样的,函数签名也应该显示传递的类型。
Linux上的emacs 22.2.1
我正在使用emacs进行C/C++编程。我想知道emacs是否支持自动完成(类似于Visual Studio中的IntelliSense)。
例如,在填写结构时,我希望在输入句点或箭头操作符时看到成员列表。
同样的,函数签名也应该显示传递的类型。
您需要获取最新版本的CEDET软件包(最好直接从CVS获取)。您可以按照本网站上的文档说明进行设置。
;;needed if cedet is in a custom location
(load-file "~/tmp/emacs-stuff/cedet/common/cedet.el")
;; Enable EDE (Project Management) features
(global-ede-mode t)
;;to enable code folding
(global-semantic-tag-folding-mode)
;; Enabling Semantic (code parsing, smart completion) features
;; (select only one)
;;(semantic-load-enable-minimum-features)
;;(semantic-load-enable-code-helpers)
(semantic-load-enable-gaudy-code-helpers)
;;(semantic-load-enable-all-exuberent-ctags-support)
(global-semantic-idle-scheduler-mode 1) ;The idle scheduler with automatically reparse buffers in idle time.
(global-semantic-idle-completions-mode 1) ;Display a tooltip with a list of possible completions near the cursor.
(global-semantic-idle-summary-mode 1) ;Display a tag summary of the lexical token under the cursor.
;;to work with my include files and cedet
(semantic-add-system-include "~/include" 'c++-mode)
(semantic-add-system-include "~/include" 'c-mode)
;;To use additional features for names completion, and displaying of information for tags & classes,
;; you also need to load the semantic-ia package. This could be performed with following command:
(require 'semantic-ia)
;;to work with systme include files and gcc
(require 'semantic-gcc)
;;integrate semantic with Imenu
(defun my-semantic-hook ()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)
;;load Semanticdb
(require 'semanticdb)
;;(global-semanticdb-minor-mode 1)
;;working with tags
;; gnu global support
(require 'semanticdb-global)
(semanticdb-enable-gnu-global-databases 'c-mode)
(semanticdb-enable-gnu-global-databases 'c++-mode)
;; ctags
(require 'semanticdb-ectag)
(semantic-load-enable-primary-exuberent-ctags-support)
(defun my-semantic-hook ()
(imenu-add-to-menubar "TAGS"))
(add-hook 'semantic-init-hooks 'my-semantic-hook)
这个文件被我的 ~/.emacs 文件调用,以下是它的一行代码: (load-file "~/.emacs.d/custom.el")
现在当你输入一个变量并按下CTRL+SHIFT+ENTER时,会出现一个包含建议的选择菜单。
此外,如果你已经将semantic-complete-inline-analyzer-idle-displayor-class变量设置为引用semantic-displayor-tooltip,则在一段空闲时间(1或2秒)后还会出现一个带有建议的工具提示。
有关简短介绍,请参见http://xtalk.msk.su/~ott/en/writings/emacs-devenv/EmacsCedet.html
有关Cedet文档,请参见:http://cedet.sourceforge.net/
祝好运。
我在我的.emacs文件中加入了以下内容,这样可以让事情变得更容易一些。
(require 'c-eldoc) (add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
这样,我就不必查找函数定义了。
虽然我不写那么多代码,但我同意TAGS也是一个非常有用的功能。