code browsing, refactoring, auto completion in Ema

2019-01-13 08:59发布

问题:

I recently switched to Emacs and still finding my way through it. I code in C++ and was wondering what tools out there extend Emacs to support code browsing (finding a symbol etc), refactoring and code completion. I have heard of:

  • cedet
  • etags
  • cscope

But I'm so confused about what I need. Some places say that cedet provides all of the functionality but other places say that I need to invoke etags for cedet to work properly.

Can someone clear this up for me? Do I need all of these tools?

回答1:

Maybe you will find my article about Cedet useful. Cedet has support for etags, gtags, cscope and other tools.

But refactoring is missing. You may need to look into the Xrefactory tool (but it isn't free)



回答2:

Cscope is very good as "find symbol" usage tool. It is very fast.
Etags will show you your class hierarchy and will help you to find method definition/declaration.

So these two tools are must have and they are independent.

Cedet. It is kind of replacement of these two tools above with additional features. So your choice either cscope/etags or cedet.



回答3:

For refactoring, I started using emacs exclusively for this and related tasks after I read this article by emacs hacker Xah Lee.

For autocompletion, see this SO post. Personally, I've found yasnippet very helpful throughout the years.



回答4:

gtags (http://www.gnu.org/software/global/) is also available and perhaps simpler to use.



回答5:

Personally, I don't like cedet. It makes Emacs take an hour to load. The auto-complete feature has never worked quite right with me. I don't need its project-management nor its UML features. The only thing I miss about it is the Emacs Code Browser, which is very useful but requires cedet

I would advice you to just use cscope and etags and see how you like them. You can install cedet later once you're more familiar with emacs.



回答6:

I wrote a blog article about using Global/gtags and Speedbar for code browsing you might find useful... (I also thought CEDET was a bit slow... and extremely complicated to set up =)



标签: c++ emacs