I am using Emacs24, and my auto-complete plugin was working when I opened my .emacs file. However, it doesn't work when I open some file like :


To add to this, the auto-complete-c-headers do not work. I believe that auto-complete doesn't work on c/c++ mode.

Here is my .emacs file:

(add-to-list 'load-path "~/.emacs.d/elpa/neotree")
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)

(defun my:ac-c-header-init()
    (require 'auto-complete-c-headers)
    (add-to-list 'ac-sources 'ac-source-c-header))
(add-hook 'c++-mode-hook 'my:a-c-header-init)
(add-hook 'c-mode-hook 'my:ac-c-header-init)

(require 'cc-mode)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))

(setq-default c-basic-offset 2 c-default-style "linux")
(setq-default tab-width 2 indent-tabs-mode t)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)

(add-to-list 'load-path
(require 'yasnippet)
(yas-global-mode 1)

(add-to-list 'load-path "~/.emacs.d/elpa")
(require 'linum)
(global-linum-mode 1)

(add-to-list 'load-path "~/.emacs.d/elpa/auto-complete-1.3.1")
(require 'auto-complete)
(require 'auto-complete-config)
(define-globalized-minor-mode real-global-auto-complete-mode
  auto-complete-mode (lambda ()
                       (if (not (minibufferp (current-buffer)))
                         (auto-complete-mode 1))
(real-global-auto-complete-mode t)
(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")
  • I figure it out just right now I've edited thanks for your attention – Vivian Maya Oct 28 '14 at 21:27
  • @VivianMaya, can you post the answer/solution to your problem? Just make an answer that says "Adding the line of code... Solved my problem...". :) – Luke Shimkus Oct 28 '14 at 21:31
  • 1
    I did it thanks, I'm a kind of newbie around here. – Vivian Maya Oct 28 '14 at 21:37
  • No problem. We all have to start somewhere. :) – Luke Shimkus Dec 13 '14 at 23:32

I added the following code to solve most of my problem:

(setq ac-source-yasnippet nil)

But, it caused complexity between yasnippet and auto-complete so I added this:

(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)

Modified some keys:

(ac-set-trigger-key "TAB")
(ac-set-trigger-key "<tab>")

And solved all of my problems.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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