emacs completions or IntelliSense the same as on V

2019-02-02 03:04发布

emacs 22.2.1 on Linux

I am doing some C/C++ programming using emacs. I am wondering does emacs support completions (IntelliSense in Visual Studio).

For example when filling structures I would like to see the list of members when I type the dot operator or arrow operator.

The same would go for function signatures that give me the types I am passing would display.

6条回答
家丑人穷心不美
2楼-- · 2019-02-02 03:43

I am using cedet with emacs. I tried using the cedet version in Debian but it has some bugs so I uninstalled that and downloaded the cvs version from http://sourceforge.net/projects/cedet/develop

I compiled it in my ~/tmp/emacs-stuff/ directory and then added the following lines to my ~/.emacs.d/custom.el file:




;;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)


This file gets called by my ~/.emacs file which the following line in it: (load-file "~/.emacs.d/custom.el")

Now when you are typing a variable and press CTRL+SHIFT+ENTER, a menu of selections will come up with suggestions.

Further, if you have set semantic-complete-inline-analyzer-idle-displayor-class variable to quote semantic-displayor-tooltip, a tooltip with suggestions will also come up after some idle time (1 or 2 seconds).

For some short intro, see http://xtalk.msk.su/~ott/en/writings/emacs-devenv/EmacsCedet.html

For Cedet docs, see: http://cedet.sourceforge.net/

Good luck.

查看更多
混吃等死
3楼-- · 2019-02-02 03:43

Meta-/ isn't exactly intelligent, but it does iterate through known names.

This project provides the dropdown style menus you're used to:

http://ecb.sourceforge.net/

查看更多
闹够了就滚
4楼-- · 2019-02-02 03:46

I have this in my .emacs, which makes things a bit easier.

(require 'c-eldoc) (add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)

This way, I don't have to look up function definitions.

I don't write that much, but I agree that TAGS are also a very useful feature.

查看更多
小情绪 Triste *
5楼-- · 2019-02-02 03:48

you need to take latest version of CEDET package (better, directly from CVS). You can setup it, as described in documentation on this site

查看更多
劫难
6楼-- · 2019-02-02 04:00

I think you're looking for etags. http://tulrich.com/geekstuff/emacs.html

Search for TAGS.

查看更多
放我归山
7楼-- · 2019-02-02 04:01

If you'd like to use stock emacs to do completion from your project and library include files try this answer

查看更多
登录 后发表回答