foboi1122
foboi1122

Reputation: 1757

setting up emacs autcomplete with gtags

I've been struggling with getting tags to work with auto-complete mode for quite a while now, and it seems like my attempts have been futile.

I have two questions:

  1. How can I tell if auto-complete mode is working with gtags?
  2. How do I setup gtags to work with auto-complete? (including the steps I need to do outside of emacs to get everything setup.)

Here's my situation:

I have a relatively large code base and I would like to index it with gtags, then use the gtags in my autocomplete for code hints. There are many levels of directories in the source, but they all belong to a root directory where I generated my gtags.

To my understanding, if I have everything correctly setup, I should be able to type a few letters, and get auto-complete based on gtags if the source is within the directories that gtags indexed. For example, if I have saved my gtags (by calling gtags from the command line) at the root directory like so:

Root_Project_Dir
├── GPATH
├── GRTAGS
├── GSYMS
├── GTAGS
│
├── Folder1
│   └──my_structs.h
├── Folder2
    └──some_code.cpp

Where my_structs.h has something defined like...

struct testStruct{
    int a;
    char blah_blah;
    double context;
};

Then that would mean that if I were to define this struct in some_code.cpp, auto-complete could attempt to complete my struct in the .cpp source. Is this correct? In other words, if I defined testStruct mystruct = new testStruct(); then the next time I call something like "mystruct->", the autocomplete dialog should pop up with the members of the struct?

My toy .emacs file has the following bare bone auto-complete setup (along with the correct load path). It seems to be able to recognize and auto-complete code from within the working directory. However, it doesn't seem to be aware of anything beyond the directory that the source is currently in.

;; auto-complete stuff
require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
(defun ac-common-setup ()
  (setq ac-sources (append ac-sources '(ac-source-gtags))))

I've looked around a lot on the internet, but I haven't really found any solutions. I saw this post, but the solution just says to add ac-source-gtags. I think I need a little more instruction to get things working since I'm not too familiar with elisp.

Upvotes: 4

Views: 1505

Answers (0)

Related Questions