I get a error when I try install auto

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!!!


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.


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 to add-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.


.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

链接地址: http://www.djcxy.com/p/66220.html

上一篇: 麻烦运行Common Lisp

下一篇: 当我尝试安装auto时出现错误