【问题标题】:I get a error when I try install auto-complete in emacs当我尝试在 emacs 中安装自动完成时出现错误
【发布时间】:2011-05-15 23:01:21
【问题描述】:

我是 emacs 的新手...我有几天了,我认为 emacs 很棒,但是当我尝试安装自动完成时出现错误...我从 http://cx4a.org/software/auto-complete/ 安装它,安装工作正常(我使用makefile)......但是当我把这行放在我的emacs.d中时

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

我收到此错误

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

我在 /home/yo/.emacs 中有我的文件夹 .emacs,在里面我有文件夹 ac-dic..在里面有 c++ 模式..lisp 模式 ruby​​ 模式...etc..etc ……等等……

我的 autocomplete.el 也在我的 .emacs 中...我做错了什么??...谢谢!!!

【问题讨论】:

    标签: emacs autocomplete lisp


    【解决方案1】:

    .emacs. 通常是一个 elisp 文件,.emacs.d 是目录。看起来你正在以相反的方式对待他们。你把

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

    ~/.emacs,而不是.emacs.d

    或者,您的问题不清楚。你的~/.emacs 是什么样的?

    编辑:

    或者,你想做

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

    而不是

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

    我在 /home/yo/.emacs 中有我的文件夹 .emacs,在里面我有文件夹 ac-dic..在里面有 c++ 模式..lisp 模式 ruby​​ 模式...etc..etc ……等等……

    ~/.emacs 应该是一个文件。不是目录。

    但是当我把这行放在我的 emacs.d 中时

    ~/.emacs.d/ 应该是一个目录

    【讨论】:

      【解决方案2】:

      我怀疑问题是 add-to-list 想要添加到现有列表中,但在您调用它时没有这样的变量。

      您可以改用(setq 'ac-dictionary-directories "~/.emacs.d/ac-dict") 或按照添加到列表帮助中的建议:

      如果你想使用add-to-list' on a variable that is not defined until a certain package is loaded, you should put the call toadd-to-list' 进入一个只有在加载包后才会运行的钩子函数。 `eval-after-load' 提供了一种方法来做到这一点。在某些情况下 其他钩子,例如主要模式钩子,可以完成这项工作。

      换句话说:

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

      或者,最后,您可以在 require 之后设置变量,但我不确定它如何与自动完成的初始化交互。

      【讨论】:

        【解决方案3】:

        ac-dictionary-directories 是在 auto-complete.el 中定义的,所以显然 emacs 不会找到它。所以只需改变语句的顺序:

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

        现在,它应该可以工作了。

        【讨论】:

        • 只是想补充一点,这对我不起作用... Emacs 24.2.2,自动完成 v1.3.1。并且根本没有 yasn-p 的配置。
        • +1。我还需要在这三行上方添加 (add-to-list 'load-path "~/.emacs.d")。
        【解决方案4】:

        我遇到了这个问题。这是因为我从另一台计算机复制了自动完成文件。为了解决它,我重新下载了sources 然后我重新编译它并复制到我的 .emacs.d cd auto-complete make byte-compile cp *.el *.elc ~/.emacs.d

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-06-16
          • 1970-01-01
          • 1970-01-01
          • 2014-04-05
          • 2021-11-03
          • 2015-01-05
          相关资源
          最近更新 更多