Eclipse Style Function Completions in Emacs for C,

2019-01-31 12:36发布

问题:

How Do I Get Eclipse Style Function Completions in Emacs for C, C++ and JAVA? I love the power of the Emacs text editor but the lack of an "intellisense" feature leaves me using Eclipse.

回答1:

M-/ is a quick and dirty autocomplete based on the contents of your current buffer. It won't give you everything you get in Eclipse but is surprisingly powerful.



回答2:

I can only answer your question as one who has not used Eclipse much. But! What if there was a really nice fast heuristic analysis of everything you typed or looked at in your emacs buffers, and you got smart completion over all that everywhere, not just in code?

M-x load-library completion
M-x global-set-key C-RET complete RET


回答3:

When I was doing java development I used to use the:

Java Development Environment for Emacs (JDEE)

The JDEE will provide method name completion when you explicitly invoke a jdee provided function. It has a keyboard binding for this functionality in the jdee-mode.



回答4:

The CEDET package provides completion for C/C++ & Java (and for some other languages). To initial customization you can take my config that i use to work with C++ projects



回答5:

Right now, I'm using Auto Complete for Emacs. As a current Visual Studio and ex-Eclipse user, I can say that it rivals both applications quite well. It's still not as good as Microsoft's IntelliSense for C#, but some would say that C++ is notoriously difficult to parse.

It leverages the power of (I believe) the Semantic package from Cedet, and I find it feels nicer to use when compared to Smart Complete. It completes C++ members, local variables, etc. It's pretty good. However, it falls down on not being able to complete overloaded methods (it only shows the function once with no parameters, but thats a limitation of Cedet I believe), and other various things. It may improve in future though!

By the way, I could be wrong here, but I think you need an EDE project set up for the class member completion to work (just like you would normally with Semantic). I've only ever used it while having an EDE project, so I assume this is true.



回答6:

Searching the web I find http://www.emacswiki.org/cgi-bin/wiki/EmacsTags#toc7 describing complete-tab in etags. It is bound to M-Tab by default. This binding may be a problem for you

Also, etags has some limits, which may annoy you...

The link also points to CEDET as having better symbol completion support.



回答7:

Have you tried the emacs plugin for eclipse?

http://people.csail.mit.edu/adonovan/hacks/eclipse-emacs.html



回答8:

I've written a C++-specific package on top of CEDET that might provide what you want. It provides an Eclipse-like function arguments hint. Overloaded functions are supported both for function arguments hint and for completion. Package is located here:

https://github.com/abo-abo/function-args

Make sure to check out the nice screenshot:

https://raw.github.com/abo-abo/function-args/master/doc/screenshot-1.png



回答9:

auto-complete-clang is what you want. Can't go wrong with using an actual C++ compiler for completions.

The only problem it has is there's no way to know what -I and -D flags to pass to the compiler. There are packages for emacs that let you declare projects and then you can use that.

Personally, I use CMake for all C and C++ work so I wrote some CMake code to pass that information to emacs through directory-local variables. It works, but I'm thinking of writing a package that calls cmake from emacs so there's less intrusion.