Golevka / emacs-clang-complete-async

An emacs plugin to complete C and C++ code using libclang
360 stars 71 forks source link

auto-complete fail #19

Closed maindoor closed 11 years ago

maindoor commented 11 years ago

Setup everything as given in the help me file. 1) My auto-complete.el that I use to load is attached.

2) When I try to auto-complete I sometimes get unrelated completions as shown in snapshot1.png

2) But when I delete vec and start again, I get the right results as shown in snapshot2.png.

auto-complete.el

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

(add-to-list 'load-path "~/.emacs.d/") (require 'auto-complete-config) (add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict") (ac-config-default) (require 'auto-complete-clang) (setq clang-completion-suppress-error 't)

;; echo "" | g++ -v -x c++ -E - (setq ac-clang-flags (mapcar (lambda (item)(concat "-I" item)) (split-string " /usr/include/c++/4.7 /usr/include/c++/4.7/x86_64-linux-gnu /usr/include/c++/4.7/backward /usr/lib/gcc/x86_64-linux-gnu/4.7/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed /usr/include/x86_64-linux-gnu /usr/include " )))

(defun my-ac-clang-mode-common-hook() (define-key c-mode-base-map (kbd "M-/") 'ac-complete-clang) )

(add-hook 'c-mode-common-hook 'my-ac-clang-mode-common-hook)

(require 'auto-complete-clang-async)

(defun ac-cc-mode-setup () (setq ac-clang-complete-executable "~/workset/emacs/pkgs/ac/clang-complete") (setq ac-sources '(ac-source-clang-async)) (ac-clang-launch-completion-process) )

(defun my-ac-config () (add-hook 'c-mode-common-hook 'ac-cc-mode-setup) (add-hook 'auto-complete-mode-hook 'ac-common-setup) (global-auto-complete-mode t))

(my-ac-config)

What is wrong here ? snapshot1 snapshot2

Golevka commented 11 years ago

I tried exactly the configurations you posted without reproducing the problem you described, however I noticed a few things that worth mention.

(defun ac-cc-mode-setup ()
  (setq ac-clang-complete-executable "~/workset/emacs/pkgs/ac/clang-complete")

  (setq ac-clang-cflags
    (mapcar (lambda (item)(concat "-I" item))
        (split-string
         "
/usr/include/c++/4.7
/usr/include/c++/4.7/x86_64-linux-gnu
/usr/include/c++/4.7/backward
/usr/lib/gcc/x86_64-linux-gnu/4.7/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
"
         )))

  (setq ac-sources '(ac-source-clang-async))
  (ac-clang-launch-completion-process)
  )
maindoor commented 11 years ago

That's great this works. One other related question: why doesn't the completion for thread library work ? std iostream related completion works but not the std threads. when i do std::t no completion for threads startup. How to do I tell clang-async that I am passing a std=c++0x during the command line ?

maindoor commented 11 years ago

The issue as reported works well. I'll open another issue for thread completion.