Auto-Complete with Emacs 24 Doesn't Work with Java, C or C ++ Modes

I set autocomplete using marmalade remarks. Everything was installed correctly and after moving the material I managed to start and perform automatic correction without any errors with the following code in my init.el:

;; auto-complete (add-to-list 'load-path "~/.emacs.d/elpa/auto-complete") (require 'auto-complete-config) (add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete/dict") (ac-config-default) 

Now I can use autocomplete without hick-ups with Emacs Lisp, but whenever I use any other mode, such as Java, C or C ++, it does not work at all.

I also have yasnippet installed (it works great), not sure if this could have anything to do with it. Here is the corresponding code in my init.el:

 ;;yasnippet (add-to-list 'load-path "~/.emacs.d/plugins/yasnippet") (require 'yasnippet) (yas-global-mode 1) 

I am involved in the training of Emacs, and currently I'm still a noob. I searched all the documentation and so on, but found nothing. I would really appreciate any help on this.

+7
source share
2 answers

You may need to add completion sources. Here is what is in my configuration:

 (set-default 'ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-yasnippet ac-source-words-in-buffer ac-source-words-in-same-mode-buffers ac-source-semantic)) 

Update: ac-config-default should cover this, but if autocomplete is not activated for these modes, try putting the following in your init.el:

 (dolist (m '(c-mode c++-mode java-mode)) (add-to-list 'ac-modes m)) (global-auto-complete-mode t) 

Update2: I posted a gist that adapts your init.el to download autocomplete using package-install .

I can’t say which version of autocomplete you specified, but the latter works fine for me.

C-mode with working auto-completions

+5
source

I have the same problem as you. Emacs-Lisp works fine with autocomplete, but C, C ++ does not work. After trying using various combinations, I find out that commenting on yasnippet from .emacs solves my problem. Hope this can help you. My automatic version is 1.3.1.

0
source

All Articles