14

I've recently switched over from Eclipse CDT to Spacemacs with the C++ layer as my development environment.

So far... awesome! However, one of the things I miss about Eclipse is its indexer.

At the moment I'm using GNU Global with the gtags layer. The problem with gtags is that it's a tagging system, not an indexer.

Example:

Searching for references for a function called set in class Field returns 165 references in my codebase, only one of which is actually a reference to Field::set

Searching for references to set in CDT returns 1 result.

Is there a better indexing solution I can use in emacs?

Searching online I found this page where 3 clang based indexers are listed.

Questions:

  • Will any of these offer a better indexing experience?
  • Any suggestion on which to use?
  • Is there a better alternative not listed?

Note:

I've also been using clang-complete for code completion, but have found it is very slow. Unusably slow. (I am not the only one to experience this) If any indexing solution suffered from the same problem, it wouldn't work.

5
  • Not that I'm working with C++ projects, but maybe you could find helpful contents on emacs.zeef.com under the C++ section?
    – ReneFroger
    May 6, 2016 at 15:19
  • I've noticed that clang-indexer hasn't had any recent development, and the author himself says it's "rough" - so I won't try that over the other two May 6, 2016 at 15:51
  • rtags seems to be the most popular of the 3 listed May 6, 2016 at 15:52
  • 1
    Strictly speaking, does this question have anything to do with Emacs?
    – PythonNut
    May 6, 2016 at 17:59
  • 1
    As currently phrased, this question is very subjective and likely to yield answers that are primarily opinion-based. Please edit your post to make the question more concrete.
    – Dan
    May 7, 2016 at 12:22

1 Answer 1

5

I can only tell for rtags that I have been using actively for the last 1-2 years.

rtags works as expected. It is compiler based and provides correct code navigation. Something I have been looking for for the past 10 years as an emacs user.

Setup can be a bit tricky. I recommend taking a look at cmake-ide, that does part of the setup automatically. https://github.com/atilaneves/cmake-ide

This blog post can also help https://vxlabs.com/2016/04/11/step-by-step-guide-to-c-navigation-and-completion-with-emacs-and-the-clang-based-rtags/

You can also take a look (or use) my own configuration: https://github.com/jardon-u/dotfiles/blob/master/emacs.d/development/c/_init.el I use a combination of cmake-ide (project discovery), irony (for code completion) and rtags (for code navigation). I am pretty sure this could be simplified as some functionalities overlap between each mode, but the result is at the level I am expecting from a modern IDE.

rtags also provides code refactoring facilities, but it is quite limited (mostly renaming)

2
  • 2
    It has been two years since this answer was accepted, are you still using rtags? I'm curious if documentation on setup got changed or easier setup got introduced. Any info on that? Could you share your setup/config file?
    – A_P
    Feb 4, 2019 at 19:02
  • 2
    @A_P For some reason I am only seeing your comment now. I am still using rtags. You should check again cmake-ide page + my config (link in my answer). I also automated most of the install. Check: github.com/jardon-u/dotfiles/blob/master/install.sh (though emacs version might not be the latest. I will try updating this)
    – log0
    Jul 4, 2019 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.