Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get a error when I try install auto-complete in emacs

I'm newbie in emacs...I've a few days and I think emacs is awesome but I get a error when I try install auto-complete...I install it from http://cx4a.org/software/auto-complete/ the installation works (I use the makefile)...but when I put this lines inside my emacs.d

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

I get this error

Warning (initialization): An error occurred while loading `/home/yo/.emacs':

Symbol's value as variable is void: ac-dictionary-directories

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace

I've my folder .emacs in /home/yo/.emacs and inside this I've the folder ac-dic..inside this there are c++ mode..lisp mode ruby mode...etc..etc...etc.....

my autocomplete.el is inside my .emacs too...what am I doing wrong??...thanks!!!

like image 914
angel Avatar asked Nov 25 '10 23:11

angel


3 Answers

ac-dictionary-directories is defined in the auto-complete.el, so obviously emacs will not find it. So simply change the order of the statements:

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

Now, it should work.

like image 55
VitoshKa Avatar answered Nov 01 '22 10:11

VitoshKa


I suspect the problem is that add-to-list wants to prepend to an existing list, but there is no such variable at the time you're calling it.

You could use (setq 'ac-dictionary-directories "~/.emacs.d/ac-dict") instead or follow the advice in the help for add-to-list:

If you want to use add-to-list' on a variable that is not defined until a certain package is loaded, you should put the call toadd-to-list' into a hook function that will be run only after loading the package. `eval-after-load' provides one way to do this. In some cases other hooks, such as major mode hooks, can do the job.

In other words something like:

(eval-after-load 'auto-complete-config
  '(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict"))

Or, finally, you could just set the variable after the require, but I'm not sure how that interacts with auto-complete's initialisation.

like image 20
brontitall Avatar answered Nov 01 '22 09:11

brontitall


.emacs. is normally an elisp file and .emacs.d is the directory. Looks like you are treating them the other way round. You put the

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

in ~/.emacs, not .emacs.d.

Or, your question is not clear. What does your ~/.emacs look like?

EDIT:

Or, you want to do

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

instead of

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

I've my folder .emacs in /home/yo/.emacs and inside this I've the folder ac-dic..inside this there are c++ mode..lisp mode ruby mode...etc..etc...etc.....

~/.emacs should be a file. Not a directory.

but when I put this lines inside my emacs.d

~/.emacs.d/ should be a directory

like image 2
vpit3833 Avatar answered Nov 01 '22 11:11

vpit3833