安装YASnippet

时间:2012-10-31 19:13:18

标签: emacs debian yasnippet

我已经安装了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,但它是一样的。)

2 个答案:

答案 0 :(得分: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)))

答案 1 :(得分:4)

如果您升级的话,请参阅:您获得的信息对于版本0.8是正确的,但是对于0.7以及yas / initialize是正确的。见https://github.com/capitaomorte/yasnippet/commit/90cd855c14f92088067425381ea5225d8af8e6f0