5

我已经安装了 YASnippet 并使用它进行了配置:

(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle

(yas--initialize)
(yas/load-directory "~/.emacs.d/packages/yasnippet-0.6.1c/snippets")

但是,当我启动 Emacs 时,它给了我一个错误:

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

Symbol's function definition is void: yas--initialize

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.
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle

(yas--initialize)
(yas/load-directory "~/.emacs.d/packages/yasnippet-0.6.1c/snippets")

我究竟做错了什么?我试图找到答案,但没有成功。(我也尝试过另一个版本的 yasnippet yasnippet-0.6.1b 但它是一样的。)

4

2 回答 2

5

乍一看,那

(yas--initialise)

应该

(yas/initialize)

我正在运行0.6.1,并且没有像yas--initialize包中那样的功能。

我的初始化代码看起来像

(require 'yasnippet)
(yas/initialize)
(yas/load-directory
 (dot-emacs "elpa/yasnippet-0.6.1/snippets"))

我想你只是在某个地方得到了一些乱码的初始化代码。

编辑

我应该load-directory在我的示例中省略调用,因为它离题了。但就其价值而言,dot-emacs它只是一个与配置无关的函数,我用来引用与我的 init 相关的文件:

(defun dot-emacs (relative-path)
  "Return the full path of a file in the user's emacs directory."
  (expand-file-name (concat user-emacs-directory relative-path)))
于 2012-10-31T19:53:31.783 回答
4

FYI in case you ever upgrade: the information you got is correct for version 0.8, but for 0.7 and below yas/initialize is correct. See this commit

于 2012-10-31T20:28:51.217 回答